Skip to content

Commit c2476b9

Browse files
committed
Yellow highlight on address fields
1 parent 85139d3 commit c2476b9

5 files changed

+69
-5
lines changed

l10n_CM/Unified/test_demo_ad_email_phone_captured_in_doorhanger_and_stored.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ def test_demo_ad_email_phone_captured_in_doorhanger_and_stored(
4242
if expected_phone:
4343
with driver.context(driver.CONTEXT_CHROME):
4444
actual_phone = autofill_popup.get_element("address-doorhanger-phone").text
45-
normalize_expected = util.normalize_regional_phone_numbers(expected_phone, region)
45+
normalize_expected = util.normalize_regional_phone_numbers(
46+
expected_phone, region
47+
)
4648
normalized_actual = util.normalize_regional_phone_numbers(actual_phone, region)
4749
assert normalized_actual == normalize_expected, (
4850
f"Phone number mismatch for {region} | Expected: {normalize_expected}, Got: {normalized_actual}"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object_autofill_popup import AutofillPopup
5+
from modules.page_object_autofill import AddressFill
6+
from modules.util import Utilities
7+
8+
9+
@pytest.fixture()
10+
def test_case():
11+
return "2888564"
12+
13+
14+
def test_address_yellow_highlight_address_fields(driver: Firefox, region: str):
15+
"""
16+
C2888564 - Verify the yellow highlight appears on autofilled fields for the address fields.
17+
"""
18+
19+
# Instantiate objects
20+
address_autofill = AddressFill(driver)
21+
address_autofill_popup = AutofillPopup(driver)
22+
util = Utilities()
23+
24+
# Create fake data and fill it in
25+
address_autofill.open()
26+
address_autofill_data = util.fake_autofill_data(region)
27+
address_autofill.save_information_basic(address_autofill_data)
28+
29+
# Click the "Save" button
30+
address_autofill_popup.click_doorhanger_button("save")
31+
32+
# Double click inside street address field and select a saved address entry from the dropdown
33+
address_autofill.double_click("form-field", labels=["street-address"])
34+
35+
# Click on the first element from the autocomplete dropdown
36+
first_item = address_autofill_popup.get_nth_element(1)
37+
address_autofill_popup.click_on(first_item)
38+
39+
# Verify the address fields are highlighted
40+
address_autofill.verify_field_yellow_highlights(
41+
region=region,
42+
fields_to_test=[
43+
"street-address",
44+
"address-level2",
45+
"address-level1",
46+
"postal-code",
47+
"country",
48+
],
49+
expected_highlighted_fields=[
50+
"street-address",
51+
"address-level2",
52+
"address-level1",
53+
"postal-code",
54+
"country",
55+
],
56+
)

l10n_CM/Unified/test_demo_ad_yellow_highlight.py renamed to l10n_CM/Unified/test_demo_ad_yellow_highlight_name_org.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_address_yellow_highlight_on_name_organization_fields(
3131
# Click the "Save" button
3232
address_autofill_popup.click_doorhanger_button("save")
3333

34-
# Double click inside phone field and select a saved address entry from the dropdown
34+
# Double click inside name field and select a saved address entry from the dropdown
3535
address_autofill.double_click("form-field", labels=["name"])
3636

3737
# Click on the first element from the autocomplete dropdown

modules/page_object_autofill.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,15 @@ def verify_autofill_data(
559559
)
560560

561561
def verify_field_yellow_highlights(
562-
self, fields_to_test=None, expected_highlighted_fields=None
562+
self, region=None, fields_to_test=None, expected_highlighted_fields=None
563563
):
564564
if fields_to_test is None:
565565
fields_to_test = self.fields # By default, test all address fields
566566

567+
# Skip 'address-level1' if region is DE or FR
568+
if region in ["DE", "FR"] and "address-level1" in fields_to_test:
569+
fields_to_test.remove("address-level1")
570+
567571
return self.verify_field_highlight(
568572
fields_to_test=fields_to_test,
569573
expected_highlighted_fields=expected_highlighted_fields,

modules/util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,15 +499,17 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
499499
digits = re.sub(r"\D", "", phone)
500500

501501
# Determine country code
502-
country_code = country_codes.get(region, "1") # Default to "1" (US/CA) if region is unknown
502+
country_code = country_codes.get(
503+
region, "1"
504+
) # Default to "1" (US/CA) if region is unknown
503505
local_number = digits
504506

505507
# Check if phone already contains a valid country code
506508
for code in country_codes.values():
507509
if digits.startswith(code):
508510
country_code = code
509511
# Remove country code from local number
510-
local_number = digits[len(code):]
512+
local_number = digits[len(code) :]
511513
break
512514

513515
# Handle leading zero in local numbers (France & Germany)

0 commit comments

Comments
 (0)