mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-08 20:30:53 -07:00
test(cli): refactor tests for async render utilities (#23252)
This commit is contained in:
committed by
GitHub
parent
86a3a913b5
commit
6c78eb7a39
@@ -30,19 +30,17 @@ describe('<FooterConfigDialog />', () => {
|
||||
{ settings },
|
||||
);
|
||||
|
||||
await renderResult.waitUntilReady();
|
||||
expect(renderResult.lastFrame()).toMatchSnapshot();
|
||||
await expect(renderResult).toMatchSvgSnapshot();
|
||||
});
|
||||
|
||||
it('toggles an item when enter is pressed', async () => {
|
||||
const settings = createMockSettings();
|
||||
const { lastFrame, stdin, waitUntilReady } = await renderWithProviders(
|
||||
const { lastFrame, stdin } = await renderWithProviders(
|
||||
<FooterConfigDialog onClose={mockOnClose} />,
|
||||
{ settings },
|
||||
);
|
||||
|
||||
await waitUntilReady();
|
||||
act(() => {
|
||||
stdin.write('\r'); // Enter to toggle
|
||||
});
|
||||
@@ -62,12 +60,11 @@ describe('<FooterConfigDialog />', () => {
|
||||
|
||||
it('reorders items with arrow keys', async () => {
|
||||
const settings = createMockSettings();
|
||||
const { lastFrame, stdin, waitUntilReady } = await renderWithProviders(
|
||||
const { lastFrame, stdin } = await renderWithProviders(
|
||||
<FooterConfigDialog onClose={mockOnClose} />,
|
||||
{ settings },
|
||||
);
|
||||
|
||||
await waitUntilReady();
|
||||
// Initial order: workspace, git-branch, ...
|
||||
const output = lastFrame();
|
||||
const cwdIdx = output.indexOf('] workspace');
|
||||
@@ -93,12 +90,11 @@ describe('<FooterConfigDialog />', () => {
|
||||
|
||||
it('closes on Esc', async () => {
|
||||
const settings = createMockSettings();
|
||||
const { stdin, waitUntilReady } = await renderWithProviders(
|
||||
const { stdin } = await renderWithProviders(
|
||||
<FooterConfigDialog onClose={mockOnClose} />,
|
||||
{ settings },
|
||||
);
|
||||
|
||||
await waitUntilReady();
|
||||
act(() => {
|
||||
stdin.write('\x1b'); // Esc
|
||||
});
|
||||
@@ -115,9 +111,8 @@ describe('<FooterConfigDialog />', () => {
|
||||
{ settings },
|
||||
);
|
||||
|
||||
const { lastFrame, stdin, waitUntilReady } = renderResult;
|
||||
const { lastFrame, stdin } = renderResult;
|
||||
|
||||
await waitUntilReady();
|
||||
expect(lastFrame()).toContain('~/project/path');
|
||||
|
||||
// Move focus down to 'code-changes' (which has colored elements)
|
||||
@@ -148,13 +143,11 @@ describe('<FooterConfigDialog />', () => {
|
||||
|
||||
it('shows an empty preview when all items are deselected', async () => {
|
||||
const settings = createMockSettings();
|
||||
const { lastFrame, stdin, waitUntilReady } = await renderWithProviders(
|
||||
const { lastFrame, stdin } = await renderWithProviders(
|
||||
<FooterConfigDialog onClose={mockOnClose} />,
|
||||
{ settings },
|
||||
);
|
||||
|
||||
await waitUntilReady();
|
||||
|
||||
// Default items are the first 5. We toggle them off.
|
||||
for (let i = 0; i < 5; i++) {
|
||||
act(() => {
|
||||
@@ -178,11 +171,10 @@ describe('<FooterConfigDialog />', () => {
|
||||
|
||||
it('moves item correctly after trying to move up at the top', async () => {
|
||||
const settings = createMockSettings();
|
||||
const { lastFrame, stdin, waitUntilReady } = await renderWithProviders(
|
||||
const { lastFrame, stdin } = await renderWithProviders(
|
||||
<FooterConfigDialog onClose={mockOnClose} />,
|
||||
{ settings },
|
||||
);
|
||||
await waitUntilReady();
|
||||
|
||||
// Default initial items in mock settings are 'git-branch', 'workspace', ...
|
||||
await waitFor(() => {
|
||||
@@ -222,8 +214,7 @@ describe('<FooterConfigDialog />', () => {
|
||||
{ settings },
|
||||
);
|
||||
|
||||
const { lastFrame, stdin, waitUntilReady } = renderResult;
|
||||
await waitUntilReady();
|
||||
const { lastFrame, stdin } = renderResult;
|
||||
|
||||
// By default labels are on
|
||||
expect(lastFrame()).toContain('workspace (/directory)');
|
||||
|
||||
Reference in New Issue
Block a user