import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import path from "node:path";

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: [
      { find: /^@\/(?!db)/, replacement: path.resolve(__dirname, "src") + "/" },
      { find: "@/db/client", replacement: path.resolve(__dirname, "db/client.ts") },
      { find: "@/db/schema", replacement: path.resolve(__dirname, "db/schema/index.ts") },
      { find: "@/db", replacement: path.resolve(__dirname, "db") },
    ],
  },
  test: {
    environment: "node",
    include: [
      "tests/unit/**/*.test.ts",
      "tests/unit/**/*.test.tsx",
      "src/lib/__tests__/**/*.test.ts",
      "src/lib/__tests__/**/*.test.tsx",
      "src/lib/offline/**/*.test.ts",
    ],
    exclude: ["node_modules", ".next", "tests/e2e/**", "tests/login/**", "tests/smoke.spec.ts"],
    // Supabase REST, Auth.js v5, and Next.js `cookies()` / `headers()` are
    // stubbed in each test — keep the timeout generous.
    testTimeout: 15_000,
  },
});
