From 1dbbf5c8ea88af19d0ce2bcae63325966de3d66d Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sun, 19 Apr 2026 18:56:41 -0700 Subject: [PATCH] Apply 15s timeout to subscription limit tests to stop 5s flakes Why: active tests in the Subscription limit enforcement block lacked the bumped timeout that the file's own comment said was needed, so the block grant test flaked at Bun's 5s boundary. Co-Authored-By: Claude Opus 4.7 --- .../v1/chat/completions/__tests__/completions.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/src/app/api/v1/chat/completions/__tests__/completions.test.ts b/web/src/app/api/v1/chat/completions/__tests__/completions.test.ts index 43b431f29..51a3eb46b 100644 --- a/web/src/app/api/v1/chat/completions/__tests__/completions.test.ts +++ b/web/src/app/api/v1/chat/completions/__tests__/completions.test.ts @@ -833,7 +833,7 @@ describe('/api/v1/chat/completions POST endpoint', () => { expect(body.error).toBe('rate_limit_exceeded') expect(body.message).toContain('weekly limit reached') expect(body.message).toContain('Enable "Continue with credits"') - }) + }, SUBSCRIPTION_TEST_TIMEOUT_MS) it('skips subscription limit check when in FREE mode even with fallback disabled', async () => { const weeklyLimitError: BlockGrantResult = { @@ -880,7 +880,7 @@ describe('/api/v1/chat/completions POST endpoint', () => { }) expect(response.status).toBe(200) - }) + }, SUBSCRIPTION_TEST_TIMEOUT_MS) it('returns 429 when block exhausted and fallback disabled', async () => { const blockExhaustedError: BlockGrantResult = { @@ -914,7 +914,7 @@ describe('/api/v1/chat/completions POST endpoint', () => { expect(body.error).toBe('rate_limit_exceeded') expect(body.message).toContain('5-hour session limit reached') expect(body.message).toContain('Enable "Continue with credits"') - }) + }, SUBSCRIPTION_TEST_TIMEOUT_MS) it('continues when weekly limit reached but fallback is enabled', async () => { const weeklyLimitError: BlockGrantResult = { @@ -945,7 +945,7 @@ describe('/api/v1/chat/completions POST endpoint', () => { expect(response.status).toBe(200) expect(mockLogger.info).toHaveBeenCalled() - }) + }, SUBSCRIPTION_TEST_TIMEOUT_MS) it('continues when block grant is created successfully', async () => { const blockGrant: BlockGrantResult = { @@ -977,7 +977,7 @@ describe('/api/v1/chat/completions POST endpoint', () => { expect(response.status).toBe(200) // getUserPreferences should not be called when block grant succeeds expect(mockGetUserPreferences).not.toHaveBeenCalled() - }) + }, SUBSCRIPTION_TEST_TIMEOUT_MS) it.skip('continues when ensureSubscriberBlockGrant throws an error (fail open)', async () => { const mockEnsureSubscriberBlockGrant = mock(async () => {