// Gemini-dependent e2e suites are opt-in: they make real API calls and were
// silently failing on master because the keychain held an invalid key.
// Set RUN_GEMINI_E2E=1 with a known-good key to run them locally.
const GEMINI_E2E_SUITES = [
  'tests/e2e/conversation-flows\\.test\\.ts$',
  'tests/e2e/quick-smoke\\.test\\.ts$',
  'tests/e2e/regression-flows\\.test\\.ts$',
  'tests/orchestrator/full-stack-e2e\\.test\\.ts$',
  'tests/orchestrator/project-init-e2e\\.test\\.ts$',
  'tests/orchestrator/cognitive-e2e\\.test\\.ts$',
  'tests/orchestrator/interactive-session-e2e\\.test\\.ts$',
];

// Known-broken test suites, excluded from the default run so CI can ship a
// green baseline. These failures existed on master before CI was added; they
// were hidden because nobody ran the full suite. Each suite is tracked as
// tech debt, to be fixed in separate PRs one at a time. When a suite is
// fixed, REMOVE it from this list — do not accumulate exclusions without
// burndown.
//
// Set RUN_KNOWN_BROKEN=1 locally when actively fixing one of them.
const KNOWN_BROKEN_SUITES = [
  'tests/cli/mcp-handlers\\.test\\.ts$',           // dispatch budget assertions
  'tests/cli/mcp-signals-validation\\.test\\.ts$', // signal schema edge cases
  'tests/orchestrator/skill-catalog\\.test\\.ts$', // catalog shape drift
  'tests/orchestrator/consensus-e2e\\.test\\.ts$', // requires local .gossip/config.json fixture
  'tests/relay/dashboard-edge-cases\\.test\\.ts$', // dashboard API edges
];

module.exports = {
  testEnvironment: 'node',
  roots: ['<rootDir>/tests'],
  testMatch: ['**/*.test.ts'],
  testPathIgnorePatterns: [
    '/node_modules/',
    ...(process.env.RUN_GEMINI_E2E === '1' ? [] : GEMINI_E2E_SUITES),
    ...(process.env.RUN_KNOWN_BROKEN === '1' ? [] : KNOWN_BROKEN_SUITES),
  ],
  transform: {
    '^.+\\.tsx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.json' }]
  },
  moduleNameMapper: {
    '^@gossip/types$': '<rootDir>/packages/types/src',
    '^@gossip/types/(.*)$': '<rootDir>/packages/types/src/$1',
    '^@gossip/relay$': '<rootDir>/packages/relay/src',
    '^@gossip/relay/(.*)$': '<rootDir>/packages/relay/src/$1',
    '^@gossip/client$': '<rootDir>/packages/client/src',
    '^@gossip/client/(.*)$': '<rootDir>/packages/client/src/$1',
    '^@gossip/tools$': '<rootDir>/packages/tools/src',
    '^@gossip/tools/(.*)$': '<rootDir>/packages/tools/src/$1',
    '^@gossip/orchestrator$': '<rootDir>/packages/orchestrator/src',
    '^@gossip/orchestrator/(.*)$': '<rootDir>/packages/orchestrator/src/$1',
    '^@/(.*)$': '<rootDir>/packages/dashboard-v2/src/$1'
  }
};
