]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] WebUI: fix race in history reset E2E test
authorAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 5 Jul 2026 19:17:18 +0000 (22:17 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 5 Jul 2026 19:17:18 +0000 (22:17 +0300)
Register the historyreset/history response listeners before the click
via Promise.all. waitForResponse only catches responses arriving after
it is set up, and the fast local historyreset round-trip could beat a
listener attached post-click, causing a flaky 10s timeout under CI load.

test/playwright/tests/scan.spec.mjs

index 47a1b4e99b73e11bec4660c58f1fa660c20201dd..c573f6d7a819e686cb13ca81b88ab1b844916bcf 100644 (file)
@@ -176,16 +176,20 @@ test.describe.serial("Scan flow across WebUI tabs", () => {
             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(
-                (r) => r.url().includes("history") && r.url().includes("from="),
-                {timeout: 10000}
-            );
+            // Listeners must be registered BEFORE the click: waitForResponse only
+            // catches responses arriving after setup, and the local historyreset
+            // round-trip can otherwise beat a listener attached post-click.
+            await Promise.all([
+                page.waitForResponse((r) => r.url().includes("historyreset"), {timeout: 10000}),
+                page.waitForResponse(
+                    (r) => r.url().includes("history") && r.url().includes("from="),
+                    {timeout: 10000}
+                ),
+                resetBtn.click(),
+            ]);
 
             const updateHistoryBtn = page.locator("#updateHistory");
             await expect(updateHistoryBtn).toBeEnabled();