Skip to content

Commit 8c5cf0a

Browse files
philimon-resetvsangereanMOZ
authored andcommitted
proof of concept complete
1 parent 70c03a4 commit 8c5cf0a

File tree

51 files changed

+320
-101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+320
-101
lines changed

l10n_CM/Unified/conftest.py

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515

1616
@pytest.fixture()
1717
def region():
18-
return os.environ.get("FX_REGION", "US")
18+
return os.environ.get("FX_REGION")
19+
20+
21+
@pytest.fixture()
22+
def live_site():
23+
return os.environ.get("FX_SITE")
1924

2025

2126
@pytest.fixture()
@@ -37,36 +42,50 @@ def prefs_list(add_to_prefs_list: List[tuple[str, str | bool]], region: str):
3742

3843

3944
@pytest.fixture()
40-
def site_data():
41-
# live_site = os.environ.get("FX_SITE", None)
42-
# un comment to test a live site form
43-
live_site = "amazon/amazon_ad"
45+
def ad_site_data(live_site):
46+
ad_live_site = f"{live_site}/{live_site}_ad"
4447
if live_site:
4548
path_to_site = parent_dir + "/constants/"
46-
with open(path_to_site + live_site + ".json", "r") as fp:
49+
with open(path_to_site + ad_live_site + ".json", "r") as fp:
4750
live_site_data = load(fp)
4851
return live_site_data
4952
return {}
5053

5154

5255
@pytest.fixture()
53-
def url_template(site_data):
54-
return site_data.get("url", None)
56+
def ad_url_template(ad_site_data):
57+
return ad_site_data.get("url", None)
58+
59+
60+
@pytest.fixture()
61+
def cc_site_data(live_site):
62+
cc_live_site = f"{live_site}/{live_site}_cc"
63+
if live_site:
64+
path_to_site = parent_dir + "/constants/"
65+
with open(path_to_site + cc_live_site + ".json", "r") as fp:
66+
live_site_data = load(fp)
67+
return live_site_data
68+
return {}
5569

5670

5771
@pytest.fixture()
58-
def fields(site_data):
59-
return site_data.get("fields", None)
72+
def cc_url_template(cc_site_data):
73+
return cc_site_data.get("url", None)
6074

6175

6276
@pytest.fixture()
63-
def field_mapping(site_data):
64-
return site_data.get("field_mapping", None)
77+
def ad_form_field(ad_site_data):
78+
selector = ad_site_data.get("form_field", None)
79+
return (
80+
{"form-field": {"selectorData": selector, "strategy": "css", "groups": []}}
81+
if selector
82+
else {}
83+
)
6584

6685

