From b92d115a3912990783f2c4ab6aac38b87d94d3d4 Mon Sep 17 00:00:00 2001 From: Bobby Noelte Date: Mon, 9 Nov 2026 12:53:26 +0000 Subject: [PATCH] test(eosdash): wait for the htmx swap before checking a tab's content The browser test read the content area right after the tab's response arrived. htmx swaps the response in after that, and wait_for_load_state() did not wait for it, as the page itself was loaded long before. For the large configuration tab the content area was sometimes still empty, so the test failed in CI. Wait until the content area is filled again after a successful response. Co-Authored-By: Claude Opus 5.5 --- tests/test_eosdashbrowser.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/test_eosdashbrowser.py b/tests/test_eosdashbrowser.py index c48c07e0..737c3cf4 100644 --- a/tests/test_eosdashbrowser.py +++ b/tests/test_eosdashbrowser.py @@ -89,21 +89,35 @@ class DashPage: the previous tab cannot be mistaken for the new tab: htmx does not swap error responses, which leaves the content area empty. + htmx swaps the content in after the response has arrived. For a + successful response this waits until the content area is filled again; + ``wait_for_load_state()`` would not wait, as the page itself is loaded. + Args: path: Path of the tab, as in its ``hx-get`` attribute. Returns: HTTP status of the tab request. """ + from playwright.sync_api import TimeoutError as PlaywrightTimeoutError + self.page.eval_on_selector(PAGE_CONTENT_SELECTOR, "element => element.replaceChildren()") # The tabs add query values (e.g. dark=true): compare the path only. with self.page.expect_response( lambda response: urlsplit(response.url).path == path ) as response_info: self.page.click(f"button[hx-get='{path}']") - status = response_info.value.status - self.page.wait_for_load_state("networkidle") - return status + response = response_info.value + if response.ok: + try: + self.page.wait_for_function( + "selector => document.querySelector(selector)?.innerHTML.trim() !== ''", + arg=PAGE_CONTENT_SELECTOR, + ) + except PlaywrightTimeoutError: + # Nothing was swapped in; the caller's content check reports it. + pass + return response.status def wait_for_eosdash(base_url: str) -> None: