Skip to content

Commit c819416

Browse files
committed
fix: remove supabase from gh action
1 parent 773ad7e commit c819416

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@ jobs:
3232

3333
- name: Run tests
3434
run: npm run test -- --run
35+
env:
36+
VITE_SUPABASE_URL: https://test.supabase.co
37+
VITE_SUPABASE_ANON_KEY: test-key
3538

3639
- name: Build project
3740
run: npm run build
41+
env:
42+
VITE_SUPABASE_URL: https://test.supabase.co
43+
VITE_SUPABASE_ANON_KEY: test-key
3844

3945
- name: Upload test results
4046
if: always()

docs/CI_CD.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ TimeTracker Pro uses GitHub Actions for continuous integration and continuous de
1717
2. **Setup Node.js** - Configures Node.js 20.x environment
1818
3. **Install dependencies** - Runs `npm ci` for clean install
1919
4. **Run linter** - Executes ESLint to check code quality
20-
5. **Run tests** - Runs the Vitest test suite (41 tests)
21-
6. **Build project** - Verifies the production build succeeds
20+
5. **Run tests** - Runs the Vitest test suite (41 tests) with mock Supabase environment
21+
6. **Build project** - Verifies the production build succeeds with mock Supabase environment
2222
7. **Upload test results** - Archives test results and coverage (if generated)
2323

24+
**Environment Variables:**
25+
The workflow sets mock Supabase credentials for testing:
26+
- `VITE_SUPABASE_URL`: Test URL (not a real Supabase instance)
27+
- `VITE_SUPABASE_ANON_KEY`: Test key (not a real key)
28+
29+
These are only used for CI/CD and are completely mocked in tests.
30+
2431
**Status Badge:**
2532
The test workflow status is displayed at the top of the README.md file.
2633

src/test-setup.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,40 @@
1-
import { expect, afterEach, vi } from "vitest";
1+
import { expect, afterEach, vi, beforeAll } from "vitest";
22
import { cleanup } from "@testing-library/react";
33
import "@testing-library/jest-dom/vitest";
44

5+
// Mock Supabase before any imports
6+
vi.mock("@/lib/supabase", () => ({
7+
supabase: {
8+
auth: {
9+
getSession: vi.fn(() => Promise.resolve({ data: { session: null }, error: null })),
10+
getUser: vi.fn(() => Promise.resolve({ data: { user: null }, error: null })),
11+
onAuthStateChange: vi.fn(() => ({
12+
data: { subscription: { unsubscribe: vi.fn() } }
13+
}))
14+
},
15+
from: vi.fn(() => ({
16+
select: vi.fn(() => ({
17+
eq: vi.fn(() => Promise.resolve({ data: [], error: null }))
18+
})),
19+
insert: vi.fn(() => Promise.resolve({ data: null, error: null })),
20+
update: vi.fn(() => ({
21+
eq: vi.fn(() => Promise.resolve({ data: null, error: null }))
22+
})),
23+
delete: vi.fn(() => ({
24+
eq: vi.fn(() => Promise.resolve({ data: null, error: null }))
25+
}))
26+
}))
27+
},
28+
getCachedUser: vi.fn(() => Promise.resolve(null)),
29+
clearUserCache: vi.fn()
30+
}));
31+
32+
// Set required environment variables for tests
33+
beforeAll(() => {
34+
process.env.VITE_SUPABASE_URL = "https://test.supabase.co";
35+
process.env.VITE_SUPABASE_ANON_KEY = "test-anon-key";
36+
});
37+
538
// Cleanup after each test case (e.g., clearing jsdom)
639
afterEach(() => {
740
cleanup();

0 commit comments

Comments
 (0)