import path from "node:path";
import { mergeConfig } from "vitest/config";
import { nodeVitestConfig } from "@repo/core-typescript/vitest.base.node";
import {
  DEFAULT_COVERAGE_BANDS,
  vitestThresholdsFromBands,
} from "@repo/core-shared/conformance/coverage";

// Coverage thresholds derived from DEFAULT_COVERAGE_BANDS via the shared
// helper — one source of truth for the conventional band shape across all
// features (ADR-020). The feature.manifest.ts `coverage.bands` section also
// declares these for boot-time `assertFeatureConformance` (which reads the
// manifest directly, not the vitest config). For features that need
// non-default bands, override here AND in the manifest, then add a drift
// test in core-shared/conformance/.
export default mergeConfig(nodeVitestConfig, {
  test: {
    coverage: {
      exclude: [
        // DI bootstrap — wires InversifyJS at app startup; not unit-testable
        "src/di/bind-production.ts",
        // Pure TypeScript interface files — not executable
        "src/application/repositories/**",
        "src/application/services/**",
        // Payload CMS collection config — declarative data, tested via Payload integration
        "src/integrations/cms/**",
        // Pure type-alias file — no executable code
        "src/entities/cookie.ts",
        // React Query option builders — integration-tested in apps
        "src/ui/**",
      ],
      thresholds: vitestThresholdsFromBands(DEFAULT_COVERAGE_BANDS),
    },
  },
  resolve: {
    alias: { "@": path.resolve(__dirname, "./src") },
  },
});
