Skip to content

Commit 0fcdee9

Browse files
committed
Fix flaky e2e tests
1 parent 72d402f commit 0fcdee9

2 files changed

Lines changed: 30 additions & 7 deletions

File tree

e2e_playwright/e2e_utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,13 @@ def open_settings_panel(page: Page, container: Locator) -> Locator:
183183
# If the panel is animating out, wait for it to fully disappear first
184184
if panel.count():
185185
try:
186-
panel.wait_for(state="hidden", timeout=500)
186+
panel.wait_for(state="hidden", timeout=1500)
187187
except Exception:
188-
expect(panel).to_be_visible(timeout=5000)
189-
return panel
188+
try:
189+
if panel.is_visible():
190+
return panel
191+
except Exception:
192+
pass
190193

191194
button = container.get_by_test_id("toolbar-settings")
192195
button.scroll_into_view_if_needed()

e2e_playwright/pivot_table_interactions_test.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,21 +535,29 @@ def test_mixed_row_dimension_collapse_preserves_temporal_state(page_at_app: Page
535535
1, timeout=10000
536536
)
537537

538-
us_total_row = container.locator("tr").filter(has_text="US Total")
538+
us_total_row = container.locator(
539+
'tr[data-testid="pivot-subtotal-row"]:visible'
540+
).filter(has_text="US Total")
539541
expect(us_total_row).to_have_count(1, timeout=5000)
540542
us_group_toggle = us_total_row.get_by_test_id("pivot-group-toggle-US")
541-
us_group_toggle.dispatch_event("click")
543+
us_group_toggle.evaluate(
544+
"el => { el.scrollIntoView({ block: 'center', inline: 'nearest' }); el.click(); }"
545+
)
542546
expect(us_group_toggle).to_have_attribute("aria-expanded", "false", timeout=5000)
543547
expect(container.get_by_text("US Total")).to_be_visible(timeout=5000)
544548
expect(container.get_by_test_id("pivot-temporal-parent-row")).to_have_count(
545549
0, timeout=5000
546550
)
547551

548-
us_total_row = container.locator("tr").filter(has_text="US Total")
552+
us_total_row = container.locator(
553+
'tr[data-testid="pivot-subtotal-row"]:visible'
554+
).filter(has_text="US Total")
549555
expect(us_total_row).to_have_count(1, timeout=5000)
550556
us_group_toggle = us_total_row.get_by_test_id("pivot-group-toggle-US")
551557
expect(us_group_toggle).to_have_attribute("aria-expanded", "false", timeout=5000)
552-
us_group_toggle.dispatch_event("click")
558+
us_group_toggle.evaluate(
559+
"el => { el.scrollIntoView({ block: 'center', inline: 'nearest' }); el.click(); }"
560+
)
553561
expect(us_group_toggle).to_have_attribute("aria-expanded", "true", timeout=5000)
554562
expect(container.get_by_test_id("pivot-temporal-parent-row")).to_have_count(
555563
1, timeout=10000
@@ -1184,6 +1192,15 @@ def _drilldown_sort_button(panel, column_name: str):
11841192
)
11851193

11861194

1195+
def _drilldown_sort_header(panel, column_name: str):
1196+
"""Return the sortable header cell for a drilldown column."""
1197+
return (
1198+
panel.get_by_test_id("drilldown-table")
1199+
.locator("th")
1200+
.filter(has_text=column_name)
1201+
)
1202+
1203+
11871204
def test_drilldown_client_pagination_shows_controls(page_at_app: Page):
11881205
"""Client-only: clicking a cell with >500 records shows pagination controls."""
11891206
page = page_at_app
@@ -1215,8 +1232,11 @@ def test_drilldown_client_sort_orders_full_result_before_pagination(page_at_app:
12151232
page = page_at_app
12161233
_, panel = _open_drilldown_with_pagination(page, "test_pivot_drilldown_pagination")
12171234

1235+
revenue_header = _drilldown_sort_header(panel, "Revenue")
12181236
_drilldown_sort_button(panel, "Revenue").click()
1237+
expect(revenue_header).to_have_attribute("aria-sort", "ascending", timeout=5000)
12191238
_drilldown_sort_button(panel, "Revenue").click()
1239+
expect(revenue_header).to_have_attribute("aria-sort", "descending", timeout=5000)
12201240

12211241
# Fixture values for Alpha/2023 are 10..709 inclusive, so descending page 1
12221242
# starts at 709 and descending page 2 starts at 209 after the first 500 rows.

0 commit comments

Comments
 (0)