Skip to content

Commit 8466fb2

Browse files
authored
Merge pull request #619 from mozilla/ben/stabilize-addon-plus
Stabilize Various Tests, improve About:Logins methods
2 parents 562d7d4 + 9ba59df commit 8466fb2

11 files changed

+40
-19
lines changed

choose_ci_set.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ def dedupe(run_list: list, slash: str) -> list:
9393
for j, entry_b in enumerate(run_list):
9494
if i == j:
9595
continue
96-
candidate = max((i, j))
97-
if entry_a in entry_b and candidate not in removes:
98-
removes.append(candidate)
96+
candidate = max((entry_a, entry_b))
97+
cand_index = run_list.index(candidate)
98+
if entry_a in entry_b and cand_index not in removes:
99+
removes.append(cand_index)
99100

100101
removes.sort(reverse=True)
101102
for remove in removes:
@@ -228,6 +229,8 @@ def dedupe(run_list: list, slash: str) -> list:
228229
run_list.extend(ci_paths)
229230

230231
# Dedupe just in case
232+
if slash == "\\":
233+
run_list = [entry.replace("/", slash) for entry in run_list]
231234
run_list = dedupe(run_list, slash)
232235
run_list = [entry for entry in run_list if os.path.exists(entry.split("::")[0])]
233236
with open(OUTPUT_FILE, "w") as fh:

dev_pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ markers = [
1212
"ci: basic tests to run in ci",
1313
"locale_de: tests run in DE locale versions",
1414
"locale_fr: tests run in FR locale versions",
15-
"locale_gb: tests run in GB locale versions"
15+
"locale_gb: tests run in GB locale versions",
16+
"noxvfb: tests that should not run in xvfb sessions"
1617
]
1718

1819
[tool.ruff]

modules/page_object_about_pages.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,14 @@ def create_new_login(self, form_info: dict) -> Page:
152152
try:
153153
for item_type, value in form_info.items():
154154
logging.info(f"Filling {item_type} with {value}")
155-
self.ba.clear_and_fill(
156-
self.get_element("login-item-type", labels=[item_type]), value
157-
)
155+
self.fill("login-item-type", value, labels=[item_type])
158156
logging.info("Clicking submit...")
159-
self.get_element("create-login-button")
157+
self.wait.until(
158+
lambda _: self.get_element("create-login-button").get_attribute(
159+
"disabled"
160+
)
161+
is None
162+
)
160163
logging.info("Submitted.")
161164
except (WebDriverException, StaleElementReferenceException):
162165
logging.info("Element not found or stale, pressing 'Save Changes'")

modules/testrail_scripts/testrail_status_analyses.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,30 +281,30 @@ def print_numerical_summary(project_stats):
281281
report.info("NUMERICAL SUMMARY - TOTAL COUNTS")
282282
report.info(f"{'=' * 80}")
283283

284-
report.info(f"\n OVERALL TOTALS:")
284+
report.info("\n OVERALL TOTALS:")
285285
report.info(f" Total Suites: {project_stats['total_suites']}")
286286
report.info(f" Total Test Cases: {project_stats['total_cases']}")
287287

288288
if project_stats["total_cases"] == 0:
289289
return
290290

291-
report.info(f"\n SUB TEST SUITE TOTALS:")
291+
report.info("\n SUB TEST SUITE TOTALS:")
292292
total_by_sub_suite = sorted(
293293
project_stats["by_sub_test_suite"].items(), key=lambda x: x[1], reverse=True
294294
)
295295
for sub_suite, count in total_by_sub_suite:
296296
percentage = (count / project_stats["total_cases"]) * 100
297297
report.info(f" {sub_suite:30}: {count:6} cases ({percentage:5.1f}%)")
298298

299-
report.info(f"\n AUTOMATION STATUS TOTALS:")
299+
report.info("\n AUTOMATION STATUS TOTALS:")
300300
total_by_status = sorted(
301301
project_stats["by_automation_status"].items(), key=lambda x: x[1], reverse=True
302302
)
303303
for status, count in total_by_status:
304304
percentage = (count / project_stats["total_cases"]) * 100
305305
report.info(f" {status:20}: {count:6} cases ({percentage:5.1f}%)")
306306

