import '@testing-library/jest-dom';
import { cleanup } from '@testing-library/react';
import { afterEach, vi } from 'vitest';

// Cleanup after each test
afterEach(() => {
  cleanup();
});

// Mock environment variables
process.env.NODE_ENV = 'test';

// Mock Clerk
vi.mock('@clerk/react-router/server', () => ({
  getAuth: vi.fn(() => Promise.resolve({ userId: 'test-user-id' })),
  clerkMiddleware: vi.fn(() => (req: unknown, res: unknown, next: () => void) => next()),
  rootAuthLoader: vi.fn(() => Promise.resolve({ userId: 'test-user-id' })),
}));

// Mock database context
vi.mock('~/database/context', () => ({
  database: vi.fn(() => ({
    query: {},
    insert: vi.fn(),
    update: vi.fn(),
    delete: vi.fn(),
    select: vi.fn(),
  })),
}));
