mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-04 00:44:05 -07:00
feat(cli): add --delete flag to /exit command for session deletion (#19332)
Co-authored-by: David Pierce <davidapierce@google.com>
This commit is contained in:
@@ -33,11 +33,12 @@ describe('quitCommand', () => {
|
||||
});
|
||||
|
||||
if (!quitCommand.action) throw new Error('Action is not defined');
|
||||
const result = quitCommand.action(mockContext, 'quit');
|
||||
const result = quitCommand.action(mockContext, '');
|
||||
|
||||
expect(formatDuration).toHaveBeenCalledWith(3600000); // 1 hour in ms
|
||||
expect(result).toEqual({
|
||||
type: 'quit',
|
||||
deleteSession: false,
|
||||
messages: [
|
||||
{
|
||||
type: 'user',
|
||||
@@ -52,4 +53,54 @@ describe('quitCommand', () => {
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('sets deleteSession to true when --delete flag is provided', () => {
|
||||
const mockContext = createMockCommandContext({
|
||||
session: {
|
||||
stats: {
|
||||
sessionStartTime: new Date('2025-01-01T00:00:00Z'),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!quitCommand.action) throw new Error('Action is not defined');
|
||||
const result = quitCommand.action(mockContext, '--delete');
|
||||
|
||||
expect(result).toEqual({
|
||||
type: 'quit',
|
||||
deleteSession: true,
|
||||
messages: [
|
||||
{
|
||||
type: 'user',
|
||||
text: '/quit',
|
||||
id: expect.any(Number),
|
||||
},
|
||||
{
|
||||
type: 'quit',
|
||||
duration: '1h 0m 0s',
|
||||
id: expect.any(Number),
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('does not set deleteSession for unrecognized args', () => {
|
||||
const mockContext = createMockCommandContext({
|
||||
session: {
|
||||
stats: {
|
||||
sessionStartTime: new Date('2025-01-01T00:00:00Z'),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!quitCommand.action) throw new Error('Action is not defined');
|
||||
const result = quitCommand.action(mockContext, 'some-random-arg');
|
||||
|
||||
expect(result).toEqual(
|
||||
expect.objectContaining({
|
||||
type: 'quit',
|
||||
deleteSession: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user