Skip to content

Commit ee6b281

Browse files
authored
Merge pull request #487 from mozilla/as/yellow-highlight-tel-email
Anca/l10n demo - yellow highlight on email and phone fields
2 parents 85139d3 + e8efd83 commit ee6b281

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
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: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 "2888570"
12+
13+
14+
def test_address_yellow_highlight_address_fields(
15+
driver: Firefox,
16+
region: str,
17+
address_autofill: AddressFill,
18+
util: Utilities,
19+
autofill_popup: AutofillPopup,
20+
):
21+
"""
22+
C2888570 - Verify the yellow highlight appears on autofilled fields for the email and phone fields.
23+
"""
24+
25+
# Create fake data and fill it in
26+
address_autofill.open()
27+
address_autofill_data = util.fake_autofill_data(region)
28+
address_autofill.save_information_basic(address_autofill_data)
29+
30+
# Click the "Save" button
31+
autofill_popup.click_doorhanger_button("save")
32+
33+
# Double click inside email field and select a saved address entry from the dropdown
34+
address_autofill.double_click("form-field", labels=["email"])
35+
36+
# Click on the first element from the autocomplete dropdown
37+
first_item = autofill_popup.get_nth_element(1)
38+
autofill_popup.click_on(first_item)
39+
40+
# Verify the email and phone fields are highlighted
41+
address_autofill.verify_field_yellow_highlights(
42+
fields_to_test=["email", "tel"], expected_highlighted_fields=["email", "tel"]
43+
)

l10n_CM/region/Unified.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"test_demo_cc_doorhanger_shown_on_valid_credit_card_submission.py",
1414
"test_demo_cc_dropdown-presence.py",
1515
"test_demo_cc_yellow_highlight.py",
16-
"test_demo_ad_yellow_highlight.py"
16+
"test_demo_ad_yellow_highlight.py",
17+
"test_demo_ad_yellow_highlight_phone_email.py"
1718
]
1819
}

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)