From 176b15615189f73f07b6fb54f5eb1da4657201d2 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Thu, 18 Sep 2025 18:55:20 -0300 Subject: [PATCH] fix tests --- src/hooks/useGitHubOAuth.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hooks/useGitHubOAuth.test.ts b/src/hooks/useGitHubOAuth.test.ts index 7899815f..8f40c5d3 100644 --- a/src/hooks/useGitHubOAuth.test.ts +++ b/src/hooks/useGitHubOAuth.test.ts @@ -3,6 +3,10 @@ import { renderHook, act } from '@testing-library/react'; import { useGitHubOAuth } from './useGitHubOAuth'; import { TestApp } from '@/test/TestApp'; +// Mock environment variables for testing +vi.stubEnv('VITE_GITHUB_OAUTH_CLIENT_ID', '********************'); +vi.stubEnv('VITE_GITHUB_OAUTH_CLIENT_SECRET', '****************************************'); + // Mock crypto.subtle for PKCE testing const mockCryptoSubtle = { digest: vi.fn(), @@ -57,7 +61,7 @@ describe('useGitHubOAuth PKCE', () => { wrapper: TestApp, }); - // Mock fetch for token exchange and user info + // Mock fetch for token exchange and user info (using corsproxy.io URLs) const mockFetch = vi.fn() .mockResolvedValueOnce({ ok: true, @@ -143,7 +147,7 @@ describe('useGitHubOAuth PKCE', () => { // Check that the token request includes the code verifier expect(mockFetch).toHaveBeenCalledWith( - expect.stringContaining('github.com/login/oauth/access_token'), + expect.stringContaining('corsproxy.io/?url=https://github.com/login/oauth/access_token'), expect.objectContaining({ method: 'POST', body: expect.stringContaining('"code_verifier":"test-verifier"'),