Skip to content

Commit 40a10a8

Browse files
philimon-resetvsangereanMOZ
authored andcommitted
inital progress on poc
1 parent 5aa69a9 commit 40a10a8

18 files changed

+325
-198
lines changed

l10n_CM/Unified/conftest.py

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from json import load
23
from typing import List
34

45
import pytest
@@ -8,12 +9,42 @@
89
from modules.page_object_prefs import AboutPrefs
910
from modules.util import Utilities
1011

12+
current_dir = os.path.dirname(__file__)
13+
parent_dir = os.path.dirname(current_dir)
14+
1115

1216
@pytest.fixture()
1317
def region():
1418
return os.environ.get("FX_REGION", "US")
1519

1620

21+
@pytest.fixture()
22+
def site_data():
23+
live_site = os.environ.get("FX_SITE", None)
24+
# live_site = "amazon"
25+
if live_site:
26+
path_to_site = parent_dir + "/constants/"
27+
with open(path_to_site + live_site + ".json", "r") as fp:
28+
live_site_data = load(fp)
29+
return live_site_data
30+
return {}
31+
32+
33+
@pytest.fixture()
34+
def url_template(site_data):
35+
return site_data.get("url", None)
36+
37+
38+
@pytest.fixture()
39+
def fields(site_data):
40+
return site_data.get("fields", None)
41+
42+
43+
@pytest.fixture()
44+
def field_mapping(site_data):
45+
return site_data.get("field_mapping", None)
46+
47+
1748
@pytest.fixture()
1849
def add_to_prefs_list(region: str):
1950
return []
@@ -33,8 +64,17 @@ def prefs_list(add_to_prefs_list: List[tuple[str, str | bool]], region: str):
3364

3465

3566
@pytest.fixture()
36-
def address_autofill(driver):
37-
yield AddressFill(driver)
67+
def address_autofill(driver, url_template, fields, field_mapping):
68+
yield AddressFill(
69+
driver, url_template=url_template, field_mapping=field_mapping, fields=fields
70+
)
71+
72+
73+
@pytest.fixture()
74+
def credit_card_autofill(driver, url_template, fields, field_mapping):
75+
yield CreditCardFill(
76+
driver, url_template=url_template, field_mapping=field_mapping, fields=fields
77+
)
3878

3979

4080
@pytest.fixture()
@@ -55,8 +95,3 @@ def about_prefs_privacy(driver):
5595
@pytest.fixture()
5696
def about_prefs(driver):
5797
yield AboutPrefs(driver)
58-
59-
60-
@pytest.fixture()
61-
def credit_card_autofill(driver):
62-
yield CreditCardFill(driver)

