From d8fb4373dbd887187d857ac74edd01cf1d22aa04 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 8 Mar 2026 14:13:06 -0500 Subject: [PATCH] fix: improve alert notification navigation test reliability Changed from arbitrary 500ms timeout to waitForURL with 10s timeout. Properly skip test when no alerts are present instead of failing. Wait for link to be fully visible before clicking to avoid race conditions. This should fix the flaky test failure where clicking the alert link wasn't navigating properly. --- e2e/tests/alert-workflows.spec.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/e2e/tests/alert-workflows.spec.ts b/e2e/tests/alert-workflows.spec.ts index ec991f51..09519c25 100644 --- a/e2e/tests/alert-workflows.spec.ts +++ b/e2e/tests/alert-workflows.spec.ts @@ -211,13 +211,22 @@ test.describe('Alert Workflows', () => { test('can navigate to alerts from notification', async ({ page }) => { await page.goto('/dashboard'); + // Wait for alert link to be present (defensive check for no alerts case) const alertLink = page.locator('a[href*="/alerts"]').first(); + const hasAlertLink = await alertLink.isVisible({ timeout: 2000 }).catch(() => false); - if (await alertLink.isVisible({ timeout: 2000 }).catch(() => false)) { - await alertLink.click(); - await page.waitForTimeout(500); - await expect(page).toHaveURL(/\/alerts/); + // Skip test if no alerts are present (not a failure, just no data to test) + if (!hasAlertLink) { + test.skip(); + return; } + + // Ensure link is ready for interaction and click it + await alertLink.waitFor({ state: 'visible' }); + await alertLink.click(); + + // Wait for navigation to complete (not arbitrary timeout) + await page.waitForURL(/\/alerts/, { timeout: 10000 }); }); });