/**
 * Runs before every test file. `src/env.ts` zod-validates process.env at import,
 * so provide safe fallbacks for anything a CI runner or a bare checkout might not
 * have set. A real .env (or CI's exported vars) always wins — we only fill gaps.
 */
const fallbacks: Record<string, string> = {
  NODE_ENV: 'test',
  DB_HOST: '127.0.0.1',
  DB_PORT: '3306',
  DB_USER: 'root',
  DB_PASSWORD: '',
  DB_NAME: 'genesis_dev',
  PUBLIC_ORIGINS: 'http://localhost:5173',
  ADMIN_ORIGINS: 'http://localhost:5174',
  ASSET_BASE_URL: 'http://localhost:4000/media',
  MEDIA_ROOT: './storage/media',
  STORAGE_ROOT: './storage',
  IP_HASH_SALT: 'test-hash-salt-0123456789',
  JWT_ACCESS_SECRET: 'test-access-secret-0123456789-0123456789',
  JWT_REFRESH_SECRET: 'test-refresh-secret-0123456789-0123456789',
  ADMIN_PORTAL_URL: 'http://localhost:5174',
};

for (const [key, value] of Object.entries(fallbacks)) {
  if (!process.env[key]) process.env[key] = value;
}
