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 }); }); });