From 02dfab578c4d5cbf74810635b170bd7b32da79de Mon Sep 17 00:00:00 2001 From: Gergo Magyar Date: Wed, 18 Mar 2026 08:12:25 +0000 Subject: [PATCH] fix(test): add --repo to CLI e2e tool tests for multi-repo environment --- .../gitnexus/vitest.config_20260317171253.ts | 33 +++++++++++++++++++ gitnexus/test/integration/cli-e2e.test.ts | 12 ++++--- 2 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 .history/gitnexus/vitest.config_20260317171253.ts diff --git a/.history/gitnexus/vitest.config_20260317171253.ts b/.history/gitnexus/vitest.config_20260317171253.ts new file mode 100644 index 000000000..b3beecb1b --- /dev/null +++ b/.history/gitnexus/vitest.config_20260317171253.ts @@ -0,0 +1,33 @@ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + globalSetup: ['test/global-setup.ts'], + include: ['test/**/*.test.ts'], + testTimeout: 30000, + hookTimeout: 120000, + pool: 'forks', + globals: true, + setupFiles: ['test/setup.ts'], + teardownTimeout: 3000, + dangerouslyIgnoreUnhandledErrors: true, // LadybugDB N-API destructor segfaults on fork exit — not a test failure + coverage: { + provider: 'v8', + include: ['src/**/*.ts'], + exclude: [ + 'src/cli/index.ts', // CLI entry point (commander wiring) + 'src/server/**', // HTTP server (requires network) + 'src/core/wiki/**', // Wiki generation (requires LLM) + ], + // Auto-ratchet: vitest bumps thresholds when coverage exceeds them. + // CI will fail if a PR drops below these floors. + thresholds: { + statements: 26, + branches: 23, + functions: 28, + lines: 27, + autoUpdate: true, + }, + }, + }, +}); diff --git a/gitnexus/test/integration/cli-e2e.test.ts b/gitnexus/test/integration/cli-e2e.test.ts index c89684631..606e1a89f 100644 --- a/gitnexus/test/integration/cli-e2e.test.ts +++ b/gitnexus/test/integration/cli-e2e.test.ts @@ -236,9 +236,11 @@ describe('CLI end-to-end', () => { // These tests verify that tool output goes to stdout (fd 1), not stderr. // Requires analyze to have run first (the analyze test above populates .gitnexus/). + // All tool commands pass --repo to disambiguate when the global registry + // has multiple indexed repos (e.g. the parent project is also indexed). describe('tool output goes to stdout via fd 1 (#324)', () => { it('cypher: JSON appears on stdout, not stderr', () => { - const result = runCliRaw(['cypher', 'MATCH (n) RETURN n.name LIMIT 3'], MINI_REPO); + const result = runCliRaw(['cypher', 'MATCH (n) RETURN n.name LIMIT 3', '--repo', 'mini-repo'], MINI_REPO); if (result.status === null) return; // CI timeout tolerance expect(result.status).toBe(0); @@ -255,7 +257,7 @@ describe('CLI end-to-end', () => { it('query: JSON appears on stdout, not stderr', () => { // "handler" is a generic term likely to match something in mini-repo - const result = runCliRaw(['query', 'handler'], MINI_REPO); + const result = runCliRaw(['query', 'handler', '--repo', 'mini-repo'], MINI_REPO); if (result.status === null) return; expect(result.status).toBe(0); @@ -264,7 +266,7 @@ describe('CLI end-to-end', () => { it('impact: JSON appears on stdout, not stderr', () => { const result = runCliRaw( - ['impact', 'handleRequest', '--direction', 'upstream'], + ['impact', 'handleRequest', '--direction', 'upstream', '--repo', 'mini-repo'], MINI_REPO, ); if (result.status === null) return; @@ -277,7 +279,7 @@ describe('CLI end-to-end', () => { it('stdout is pipeable: cypher output parses as valid JSON', () => { const result = runCliRaw( - ['cypher', 'MATCH (n:Function) RETURN n.name LIMIT 5'], + ['cypher', 'MATCH (n:Function) RETURN n.name LIMIT 5', '--repo', 'mini-repo'], MINI_REPO, ); if (result.status === null) return; @@ -297,7 +299,7 @@ describe('CLI end-to-end', () => { return new Promise((resolve, reject) => { const child = spawn( process.execPath, - ['--import', 'tsx', cliEntry, 'cypher', 'MATCH (n) RETURN n LIMIT 500'], + ['--import', 'tsx', cliEntry, 'cypher', 'MATCH (n) RETURN n LIMIT 500', '--repo', 'mini-repo'], { cwd: MINI_REPO, stdio: ['ignore', 'pipe', 'pipe'],