Skip to content

Commit 66d4520

Browse files
committed
Fix tests
1 parent a6b4fca commit 66d4520

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/services/code-index/processors/__tests__/file-watcher.spec.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,22 @@ vi.mock("../../../utils/path", () => ({
127127
getWorkspacePath: vi.fn().mockReturnValue("/mock/workspace"),
128128
}))
129129

130+
// Also mock the get-relative-path module to ensure it uses our mocked getWorkspacePath
131+
vi.mock("../../shared/get-relative-path", async () => {
132+
const actual = await vi.importActual("../../shared/get-relative-path")
133+
return {
134+
...actual,
135+
generateRelativeFilePath: vi.fn((absolutePath: string) => {
136+
// Mock the relative path calculation
137+
const workspaceRoot = "/mock/workspace"
138+
if (absolutePath.startsWith(workspaceRoot)) {
139+
return absolutePath.substring(workspaceRoot.length + 1)
140+
}
141+
return absolutePath
142+
}),
143+
}
144+
})
145+
130146
// Type the mocked functions for proper intellisense
131147
const mockedVscode = vi.mocked(vscode, true)
132148

@@ -467,7 +483,7 @@ describe("FileWatcher", () => {
467483
id: "mocked-uuid-v5-for-testing",
468484
vector: [0.1, 0.2, 0.3],
469485
payload: {
470-
filePath: "../../../../../mock/workspace/test.js",
486+
filePath: "test.js",
471487
codeChunk: "test content",
472488
startLine: 1,
473489
endLine: 5,

0 commit comments

Comments
 (0)