From: Vsevolod Stakhov Date: Sat, 11 Jul 2026 09:19:38 +0000 (+0100) Subject: [Test] Fix race in history reset e2e test X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d934a9790956fd21b89532e5ecfe2e00115285c;p=thirdparty%2Frspamd.git [Test] Fix race in history reset e2e test 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. --- diff --git a/test/playwright/tests/scan.spec.mjs b/test/playwright/tests/scan.spec.mjs index 47a1b4e99b..425710d8a7 100644 --- a/test/playwright/tests/scan.spec.mjs +++ b/test/playwright/tests/scan.spec.mjs @@ -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();