From ebaaf51c227df2c0daa39d0b3a34095cf7cd5551 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Thu, 18 Sep 2025 18:37:47 -0300 Subject: [PATCH 1/2] Revert "fix test CI" This reverts commit aac0d5d32004a5dba55aec65d424da17cb7f80bc. --- .gitlab-ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e210e0fe..14b7efa7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,9 +10,6 @@ stages: test: stage: test - variables: - VITE_GITHUB_OAUTH_CLIENT_ID: "********************" - VITE_GITHUB_OAUTH_CLIENT_SECRET: "****************************************" script: - npm run test From 176b15615189f73f07b6fb54f5eb1da4657201d2 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Thu, 18 Sep 2025 18:55:20 -0300 Subject: [PATCH 2/2] 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"'),