From 735609c137530646a910769f7cf988d9d73c0918 Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Sun, 5 Jul 2026 22:17:18 +0300 Subject: [PATCH] [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. --- test/playwright/tests/scan.spec.mjs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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(); -- 2.47.3