summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/atCommandProcessor.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/ui/hooks/atCommandProcessor.test.ts')
-rw-r--r--packages/cli/src/ui/hooks/atCommandProcessor.test.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/cli/src/ui/hooks/atCommandProcessor.test.ts b/packages/cli/src/ui/hooks/atCommandProcessor.test.ts
index 6380a187..572131af 100644
--- a/packages/cli/src/ui/hooks/atCommandProcessor.test.ts
+++ b/packages/cli/src/ui/hooks/atCommandProcessor.test.ts
@@ -21,6 +21,7 @@ const mockConfig = {
isSandboxed: vi.fn(() => false),
getFileService: vi.fn(),
getFileFilteringRespectGitIgnore: vi.fn(() => true),
+ getEnableRecursiveFileSearch: vi.fn(() => true),
} as unknown as Config;
const mockReadManyFilesExecute = vi.fn();
@@ -720,4 +721,35 @@ describe('handleAtCommand', () => {
expect(result.shouldProceed).toBe(true);
});
});
+
+ describe('when recursive file search is disabled', () => {
+ beforeEach(() => {
+ vi.mocked(mockConfig.getEnableRecursiveFileSearch).mockReturnValue(false);
+ });
+
+ it('should not use glob search for a nonexistent file', async () => {
+ const invalidFile = 'nonexistent.txt';
+ const query = `@${invalidFile}`;
+
+ vi.mocked(fsPromises.stat).mockRejectedValue(
+ Object.assign(new Error('ENOENT'), { code: 'ENOENT' }),
+ );
+
+ const result = await handleAtCommand({
+ query,
+ config: mockConfig,
+ addItem: mockAddItem,
+ onDebugMessage: mockOnDebugMessage,
+ messageId: 300,
+ signal: abortController.signal,
+ });
+
+ expect(mockGlobExecute).not.toHaveBeenCalled();
+ expect(mockOnDebugMessage).toHaveBeenCalledWith(
+ `Glob tool not found. Path ${invalidFile} will be skipped.`,
+ );
+ expect(result.processedQuery).toEqual([{ text: query }]);
+ expect(result.shouldProceed).toBe(true);
+ });
+ });
});