Merge test/fix-vacuous-429-test: 429 retry test now actually fires

This commit is contained in:
fabi
2026-07-01 19:33:28 +02:00

View File

@@ -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;