Skip to content

Commit 529a7d5

Browse files
committed
test: Add support for processing files under hidden parent directories in FileWatcher and DirectoryScanner
1 parent 9c0864c commit 529a7d5

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,30 @@ describe("FileWatcher", () => {
275275
expect(processedFiles).not.toContain(".hidden/src/components/Button.tsx")
276276
expect(processedFiles).not.toContain("src/components/.hidden/Button.tsx")
277277
})
278+
279+
it("should process files when workspace is under hidden parent directory", async () => {
280+
// Create file watcher with workspace under hidden parent directory
281+
const watcherUnderHidden = new FileWatcher(
282+
"/Users/test/.config/project",
283+
mockContext,
284+
mockCacheManager,
285+
mockEmbedder,
286+
mockVectorStore,
287+
mockIgnoreInstance,
288+
)
289+
290+
await watcherUnderHidden.initialize()
291+
292+
// Simulate file creation in workspace under hidden parent
293+
await mockOnDidCreate({ fsPath: "/Users/test/.config/project/src/file.ts" })
294+
295+
// Wait for batch processing
296+
await new Promise((resolve) => setTimeout(resolve, 600))
297+
298+
// File should be processed, not filtered out
299+
// The key assertion is that upsertPoints was called, meaning the file wasn't filtered
300+
expect(mockVectorStore.upsertPoints).toHaveBeenCalled()
301+
})
278302
})
279303

280304
describe("dispose", () => {

src/services/code-index/processors/__tests__/scanner.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,32 @@ describe("DirectoryScanner", () => {
259259
expect(mockCodeParser.parseFile).toHaveBeenCalledTimes(2)
260260
})
261261

262+
it("should process files when workspace is under hidden parent directory", async () => {
263+
const { listFiles } = await import("../../../glob/list-files")
264+
// Simulate workspace at /Users/test/.root-project
265+
vi.mocked(listFiles).mockResolvedValue([["src/file1.js"], false])
266+
267+
const mockBlocks: any[] = [
268+
{
269+
file_path: "src/file1.js",
270+
content: "test content",
271+
start_line: 1,
272+
end_line: 5,
273+
identifier: "test",
274+
type: "function",
275+
fileHash: "hash",
276+
segmentHash: "segment-hash",
277+
},
278+
]
279+
;(mockCodeParser.parseFile as any).mockResolvedValue(mockBlocks)
280+
281+
const result = await scanner.scanDirectory("/Users/test/.root-project")
282+
283+
// File should be processed, not filtered out
284+
expect(result.stats.processed).toBe(1)
285+
expect(mockCodeParser.parseFile).toHaveBeenCalledWith("src/file1.js", expect.any(Object))
286+
})
287+
262288
it("should process markdown files alongside code files", async () => {
263289
// Create scanner without embedder to test the non-embedding path
264290
const scannerNoEmbeddings = new DirectoryScanner(

0 commit comments

Comments
 (0)