307-
report.info(f"\n AUTOMATION COVERAGE TOTALS:")
307+
report.info("\n AUTOMATION COVERAGE TOTALS:")
308308
total_by_coverage = sorted(
309309
project_stats["by_automation_coverage"].items(),
310310
key=lambda x: x[1],
@@ -434,7 +434,7 @@ def main():
434434
report.info(f"{'=' * 80}")
435435
report.info(f" Analyzed {project_stats['total_suites']} suites")
436436
report.info(f" Processed {project_stats['total_cases']} test cases")
437-
report.info(f" Generated detailed statistics and breakdowns")
437+
report.info(" Generated detailed statistics and breakdowns")
438438
else:
439439
op_log.error(" Analysis failed!")
440440

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ markers = [
1212
"ci: basic tests to run in ci",
1313
"locale_de: tests run in DE locale versions",
1414
"locale_fr: tests run in FR locale versions",
15-
"locale_gb: tests run in GB locale versions"
15+
"locale_gb: tests run in GB locale versions",
16+
"noxvfb: tests that should not run in xvfb sessions"
1617
]
1718

1819
[tool.ruff]

tests/bookmarks_and_history/test_open_bookmark_in_private_window_via_toolbar_context_menu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from selenium.webdriver import Firefox
33

4-
from modules.browser_object import ContextMenu, Navigation, PanelUi, TabBar
4+
from modules.browser_object import Navigation, TabBar
55
from modules.page_object_generics import GenericPage
66

77

tests/password_manager/test_add_password_non_ascii_chars.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_add_password_non_ascii_chars(driver: Firefox):
2222

2323
# Open about:logins and click on the "Add password" button
2424
about_logins.open()
25+
original_logins_amount = len(about_logins.get_elements("login-list-item"))
2526
about_logins.click_add_login_button()
2627

2728
# Complete all the fields with valid data and click the "Save" button.
@@ -34,7 +35,12 @@ def test_add_password_non_ascii_chars(driver: Firefox):
3435
)
3536

3637
# Check password added in the listbox
38+
about_logins.wait.until(
39+
lambda _: len(about_logins.get_elements("login-list-item"))
40+
> original_logins_amount
41+
)
3742
logins = about_logins.get_elements("login-list-item")
43+
3844
mozilla_login = next(
3945
login for login in logins if login.get_attribute("title") == WEBSITE_ADDRESS
4046
)

tests/password_manager/test_changes_made_in_edit_mode_are_saved.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def test_changes_made_in_edit_mode_are_saved(driver: Firefox):
3434
}
3535
)
3636
# Click the "Edit" button
37+
about_logins.element_visible("edit-login")
3738
about_logins.click_on("edit-login")
3839

3940
# Change username and the password

tests/password_manager/test_multiple_saved_logins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_multiple_saved_logins(driver: Firefox, temp_selectors):
5555
"password": PASSWORD,
5656
}
5757
)
58-
time.sleep(0.1)
58+
time.sleep(0.8)
5959
about_logins.click_add_login_button()
6060
about_logins.create_new_login(
6161
{
@@ -64,7 +64,7 @@ def test_multiple_saved_logins(driver: Firefox, temp_selectors):
6464
"password": PASSWORD2,
6565
}
6666
)
67-
time.sleep(0.1)
67+
time.sleep(0.8)
6868
about_logins.click_add_login_button()
6969
about_logins.create_new_login(
7070
{

tests/password_manager/test_primary_password_triggered_on_about_logins_access.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def test_primary_password_triggered_on_about_logins_access_via_hamburger_menu(
6666
)
6767

6868
# Attempt to view the saved password in order to trigger the primary password prompt
69+
about_logins.element_visible("show-password-checkbox")
6970
about_logins.click_on("show-password-checkbox")
7071

7172
# Dismiss the primary password prompt without entering the password

0 commit comments

Comments
 (0)