l10n_CM/Unified/test_demo_ad_1b_dropdown_address_fields.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ def test_dropdown_presence_address_field(
2828
address_autofill.fill_and_save(region)
2929

3030
fields_to_test = [
31-
"street-address",
32-
"address-level2",
33-
"address-level1",
34-
"postal-code",
35-
"country",
31+
"street_address",
32+
"address_level_2",
33+
"address_level_1",
34+
"postal_code",
35+
"country_code",
3636
]
3737

3838
address_autofill.verify_field_autofill_dropdown(

l10n_CM/Unified/test_demo_ad_1c_dropdown_phone_email_fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_dropdown_presence_email_phone_field(
2727
address_autofill.open()
2828
address_autofill.fill_and_save(region)
2929

30-
fields_to_test = ["email", "tel"]
30+
fields_to_test = ["email", "telephone"]
3131

3232
address_autofill.verify_field_autofill_dropdown(
3333
region=region, fields_to_test=fields_to_test

l10n_CM/Unified/test_demo_ad_2b_preview_address_fields.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def test_hover_address_is_previewed(
3737

3838
# Hover over each field and check data preview
3939
fields_to_test = [
40-
"street-address",
41-
"address-level2", # city
42-
"address-level1", # state/province
43-
"postal-code",
44-
"country",
40+
"street_address",
41+
"address_level_2",
42+
"address_level_1",
43+
"postal_code",
44+
"country_code",
4545
]
4646
for field in fields_to_test:
4747
address_autofill.check_autofill_preview_for_field(field, autofill_data, region)

l10n_CM/Unified/test_demo_ad_2c_preview_phone_email_fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ def test_hover_email_and_phone_autofill_preview(
2525
autofill_data = address_autofill.fill_and_save(region)
2626

2727
# Hover over each field and check data preview
28-
fields_to_test = ["email", "tel"]
28+
fields_to_test = ["email", "telephone"]
2929
for field in fields_to_test:
3030
address_autofill.check_autofill_preview_for_field(field, autofill_data, region)

l10n_CM/Unified/test_demo_ad_3a_autofill_address_fields.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ def test_demo_ad_autofill_address_fields(
2727

2828
# List of field labels to be autofilled and verified
2929
fields_to_test = [
30-
"address-level1", # This will be skipped for DE/FR
31-
"address-level2",
32-
"street-address",
33-
"postal-code",
34-
"country",
30+
"street_address",
31+
"address_level_2",
32+
"address_level_1",
33+
"postal_code",
34+
"country_code",
3535
]
36-
3736
# Loop through each field and perform the autofill test
3837
for field in fields_to_test:
3938
address_autofill.clear_and_verify(field, address_autofill_data, region=region)

l10n_CM/Unified/test_demo_ad_3c_autofill_phone_email_fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_demo_ad_autofill_phone_email(
2626
address_autofill_data = address_autofill.fill_and_save(region)
2727

2828
# List of field labels to be autofilled and verified
29-
fields_to_test = ["email", "tel"]
29+
fields_to_test = ["email", "telephone"]
3030

3131
# Loop through each field and perform the autofill test
3232
for field in fields_to_test:

l10n_CM/Unified/test_demo_ad_4a_highlight_name_org_fields.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,22 @@ def test_address_yellow_highlight_on_name_organization_fields(
2121
"""
2222
C2888559 - Verify the yellow highlight appears on autofilled fields for name and organization.
2323
"""
24-
# Create fake data and fill it in
25-
address_autofill.open()
26-
address_autofill.fill_and_save(region)
27-
28-
# Double click inside name field and select a saved address entry from the dropdown
29-
address_autofill.double_click("form-field", labels=["name"])
30-
autofill_popup.ensure_autofill_dropdown_visible()
31-
32-
# Click on the first element from the autocomplete dropdown
33-
autofill_popup.select_nth_element(1)
34-
35-
field_to_test = ["name", "organization"]
36-
# Verify the name and organization fields are highlighted
37-
address_autofill.verify_field_highlight(
38-
fields_to_test=field_to_test,
39-
expected_highlighted_fields=field_to_test,
40-
region=region,
41-
)
24+
if address_autofill.is_field_present("name"):
25+
# Create fake data and fill it in
26+
address_autofill.open()
27+
address_autofill.fill_and_save(region)
28+
29+
# Double click inside name field and select a saved address entry from the dropdown
30+
address_autofill.click_form_field("name")
31+
autofill_popup.ensure_autofill_dropdown_visible()
32+
33+
# Click on the first element from the autocomplete dropdown
34+
autofill_popup.select_nth_element(1)
35+
36+
field_to_test = ["name", "organization"]
37+
# Verify the name and organization fields are highlighted
38+
address_autofill.verify_field_highlight(
39+
fields_to_test=field_to_test,
40+
expected_highlighted_fields=field_to_test,
41+
region=region,
42+
)

l10n_CM/Unified/test_demo_ad_4b_highlight_address_fields.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,29 @@ def test_address_yellow_highlight_address_fields(
2121
"""
2222
C2888564 - Verify the yellow highlight appears on autofilled fields for the address fields.
2323
"""
24-
# Create fake data and fill it in
25-
address_autofill.open()
26-
address_autofill.fill_and_save(region)
27-
28-
# Double click inside name field and select a saved address entry from the dropdown
29-
address_autofill.double_click("form-field", labels=["street-address"])
30-
autofill_popup.ensure_autofill_dropdown_visible()
31-
32-
# Click on the first element from the autocomplete dropdown
33-
autofill_popup.select_nth_element(1)
34-
35-
field_to_test = [
36-
"street-address",
37-
"address-level2",
38-
"address-level1",
39-
"postal-code",
40-
"country",
41-
]
42-
43-
# Verify the address fields are highlighted
44-
address_autofill.verify_field_highlight(
45-
fields_to_test=field_to_test,
46-
expected_highlighted_fields=field_to_test,
47-
region=region,
48-
)
24+
if address_autofill.is_field_present("street_address"):
25+
# Create fake data and fill it in
26+
address_autofill.open()
27+
address_autofill.fill_and_save(region)
28+
29+
# Double click inside name field and select a saved address entry from the dropdown
30+
address_autofill.click_form_field("street_address")
31+
autofill_popup.ensure_autofill_dropdown_visible()
32+
33+
# Click on the first element from the autocomplete dropdown
34+
autofill_popup.select_nth_element(1)
35+
36+
field_to_test = [
37+
"street_address",
38+
"address_level_2",
39+
"address_level_1",
40+
"postal_code",
41+
"country_code",
42+
]
43+
44+
# Verify the address fields are highlighted
45+
address_autofill.verify_field_highlight(
46+
fields_to_test=field_to_test,
47+
expected_highlighted_fields=field_to_test,
48+
region=region,
49+
)

l10n_CM/Unified/test_demo_ad_4c_highlight_phone_email_fields.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,22 @@ def test_address_yellow_highlight_address_fields(
2121
"""
2222
C2888570 - Verify the yellow highlight appears on autofilled fields for the email and phone fields.
2323
"""
24-
# Create fake data and fill it in
25-
address_autofill.open()
26-
address_autofill.fill_and_save(region)
27-
28-
# Double click inside name field and select a saved address entry from the dropdown
29-
address_autofill.double_click("form-field", labels=["email"])
30-
autofill_popup.ensure_autofill_dropdown_visible()
31-
32-
# Click on the first element from the autocomplete dropdown
33-
autofill_popup.select_nth_element(1)
34-
35-
field_to_test = ["email", "tel"]
36-
# Verify the address fields are highlighted
37-
address_autofill.verify_field_highlight(
38-
fields_to_test=field_to_test,
39-
expected_highlighted_fields=field_to_test,
40-
region=region,
41-
)
24+
if address_autofill.is_field_present("email"):
25+
# Create fake data and fill it in
26+
address_autofill.open()
27+
address_autofill.fill_and_save(region)
28+
29+
# Double click inside name field and select a saved address entry from the dropdown
30+
address_autofill.click_form_field("email")
31+
autofill_popup.ensure_autofill_dropdown_visible()
32+
33+
# Click on the first element from the autocomplete dropdown
34+
autofill_popup.select_nth_element(1)
35+
36+
field_to_test = ["email", "telephone"]
37+
# Verify the address fields are highlighted
38+
address_autofill.verify_field_highlight(
39+
fields_to_test=field_to_test,
40+
expected_highlighted_fields=field_to_test,
41+
region=region,
42+
)

0 commit comments

Comments
 (0)