diff options
| author | uttamkanodia14 <[email protected]> | 2025-07-10 00:19:30 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-09 18:49:30 +0000 |
| commit | 063481faa4b1c86868689580ff0fbd8cb04141e3 (patch) | |
| tree | f7b38f46a95cd22bbf15a7454963ba834e15d134 /packages/cli/src/nonInteractiveCli.test.ts | |
| parent | 6c12f9e0d902c60fa5e01422018ce773c405da8d (diff) | |
Adding TurnId to Tool call and API responses and error logs. (#3039)
Co-authored-by: Scott Densmore <[email protected]>
Diffstat (limited to 'packages/cli/src/nonInteractiveCli.test.ts')
| -rw-r--r-- | packages/cli/src/nonInteractiveCli.test.ts | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/packages/cli/src/nonInteractiveCli.test.ts b/packages/cli/src/nonInteractiveCli.test.ts index 2a32cacb..14352f53 100644 --- a/packages/cli/src/nonInteractiveCli.test.ts +++ b/packages/cli/src/nonInteractiveCli.test.ts @@ -81,15 +81,18 @@ describe('runNonInteractive', () => { })(); mockChat.sendMessageStream.mockResolvedValue(inputStream); - await runNonInteractive(mockConfig, 'Test input'); + await runNonInteractive(mockConfig, 'Test input', 'prompt-id-1'); - expect(mockChat.sendMessageStream).toHaveBeenCalledWith({ - message: [{ text: 'Test input' }], - config: { - abortSignal: expect.any(AbortSignal), - tools: [{ functionDeclarations: [] }], + expect(mockChat.sendMessageStream).toHaveBeenCalledWith( + { + message: [{ text: 'Test input' }], + config: { + abortSignal: expect.any(AbortSignal), + tools: [{ functionDeclarations: [] }], + }, }, - }); + expect.any(String), + ); expect(mockProcessStdoutWrite).toHaveBeenCalledWith('Hello'); expect(mockProcessStdoutWrite).toHaveBeenCalledWith(' World'); expect(mockProcessStdoutWrite).toHaveBeenCalledWith('\n'); @@ -131,7 +134,7 @@ describe('runNonInteractive', () => { .mockResolvedValueOnce(stream1) .mockResolvedValueOnce(stream2); - await runNonInteractive(mockConfig, 'Use a tool'); + await runNonInteractive(mockConfig, 'Use a tool', 'prompt-id-2'); expect(mockChat.sendMessageStream).toHaveBeenCalledTimes(2); expect(mockCoreExecuteToolCall).toHaveBeenCalledWith( @@ -144,6 +147,7 @@ describe('runNonInteractive', () => { expect.objectContaining({ message: [toolResponsePart], }), + expect.any(String), ); expect(mockProcessStdoutWrite).toHaveBeenCalledWith('Final answer'); }); @@ -190,7 +194,7 @@ describe('runNonInteractive', () => { .spyOn(console, 'error') .mockImplementation(() => {}); - await runNonInteractive(mockConfig, 'Trigger tool error'); + await runNonInteractive(mockConfig, 'Trigger tool error', 'prompt-id-3'); expect(mockCoreExecuteToolCall).toHaveBeenCalled(); expect(consoleErrorSpy).toHaveBeenCalledWith( @@ -200,6 +204,7 @@ describe('runNonInteractive', () => { expect.objectContaining({ message: [errorResponsePart], }), + expect.any(String), ); expect(mockProcessStdoutWrite).toHaveBeenCalledWith( 'Could not complete request.', @@ -213,7 +218,7 @@ describe('runNonInteractive', () => { .spyOn(console, 'error') .mockImplementation(() => {}); - await runNonInteractive(mockConfig, 'Initial fail'); + await runNonInteractive(mockConfig, 'Initial fail', 'prompt-id-4'); expect(consoleErrorSpy).toHaveBeenCalledWith( '[API Error: API connection failed]', @@ -265,7 +270,11 @@ describe('runNonInteractive', () => { .spyOn(console, 'error') .mockImplementation(() => {}); - await runNonInteractive(mockConfig, 'Trigger tool not found'); + await runNonInteractive( + mockConfig, + 'Trigger tool not found', + 'prompt-id-5', + ); expect(consoleErrorSpy).toHaveBeenCalledWith( 'Error executing tool nonExistentTool: Tool "nonExistentTool" not found in registry.', @@ -278,6 +287,7 @@ describe('runNonInteractive', () => { expect.objectContaining({ message: [errorResponsePart], }), + expect.any(String), ); expect(mockProcessStdoutWrite).toHaveBeenCalledWith( |
