Skip to content

Commit 041c8e1

Browse files
committed
Merge main
2 parents 5c19352 + c78827b commit 041c8e1

File tree

11 files changed

+171
-54
lines changed

11 files changed

+171
-54
lines changed

.github/workflows/check-beta-l10n.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Check new beta version - L10N
22

33
on:
44
schedule:
5-
- cron: "40 */1 * * *"
5+
- cron: "21 */1 * * *"
66
env:
77
LATEST: ""
88
permissions:

choose_l10n_ci_set.py

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import json
2+
import logging
23
import os
34
import re
5+
import subprocess
46
import sys
57
from collections import defaultdict
68
from subprocess import check_output
@@ -32,16 +34,28 @@ def valid_l10n_mappings():
3234
return mapping
3335

3436

35-
def add_selected_mappings(mappings):
37+
def distribute_mappings_evenly(mappings, version):
3638
"""
3739
Write the selected mappings to the output file.
3840
3941
Args:
4042
mappings (dict): A dictionary of mappings, where the keys are sites and the values are sets of regions.
43+
version (int): The beta_version of the beta.
4144
"""
42-
for site, regions in mappings.items():
43-
with open(OUTPUT_FILE, "a+") as f:
44-
f.write(f"{site} {' '.join(regions)}\n")
45+
if not mappings:
46+
return {}
47+
# sort the mappings by the length of the regions per site
48+
mappings = dict(sorted(mappings.items(), key=lambda val: len(val[1]), reverse=True))
49+
# place the mappings into 3 containers evenly according to the load
50+
loads = [0, 0, 0]
51+
containers = [defaultdict(set) for _ in range(3)]
52+
for key, value in mappings.items():
53+
min_idx = loads.index(min(loads))
54+
containers[min_idx][key] = value
55+
loads[min_idx] += len(value)
56+
# get container index according to beta beta_version
57+
run_idx = version % 3
58+
return containers[run_idx]
4559

4660

