Skip to content

Commit 99c89c6

Browse files
authored
test: stabilize follow-up integration suites (#99)
* test: stabilize follow-up integration suites * test(search): stabilize reranker-backed suites * test(search): extend decision-card integration timeouts
1 parent e8acbfe commit 99c89c6

6 files changed

Lines changed: 35 additions & 11 deletions

tests/impact-2hop.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
1+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
22
import { promises as fs } from 'fs';
33
import os from 'os';
44
import path from 'path';
@@ -15,6 +15,12 @@ import {
1515
RELATIONSHIPS_FILENAME
1616
} from '../src/constants/codebase-context.js';
1717

18+
vi.mock('../src/core/reranker.js', () => ({
19+
rerank: vi.fn(async (_query: string, results: unknown) => results),
20+
getRerankerStatus: vi.fn(() => 'fallback'),
21+
isAmbiguous: vi.fn(() => false)
22+
}));
23+
1824
describe('Impact candidates (2-hop)', () => {
1925
let tempRoot: string | null = null;
2026
const token = 'UNIQUETOKEN123';

tests/index-migration-atomic-swap.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export function greet(user: User): string {
214214
// Verify staging directory is cleaned up
215215
const hasStaging = await stagingDirExists(contextDir);
216216
expect(hasStaging).toBe(false);
217-
});
217+
}, 30000);
218218

219219
it('should fail closed when meta points to missing artifacts', async () => {
220220
// Create an index with meta pointing to non-existent files

tests/search-decision-card.test.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import path from 'path';
55
import { CodebaseIndexer } from '../src/core/indexer.js';
66
import { rmWithRetries } from './test-helpers.js';
77

8+
vi.mock('../src/core/reranker.js', () => ({
9+
rerank: vi.fn(async (_query: string, results: unknown) => results),
10+
getRerankerStatus: vi.fn(() => 'fallback'),
11+
isAmbiguous: vi.fn(() => false)
12+
}));
13+
814
type ToolCallRequest = {
915
jsonrpc: '2.0';
1016
id: number;
@@ -201,7 +207,7 @@ export class ProfileService {
201207
}
202208
expect(preflight.ready).toBeDefined();
203209
expect(typeof preflight.ready).toBe('boolean');
204-
});
210+
}, 30000);
205211

206212
it('decision card has all expected fields when returned', async () => {
207213
if (!tempRoot) throw new Error('tempRoot not initialized');
@@ -253,7 +259,7 @@ export class ProfileService {
253259
if (preflight.whatWouldHelp) {
254260
expect(Array.isArray(preflight.whatWouldHelp)).toBe(true);
255261
}
256-
});
262+
}, 30000);
257263

258264
it('intent="explore" returns lightweight preflight', async () => {
259265
if (!tempRoot) throw new Error('tempRoot not initialized');
@@ -284,7 +290,7 @@ export class ProfileService {
284290
expect(typeof preflight.ready).toBe('boolean');
285291
// Should NOT have full decision card fields for explore
286292
}
287-
});
293+
}, 30000);
288294

289295
it('includes snippet field when includeSnippets=true', async () => {
290296
if (!tempRoot) throw new Error('tempRoot not initialized');
@@ -315,7 +321,7 @@ export class ProfileService {
315321
// At least some results should have a snippet
316322
const withSnippets = parsed.results.filter((result) => result.snippet);
317323
expect(withSnippets.length).toBeGreaterThan(0);
318-
});
324+
}, 30000);
319325

320326
it('does not include snippet field when includeSnippets=false', async () => {
321327
if (!tempRoot) throw new Error('tempRoot not initialized');
@@ -344,7 +350,7 @@ export class ProfileService {
344350
parsed.results.forEach((result) => {
345351
expect(result.snippet).toBeUndefined();
346352
});
347-
});
353+
}, 30000);
348354

349355
it('scope header starts snippet when includeSnippets=true', async () => {
350356
if (!tempRoot) throw new Error('tempRoot not initialized');
@@ -375,5 +381,5 @@ export class ProfileService {
375381
const firstLine = withSnippet.snippet.split('\n')[0].trim();
376382
expect(firstLine).toMatch(/^\/\//);
377383
}
378-
});
384+
}, 30000);
379385
});

tests/search-hints.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import {
1111
KEYWORD_INDEX_FILENAME
1212
} from '../src/constants/codebase-context.js';
1313

14+
vi.mock('../src/core/reranker.js', () => ({
15+
rerank: vi.fn(async (_query: string, results: unknown) => results),
16+
getRerankerStatus: vi.fn(() => 'fallback'),
17+
isAmbiguous: vi.fn(() => false)
18+
}));
19+
1420
describe('Search Hints', () => {
1521
let tempRoot: string | null = null;
1622

@@ -145,7 +151,7 @@ describe('Search Hints', () => {
145151
// Should be capped at 3
146152
expect(utilResult.hints.callers.length).toBeLessThanOrEqual(3);
147153
}
148-
});
154+
}, 30000);
149155

150156
it('hints include tests when test files are detected', async () => {
151157
if (!tempRoot) throw new Error('tempRoot not initialized');

tests/search-snippets.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import path from 'path';
55
import { CodebaseIndexer } from '../src/core/indexer.js';
66
import { rmWithRetries } from './test-helpers.js';
77

8+
vi.mock('../src/core/reranker.js', () => ({
9+
rerank: vi.fn(async (_query: string, results: unknown) => results),
10+
getRerankerStatus: vi.fn(() => 'fallback'),
11+
isAmbiguous: vi.fn(() => false)
12+
}));
13+
814
describe('Search Snippets with Scope Headers', () => {
915
let tempRoot: string | null = null;
1016

tests/zombie-guard.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,6 @@ describe('zombie process prevention', () => {
117117
expect(result.code).toBe(1);
118118
// Should still honor a short timeout (allow CI/Windows process jitter).
119119
expect(elapsed).toBeGreaterThan(800);
120-
expect(elapsed).toBeLessThan(7_000);
121-
}, 10_000);
120+
expect(elapsed).toBeLessThan(8_000);
121+
}, 12_000);
122122
});

0 commit comments

Comments
 (0)