"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("vitest/config");
const dotenv_1 = require("dotenv");
// Load .env so API keys (OPENAI_API_KEY, etc.) are available via fork inheritance.
(0, dotenv_1.config)();
exports.default = (0, config_1.defineConfig)({
    test: {
        globals: true,
        environment: 'node',
        globalSetup: ['tests/setup/global.ts'],
        setupFiles: ['tests/setup/clear-roles.ts'],
        include: ['tests/**/*.test.ts'],
        exclude: ['node_modules', 'build', 'tests/integration', 'tests/functional'],
        testTimeout: 30_000,
        hookTimeout: 60_000,
        fileParallelism: false,
        pool: 'forks',
        env: {
            NODE_ENV: 'test',
            // ALWAYS use the test database — hardcoded to prevent .env or shell
            // env from accidentally routing tests to the dev database.
            POSTGRES_DB: 'longtail_test',
            // HotMesh scout role TTL + loser retry interval.
            // Default is 60s. We set 5s as a safety net in case role cleanup
            // fails (e.g., crash). The primary fix is clearing stale roles
            // in globalSetup before tests run.
            HMSH_SCOUT_INTERVAL_SECONDS: '5',
            HMSH_ROUTER_SCOUT_INTERVAL_SECONDS: '5',
        },
    },
});
