Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions l10n_CM/constants/mediamarkt/AT/mediamarkt_ad.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"url": "http://127.0.0.1:8080/mediamarkt_ad.html",
"field_mapping": {
"given_name": "eb82fd1f-6ebc-4e00-91b0-b33126e3ef51",
"family_name": "5f200911-7e5f-4d9a-9d75-8cc496b455a7",
"street_address": "81b35c70-5949-4b70-afc8-030bdc2d9128",
"email": "ddde9f4b-5d3d-4346-bb45-1df768613507",
"telephone": "721fc82e-817e-4bff-8b5d-e4360eee4724"

},
"form_field": "*[data-moz-autofill-inspect-id='{name}']",
"fields": [
"eb82fd1f-6ebc-4e00-91b0-b33126e3ef51",
"5f200911-7e5f-4d9a-9d75-8cc496b455a7",
"81b35c70-5949-4b70-afc8-030bdc2d9128",
"ddde9f4b-5d3d-4346-bb45-1df768613507",
"721fc82e-817e-4bff-8b5d-e4360eee4724"
]
}
16 changes: 16 additions & 0 deletions l10n_CM/constants/mediamarkt/AT/mediamarkt_cc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"url": "http://127.0.0.1:8080/mediamarkt_cc.html",
"field_mapping": {
"card_number": "1d77675c-2591-4e83-b5b5-286b1196d918",
"expiration_date": "811f3be9-b204-469f-aff5-294aa91fb232",
"name": "cdf66cc6-01cb-4f0d-b905-fc4bd37c51e1",
"cvv": "839f304f-4191-4bb7-b3bc-75d9d2314715"
},
"form_field": "*[data-moz-autofill-inspect-id='{name}']",
"fields": [
"1d77675c-2591-4e83-b5b5-286b1196d918",
"811f3be9-b204-469f-aff5-294aa91fb232",
"cdf66cc6-01cb-4f0d-b905-fc4bd37c51e1",
"839f304f-4191-4bb7-b3bc-75d9d2314715"
]
}
20 changes: 20 additions & 0 deletions l10n_CM/constants/zalando/IT/zalando_ad.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"url": "http://127.0.0.1:8080/zalando_ad.html",
"field_mapping": {
"given_name":"c5f8ff92-697e-46dc-bfba-9b9e7cdc14e7",
"family_name":"325c01d4-84df-4932-8db6-bfc0cb44a434",
"street_address":"e5d2f67c-2506-4d2a-a26d-7c373fe652f2",
"postal_code":"116ae2a6-aaf6-4d83-9dc6-6ab532b2613d",
"address_level_2": "2373a2e4-629e-41a7-b2fb-2a7d76dbb093"

},
"form_field": "*[data-moz-autofill-inspect-id='{name}']",
"fields": [
"c5f8ff92-697e-46dc-bfba-9b9e7cdc14e7",
"325c01d4-84df-4932-8db6-bfc0cb44a434",
"e5d2f67c-2506-4d2a-a26d-7c373fe652f2",
"116ae2a6-aaf6-4d83-9dc6-6ab532b2613d",
"2373a2e4-629e-41a7-b2fb-2a7d76dbb093"

]
}
17 changes: 17 additions & 0 deletions l10n_CM/constants/zalando/IT/zalando_cc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"url": "http://127.0.0.1:8080/zalando_cc.html",
"field_mapping": {
"card_name": "9698e0d8-06d5-4538-a5e2-49931904c8a1",
"card_number": "bb810e33-ff6f-4755-af03-924b6263b822",
"expiration_date": "0f3e3c5e-a4ef-4fbe-997b-40d146ab7e96",
"cvv": "adda6a56-6f74-4cb4-9829-19393edf1e2c"
},
"form_field": "*[data-moz-autofill-inspect-id='{name}']",
"skip": "True",
"fields": [
"9698e0d8-06d5-4538-a5e2-49931904c8a1",
"bb810e33-ff6f-4755-af03-924b6263b822",
"0f3e3c5e-a4ef-4fbe-997b-40d146ab7e96",
"adda6a56-6f74-4cb4-9829-19393edf1e2c"
]
}
2 changes: 1 addition & 1 deletion l10n_CM/region/AT.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"region": "AT",
"sites": [
"demo",
"torfs"
"mediamarkt"
],
"tests": [
]
Expand Down
1 change: 0 additions & 1 deletion l10n_CM/run_l10n.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"bijoubrigitte",
"brico",
"burtsbees",
"burtsbeescalvinklein",
"calvinklein",
"canadatire",
"cdiscount",
Expand Down
2 changes: 2 additions & 0 deletions l10n_CM/sites/mediamarkt/AT/mediamarkt_ad.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions l10n_CM/sites/mediamarkt/AT/mediamarkt_cc.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions l10n_CM/sites/zalando/IT/zalando_ad.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions l10n_CM/sites/zalando/IT/zalando_cc.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions modules/page_object_autofill.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ def verify_autofill_data_on_hover(
is_present = any(
[value in val for val in autofill_data.__dict__.values()]
)

assert is_present, (
f"Mismatched data: {(field, value)} not in {autofill_data.__dict__.values()}."
)
Expand Down
48 changes: 27 additions & 21 deletions modules/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ def __init__(self):
"Belgium": "België",
"Austria": "Österreich",
}
# Country code mapping for different regions
self.country_codes = {
"US": "1",
"CA": "1",
"FR": "33",
"DE": "49",
"GB": "44",
"IT": "39",
"PL": "48",
"ES": "34",
"BE": "32",
"AT": "43",
}

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

# Country code mapping for different regions
country_codes = {
"US": "1",
"CA": "1",
"FR": "33",
"DE": "49",
"GB": "44",
"IT": "39",
"PL": "48",
"ES": "34",
"BE": "32",
"AT": "43",
}
# Fix Austrian phone number duplication issue before processing
if region == "AT" and "4343" in phone:
# Remove the duplicated country code
phone = phone.replace("4343", "43")

# If phone is already normalized, return as it is
expected_country_code = country_codes.get(region)
expected_country_code = self.country_codes.get(region)
if (
expected_country_code
and phone.isdigit()
Expand All @@ -581,17 +589,13 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
):
return phone

# Fix Austrian duplicated country code before processing
if region == "AT" and phone.startswith("+4343"):
phone = "+43" + phone[5:] # Remove duplicated 43

# Sub out anything that matches this regex statement with an empty string to get rid of extensions in generated phone numbers
phone = re.sub(r"\s*(?:x|ext)\s*\d*$", "", phone, flags=re.IGNORECASE)
# 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
digits = re.sub(r"\D", "", phone)

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

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

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


class BrowserActions:
Expand Down
Loading