From: Alexander Moisseev Date: Sun, 28 Sep 2025 17:13:20 +0000 (+0300) Subject: [Test] Handle multiple alerts in E2E scan test X-Git-Tag: 3.13.1~3^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e1f850d83a4d4d6b0aec2317b5220af690805484;p=thirdparty%2Frspamd.git [Test] Handle multiple alerts in E2E scan test by waiting for new alert appearance --- diff --git a/test/playwright/tests/scan.spec.mjs b/test/playwright/tests/scan.spec.mjs index 0d30f64e28..5ac9a9abb0 100644 --- a/test/playwright/tests/scan.spec.mjs +++ b/test/playwright/tests/scan.spec.mjs @@ -34,7 +34,17 @@ test.describe.serial("Scan flow across WebUI tabs", () => { } async function expectAlertSuccess(expectedText) { - const alert = page.locator(".alert-success, .alert-modal.alert-success"); + // Wait for a new alert to appear by counting existing alerts first + const initialAlertCount = await page.locator(".alert-success, .alert-modal.alert-success").count(); + + // Wait for a new alert to appear + await expect(async () => { + const currentCount = await page.locator(".alert-success, .alert-modal.alert-success").count(); + return currentCount > initialAlertCount; + }).toPass({timeout: 5000}); + + // Get the most recently appeared alert (last one) + const alert = page.locator(".alert-success, .alert-modal.alert-success").last(); await expect(alert).toBeVisible(); const text = await alert.textContent(); expect(text).toContain(expectedText);