Skip to content

Commit 0777f74

Browse files
Merge pull request #756 from mozilla/anca/cm-at-mediamarkt
Anca/ L10n [AT] Mediamarkt
2 parents 994af7f + 6caf509 commit 0777f74

File tree

8 files changed

+67
-23
lines changed

8 files changed

+67
-23
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"url": "http://127.0.0.1:8080/mediamarkt_ad.html",
3+
"field_mapping": {
4+
"given_name": "eb82fd1f-6ebc-4e00-91b0-b33126e3ef51",
5+
"family_name": "5f200911-7e5f-4d9a-9d75-8cc496b455a7",
6+
"street_address": "81b35c70-5949-4b70-afc8-030bdc2d9128",
7+
"email": "ddde9f4b-5d3d-4346-bb45-1df768613507",
8+
"telephone": "721fc82e-817e-4bff-8b5d-e4360eee4724"
9+
10+
},
11+
"form_field": "*[data-moz-autofill-inspect-id='{name}']",
12+
"fields": [
13+
"eb82fd1f-6ebc-4e00-91b0-b33126e3ef51",
14+
"5f200911-7e5f-4d9a-9d75-8cc496b455a7",
15+
"81b35c70-5949-4b70-afc8-030bdc2d9128",
16+
"ddde9f4b-5d3d-4346-bb45-1df768613507",
17+
"721fc82e-817e-4bff-8b5d-e4360eee4724"
18+
]
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"url": "http://127.0.0.1:8080/mediamarkt_cc.html",
3+
"field_mapping": {
4+
"card_number": "1d77675c-2591-4e83-b5b5-286b1196d918",
5+
"expiration_date": "811f3be9-b204-469f-aff5-294aa91fb232",
6+
"name": "cdf66cc6-01cb-4f0d-b905-fc4bd37c51e1",
7+
"cvv": "839f304f-4191-4bb7-b3bc-75d9d2314715"
8+
},
9+
"form_field": "*[data-moz-autofill-inspect-id='{name}']",
10+
"fields": [
11+
"1d77675c-2591-4e83-b5b5-286b1196d918",
12+
"811f3be9-b204-469f-aff5-294aa91fb232",
13+
"cdf66cc6-01cb-4f0d-b905-fc4bd37c51e1",
14+
"839f304f-4191-4bb7-b3bc-75d9d2314715"
15+
]
16+
}

l10n_CM/region/AT.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"region": "AT",
33
"sites": [
44
"demo",
5-
"torfs"
5+
"mediamarkt"
66
],
77
"tests": [
88
]

l10n_CM/run_l10n.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"bijoubrigitte",
2727
"brico",
2828
"burtsbees",
29-
"burtsbeescalvinklein",
3029
"calvinklein",
3130
"canadatire",
3231
"cdiscount",

l10n_CM/sites/mediamarkt/AT/mediamarkt_ad.html

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

l10n_CM/sites/mediamarkt/AT/mediamarkt_cc.html

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

modules/page_object_autofill.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ def verify_autofill_data_on_hover(
510510
is_present = any(
511511
[value in val for val in autofill_data.__dict__.values()]
512512
)
513+
513514
assert is_present, (
514515
f"Mismatched data: {(field, value)} not in {autofill_data.__dict__.values()}."
515516
)

modules/util.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@ def __init__(self):
112112
"Belgium": "België",
113113
"Austria": "Österreich",
114114
}
115+
# Country code mapping for different regions
116+
self.country_codes = {
117+
"US": "1",
118+
"CA": "1",
119+
"FR": "33",
120+
"DE": "49",
121+
"GB": "44",
122+
"IT": "39",
123+
"PL": "48",
124+
"ES": "34",
125+
"BE": "32",
126+
"AT": "43",
127+
}
115128

116129
self.fake = None
117130
self.locale = None
@@ -556,23 +569,18 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
556569
str
557570
The normalized phone number in the format <country-code><number>.
558571
"""
572+
# Handle leading zero in local numbers before country code is removed
573+
if region not in ["US", "CA"] and phone.startswith("0"):
574+
# Remove the leading zero
575+
phone = phone[1:]
559576

560-
# Country code mapping for different regions
561-
country_codes = {
562-
"US": "1",
563-
"CA": "1",
564-
"FR": "33",
565-
"DE": "49",
566-
"GB": "44",
567-
"IT": "39",
568-
"PL": "48",
569-
"ES": "34",
570-
"BE": "32",
571-
"AT": "43",
572-
}
577+
# Fix Austrian phone number duplication issue before processing
578+
if region == "AT" and "4343" in phone:
579+
# Remove the duplicated country code
580+
phone = phone.replace("4343", "43")
573581

574582
# If phone is already normalized, return as it is
575-
expected_country_code = country_codes.get(region)
583+
expected_country_code = self.country_codes.get(region)
576584
if (
577585
expected_country_code
578586
and phone.isdigit()
@@ -581,17 +589,13 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
581589
):
582590
return phone
583591

584-
# Fix Austrian duplicated country code before processing
585-
if region == "AT" and phone.startswith("+4343"):
586-
phone = "+43" + phone[5:] # Remove duplicated 43
587-
588592
# Sub out anything that matches this regex statement with an empty string to get rid of extensions in generated phone numbers
589593
phone = re.sub(r"\s*(?:x|ext)\s*\d*$", "", phone, flags=re.IGNORECASE)
590594
# Sub out anything that is not a digit with the empty string to ensure the phone number is formatted with no spaces or special characters
591595
digits = re.sub(r"\D", "", phone)
592596

593597
# Determine country code
594-
country_code = country_codes.get(
598+
country_code = self.country_codes.get(
595599
region, "1"
596600
) # Default to "1" (US/CA) if the region is unknown
597601
# handle leading zeros
@@ -602,7 +606,7 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
602606
# Remove country code from the local number
603607
local_number = digits[len(country_code) :]
604608

605-
# Handle leading zero in local numbers
609+
# Handle leading zero in local numbers after country code is removed
606610
if region not in ["US", "CA"] and local_number.startswith("0"):
607611
# Remove the leading zero
608612
local_number = local_number[1:]
@@ -613,7 +617,9 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
613617
return ""
614618

615619
# Return formatted phone number with correct country code
616-
return f"{country_code}{local_number}"
620+
result = f"{country_code}{local_number}"
621+
logging.info(f"Phone normalization result: {phone} -> {result}")
622+
return result
617623

618624

619625
class BrowserActions:

0 commit comments

Comments
 (0)