|
| 1 | +/** |
| 2 | + * @vitest-environment node |
| 3 | + */ |
| 4 | +import type { ReactNode } from 'react' |
| 5 | +import { renderToStaticMarkup } from 'react-dom/server' |
| 6 | +import { describe, expect, it, vi } from 'vitest' |
| 7 | +import { ToolCallItem } from './tool-call-item' |
| 8 | + |
| 9 | +vi.mock('@/components/ui', () => ({ |
| 10 | + ShimmerText: ({ children }: { children: ReactNode }) => <span>{children}</span>, |
| 11 | +})) |
| 12 | + |
| 13 | +describe('ToolCallItem', () => { |
| 14 | + it.each(['executing', 'success', 'error', 'cancelled'] as const)( |
| 15 | + 'renders the %s tool row without an icon', |
| 16 | + (status) => { |
| 17 | + const markup = renderToStaticMarkup( |
| 18 | + <ToolCallItem |
| 19 | + toolName='grep' |
| 20 | + displayTitle={status === 'executing' ? 'Searching for Pulse' : 'Searched for Pulse'} |
| 21 | + status={status} |
| 22 | + /> |
| 23 | + ) |
| 24 | + |
| 25 | + expect(markup).not.toContain('<svg') |
| 26 | + } |
| 27 | + ) |
| 28 | + |
| 29 | + it('does not restore a progressive streamed title after the tool settles', () => { |
| 30 | + const markup = renderToStaticMarkup( |
| 31 | + <ToolCallItem |
| 32 | + toolName='workspace_file' |
| 33 | + displayTitle='Wrote brief.md' |
| 34 | + status='success' |
| 35 | + streamingArgs='{"operation":"update","title":"brief.md"}' |
| 36 | + /> |
| 37 | + ) |
| 38 | + |
| 39 | + expect(markup).toContain('Wrote brief.md') |
| 40 | + expect(markup).not.toContain('Writing brief.md') |
| 41 | + }) |
| 42 | +}) |
0 commit comments