From 256ce15184ad75e1830cca63955749fd6a69d65c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Jul 2026 16:24:05 +0000 Subject: [PATCH] Fix race in mobile column actions dialog test The dialog's aria-expanded sync on the trigger button runs from the native dialog close event, which fires in a queued task after the dialog is already hidden. Use a retrying expect() assertion instead of reading the attribute immediately. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01TShiUYVMmmF4zyJR6GMw34 --- tests/test_playwright.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_playwright.py b/tests/test_playwright.py index 6674501f..b38ba35f 100644 --- a/tests/test_playwright.py +++ b/tests/test_playwright.py @@ -937,6 +937,9 @@ def test_column_chooser_dialog_escape_discards_changes(page, datasette_server): @pytest.mark.playwright def test_mobile_column_actions_dialog(page, datasette_server): + # Deferred import so collecting this module works without playwright + from playwright.sync_api import expect + page.set_viewport_size({"width": 400, "height": 800}) page.goto(f"{datasette_server}data/projects") trigger = page.locator("button.column-actions-mobile") @@ -956,7 +959,9 @@ def test_mobile_column_actions_dialog(page, datasette_server): dialog.locator(".mobile-column-actions-done").click() dialog.wait_for(state="hidden") - assert trigger.get_attribute("aria-expanded") == "false" + # aria-expanded resets from the dialog close event, which fires in a + # queued task after the dialog is already hidden - so poll for it + expect(trigger).to_have_attribute("aria-expanded", "false") @pytest.mark.playwright