From e498ad11fbb325e6db4f2ffa61b794c436de1a6f Mon Sep 17 00:00:00 2001 From: PatrickSys Date: Tue, 14 Apr 2026 14:23:59 +0200 Subject: [PATCH 1/3] test: stabilize follow-up integration suites --- tests/impact-2hop.test.ts | 7 ++++++- tests/index-migration-atomic-swap.test.ts | 2 +- tests/search-decision-card.test.ts | 5 +++++ tests/search-hints.test.ts | 2 +- tests/search-snippets.test.ts | 5 +++++ tests/zombie-guard.test.ts | 4 ++-- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/impact-2hop.test.ts b/tests/impact-2hop.test.ts index f284b64..4e646e1 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,11 @@ 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') +})); + 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..b59a607 100644 --- a/tests/search-decision-card.test.ts +++ b/tests/search-decision-card.test.ts @@ -5,6 +5,11 @@ 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') +})); + type ToolCallRequest = { jsonrpc: '2.0'; id: number; diff --git a/tests/search-hints.test.ts b/tests/search-hints.test.ts index bc7c2ea..317b673 100644 --- a/tests/search-hints.test.ts +++ b/tests/search-hints.test.ts @@ -145,7 +145,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..48e0b8e 100644 --- a/tests/search-snippets.test.ts +++ b/tests/search-snippets.test.ts @@ -5,6 +5,11 @@ 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') +})); + 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); }); From cdc0edd038595edf87a823e5c7470c1f2d17acfd Mon Sep 17 00:00:00 2001 From: PatrickSys Date: Tue, 14 Apr 2026 20:39:13 +0200 Subject: [PATCH 2/3] test(search): stabilize reranker-backed suites --- tests/impact-2hop.test.ts | 3 ++- tests/search-decision-card.test.ts | 3 ++- tests/search-hints.test.ts | 6 ++++++ tests/search-snippets.test.ts | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/impact-2hop.test.ts b/tests/impact-2hop.test.ts index 4e646e1..f0bea37 100644 --- a/tests/impact-2hop.test.ts +++ b/tests/impact-2hop.test.ts @@ -17,7 +17,8 @@ import { vi.mock('../src/core/reranker.js', () => ({ rerank: vi.fn(async (_query: string, results: unknown) => results), - getRerankerStatus: vi.fn(() => 'fallback') + getRerankerStatus: vi.fn(() => 'fallback'), + isAmbiguous: vi.fn(() => false) })); describe('Impact candidates (2-hop)', () => { diff --git a/tests/search-decision-card.test.ts b/tests/search-decision-card.test.ts index b59a607..21b27c1 100644 --- a/tests/search-decision-card.test.ts +++ b/tests/search-decision-card.test.ts @@ -7,7 +7,8 @@ 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') + getRerankerStatus: vi.fn(() => 'fallback'), + isAmbiguous: vi.fn(() => false) })); type ToolCallRequest = { diff --git a/tests/search-hints.test.ts b/tests/search-hints.test.ts index 317b673..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; diff --git a/tests/search-snippets.test.ts b/tests/search-snippets.test.ts index 48e0b8e..79cba1b 100644 --- a/tests/search-snippets.test.ts +++ b/tests/search-snippets.test.ts @@ -7,7 +7,8 @@ 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') + getRerankerStatus: vi.fn(() => 'fallback'), + isAmbiguous: vi.fn(() => false) })); describe('Search Snippets with Scope Headers', () => { From 1410a77fcc3eb58f0cd2bcd5e4eb1399f3cafe6a Mon Sep 17 00:00:00 2001 From: PatrickSys Date: Tue, 14 Apr 2026 20:44:04 +0200 Subject: [PATCH 3/3] test(search): extend decision-card integration timeouts --- tests/search-decision-card.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/search-decision-card.test.ts b/tests/search-decision-card.test.ts index 21b27c1..d99b4c7 100644 --- a/tests/search-decision-card.test.ts +++ b/tests/search-decision-card.test.ts @@ -207,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'); @@ -259,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'); @@ -290,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'); @@ -321,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'); @@ -350,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'); @@ -381,5 +381,5 @@ export class ProfileService { const firstLine = withSnippet.snippet.split('\n')[0].trim(); expect(firstLine).toMatch(/^\/\//); } - }); + }, 30000); });