/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { describe, it, expect } from 'vitest'; import { renderWithProviders } from '../../../test-utils/render.js'; import { ThinkingMessage } from './ThinkingMessage.js'; import React from 'react'; describe('ThinkingMessage', () => { it('renders subject line with vertical rule and "Thinking..." header', async () => { const renderResult = await renderWithProviders( , ); await renderResult.waitUntilReady(); const output = renderResult.lastFrame(); expect(output).toContain(' Thinking...'); expect(output).toContain('│'); expect(output).toContain('Planning'); expect(output).toMatchSnapshot(); await expect(renderResult).toMatchSvgSnapshot(); renderResult.unmount(); }); it('uses description when subject is empty', async () => { const renderResult = await renderWithProviders( , ); await renderResult.waitUntilReady(); const output = renderResult.lastFrame(); expect(output).toContain('Processing details'); expect(output).toContain('│'); expect(output).toMatchSnapshot(); await expect(renderResult).toMatchSvgSnapshot(); renderResult.unmount(); }); it('renders full mode with left border and full text', async () => { const renderResult = await renderWithProviders( , ); await renderResult.waitUntilReady(); const output = renderResult.lastFrame(); expect(output).toContain('│'); expect(output).toContain('Planning'); expect(output).toContain('I am planning the solution.'); expect(output).toMatchSnapshot(); await expect(renderResult).toMatchSvgSnapshot(); renderResult.unmount(); }); it('renders "Thinking..." header when isFirstThinking is true', async () => { const renderResult = await renderWithProviders( , ); await renderResult.waitUntilReady(); const output = renderResult.lastFrame(); expect(output).toContain(' Thinking...'); expect(output).toContain('Summary line'); expect(output).toContain('│'); expect(output).toMatchSnapshot(); await expect(renderResult).toMatchSvgSnapshot(); renderResult.unmount(); }); it('normalizes escaped newline tokens', async () => { const renderResult = await renderWithProviders( , ); await renderResult.waitUntilReady(); expect(renderResult.lastFrame()).toMatchSnapshot(); await expect(renderResult).toMatchSvgSnapshot(); renderResult.unmount(); }); it('renders empty state gracefully', async () => { const renderResult = await renderWithProviders( , ); await renderResult.waitUntilReady(); expect(renderResult.lastFrame({ allowEmpty: true })).toBe(''); renderResult.unmount(); }); it('renders multiple thinking messages sequentially correctly', async () => { const renderResult = await renderWithProviders( , ); await renderResult.waitUntilReady(); expect(renderResult.lastFrame()).toMatchSnapshot(); await expect(renderResult).toMatchSvgSnapshot(); renderResult.unmount(); }); it('filters out progress dots and empty lines', async () => { const renderResult = await renderWithProviders( , ); await renderResult.waitUntilReady(); const output = renderResult.lastFrame(); expect(output).toContain('Thinking'); expect(output).toContain('Done'); expect(renderResult.lastFrame()).toMatchSnapshot(); await expect(renderResult).toMatchSvgSnapshot(); renderResult.unmount(); }); });