Skip to content

Commit 445fe22

Browse files
authored
Merge pull request #494 from mozilla/tracy/set-add-prefs-refactor
tracy/ Standardize method to set and add prefs
2 parents 29f9596 + 99a27e9 commit 445fe22

File tree

88 files changed

+393
-232
lines changed

Some content is hidden

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

88 files changed

+393
-232
lines changed

conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def driver(
394394
fx_executable: str,
395395
opt_headless: bool,
396396
opt_implicit_timeout: int,
397-
set_prefs: List[Tuple],
397+
prefs_list: List[Tuple],
398398
opt_ci: bool,
399399
opt_window_size: str,
400400
use_profile: Union[bool, str],
@@ -426,7 +426,7 @@ def driver(
426426
opt_implicit_timeout: int
427427
Timeout, in seconds for driver-level wait attribute.
428428
429-
set_prefs: List[Tuple]
429+
prefs_list: List[Tuple]
430430
Preferences to set before the Firefox object is created.
431431
Usually set in the conftest.py inside a test suite folder.
432432
@@ -454,7 +454,7 @@ def driver(
454454
profile_path = tmp_path / use_profile
455455
unpack_archive(os.path.join("profiles", f"{use_profile}.zip"), profile_path)
456456
options.profile = profile_path
457-
for opt, value in set_prefs:
457+
for opt, value in prefs_list:
458458
options.set_preference(opt, value)
459459
driver = Firefox(options=options)
460460
separator = "x"

l10n_CM/Unified/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ def region():
1515

1616

1717
@pytest.fixture()
18-
def add_prefs(region: str):
18+
def add_to_prefs_list(region: str):
1919
return []
2020

2121

2222
@pytest.fixture()
23-
def set_prefs(add_prefs: List[tuple[str, str | bool]], region: str):
24-
"""Set prefs"""
23+
def prefs_list(add_to_prefs_list: List[tuple[str, str | bool]], region: str):
24+
"""List of prefs to send to main conftest.py driver fixture"""
2525
prefs = [
2626
("extensions.formautofill.creditCards.reauth.optout", False),
2727
("extensions.formautofill.reauth.enabled", False),
2828
("browser.aboutConfig.showWarning", False),
2929
("browser.search.region", region),
3030
]
31-
prefs.extend(add_prefs)
31+
prefs.extend(add_to_prefs_list)
3232
return prefs
3333

3434

l10n_CM/Unified/test_demo_ad_autofill_name_org.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ def test_demo_ad_autofill_name_org(
3030
autofill_popup.click_doorhanger_button("save")
3131

3232
# List of field labels to be autofilled and verified
33-
fields_to_test = [
34-
"name",
35-
"organization"
36-
]
33+
fields_to_test = ["name", "organization"]
3734

3835
# Loop through each field and perform the autofill test
3936
for field in fields_to_test:
40-
address_autofill.autofill_and_verify(autofill_popup, field,
41-
address_autofill_data, util)
37+
address_autofill.autofill_and_verify(
38+
autofill_popup, field, address_autofill_data, util
39+
)

l10n_CM/Unified/test_demo_ad_autofill_phone_email.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ def test_demo_ad_autofill_phone_email(
3131
autofill_popup.click_doorhanger_button("save")
3232

3333
# List of field labels to be autofilled and verified
34-
fields_to_test = [
35-
"email",
36-
"tel"
37-
]
34+
fields_to_test = ["email", "tel"]
3835

3936
# Loop through each field and perform the autofill test
4037
for field in fields_to_test:
41-
address_autofill.autofill_and_verify(autofill_popup, field,
42-
address_autofill_data, util)
38+
address_autofill.autofill_and_verify(
39+
autofill_popup, field, address_autofill_data, util
40+
)

l10n_CM/Unified/test_demo_ad_clear_address_fields.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ def test_case():
1212

1313

1414
def test_demo_ad_clear_address_fields(
15-
driver: Firefox,
16-
region: str,
17-
address_autofill: AddressFill,
18-
util: Utilities,
19-
autofill_popup: AutofillPopup
15+
driver: Firefox,
16+
region: str,
17+
address_autofill: AddressFill,
18+
util: Utilities,
19+
autofill_popup: AutofillPopup,
2020
):
2121
"""
2222
C2888565 - Verify clear functionality after selecting an entry from address fields
@@ -35,7 +35,7 @@ def test_demo_ad_clear_address_fields(
3535
"address-level2",
3636
"address-level1", # This will be skipped for DE/FR
3737
"postal-code",
38-
"country"
38+
"country",
3939
]
4040

4141
# Loop through each field and perform the autofill test

l10n_CM/Unified/test_demo_ad_clear_name_org.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ def test_case():
1212

1313

1414
def test_demo_ad_clear_name_org(
15-
driver: Firefox,
16-
region: str,
17-
address_autofill: AddressFill,
18-
util: Utilities,
19-
autofill_popup: AutofillPopup
15+
driver: Firefox,
16+
region: str,
17+
address_autofill: AddressFill,
18+
util: Utilities,
19+
autofill_popup: AutofillPopup,
2020
):
2121
"""
2222
C2888560 - Verify clear functionality after selecting an entry from name/org fields
@@ -30,10 +30,7 @@ def test_demo_ad_clear_name_org(
3030
autofill_popup.click_doorhanger_button("save")
3131

3232
# List of field labels to be autofilled and verified
33-
fields_to_test = [
34-
"name",
35-
"organization"
36-
]
33+
fields_to_test = ["name", "organization"]
3734

3835
# Loop through each field and perform the autofill test
3936
for field in fields_to_test:

l10n_CM/Unified/test_demo_ad_clear_tel_email.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ def test_case():
1212

1313

1414
def test_demo_ad_clear_tel_email(
15-
driver: Firefox,
16-
region: str,
17-
address_autofill: AddressFill,
18-
util: Utilities,
19-
autofill_popup: AutofillPopup
15+
driver: Firefox,
16+
region: str,
17+
address_autofill: AddressFill,
18+
util: Utilities,
19+
autofill_popup: AutofillPopup,
2020
):
2121
"""
2222
C2888571 - Verify clear functionality after selecting an entry from tele/email fields
@@ -31,10 +31,7 @@ def test_demo_ad_clear_tel_email(
3131
autofill_popup.click_doorhanger_button("save")
3232

3333
# List of field labels to be autofilled and verified
34-
fields_to_test = [
35-
"email",
36-
"tel"
37-
]
34+
fields_to_test = ["email", "tel"]
3835

3936
# Loop through each field and perform the autofill test
4037
for field in fields_to_test:

l10n_CM/Unified/test_demo_ad_verify_new_address_added.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def region():
1818

1919

2020
@pytest.fixture()
21-
def add_prefs(region: str):
21+
def add_to_prefs_list(region: str):
2222
return [
2323
("extensions.formautofill.creditCards.supportedCountries", region),
2424
("extensions.formautofill.addresses.supported", "on"),

l10n_CM/Unified/test_demo_cc_autofill_from_dropdown.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from modules.util import Utilities
77

88

9-
109
@pytest.fixture()
1110
def test_case():
1211
return "2886600"
@@ -17,7 +16,6 @@ def test_cc_autofill_from_dropdown(
1716
util: Utilities,
1817
autofill_popup: AutofillPopup,
1918
credit_card_fill_obj: CreditCardFill,
20-
2119
):
2220
"""
2321
Verify that saved credit card information is autofilled correctly when selected from the dropdown,
@@ -37,4 +35,4 @@ def test_cc_autofill_from_dropdown(
3735

3836
# Step 5: Click the csc field (cc-csc), ensure autofill popup is not present
3937
credit_card_fill_obj.click_on("form-field", labels=["cc-csc"]) # Use single click
40-
autofill_popup.ensure_autofill_dropdown_not_visible()
38+
autofill_popup.ensure_autofill_dropdown_not_visible()

l10n_CM/conftest.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ def suite_id():
77

88

99
@pytest.fixture()
10-
def set_prefs():
11-
"""Set prefs"""
10+
def prefs_list(add_to_prefs_list: dict):
11+
"""List of prefs to send to main conftest.py driver fixture"""
12+
prefs = []
13+
prefs.extend(add_to_prefs_list)
14+
return prefs
15+
16+
17+
@pytest.fixture()
18+
def add_to_prefs_list():
1219
return []

0 commit comments

Comments
 (0)