From: Alexander Moisseev Date: Sun, 5 Jul 2026 19:17:18 +0000 (+0300) Subject: [Test] WebUI: fix race in history reset E2E test X-Git-Tag: 4.1.3~52^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=735609c1;p=thirdparty%2Frspamd.git [Test] WebUI: fix race in history reset E2E test 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. --- diff --git a/test/playwright/tests/scan.spec.mjs b/test/playwright/tests/scan.spec.mjs index 47a1b4e99b..c573f6d7a8 100644 --- a/test/playwright/tests/scan.spec.mjs +++ b/test/playwright/tests/scan.spec.mjs @@ -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();