From 633e9778d1dcd5ae335cd04a2d7d1455f7b7afec Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Sat, 5 Sep 2026 16:45:25 +0000 Subject: [PATCH] Make the session-refresh test own every Supabase env var it reads CI failed on "refreshes an expiring session for a browser and writes the new tokens back" with `expected '***' to be 'anon-key'`: the test stubbed SUPABASE_ANON_KEY but refreshSession prefers NEXT_PUBLIC_SUPABASE_ANON_KEY, which CI sets to the real key. The URL pair has the opposite precedence, so that half passed by luck. Stub all four variables so the test passes with and without real keys in the environment. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01WJaXiqE9BDoNfoJBhfXroC --- src/proxy.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/proxy.test.ts b/src/proxy.test.ts index 9da5522..c7a0dba 100644 --- a/src/proxy.test.ts +++ b/src/proxy.test.ts @@ -200,8 +200,14 @@ describe('Supabase session refresh and referral cookie', () => { const fetchMock = vi.fn(); beforeEach(() => { + // Stub every variable refreshSession can read. The code prefers + // NEXT_PUBLIC_SUPABASE_ANON_KEY over SUPABASE_ANON_KEY (and SUPABASE_URL + // over NEXT_PUBLIC_SUPABASE_URL), so stubbing only one of each pair lets a + // real key in the environment (CI has one) win over the test's value. vi.stubEnv('SUPABASE_URL', SUPABASE_URL); + vi.stubEnv('NEXT_PUBLIC_SUPABASE_URL', SUPABASE_URL); vi.stubEnv('SUPABASE_ANON_KEY', 'anon-key'); + vi.stubEnv('NEXT_PUBLIC_SUPABASE_ANON_KEY', 'anon-key'); fetchMock.mockReset(); fetchMock.mockResolvedValue( new Response(JSON.stringify({ access_token: jwt(3600), refresh_token: 'new-refresh', expires_in: 3600, token_type: 'bearer' }), {