4761
def process_changed_file(f, selected_mappings):
@@ -53,7 +67,6 @@ def process_changed_file(f, selected_mappings):
5367
selected_mappings: the selected mappings dictionary (updated in place).
5468
"""
5569
split = f.split(SLASH)
56-
5770
if f.startswith(os.path.join("l10n_CM", "sites")) or f.startswith(
5871
os.path.join("l10n_CM", "constants")
5972
):
@@ -73,6 +86,23 @@ def process_changed_file(f, selected_mappings):
7386
selected_mappings[site].add(region)
7487

7588

89+
def save_mappings(selected_container):
90+
"""
91+
Save the selected mappings to the output file.
92+
93+
Args:
94+
selected_container: the selected mappings container.
95+
"""
96+
if not selected_container:
97+
return
98+
current_running_mappings = [
99+
f"{key} {' '.join(value)}\n" for key, value in selected_container.items()
100+
]
101+
logging.warning(f"Running the mappings:\n{''.join(current_running_mappings)}")
102+
with open(OUTPUT_FILE, "a+") as f:
103+
f.writelines(current_running_mappings)
104+
105+
76106
if __name__ == "__main__":
77107
if os.path.exists(".env"):
78108
with open(".env") as fh:
@@ -83,11 +113,27 @@ def process_changed_file(f, selected_mappings):
83113
os.environ["MANUAL"] = "true"
84114
with open(OUTPUT_FILE, "w") as file:
85115
pass # File is created or cleared
116+
try:
117+
beta_version = int(
118+
(
119+
subprocess.check_output(
120+
[sys.executable, "./collect_executables.py", "-n"]
121+
)
122+
.strip()
123+
.decode()
124+
)
125+
.split("-")[0]
126+
.split(".")[1]
127+
.split("b")[1]
128+
)
129+
except ValueError:
130+
# failsafe beta_version
131+
beta_version = 0
86132
l10n_mappings = valid_l10n_mappings()
87133
sample_mappings = {k: v for k, v in l10n_mappings.items() if k.startswith("demo")}
88134
if os.environ.get("TESTRAIL_REPORT") or os.environ.get("MANUAL"):
89135
# Run all tests if this is a scheduled beta or a manual run
90-
add_selected_mappings(l10n_mappings)
136+
save_mappings(distribute_mappings_evenly(l10n_mappings, beta_version))
91137
sys.exit(0)
92138

93139
re_set_all = [
@@ -148,5 +194,5 @@ def process_changed_file(f, selected_mappings):
148194
selected_mappings |= sample_mappings
149195
break
150196

151-
add_selected_mappings(selected_mappings)
197+
save_mappings(distribute_mappings_evenly(selected_mappings, beta_version))
152198
sys.exit(0)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"url": "http://127.0.0.1:8080/burtsbees_ad.html",
3+
"field_mapping": {
4+
"given_name": "484c9a5e-d921-4d8d-8006-45ba05e0f68a",
5+
"family_name": "f5cade23-4cbf-47dd-8011-4979698b5d12",
6+
"street_address": "5bad4ca0-fc9e-452c-a04c-1ffc66bd2024",
7+
"address_level_2": "7a97a81e-44e2-40b0-a3ac-d8608463cd1e",
8+
"postal_code": "95c16291-635f-4ed0-b18e-e733d36fcc83",
9+
"telephone": "75d72d2e-61d0-415f-b51f-0ed1fe1d1922"
10+
},
11+
"form_field": "*[data-moz-autofill-inspect-id='{name}']",
12+
"fields": [
13+
"484c9a5e-d921-4d8d-8006-45ba05e0f68a",
14+
"f5cade23-4cbf-47dd-8011-4979698b5d12",
15+
"5bad4ca0-fc9e-452c-a04c-1ffc66bd2024",
16+
"7a97a81e-44e2-40b0-a3ac-d8608463cd1e",
17+
"95c16291-635f-4ed0-b18e-e733d36fcc83",
18+
"75d72d2e-61d0-415f-b51f-0ed1fe1d1922"
19+
]
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"url": "http://127.0.0.1:8080/burtsbees_cc.html",
3+
"field_mapping": {
4+
"card_number": "39b722f9-ff49-4e30-a801-4a38945cc7e1",
5+
"expiration_date": "57021e0e-6309-45b1-9c15-62cd56e1e930",
6+
"cvv": "57021e0e-6309-45b1-9c15-62cd56e1e930"
7+
},
8+
"form_field": "*[data-moz-autofill-inspect-id='{name}']",
9+
"skip": "True",
10+
"fields": [
11+
"39b722f9-ff49-4e30-a801-4a38945cc7e1",
12+
"57021e0e-6309-45b1-9c15-62cd56e1e930",
13+
"57021e0e-6309-45b1-9c15-62cd56e1e930"
14+
]
15+
}

l10n_CM/region/CA.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
"region": "CA",
33
"sites": [
44
"amazon",
5-
"canadatire",
5+
"walmart",
66
"demo",
7-
"ebay",
87
"etsy",
98
"newbalance",
10-
"staples",
11-
"walmart"
9+
"canadatire",
10+
"ebay",
11+
"burtsbees",
12+
"staples"
1213
],
1314
"tests": [
1415
]

l10n_CM/region/GB.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"region": "GB",
33
"sites": [
4-
"assos",
5-
"demo",
6-
"diy",
74
"ebay",
5+
"demo",
86
"peacocks",
9-
"whittard"
7+
"whittard",
8+
"diy",
9+
"assos"
1010
],
1111
"tests": [
1212
]

l10n_CM/run_l10n.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,36 @@
1717
flag_with_parameter = {"-n", "--reruns"}
1818
valid_region = {"US", "CA", "DE", "FR", "IT", "GB"}
1919
valid_sites = {
20-
"aldoshoes",
20+
"demo",
2121
"amazon",
22-
"apple",
23-
"artsper",
24-
"assos",
25-
"bestbuy",
26-
"bijoubrigitte",
22+
"walmart",
23+
"mediamarkt",
24+
"lowes",
25+
"etsy",
2726
"calvinklein",
28-
"canadatire",
29-
"cdiscount",
27+
"bestbuy",
3028
"decathlon",
31-
"demo",
32-
"diy",
29+
"newegg",
30+
"vans",
3331
"ebay",
34-
"etsy",
35-
"justspices",
36-
"lowes",
37-
"mediamarkt",
3832
"newbalance",
39-
"newegg",
40-
"peacocks",
41-
"staples",
33+
"zalando",
34+
"cdiscount",
35+
"aldoshoes",
36+
"canadatire",
37+
"apple",
4238
"thomann",
43-
"vans",
44-
"walmart",
45-
"whittard",
4639
"wish",
40+
"artsper",
41+
"justspices",
4742
"yellowkorner",
48-
"zalando",
43+
"bijoubrigitte",
44+
"burtsbees",
45+
"peacocks",
46+
"whittard",
47+
"diy",
48+
"assos",
49+
"staples",
4950
}
5051

5152
loaded_valid_sites = valid_l10n_mappings().keys()

l10n_CM/sites/burtsbees/CA/burtsbees_ad.html

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

l10n_CM/sites/burtsbees/CA/burtsbees_cc.html

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

modules/browser_object_autofill_popup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
from typing import Union
23

34
from selenium.webdriver.remote.webelement import WebElement
@@ -45,7 +46,13 @@ def ensure_autofill_dropdown_visible(self, field_element: WebElement = None):
4546
field_element: if field element is given.
4647
check whether it is a select element. pass the check if it is.
4748
"""
48-
self.element_visible("select-form-option")
49+
self.element_exists("pop-up-component")
50+
popup_component = self.get_element("pop-up-component")
51+
logging.warning(
52+
f"Parent pop up component: {len(popup_component.get_attribute('innerHTML')) > 1}"
53+
)
54+
if popup_component:
55+
self.element_visible("select-form-option")
4956
return self
5057

5158
# Interaction with popup elements

0 commit comments

Comments
 (0)