test: add comprehensive automated test coverage

- Vitest multi-project setup (unit / integration / component)
- Real-Postgres integration harness via in-process PGlite (TEST_DATABASE_URL
  override), migrations applied per worker; production code untouched
- Unit: routing, locale, validation/Zod schemas, metadata, mail, site-theme,
  marquee, media, portfolio helpers, plus architecture-rule tests
- Integration: Prisma data layer, API routes, and all server actions
- Component: UI primitives and form components (jsdom + Testing Library)
- 371 tests passing
This commit is contained in:
Moh
2026-08-06 02:27:20 +02:00
parent 0f48381894
commit e2e06be86e
50 changed files with 4975 additions and 26 deletions
+42 -6
View File
@@ -4,14 +4,50 @@ import { fileURLToPath } from "url";
import { defineConfig } from "vitest/config";
const rootDir = path.dirname(fileURLToPath(new URL(import.meta.url)));
const alias = { "@": rootDir };
const esbuild = { jsx: "automatic" as const };
export default defineConfig({
resolve: {
alias: {
"@": rootDir,
},
},
resolve: { alias },
esbuild,
test: {
environment: "node",
projects: [
{
resolve: { alias },
esbuild,
test: {
name: "unit",
environment: "node",
include: ["tests/unit/**/*.test.ts", "tests/*.test.ts"],
},
},
{
resolve: { alias },
esbuild,
test: {
name: "integration",
environment: "node",
include: ["tests/integration/**/*.test.{ts,tsx}"],
// One shared test database. Files run sequentially (never in parallel)
// but each in its own worker, so every file gets a fresh database
// connection and truncation between tests never races another file.
fileParallelism: false,
globalSetup: ["tests/helpers/global-db-setup.ts"],
setupFiles: ["tests/helpers/integration-setup.ts"],
hookTimeout: 60_000,
testTimeout: 30_000,
},
},
{
resolve: { alias },
esbuild,
test: {
name: "component",
environment: "jsdom",
include: ["tests/component/**/*.test.{ts,tsx}"],
setupFiles: ["tests/helpers/component-setup.ts"],
},
},
],
},
});