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.
This commit is contained in:
parent
8fd18b08ab
commit
d8fb4373db
1 changed files with 13 additions and 4 deletions
|
|
@ -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 });
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue