test(cli): fix flaky ToolResultDisplay overflow test (#20518)

This commit is contained in:
Jarrod Whelan
2026-02-26 16:30:43 -08:00
committed by GitHub
parent bc622a443e
commit 049d48ef60
@@ -8,7 +8,6 @@ import { describe, it, expect } from 'vitest';
import { ToolGroupMessage } from './ToolGroupMessage.js'; import { ToolGroupMessage } from './ToolGroupMessage.js';
import { renderWithProviders } from '../../../test-utils/render.js'; import { renderWithProviders } from '../../../test-utils/render.js';
import { StreamingState, type IndividualToolCallDisplay } from '../../types.js'; import { StreamingState, type IndividualToolCallDisplay } from '../../types.js';
import { OverflowProvider } from '../../contexts/OverflowContext.js';
import { waitFor } from '../../../test-utils/async.js'; import { waitFor } from '../../../test-utils/async.js';
import { CoreToolCallStatus } from '@google/gemini-cli-core'; import { CoreToolCallStatus } from '@google/gemini-cli-core';
@@ -32,16 +31,14 @@ describe('ToolResultDisplay Overflow', () => {
}, },
]; ];
const { lastFrame } = renderWithProviders( const { lastFrame, waitUntilReady } = renderWithProviders(
<OverflowProvider> <ToolGroupMessage
<ToolGroupMessage item={{ id: 1, type: 'tool_group', tools: toolCalls }}
item={{ id: 1, type: 'tool_group', tools: toolCalls }} toolCalls={toolCalls}
toolCalls={toolCalls} availableTerminalHeight={15} // Small height to force overflow
availableTerminalHeight={15} // Small height to force overflow terminalWidth={80}
terminalWidth={80} isExpandable={true}
isExpandable={true} />,
/>
</OverflowProvider>,
{ {
uiState: { uiState: {
streamingState: StreamingState.Idle, streamingState: StreamingState.Idle,
@@ -51,12 +48,13 @@ describe('ToolResultDisplay Overflow', () => {
}, },
); );
// ResizeObserver might take a tick await waitUntilReady();
await waitFor(() =>
expect(lastFrame()?.toLowerCase()).toContain( // ResizeObserver might take a tick, though ToolGroupMessage calculates overflow synchronously
'press ctrl+o to show more lines', await waitFor(() => {
), const frame = lastFrame();
); expect(frame.toLowerCase()).toContain('press ctrl+o to show more lines');
});
const frame = lastFrame(); const frame = lastFrame();
expect(frame).toBeDefined(); expect(frame).toBeDefined();