mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-19 09:41:17 -07:00
refactor(cli): simplify keypress and mouse providers and update tests (#22853)
This commit is contained in:
committed by
GitHub
parent
81a97e78f1
commit
d7dfcf7f99
@@ -4,12 +4,10 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
import { waitFor } from '../../../test-utils/async.js';
|
||||
import { render } from '../../../test-utils/render.js';
|
||||
import { renderWithProviders } from '../../../test-utils/render.js';
|
||||
import { SubagentGroupDisplay } from './SubagentGroupDisplay.js';
|
||||
import { Kind, CoreToolCallStatus } from '@google/gemini-cli-core';
|
||||
import type { IndividualToolCallDisplay } from '../../types.js';
|
||||
import { KeypressProvider } from '../../contexts/KeypressContext.js';
|
||||
import { OverflowProvider } from '../../contexts/OverflowContext.js';
|
||||
import { vi } from 'vitest';
|
||||
import { Text } from 'ink';
|
||||
|
||||
@@ -69,36 +67,32 @@ describe('<SubagentGroupDisplay />', () => {
|
||||
const renderSubagentGroup = (
|
||||
toolCallsToRender: IndividualToolCallDisplay[],
|
||||
height?: number,
|
||||
) => (
|
||||
<OverflowProvider>
|
||||
<KeypressProvider>
|
||||
<SubagentGroupDisplay
|
||||
toolCalls={toolCallsToRender}
|
||||
terminalWidth={80}
|
||||
availableTerminalHeight={height}
|
||||
isExpandable={true}
|
||||
/>
|
||||
</KeypressProvider>
|
||||
</OverflowProvider>
|
||||
);
|
||||
) =>
|
||||
renderWithProviders(
|
||||
<SubagentGroupDisplay
|
||||
toolCalls={toolCallsToRender}
|
||||
terminalWidth={80}
|
||||
availableTerminalHeight={height}
|
||||
isExpandable={true}
|
||||
/>,
|
||||
);
|
||||
|
||||
it('renders nothing if there are no agent tool calls', async () => {
|
||||
const { lastFrame } = render(renderSubagentGroup([], 40));
|
||||
const { lastFrame } = renderSubagentGroup([], 40);
|
||||
expect(lastFrame({ allowEmpty: true })).toBe('');
|
||||
});
|
||||
|
||||
it('renders collapsed view by default with correct agent counts and states', async () => {
|
||||
const { lastFrame, waitUntilReady } = render(
|
||||
renderSubagentGroup(mockToolCalls, 40),
|
||||
const { lastFrame, waitUntilReady } = renderSubagentGroup(
|
||||
mockToolCalls,
|
||||
40,
|
||||
);
|
||||
await waitUntilReady();
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('expands when availableTerminalHeight is undefined', async () => {
|
||||
const { lastFrame, rerender } = render(
|
||||
renderSubagentGroup(mockToolCalls, 40),
|
||||
);
|
||||
const { lastFrame, rerender } = renderSubagentGroup(mockToolCalls, 40);
|
||||
|
||||
// Default collapsed view
|
||||
await waitFor(() => {
|
||||
@@ -106,13 +100,27 @@ describe('<SubagentGroupDisplay />', () => {
|
||||
});
|
||||
|
||||
// Expand view
|
||||
rerender(renderSubagentGroup(mockToolCalls, undefined));
|
||||
rerender(
|
||||
<SubagentGroupDisplay
|
||||
toolCalls={mockToolCalls}
|
||||
terminalWidth={80}
|
||||
availableTerminalHeight={undefined}
|
||||
isExpandable={true}
|
||||
/>,
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(lastFrame()).toContain('(ctrl+o to collapse)');
|
||||
});
|
||||
|
||||
// Collapse view
|
||||
rerender(renderSubagentGroup(mockToolCalls, 40));
|
||||
rerender(
|
||||
<SubagentGroupDisplay
|
||||
toolCalls={mockToolCalls}
|
||||
terminalWidth={80}
|
||||
availableTerminalHeight={40}
|
||||
isExpandable={true}
|
||||
/>,
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(lastFrame()).toContain('(ctrl+o to expand)');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user