diff options
| author | Billy Biggs <[email protected]> | 2025-06-21 18:23:35 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-22 01:23:35 +0000 |
| commit | 0779697da6caeae09b67a146013612a34f369b74 (patch) | |
| tree | 665d2b22773b28843648b01fd74b5f0dcb392c6f /packages/cli/src/ui/hooks/useCompletion.integration.test.ts | |
| parent | 63f6a497cba61299a1c24aa96795a55479740ac6 (diff) | |
Add setting enableRecursiveFileSearch to control @-file completion (#1290)
Diffstat (limited to 'packages/cli/src/ui/hooks/useCompletion.integration.test.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/useCompletion.integration.test.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/packages/cli/src/ui/hooks/useCompletion.integration.test.ts b/packages/cli/src/ui/hooks/useCompletion.integration.test.ts index 40af5d4f..237b6aae 100644 --- a/packages/cli/src/ui/hooks/useCompletion.integration.test.ts +++ b/packages/cli/src/ui/hooks/useCompletion.integration.test.ts @@ -47,6 +47,7 @@ describe('useCompletion git-aware filtering integration', () => { mockConfig = { getFileFilteringRespectGitIgnore: vi.fn(() => true), getFileService: vi.fn().mockReturnValue(mockFileDiscoveryService), + getEnableRecursiveFileSearch: vi.fn(() => true), }; vi.mocked(FileDiscoveryService).mockImplementation( @@ -170,6 +171,35 @@ describe('useCompletion git-aware filtering integration', () => { ); }); + it('should not perform recursive search when disabled in config', async () => { + const globResults = [`${testCwd}/data`, `${testCwd}/dist`]; + vi.mocked(glob).mockResolvedValue(globResults); + + // Disable recursive search in the mock config + const mockConfigNoRecursive = { + ...mockConfig, + getEnableRecursiveFileSearch: vi.fn(() => false), + }; + + vi.mocked(fs.readdir).mockResolvedValue([ + { name: 'data', isDirectory: () => true }, + { name: 'dist', isDirectory: () => true }, + ] as Array<{ name: string; isDirectory: () => boolean }>); + + renderHook(() => + useCompletion('@d', testCwd, true, slashCommands, mockConfigNoRecursive), + ); + + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 150)); + }); + + // `glob` should not be called because recursive search is disabled + expect(glob).not.toHaveBeenCalled(); + // `fs.readdir` should be called for the top-level directory instead + expect(fs.readdir).toHaveBeenCalledWith(testCwd, { withFileTypes: true }); + }); + it('should work without config (fallback behavior)', async () => { vi.mocked(fs.readdir).mockResolvedValue([ { name: 'src', isDirectory: () => true }, |
