Skip to content

Commit 689ee3d

Browse files
authored
Merge branch 'main' into anca/cm-pl-zalando
2 parents d69f7bb + 455614d commit 689ee3d

File tree

9 files changed

+79
-7
lines changed

9 files changed

+79
-7
lines changed

l10n_CM/Unified/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ def cc_site_data(live_site, region):
106106
@pytest.fixture
107107
def is_live_site(live_site, region):
108108
"""Determine if the site is live.
109-
Treat demo IT as a live site until the doorhanger bug is fixed.
109+
Treat demo IT and ES as a live site until the doorhanger bug is fixed.
110110
"""
111-
return live_site != "demo" or region in {"IT"}
111+
return live_site != "demo" or region in {"IT", "ES"}
112112

113113

114114
@pytest.fixture(scope="session")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"url": "http://127.0.0.1:8080/ebay_ad.html",
3+
"field_mapping": {
4+
"country": "country",
5+
"given_name": "firstName",
6+
"family_name": "lastName",
7+
"telephone": "phoneNumber",
8+
"street_address": "addressLine1",
9+
"address_level_1": "stateOrProvince",
10+
"address_level_2": "city",
11+
"postal_code": "postalCode"
12+
},
13+
"form_field": "*[id='{name}']",
14+
"fields": [
15+
"country",
16+
"firstName",
17+
"lastName",
18+
"phoneNumber",
19+
"addressLine1",
20+
"stateOrProvince",
21+
"city",
22+
"postalCode"
23+
],
24+
"skip_os": ["Linux"]
25+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"url": "http://127.0.0.1:8080/ebay_cc.html",
3+
"field_mapping": {
4+
"card_number": "c995cecd-7228-4738-8b0c-8334752df865",
5+
"given_name": "ea7b6d20-f825-4fda-995d-f461ec3b4e28",
6+
"family_name": "07a705dd-d116-4036-abaa-494e1a20483d",
7+
"expiration_date": "25921b11-f253-488b-ab18-5db93cc912ec",
8+
"cvv":"38d8e85e-5fdb-498a-ba95-f4a04e38b876"
9+
},
10+
"form_field": "*[data-moz-autofill-inspect-id='{name}']",
11+
"fields": [
12+
"c995cecd-7228-4738-8b0c-8334752df865",
13+
"ea7b6d20-f825-4fda-995d-f461ec3b4e28",
14+
"07a705dd-d116-4036-abaa-494e1a20483d",
15+
"25921b11-f253-488b-ab18-5db93cc912ec",
16+
"38d8e85e-5fdb-498a-ba95-f4a04e38b876"
17+
]
18+
}

l10n_CM/region/ES.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"region": "ES",
3+
"sites": [
4+
"demo",
5+
"ebay"
6+
],
7+
"tests": [
8+
]
9+
}

l10n_CM/run_l10n.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
current_dir = os.path.dirname(__file__)
1616
valid_flags = {"--run-headless", "-n", "--reruns", "--fx-executable", "--ci"}
1717
flag_with_parameter = {"-n", "--reruns"}
18-
valid_region = {"US", "CA", "DE", "FR", "IT", "GB", "PL"}
18+
valid_region = {"US", "CA", "DE", "FR", "IT", "GB", "PL", "ES"}
1919
valid_sites = {
2020
"demo",
2121
"amazon",

l10n_CM/sites/ebay/ES/ebay_ad.html

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

l10n_CM/sites/ebay/ES/ebay_cc.html

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

modules/page_object_autofill.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ def verify_form_data(
241241
attr_name, expected_value, auto_filled_field_value, region
242242
)
243243

244+
# Strip whitespace before asserting
245+
if expected_value is not None and auto_filled_field_value is not None:
246+
expected_value = expected_value.strip()
247+
auto_filled_field_value = auto_filled_field_value.strip()
248+
244249
assert expected_value in auto_filled_field_value, (
245250
f"Field '{attr_name}' ('{field_name}'): expected '{expected_value}' to be in '{auto_filled_field_value}'"
246251
)

modules/util.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(self):
104104
"Yukon": "YT",
105105
}
106106
# temporary fix until faker issue is resolved
107-
self.country_local_translation = {"Germany": "Deutschland", "Italy": "Italia"}
107+
self.country_local_translation = {"Germany": "Deutschland", "Italy": "Italia", "Spain": "España"}
108108
self.fake = None
109109
self.locale = None
110110

@@ -277,7 +277,12 @@ def fake_autofill_data(self, country_code) -> AutofillAddressBase:
277277
region_attributes = ["state", "administrative_unit", "region"]
278278
fake, valid_code = self.create_localized_faker(country_code)
279279
name = fake.name()
280-
given_name, family_name = name.split()
280+
281+
# Safely split the name
282+
name_parts = name.split()
283+
given_name = name_parts[0]
284+
family_name = name_parts[-1] if len(name_parts) > 1 else ""
285+
281286
organization = fake.company().replace(",", "")
282287
street_address = fake.street_address()
283288
# find correct attribute for selected locale
@@ -325,7 +330,12 @@ def fake_credit_card_data(
325330
"""
326331
fake, valid_code = self.create_localized_faker(country_code)
327332
name = fake.name()
328-
given_name, family_name = name.split()
333+
334+
# Safely split the name
335+
name_parts = name.split()
336+
given_name = name_parts[0]
337+
family_name = name_parts[-1] if len(name_parts) > 1 else ""
338+
329339
card_number = fake.credit_card_number()
330340
generated_credit_expiry = fake.credit_card_expire()
331341
expiration_month, expiration_year = generated_credit_expiry.split("/")
@@ -547,6 +557,7 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
547557
"GB": "44",
548558
"IT": "39",
549559
"PL": "48",
560+
"ES": "34"
550561
}
551562

552563
# Sub out anything that matches this regex statement with an empty string to get rid of extensions in generated phone numbers
@@ -567,7 +578,7 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
567578
local_number = digits[len(country_code) :]
568579

569580
# Handle leading zero in local numbers (France & Germany)
570-
if region in ["FR", "DE", "GB", "IT"] and local_number.startswith("0"):
581+
if region in ["FR", "DE", "GB", "IT", "ES"] and local_number.startswith("0"):
571582
# Remove the leading zero
572583
local_number = local_number[1:]
573584

0 commit comments

Comments
 (0)