diff options
| author | Harold Mciver <[email protected]> | 2025-07-15 16:10:04 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-15 20:10:04 +0000 |
| commit | 03b3917f62e5db2b00bcb27df9d78ee5289d9a85 (patch) | |
| tree | dc6007c213bbdef4a39f1627d7c3d59a3bf44a23 /packages/cli/src/ui/hooks/slashCommandProcessor.test.ts | |
| parent | 8d9dc44b71c71dc7800f1dedcc5f88ec1ab654fa (diff) | |
updated `/stats` to use new slash command arch (#4146)
Diffstat (limited to 'packages/cli/src/ui/hooks/slashCommandProcessor.test.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/slashCommandProcessor.test.ts | 81 |
1 files changed, 10 insertions, 71 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts index 6946bde0..f39795c0 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts @@ -54,7 +54,16 @@ vi.mock('../../utils/version.js', () => ({ })); import { act, renderHook } from '@testing-library/react'; -import { vi, describe, it, expect, beforeEach, afterEach, Mock } from 'vitest'; +import { + vi, + describe, + it, + expect, + beforeEach, + afterEach, + beforeAll, + Mock, +} from 'vitest'; import open from 'open'; import { useSlashCommandProcessor } from './slashCommandProcessor.js'; import { MessageType, SlashCommandProcessorResult } from '../types.js'; @@ -207,76 +216,6 @@ describe('useSlashCommandProcessor', () => { const getProcessor = (showToolDescriptions: boolean = false) => getProcessorHook(showToolDescriptions).result.current; - describe('/stats command', () => { - it('should show detailed session statistics', async () => { - // Arrange - mockUseSessionStats.mockReturnValue({ - stats: { - sessionStartTime: new Date('2025-01-01T00:00:00.000Z'), - }, - }); - - const { handleSlashCommand } = getProcessor(); - const mockDate = new Date('2025-01-01T01:02:03.000Z'); // 1h 2m 3s duration - vi.setSystemTime(mockDate); - - // Act - await act(async () => { - handleSlashCommand('/stats'); - }); - - // Assert - expect(mockAddItem).toHaveBeenNthCalledWith( - 2, // Called after the user message - expect.objectContaining({ - type: MessageType.STATS, - duration: '1h 2m 3s', - }), - expect.any(Number), - ); - - vi.useRealTimers(); - }); - - it('should show model-specific statistics when using /stats model', async () => { - // Arrange - const { handleSlashCommand } = getProcessor(); - - // Act - await act(async () => { - handleSlashCommand('/stats model'); - }); - - // Assert - expect(mockAddItem).toHaveBeenNthCalledWith( - 2, // Called after the user message - expect.objectContaining({ - type: MessageType.MODEL_STATS, - }), - expect.any(Number), - ); - }); - - it('should show tool-specific statistics when using /stats tools', async () => { - // Arrange - const { handleSlashCommand } = getProcessor(); - - // Act - await act(async () => { - handleSlashCommand('/stats tools'); - }); - - // Assert - expect(mockAddItem).toHaveBeenNthCalledWith( - 2, // Called after the user message - expect.objectContaining({ - type: MessageType.TOOL_STATS, - }), - expect.any(Number), - ); - }); - }); - describe('Other commands', () => { it('/editor should open editor dialog and return handled', async () => { const { handleSlashCommand } = getProcessor(); |
