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';

// jsdom does not implement scrollTo on elements
HTMLElement.prototype.scrollTo = vi.fn();

// Mock BetterAuth
vi.mock('~/lib/auth.server', () => ({
  auth: {
    api: {
      getSession: vi.fn(() => Promise.resolve({
        user: { id: 'test-user-id', email: 'test@example.com', name: 'Test User' },
        session: { 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(),
  })),
}));
