]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Fix race in history reset e2e test
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 11 Jul 2026 09:19:38 +0000 (10:19 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 11 Jul 2026 09:19:38 +0000 (10:19 +0100)
Register waitForResponse listeners before clicking the reset button:
on localhost the historyreset response arrives before a listener
registered after the click can see it, which made the legacy
(Playwright 1.45.3) CI leg fail deterministically.

test/playwright/tests/scan.spec.mjs

index 47a1b4e99b73e11bec4660c58f1fa660c20201dd..425710d8a79d8b81ac7f5203c8c1381403419885 100644 (file)
@@ -175,18 +175,23 @@ test.describe.serial("Scan flow across WebUI tabs", () => {
             // Reset history
             const resetBtn = page.locator("#resetHistory");
             await expect(resetBtn).toBeVisible();
-            page.once("dialog", (dialog) => dialog.accept());
-            await resetBtn.click();
 
             // The reload disables #updateHistory only for the duration of the
             // fast, local history request, which is too brief to assert on the
             // DOM. Wait for the reset and the subsequent reload responses instead.
-            await page.waitForResponse((r) => r.url().includes("historyreset"), {timeout: 10000});
-            await page.waitForResponse(
+            // Register the waits before clicking: on localhost the responses can
+            // arrive before a listener registered after the click would see them.
+            const resetResponse = page.waitForResponse((r) => r.url().includes("historyreset"), {timeout: 10000});
+            const reloadResponse = page.waitForResponse(
                 (r) => r.url().includes("history") && r.url().includes("from="),
                 {timeout: 10000}
             );
 
+            page.once("dialog", (dialog) => dialog.accept());
+            await resetBtn.click();
+            await resetResponse;
+            await reloadResponse;
+
             const updateHistoryBtn = page.locator("#updateHistory");
             await expect(updateHistoryBtn).toBeEnabled();