Skip to content

Commit d13033a

Browse files
philimon-resetvsangereanMOZ
authored andcommitted
further work to support DE and FR regions and clean up
1 parent ff0a4e5 commit d13033a

13 files changed

+93
-56
lines changed

l10n_CM/Unified/conftest.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def region():
2020

2121
@pytest.fixture()
2222
def live_site():
23-
return os.environ.get("FX_SITE")
23+
return os.environ.get("CM_SITE", "demo")
2424

2525

2626
@pytest.fixture()
@@ -42,40 +42,44 @@ def prefs_list(add_to_prefs_list: List[tuple[str, str | bool]], region: str):
4242

4343

4444
@pytest.fixture()
45-
def ad_site_data(live_site):
45+
def ad_site_data(live_site, region):
4646
ad_live_site = f"{live_site}/{live_site}_ad"
47-
if live_site:
48-
path_to_site = parent_dir + "/constants/"
49-
with open(path_to_site + ad_live_site + ".json", "r") as fp:
50-
live_site_data = load(fp)
51-
return live_site_data
52-
return {}
47+
path_to_site = parent_dir + "/constants/"
48+
with open(path_to_site + ad_live_site + ".json", "r") as fp:
49+
live_site_data = load(fp)
50+
# Remove address level 1 for regions other than US and CA
51+
if region not in {"US", "CA"} and live_site_data["field_mapping"].get(
52+
"address_level_1"
53+
):
54+
live_site_data["fields"].remove(
55+
live_site_data["field_mapping"]["address_level_1"]
56+
)
57+
del live_site_data["field_mapping"]["address_level_1"]
58+
return live_site_data
5359

5460

5561
@pytest.fixture()
56-
def ad_url_template(ad_site_data):
57-
return ad_site_data.get("url", None)
62+
def ad_is_live_site(live_site):
63+
return live_site != "demo"
5864

5965

6066
@pytest.fixture()
6167
def cc_site_data(live_site):
6268
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 {}
69+
path_to_site = parent_dir + "/constants/"
70+
with open(path_to_site + cc_live_site + ".json", "r") as fp:
71+
live_site_data = load(fp)
72+
return live_site_data
6973

7074

7175
@pytest.fixture()
72-
def cc_url_template(cc_site_data):
73-
return cc_site_data.get("url", None)
76+
def cc_is_live_site(live_site):
77+
return live_site != "demo"
7478

7579

7680
@pytest.fixture()
7781
def ad_form_field(ad_site_data):
78-
selector = ad_site_data.get("form_field", None)
82+
selector = ad_site_data.get("form_field")
7983
return (
8084
{"form-field": {"selectorData": selector, "strategy": "css", "groups": []}}
8185
if selector
@@ -85,7 +89,7 @@ def ad_form_field(ad_site_data):
8589

8690
@pytest.fixture()
8791
def cc_form_field(cc_site_data):
88-
selector = cc_site_data.get("form_field", None)
92+
selector = cc_site_data.get("form_field")
8993
return (
9094
{"form-field": {"selectorData": selector, "strategy": "css", "groups": []}}
9195
if selector

l10n_CM/Unified/test_demo_ad_6_capture_doorhanger_appearance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ def test_address_doorhanger_displayed_after_entering_valid_address(
1717
address_autofill: AddressFill,
1818
util: Utilities,
1919
autofill_popup: AutofillPopup,
20-
ad_url_template: str,
20+
ad_is_live_site: str,
2121
):
2222
"""
2323
C2886581 - Verify the Capture Door hanger is displayed after entering valid Address data
2424
"""
25-
if not ad_url_template:
25+
if not ad_is_live_site:
2626
# Create fake data and fill it in
2727
address_autofill.open()
2828
# scroll to first form field

l10n_CM/Unified/test_demo_ad_7a_capture_doorhanger_stored_data_name_org_fields.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ def test_demo_ad_name_org_captured_in_doorhanger_and_stored(
1919
util: Utilities,
2020
autofill_popup: AutofillPopup,
2121
about_prefs_privacy: AboutPrefs,
22-
ad_url_template: str,
22+
ad_is_live_site: str,
2323
):
2424
"""
2525
C2888701 - Verify name/org fields are captured in the Capture Doorhanger and stored in about:preferences
2626
"""
27-
if not ad_url_template:
27+
if not ad_is_live_site:
2828
# Create fake data and fill it in
2929
address_autofill.open()
3030
# scroll to first form field

l10n_CM/Unified/test_demo_ad_7b_capture_doorhanger_stored_data_address_fields.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ def test_demo_ad_address_data_captured_in_doorhanger_and_stored(
1919
util: Utilities,
2020
autofill_popup: AutofillPopup,
2121
about_prefs_privacy: AboutPrefs,
22-
ad_url_template: str,
22+
ad_is_live_site: str,
2323
):
2424
"""
2525
C2888703 - Verify Address data are captured in the Capture Doorhanger and stored in about:preferences
2626
"""
27-
if not ad_url_template:
27+
if not ad_is_live_site:
2828
# Create fake data and fill it in
2929
address_autofill.open()
3030

l10n_CM/Unified/test_demo_ad_7c_capture_doorhanger_stored_data_phone_email.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ def test_demo_ad_email_phone_captured_in_doorhanger_and_stored(
1919
util: Utilities,
2020
autofill_popup: AutofillPopup,
2121
about_prefs_privacy: AboutPrefs,
22-
ad_url_template: str,
22+
ad_is_live_site: str,
2323
):
2424
"""
2525
C2888704 - Verify tele/email data are captured in the Capture Doorhanger and stored in about:preferences
2626
"""
27-
if not ad_url_template:
27+
if not ad_is_live_site:
2828
# Create fake data and fill it in
2929
address_autofill.open()
3030

l10n_CM/Unified/test_demo_cc_6_capture_doorhanger_appearance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ def test_cc_check_door_hanger_is_displayed(
1717
util: Utilities,
1818
autofill_popup: AutofillPopup,
1919
credit_card_autofill: CreditCardFill,
20-
cc_url_template: str,
20+
cc_is_live_site: str,
2121
):
2222
"""
2323
C2889441 - Ensures that the door hanger is displayed after filling credit card info
2424
"""
25-
if not cc_url_template:
25+
if not cc_is_live_site:
2626
# Navigate to page
2727
credit_card_autofill.open()
2828

l10n_CM/Unified/test_demo_cc_7_capture_doorhanger_capture_and_stored_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ def test_demo_cc_data_captured_in_doorhanger_and_stored(
1919
autofill_popup: AutofillPopup,
2020
util: Utilities,
2121
about_prefs_privacy: AboutPrefs,
22-
cc_url_template: str,
22+
cc_is_live_site: str,
2323
):
2424
"""
2525
C2889999 - Verify credit card data is captured in the Capture Doorhanger and stored in about:preferences
2626
"""
27-
if not cc_url_template:
27+
if not cc_is_live_site:
2828
# Navigate to page
2929
credit_card_autofill.open()
3030

l10n_CM/constants/amazon/amazon_ad.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"url": "http://127.0.0.1:8000/amazon_ad.html",
2+
"url": "http://127.0.0.1:8080/amazon_ad.html",
33
"field_mapping": {
44
"name": "152ffe55-1b63-4bf7-a43c-21d217d8aca1",
55
"street_address": "33198fca-ddab-40a0-bc03-8b6f83bc3a98",

l10n_CM/constants/amazon/amazon_cc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"url": "http://127.0.0.1:8000/amazon_cc.html",
2+
"url": "http://127.0.0.1:8080/amazon_cc.html",
33
"field_mapping": {
44
"card_number": "7901475e-bfea-4607-98f9-abb787d3dc57",
55
"name": "4f630b6e-efd1-458d-9762-9a12a3dd28de",

l10n_CM/constants/demo/demo_ad.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"url": "https://mozilla.github.io/form-fill-examples/basic.html",
3+
"field_mapping": {
4+
"name": "name",
5+
"organization": "organization",
6+
"street_address": "street-address",
7+
"address_level_2": "address-level2",
8+
"address_level_1": "address-level1",
9+
"postal_code": "postal-code",
10+
"country_code": "country",
11+
"email": "email",
12+
"telephone": "tel"
13+
},
14+
"fields": [
15+
"name",
16+
"organization",
17+
"street-address",
18+
"address-level2",
19+
"address-level1",
20+
"postal-code",
21+
"country",
22+
"email",
23+
"tel"
24+
]
25+
}

0 commit comments

Comments
 (0)