import { vitestConfig } from '@tooling/vitest-config'

export default vitestConfig.realPg({
  test: {
    // Gate-3 consumer fixtures boot pglite (embedded Postgres-WASM) per case —
    // the blueprint suites do it in `beforeEach` (commerce ledger + audit db).
    // Under the parallel cold gate (`pnpm gate` → turbo runs many test suites at
    // once) CPU contention pushes a pglite boot past the hook timeout (observed:
    // marketplace beforeEach timed out at 10000ms, then again at 30000ms once more
    // commerce DB packages joined the gate; the same suite passes in ~3.5s isolated).
    // Root cause is the concurrent-boot storm, not slow boots — so the durable fix
    // is singleFork (serialise THIS package's test files → at most one pglite booting
    // here at a time, capping concurrent DB boots at the turbo concurrency), mirroring
    // the real-PG commerce packages' config (gate-concurrency-deflake). Generous
    // timeouts stay as headroom for a genuinely hung hook. Mirrors packages/auth +
    // commerce — promote all to a shared @tooling/vitest-config preset (now overdue).
    poolOptions: { forks: { singleFork: true } },
    hookTimeout: 300_000,
    testTimeout: 180_000,
  },
})
