/// <reference types="vitest" />
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import { fileURLToPath, URL } from "node:url";

import { transportFromEnv } from "./src/app/transport";

// Vitest config for the frontend hexagonal layers (domain/ports/adapters/app).
// jsdom is used so React-Testing-Library can render the DI provider.
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  // Mirrors the build constant (#74, F1) through the same predicate, so code
  // reading `__IDEA_TRANSPORT__` stays testable.
  define: {
    __IDEA_TRANSPORT__: JSON.stringify(
      transportFromEnv(process.env.VITE_TRANSPORT),
    ),
  },
  test: {
    environment: "jsdom",
    globals: true,
    include: ["src/**/*.test.{ts,tsx}"],
  },
});
