diff options
| author | Abhi <[email protected]> | 2025-07-22 00:34:55 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-22 04:34:55 +0000 |
| commit | 9daead63ddc4a0bddad05ec9f4bb7c0726da44f4 (patch) | |
| tree | a756014f436f4cc356ca334a45494386027e7b4e /packages/cli/src/ui/hooks/useGeminiStream.test.tsx | |
| parent | 5f813ef51076177aadccc0046f2182310d6b0a1a (diff) | |
(feat): Initial Version of Custom Commands (#4572)
Diffstat (limited to 'packages/cli/src/ui/hooks/useGeminiStream.test.tsx')
| -rw-r--r-- | packages/cli/src/ui/hooks/useGeminiStream.test.tsx | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/packages/cli/src/ui/hooks/useGeminiStream.test.tsx b/packages/cli/src/ui/hooks/useGeminiStream.test.tsx index d7fd35c8..02fae607 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.test.tsx +++ b/packages/cli/src/ui/hooks/useGeminiStream.test.tsx @@ -1058,6 +1058,65 @@ describe('useGeminiStream', () => { expect(mockSendMessageStream).not.toHaveBeenCalled(); // No LLM call made }); }); + + it('should call Gemini with prompt content when slash command returns a `submit_prompt` action', async () => { + const customCommandResult: SlashCommandProcessorResult = { + type: 'submit_prompt', + content: 'This is the actual prompt from the command file.', + }; + mockHandleSlashCommand.mockResolvedValue(customCommandResult); + + const { result, mockSendMessageStream: localMockSendMessageStream } = + renderTestHook(); + + await act(async () => { + await result.current.submitQuery('/my-custom-command'); + }); + + await waitFor(() => { + expect(mockHandleSlashCommand).toHaveBeenCalledWith( + '/my-custom-command', + ); + + expect(localMockSendMessageStream).not.toHaveBeenCalledWith( + '/my-custom-command', + expect.anything(), + expect.anything(), + ); + + expect(localMockSendMessageStream).toHaveBeenCalledWith( + 'This is the actual prompt from the command file.', + expect.any(AbortSignal), + expect.any(String), + ); + + expect(mockScheduleToolCalls).not.toHaveBeenCalled(); + }); + }); + + it('should correctly handle a submit_prompt action with empty content', async () => { + const emptyPromptResult: SlashCommandProcessorResult = { + type: 'submit_prompt', + content: '', + }; + mockHandleSlashCommand.mockResolvedValue(emptyPromptResult); + + const { result, mockSendMessageStream: localMockSendMessageStream } = + renderTestHook(); + + await act(async () => { + await result.current.submitQuery('/emptycmd'); + }); + + await waitFor(() => { + expect(mockHandleSlashCommand).toHaveBeenCalledWith('/emptycmd'); + expect(localMockSendMessageStream).toHaveBeenCalledWith( + '', + expect.any(AbortSignal), + expect.any(String), + ); + }); + }); }); describe('Memory Refresh on save_memory', () => { |
