]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Handle multiple alerts in E2E scan test
authorAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 28 Sep 2025 17:13:20 +0000 (20:13 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 28 Sep 2025 17:54:26 +0000 (20:54 +0300)
by waiting for new alert appearance

test/playwright/tests/scan.spec.mjs

index 0d30f64e2897f6c6cf783ff5137a18481dad3eb2..5ac9a9abb0e40740e84d84d468160397f490e0e7 100644 (file)
@@ -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);