mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-08-09 16:36:40 -07:00
test(ui): refine unit tests and fix lint errors for keyboard shortcuts
This commit is contained in:
@@ -3893,4 +3893,42 @@ describe('AppContainer State Management', () => {
|
||||
unmount!();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Keyboard Shortcuts', () => {
|
||||
it('should toggle constrainHeight when Ctrl+O is pressed', async () => {
|
||||
let renderResult: {
|
||||
stdin: { write: (data: string) => boolean };
|
||||
waitUntilReady: () => Promise<void>;
|
||||
unmount: () => void;
|
||||
};
|
||||
await act(async () => {
|
||||
renderResult = renderAppContainer() as unknown as typeof renderResult;
|
||||
});
|
||||
const { stdin, waitUntilReady, unmount } = renderResult!;
|
||||
await waitUntilReady();
|
||||
|
||||
// Initially constrained
|
||||
expect(capturedUIState.constrainHeight).toBe(true);
|
||||
|
||||
// Press Ctrl+O (\x0f)
|
||||
await act(async () => {
|
||||
stdin.write('\x0f');
|
||||
});
|
||||
await waitUntilReady();
|
||||
|
||||
// Now unconstrained
|
||||
expect(capturedUIState.constrainHeight).toBe(false);
|
||||
|
||||
// Press Ctrl+O again
|
||||
await act(async () => {
|
||||
stdin.write('\x0f');
|
||||
});
|
||||
await waitUntilReady();
|
||||
|
||||
// Constrained again
|
||||
expect(capturedUIState.constrainHeight).toBe(true);
|
||||
|
||||
unmount();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
Config,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { renderWithProviders } from '../../../test-utils/render.js';
|
||||
import { act } from 'react';
|
||||
import { createMockSettings } from '../../../test-utils/settings.js';
|
||||
import { useToolActions } from '../../contexts/ToolActionsContext.js';
|
||||
|
||||
@@ -644,4 +645,55 @@ describe('ToolConfirmationMessage', () => {
|
||||
expect(output).not.toContain('Invocation Arguments:');
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should toggle MCP tool details expansion when Ctrl+O is pressed', async () => {
|
||||
const confirmationDetails: ToolCallConfirmationDetails = {
|
||||
type: 'mcp',
|
||||
title: 'Confirm MCP Tool',
|
||||
serverName: 'test-server',
|
||||
toolName: 'test-tool',
|
||||
toolDisplayName: 'Test Tool',
|
||||
toolArgs: { arg: 'val' },
|
||||
toolDescription: 'Test tool description',
|
||||
onConfirm: vi.fn(),
|
||||
};
|
||||
|
||||
const { lastFrame, waitUntilReady, stdin, unmount } = renderWithProviders(
|
||||
<ToolConfirmationMessage
|
||||
callId="test-call-id"
|
||||
confirmationDetails={confirmationDetails}
|
||||
config={mockConfig}
|
||||
getPreferredEditor={vi.fn()}
|
||||
availableTerminalHeight={30}
|
||||
terminalWidth={80}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
// Initially collapsed
|
||||
expect(lastFrame()).toContain('(press Ctrl+O to expand MCP tool details)');
|
||||
expect(lastFrame()).not.toContain('Invocation Arguments:');
|
||||
|
||||
// Press Ctrl+O (\x0f)
|
||||
await act(async () => {
|
||||
stdin.write('\x0f');
|
||||
});
|
||||
await waitUntilReady();
|
||||
|
||||
// Now expanded
|
||||
expect(lastFrame()).toContain(
|
||||
'(press Ctrl+O to collapse MCP tool details)',
|
||||
);
|
||||
expect(lastFrame()).toContain('Invocation Arguments:');
|
||||
|
||||
// Press Ctrl+O again
|
||||
await act(async () => {
|
||||
stdin.write('\x0f');
|
||||
});
|
||||
await waitUntilReady();
|
||||
|
||||
// Collapsed again
|
||||
expect(lastFrame()).toContain('(press Ctrl+O to expand MCP tool details)');
|
||||
unmount();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user