Skip to content

Commit c2ffd9b

Browse files
committed
fix: update path tests for cross-platform compatibility
- Use path.resolve() in test expectations to handle Windows drive letters - Tests now correctly expect platform-specific absolute paths - Fixes failing tests on Windows CI while maintaining Unix compatibility
1 parent 2d94d7a commit c2ffd9b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/services/code-index/shared/__tests__/get-relative-path.spec.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,24 @@ describe("get-relative-path", () => {
88
const filePath = "src/file.ts"
99
const workspaceRoot = path.join(path.sep, "custom", "workspace")
1010
const result = generateNormalizedAbsolutePath(filePath, workspaceRoot)
11-
expect(result).toBe(path.join(workspaceRoot, filePath))
11+
// On Windows, path.resolve adds the drive letter, so we need to use path.resolve for the expected value
12+
expect(result).toBe(path.resolve(workspaceRoot, filePath))
1213
})
1314

1415
it("should handle absolute paths", () => {
1516
const filePath = path.join(path.sep, "absolute", "path", "file.ts")
1617
const workspaceRoot = path.join(path.sep, "custom", "workspace")
1718
const result = generateNormalizedAbsolutePath(filePath, workspaceRoot)
18-
expect(result).toBe(filePath)
19+
// When an absolute path is provided, it should be resolved to include drive letter on Windows
20+
expect(result).toBe(path.resolve(filePath))
1921
})
2022

2123
it("should normalize paths with . and .. segments", () => {
2224
const filePath = "./src/../src/file.ts"
2325
const workspaceRoot = path.join(path.sep, "custom", "workspace")
2426
const result = generateNormalizedAbsolutePath(filePath, workspaceRoot)
25-
expect(result).toBe(path.join(workspaceRoot, "src", "file.ts"))
27+
// Use path.resolve to get the expected normalized absolute path
28+
expect(result).toBe(path.resolve(workspaceRoot, "src", "file.ts"))
2629
})
2730
})
2831

0 commit comments

Comments
 (0)