summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/commands/chatCommand.test.ts
diff options
context:
space:
mode:
authorKamal Raj Sekar <[email protected]>2025-08-14 22:00:30 +0530
committerGitHub <[email protected]>2025-08-14 16:30:30 +0000
commit4973e7e1e04004547021986a0e2dc5eeb4a8bf9d (patch)
tree493d9abb4ad0ae6eb69b5ebc8c5bc812ef05abcf /packages/cli/src/ui/commands/chatCommand.test.ts
parent8bebaedad4c82c50f570dc65c13feabcbb8444ef (diff)
/chat save command saves empty conversations with only system context (#6121)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/commands/chatCommand.test.ts')
-rw-r--r--packages/cli/src/ui/commands/chatCommand.test.ts44
1 files changed, 23 insertions, 21 deletions
diff --git a/packages/cli/src/ui/commands/chatCommand.test.ts b/packages/cli/src/ui/commands/chatCommand.test.ts
index ccdfd4b2..c7299883 100644
--- a/packages/cli/src/ui/commands/chatCommand.test.ts
+++ b/packages/cli/src/ui/commands/chatCommand.test.ts
@@ -185,30 +185,32 @@ describe('chatCommand', () => {
});
});
- it('should inform if conversation history is empty', async () => {
+ it('should inform if conversation history is empty or only contains system context', async () => {
mockGetHistory.mockReturnValue([]);
- const result = await saveCommand?.action?.(mockContext, tag);
+ let result = await saveCommand?.action?.(mockContext, tag);
expect(result).toEqual({
type: 'message',
messageType: 'info',
content: 'No conversation found to save.',
});
- });
-
- it('should save the conversation if checkpoint does not exist', async () => {
- const history: HistoryItemWithoutId[] = [
- {
- type: 'user',
- text: 'hello',
- },
- ];
- mockGetHistory.mockReturnValue(history);
- mockCheckpointExists.mockResolvedValue(false);
- const result = await saveCommand?.action?.(mockContext, tag);
+ mockGetHistory.mockReturnValue([
+ { role: 'user', parts: [{ text: 'context for our chat' }] },
+ { role: 'model', parts: [{ text: 'Got it. Thanks for the context!' }] },
+ ]);
+ result = await saveCommand?.action?.(mockContext, tag);
+ expect(result).toEqual({
+ type: 'message',
+ messageType: 'info',
+ content: 'No conversation found to save.',
+ });
- expect(mockCheckpointExists).toHaveBeenCalledWith(tag);
- expect(mockSaveCheckpoint).toHaveBeenCalledWith(history, tag);
+ mockGetHistory.mockReturnValue([
+ { role: 'user', parts: [{ text: 'context for our chat' }] },
+ { role: 'model', parts: [{ text: 'Got it. Thanks for the context!' }] },
+ { role: 'user', parts: [{ text: 'Hello, how are you?' }] },
+ ]);
+ result = await saveCommand?.action?.(mockContext, tag);
expect(result).toEqual({
type: 'message',
messageType: 'info',
@@ -237,11 +239,11 @@ describe('chatCommand', () => {
});
it('should save the conversation if overwrite is confirmed', async () => {
- const history: HistoryItemWithoutId[] = [
- {
- type: 'user',
- text: 'hello',
- },
+ const history: Content[] = [
+ { role: 'user', parts: [{ text: 'context for our chat' }] },
+ { role: 'model', parts: [{ text: 'Got it. Thanks for the context!' }] },
+ { role: 'user', parts: [{ text: 'hello' }] },
+ { role: 'model', parts: [{ text: 'Hi there!' }] },
];
mockGetHistory.mockReturnValue(history);
mockContext.overwriteConfirmed = true;