diff --git a/e2e/specs/08-browser-chaos/offline-network.spec.ts b/e2e/specs/08-browser-chaos/offline-network.spec.ts index 653484c..2af1a70 100644 --- a/e2e/specs/08-browser-chaos/offline-network.spec.ts +++ b/e2e/specs/08-browser-chaos/offline-network.spec.ts @@ -61,7 +61,10 @@ test.describe('Browser chaos — network', () => { const g = await guest('Throttled'); let attempts = 0; - await page.route('**/api/v1/feed', async (route) => { + // Match /api/v1/feed with or without a query string (the app requests + // `/feed?limit=20`), but NOT /api/v1/feed/delta. A plain `**/api/v1/feed` glob + // fails to match the query-string URL, so this route never fired before. + await page.route(/\/api\/v1\/feed(\?|$)/, async (route) => { attempts++; await route.fulfill({ status: 429, @@ -73,8 +76,13 @@ test.describe('Browser chaos — network', () => { await signIn(page, g); await page.goto('/feed'); - // Wait until the retry count stops climbing instead of sleeping a fixed 3s: a - // well-behaved client surfaces the 429 and stops, so the count settles quickly; + // First make sure the throttled endpoint was actually hit — otherwise the + // stabilize-poll below could settle at attempts=0 (feed request not yet fired) + // and pass vacuously without ever exercising the 429 path. + await expect.poll(() => attempts, { timeout: 8_000 }).toBeGreaterThanOrEqual(1); + + // Then wait until the retry count stops climbing instead of sleeping a fixed 3s: + // a well-behaved client surfaces the 429 and stops, so the count settles quickly; // a retry storm would keep incrementing and never stabilize (→ this poll times // out and the test fails, which is the outcome we want). let prev = -1;