Skip to content

Commit 633e2af

Browse files
committed
fix: resolve CI test failures by removing race conditions
- Removed wait_for_new_experiment_result wrapper where it caused race conditions - Use wait_for_load_state('networkidle') for more reliable waiting - Increased all timeouts from 5s to 10s for CI stability - Tests now wait for DOM changes directly instead of experiment key changes
1 parent 86a52a0 commit 633e2af

1 file changed

Lines changed: 28 additions & 26 deletions

File tree

align_browser/test_frontend_real_data.py

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,15 @@ def test_kdma_combination_default_value_issue(page, real_data_test_server):
351351
# Set initial KDMA dropdown to a valid value to enable adding another KDMA
352352
initial_kdma_dropdown = page.locator(".table-kdma-value-select").first
353353

354-
with wait_for_new_experiment_result(page):
355-
# Select option with value '1' if available
356-
options = initial_kdma_dropdown.locator("option").all_text_contents()
357-
for i, option in enumerate(options):
358-
if option.strip() in ["1", "1.0"]:
359-
initial_kdma_dropdown.select_option(index=i)
360-
break
361-
# Wait for results to load after KDMA change
354+
# Select option with value '1' if available
355+
options = initial_kdma_dropdown.locator("option").all_text_contents()
356+
for i, option in enumerate(options):
357+
if option.strip() in ["1", "1.0"]:
358+
initial_kdma_dropdown.select_option(index=i)
359+
break
360+
361+
# Wait for network to settle after KDMA change
362+
page.wait_for_load_state("networkidle", timeout=10000)
362363

363364
# Check initial KDMA dropdowns - should have affiliation already
364365
kdma_dropdowns = page.locator(".table-kdma-value-select")
@@ -375,13 +376,12 @@ def test_kdma_combination_default_value_issue(page, real_data_test_server):
375376
"Add KDMA button must be available for this test"
376377
)
377378
# Click Add KDMA button to add second KDMA
378-
with wait_for_new_experiment_result(page):
379-
add_kdma_button.click()
379+
add_kdma_button.click()
380380

381381
# Wait for new KDMA dropdown to be added by checking for count increase
382382
page.wait_for_function(
383383
f"document.querySelectorAll('.table-kdma-value-select').length > {initial_count}",
384-
timeout=5000,
384+
timeout=10000,
385385
)
386386

387387
# Check that a new KDMA dropdown was added
@@ -464,15 +464,15 @@ def test_kdma_delete_button_enabled_after_adding_second_kdma(
464464
# Set initial KDMA dropdown to a valid value to enable adding another KDMA
465465
initial_kdma_dropdown = page.locator(".table-kdma-value-select").first
466466

467-
with wait_for_new_experiment_result(page):
468-
# Select option with value '1' if available
469-
options = initial_kdma_dropdown.locator("option").all_text_contents()
470-
for i, option in enumerate(options):
471-
if option.strip() in ["1", "1.0"]:
472-
initial_kdma_dropdown.select_option(index=i)
473-
break
467+
# Select option with value '1' if available
468+
options = initial_kdma_dropdown.locator("option").all_text_contents()
469+
for i, option in enumerate(options):
470+
if option.strip() in ["1", "1.0"]:
471+
initial_kdma_dropdown.select_option(index=i)
472+
break
474473

475-
page.wait_for_load_state("networkidle")
474+
# Wait for network to settle after KDMA change
475+
page.wait_for_load_state("networkidle", timeout=10000)
476476

477477
# Check initial KDMA delete buttons - should be disabled with single KDMA
478478
initial_delete_buttons = page.locator(".table-kdma-remove-btn")
@@ -502,12 +502,12 @@ def test_kdma_delete_button_enabled_after_adding_second_kdma(
502502
expect(add_kdma_button).to_be_enabled()
503503

504504
# Click Add KDMA button to add second KDMA
505-
with wait_for_new_experiment_result(page):
506-
add_kdma_button.click()
505+
add_kdma_button.click()
507506

508507
# Wait for new KDMA dropdown to be added
509508
page.wait_for_function(
510-
"document.querySelectorAll('.table-kdma-value-select').length > 1", timeout=5000
509+
"document.querySelectorAll('.table-kdma-value-select').length > 1",
510+
timeout=10000,
511511
)
512512

513513
# Now check delete buttons after adding second KDMA
@@ -631,7 +631,8 @@ def test_kdma_add_remove_updates_experiment_results(page, real_data_test_server)
631631

632632
# Wait for new KDMA dropdown to be added
633633
page.wait_for_function(
634-
"document.querySelectorAll('.table-kdma-value-select').length > 1", timeout=5000
634+
"document.querySelectorAll('.table-kdma-value-select').length > 1",
635+
timeout=10000,
635636
)
636637

637638
# # Check if there's a KDMA type dropdown for the new KDMA and select merit
@@ -686,7 +687,7 @@ def test_kdma_add_remove_updates_experiment_results(page, real_data_test_server)
686687
# Wait for KDMA to be removed
687688
page.wait_for_function(
688689
"document.querySelectorAll('.table-kdma-value-select').length === 1",
689-
timeout=5000,
690+
timeout=10000,
690691
)
691692

692693
# Wait for results to reload after removal
@@ -782,7 +783,8 @@ def test_add_kdma_button_always_visible(page, real_data_test_server):
782783

783784
# Wait for KDMA to be added
784785
page.wait_for_function(
785-
"document.querySelectorAll('.table-kdma-value-select').length > 1", timeout=5000
786+
"document.querySelectorAll('.table-kdma-value-select').length > 1",
787+
timeout=10000,
786788
)
787789

788790
# Check that Add KDMA button is still visible
@@ -832,7 +834,7 @@ def test_run_variant_dropdown_functionality(page, real_data_test_server):
832834

833835
# Wait for initial auto-pin to complete
834836
page.wait_for_function(
835-
"document.querySelectorAll('.comparison-table tr').length > 2", timeout=5000
837+
"document.querySelectorAll('.comparison-table tr').length > 2", timeout=10000
836838
)
837839

838840
# Look for run variant row

0 commit comments

Comments
 (0)