diff --git a/tests/impact-2hop.test.ts b/tests/impact-2hop.test.ts index f284b64..f0bea37 100644 --- a/tests/impact-2hop.test.ts +++ b/tests/impact-2hop.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, beforeEach, afterEach } from 'vitest'; +import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; import { promises as fs } from 'fs'; import os from 'os'; import path from 'path'; @@ -15,6 +15,12 @@ import { RELATIONSHIPS_FILENAME } from '../src/constants/codebase-context.js'; +vi.mock('../src/core/reranker.js', () => ({ + rerank: vi.fn(async (_query: string, results: unknown) => results), + getRerankerStatus: vi.fn(() => 'fallback'), + isAmbiguous: vi.fn(() => false) +})); + describe('Impact candidates (2-hop)', () => { let tempRoot: string | null = null; const token = 'UNIQUETOKEN123'; diff --git a/tests/index-migration-atomic-swap.test.ts b/tests/index-migration-atomic-swap.test.ts index 44e20c1..901776e 100644 --- a/tests/index-migration-atomic-swap.test.ts +++ b/tests/index-migration-atomic-swap.test.ts @@ -214,7 +214,7 @@ export function greet(user: User): string { // Verify staging directory is cleaned up const hasStaging = await stagingDirExists(contextDir); expect(hasStaging).toBe(false); - }); + }, 30000); it('should fail closed when meta points to missing artifacts', async () => { // Create an index with meta pointing to non-existent files diff --git a/tests/search-decision-card.test.ts b/tests/search-decision-card.test.ts index 5453b7f..d99b4c7 100644 --- a/tests/search-decision-card.test.ts +++ b/tests/search-decision-card.test.ts @@ -5,6 +5,12 @@ import path from 'path'; import { CodebaseIndexer } from '../src/core/indexer.js'; import { rmWithRetries } from './test-helpers.js'; +vi.mock('../src/core/reranker.js', () => ({ + rerank: vi.fn(async (_query: string, results: unknown) => results), + getRerankerStatus: vi.fn(() => 'fallback'), + isAmbiguous: vi.fn(() => false) +})); + type ToolCallRequest = { jsonrpc: '2.0'; id: number; @@ -201,7 +207,7 @@ export class ProfileService { } expect(preflight.ready).toBeDefined(); expect(typeof preflight.ready).toBe('boolean'); - }); + }, 30000); it('decision card has all expected fields when returned', async () => { if (!tempRoot) throw new Error('tempRoot not initialized'); @@ -253,7 +259,7 @@ export class ProfileService { if (preflight.whatWouldHelp) { expect(Array.isArray(preflight.whatWouldHelp)).toBe(true); } - }); + }, 30000); it('intent="explore" returns lightweight preflight', async () => { if (!tempRoot) throw new Error('tempRoot not initialized'); @@ -284,7 +290,7 @@ export class ProfileService { expect(typeof preflight.ready).toBe('boolean'); // Should NOT have full decision card fields for explore } - }); + }, 30000); it('includes snippet field when includeSnippets=true', async () => { if (!tempRoot) throw new Error('tempRoot not initialized'); @@ -315,7 +321,7 @@ export class ProfileService { // At least some results should have a snippet const withSnippets = parsed.results.filter((result) => result.snippet); expect(withSnippets.length).toBeGreaterThan(0); - }); + }, 30000); it('does not include snippet field when includeSnippets=false', async () => { if (!tempRoot) throw new Error('tempRoot not initialized'); @@ -344,7 +350,7 @@ export class ProfileService { parsed.results.forEach((result) => { expect(result.snippet).toBeUndefined(); }); - }); + }, 30000); it('scope header starts snippet when includeSnippets=true', async () => { if (!tempRoot) throw new Error('tempRoot not initialized'); @@ -375,5 +381,5 @@ export class ProfileService { const firstLine = withSnippet.snippet.split('\n')[0].trim(); expect(firstLine).toMatch(/^\/\//); } - }); + }, 30000); }); diff --git a/tests/search-hints.test.ts b/tests/search-hints.test.ts index bc7c2ea..022f80f 100644 --- a/tests/search-hints.test.ts +++ b/tests/search-hints.test.ts @@ -11,6 +11,12 @@ import { KEYWORD_INDEX_FILENAME } from '../src/constants/codebase-context.js'; +vi.mock('../src/core/reranker.js', () => ({ + rerank: vi.fn(async (_query: string, results: unknown) => results), + getRerankerStatus: vi.fn(() => 'fallback'), + isAmbiguous: vi.fn(() => false) +})); + describe('Search Hints', () => { let tempRoot: string | null = null; @@ -145,7 +151,7 @@ describe('Search Hints', () => { // Should be capped at 3 expect(utilResult.hints.callers.length).toBeLessThanOrEqual(3); } - }); + }, 30000); it('hints include tests when test files are detected', async () => { if (!tempRoot) throw new Error('tempRoot not initialized'); diff --git a/tests/search-snippets.test.ts b/tests/search-snippets.test.ts index 457b8c8..79cba1b 100644 --- a/tests/search-snippets.test.ts +++ b/tests/search-snippets.test.ts @@ -5,6 +5,12 @@ import path from 'path'; import { CodebaseIndexer } from '../src/core/indexer.js'; import { rmWithRetries } from './test-helpers.js'; +vi.mock('../src/core/reranker.js', () => ({ + rerank: vi.fn(async (_query: string, results: unknown) => results), + getRerankerStatus: vi.fn(() => 'fallback'), + isAmbiguous: vi.fn(() => false) +})); + describe('Search Snippets with Scope Headers', () => { let tempRoot: string | null = null; diff --git a/tests/zombie-guard.test.ts b/tests/zombie-guard.test.ts index f784608..2061744 100644 --- a/tests/zombie-guard.test.ts +++ b/tests/zombie-guard.test.ts @@ -117,6 +117,6 @@ describe('zombie process prevention', () => { expect(result.code).toBe(1); // Should still honor a short timeout (allow CI/Windows process jitter). expect(elapsed).toBeGreaterThan(800); - expect(elapsed).toBeLessThan(7_000); - }, 10_000); + expect(elapsed).toBeLessThan(8_000); + }, 12_000); });