| /** | |
| * Jest Setup | |
| * Configure test environment | |
| */ | |
| require('@testing-library/jest-dom') | |
| // Mock Next.js headers | |
| jest.mock('next/headers', () => ({ | |
| cookies: jest.fn(() => ({ | |
| get: jest.fn(), | |
| set: jest.fn(), | |
| })), | |
| headers: jest.fn(() => new Headers()), | |
| })) | |
| // Mock environment variables | |
| process.env.NEXT_PUBLIC_SUPABASE_URL = 'http://localhost:54321' | |
| process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY = 'test-anon-key' | |
| process.env.SUPABASE_SERVICE_ROLE_KEY = 'test-service-role-key' | |
| process.env.LITELLM_BASE_URL = 'http://localhost:4000' | |
| process.env.LITELLM_API_KEY = 'test-litellm-key' | |
| // Global test utilities | |
| global.mockFetch = (response) => { | |
| global.fetch = jest.fn(() => | |
| Promise.resolve({ | |
| ok: true, | |
| json: () => Promise.resolve(response), | |
| text: () => Promise.resolve(JSON.stringify(response)), | |
| }) | |
| ) | |
| } | |
| // Clean up after each test | |
| afterEach(() => { | |
| jest.clearAllMocks() | |
| }) | |