From 5f523d55fe4cf5251cfb3526dd87d32a33891539 Mon Sep 17 00:00:00 2001 From: fabi Date: Wed, 1 Jul 2026 19:33:28 +0200 Subject: [PATCH] test(e2e): fix vacuous 429 retry test (route never matched the feed) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "429 from server is surfaced (no infinite retry storm)" test routed `**/api/v1/feed`, but the app requests `/api/v1/feed?limit=20` — a plain glob without a trailing wildcard doesn't match a URL with a query string, so the route never fired: `attempts` stayed 0 and `expect(attempts).toBeLessThan(15)` passed trivially. The test never forced a 429 or exercised any retry behavior. Fix: match with a regex `/\/api\/v1\/feed(\?|$)/` (catches the query-string URL, excludes /feed/delta), and gate on `attempts >= 1` before judging retry behavior so it can't pass again without actually hitting the throttled endpoint. Found during self-review of the test-quality batches. Co-Authored-By: Claude Opus 4.8 --- e2e/specs/08-browser-chaos/offline-network.spec.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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;