6786
@pytest.fixture()
68-
def form_field(site_data):
69-
selector = site_data.get("form_field", None)
87+
def cc_form_field(cc_site_data):
88+
selector = cc_site_data.get("form_field", None)
7089
return (
7190
{"form-field": {"selectorData": selector, "strategy": "css", "groups": []}}
7291
if selector
@@ -75,20 +94,26 @@ def form_field(site_data):
7594

7695

7796
@pytest.fixture()
78-
def address_autofill(driver, url_template, fields, field_mapping, form_field):
97+
def address_autofill(driver, ad_site_data, ad_form_field):
7998
af = AddressFill(
80-
driver, url_template=url_template, field_mapping=field_mapping, fields=fields
99+
driver,
100+
url_template=ad_site_data.get("url"),
101+
field_mapping=ad_site_data.get("field_mapping"),
102+
fields=ad_site_data.get("fields"),
81103
)
82-
af.elements |= form_field
104+
af.elements |= ad_form_field
83105
return af
84106

85107

86108
@pytest.fixture()
87-
def credit_card_autofill(driver, url_template, fields, field_mapping, form_field):
109+
def credit_card_autofill(driver, cc_site_data, cc_form_field):
88110
cf = CreditCardFill(
89-
driver, url_template=url_template, field_mapping=field_mapping, fields=fields
111+
driver,
112+
url_template=cc_site_data.get("url"),
113+
field_mapping=cc_site_data.get("field_mapping"),
114+
fields=cc_site_data.get("fields"),
90115
)
91-
cf.elements |= form_field
116+
cf.elements |= cc_form_field
92117
return cf
93118

94119

@@ -150,27 +175,27 @@ def populate_saved_addresses(
150175

151176
@pytest.fixture()
152177
def fill_and_save_address(
153-
address_autofill: AddressFill, url_template: str | None, region: str, request
178+
address_autofill: AddressFill, ad_site_data, region: str, request
154179
):
155180
"""
156181
Fixture to populate address entry depending on whether the url is a live site.
157182
If live site, populate data through about:prefs, if not fill directly through page.
158183
"""
159-
if url_template:
184+
if ad_site_data.get("url"):
160185
return request.getfixturevalue("populate_saved_addresses")
161186
address_autofill.open()
162187
return address_autofill.fill_and_save(region)
163188

164189

165190
@pytest.fixture()
166191
def fill_and_save_payments(
167-
credit_card_autofill: CreditCardFill, url_template: str | None, region: str, request
192+
credit_card_autofill: CreditCardFill, cc_site_data, region: str, request
168193
):
169194
"""
170195
Fixture to populate cc entry depending on whether the url is a live site.
171196
If live site, populate data through about:prefs, if not fill directly through page.
172197
"""
173-
if url_template:
198+
if cc_site_data.get("url"):
174199
return request.getfixturevalue("populate_saved_payments")
175200
credit_card_autofill.open()
176201
return credit_card_autofill.fill_and_save(region)

l10n_CM/Unified/test_demo_ad_1a_dropdown_name_org_fields.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def test_dropdown_presence_name_organization(
2727
# open address filling url page
2828
address_autofill.open()
2929

30+
# scroll to first form field
31+
address_autofill.scroll_to_form_field()
32+
3033
# Verify that the name and organization fields have the autofill dropdown present
3134
fields_to_test = ["name", "given_name", "family_name", "organization"]
3235

l10n_CM/Unified/test_demo_ad_1b_dropdown_address_fields.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def test_dropdown_presence_address_field(
2727
# open address filling url page
2828
address_autofill.open()
2929

30+
# scroll to first form field
31+
address_autofill.scroll_to_form_field()
32+
3033
fields_to_test = [
3134
"street_address",
3235
"address_level_2",

l10n_CM/Unified/test_demo_ad_1c_dropdown_phone_email_fields.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ def test_dropdown_presence_email_phone_field(
2828
# Open autofill page
2929
address_autofill.open()
3030

31+
# scroll to first form field
32+
address_autofill.scroll_to_form_field()
33+
3134
fields_to_test = ["email", "telephone"]
3235

3336
address_autofill.verify_field_autofill_dropdown(

l10n_CM/Unified/test_demo_ad_2a_preview_name_org_fields.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def test_demo_ad_hover_name_org(
2626
# Create fake data
2727
address_autofill.open()
2828

29+
# scroll to first form field
30+
address_autofill.scroll_to_form_field()
31+
2932
# created fake data
3033
autofill_data = fill_and_save_address
3134

l10n_CM/Unified/test_demo_ad_2b_preview_address_fields.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def test_hover_address_is_previewed(
3636
# Create fake data
3737
address_autofill.open()
3838

39+
# scroll to first form field
40+
address_autofill.scroll_to_form_field()
41+
3942
# created fake data
4043
autofill_data = fill_and_save_address
4144

l10n_CM/Unified/test_demo_ad_2c_preview_phone_email_fields.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ def test_hover_email_and_phone_autofill_preview(
2525
# Create fake data
2626
address_autofill.open()
2727

28+
# scroll to first form field
29+
address_autofill.scroll_to_form_field()
30+
2831
# created fake data
2932
autofill_data = fill_and_save_address
3033

l10n_CM/Unified/test_demo_ad_3a_autofill_address_fields.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def test_demo_ad_autofill_address_fields(
2626
# Create fake data
2727
address_autofill.open()
2828

29+
# scroll to first form field
30+
address_autofill.scroll_to_form_field()
31+
2932
# created fake data
3033
autofill_data = fill_and_save_address
3134

l10n_CM/Unified/test_demo_ad_3b_autofill_name_org_fields.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def test_demo_ad_autofill_name_org(
2626
# Create fake data
2727
address_autofill.open()
2828

29+
# scroll to first form field
30+
address_autofill.scroll_to_form_field()
31+
2932
# created fake data
3033
autofill_data = fill_and_save_address
3134

l10n_CM/Unified/test_demo_ad_3c_autofill_phone_email_fields.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def test_demo_ad_autofill_phone_email(
2626
# Create fake data
2727
address_autofill.open()
2828

29+
# scroll to first form field
30+
address_autofill.scroll_to_form_field()
31+
2932
# created fake data
3033
autofill_data = fill_and_save_address
3134

0 commit comments

Comments
 (0)