Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion tests/impact-2hop.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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)
}));
Comment thread
PatrickSys marked this conversation as resolved.

describe('Impact candidates (2-hop)', () => {
let tempRoot: string | null = null;
const token = 'UNIQUETOKEN123';
Expand Down
2 changes: 1 addition & 1 deletion tests/index-migration-atomic-swap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions tests/search-decision-card.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -375,5 +381,5 @@ export class ProfileService {
const firstLine = withSnippet.snippet.split('\n')[0].trim();
expect(firstLine).toMatch(/^\/\//);
}
});
}, 30000);
});
8 changes: 7 additions & 1 deletion tests/search-hints.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -145,7 +151,7 @@ describe('Search Hints', () => {
// Should be capped at 3
expect(utilResult.hints.callers.length).toBeLessThanOrEqual(3);
}
});
}, 30000);
Comment thread
PatrickSys marked this conversation as resolved.

it('hints include tests when test files are detected', async () => {
if (!tempRoot) throw new Error('tempRoot not initialized');
Expand Down
6 changes: 6 additions & 0 deletions tests/search-snippets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tests/zombie-guard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Loading