refactor(cli): integrate real config loading into async test utils (#23040)

This commit is contained in:
Tommaso Sciortino
2026-03-19 17:05:33 +00:00
committed by GitHub
parent 7de0616229
commit 23264ced9a
103 changed files with 1806 additions and 1541 deletions
@@ -41,7 +41,7 @@ describe('ExtensionDetails', () => {
mockOnInstall = vi.fn();
});
const renderDetails = (isInstalled = false) =>
const renderDetails = async (isInstalled = false) =>
renderWithProviders(
<ExtensionDetails
extension={mockExtension}
@@ -52,7 +52,7 @@ describe('ExtensionDetails', () => {
);
it('should render extension details correctly', async () => {
const { lastFrame } = renderDetails();
const { lastFrame } = await renderDetails();
await waitFor(() => {
expect(lastFrame()).toContain('Test Extension');
expect(lastFrame()).toContain('v1.2.3');
@@ -69,7 +69,7 @@ describe('ExtensionDetails', () => {
});
it('should show install prompt when not installed', async () => {
const { lastFrame } = renderDetails(false);
const { lastFrame } = await renderDetails(false);
await waitFor(() => {
expect(lastFrame()).toContain('[Enter] Install');
expect(lastFrame()).not.toContain('Already Installed');
@@ -77,7 +77,7 @@ describe('ExtensionDetails', () => {
});
it('should show already installed message when installed', async () => {
const { lastFrame } = renderDetails(true);
const { lastFrame } = await renderDetails(true);
await waitFor(() => {
expect(lastFrame()).toContain('Already Installed');
expect(lastFrame()).not.toContain('[Enter] Install');
@@ -85,7 +85,7 @@ describe('ExtensionDetails', () => {
});
it('should call onBack when Escape is pressed', async () => {
const { stdin } = renderDetails();
const { stdin } = await renderDetails();
await React.act(async () => {
stdin.write('\x1b'); // Escape
});
@@ -95,7 +95,7 @@ describe('ExtensionDetails', () => {
});
it('should call onInstall when Enter is pressed and not installed', async () => {
const { stdin } = renderDetails(false);
const { stdin } = await renderDetails(false);
await React.act(async () => {
stdin.write('\r'); // Enter
});
@@ -106,7 +106,7 @@ describe('ExtensionDetails', () => {
it('should NOT call onInstall when Enter is pressed and already installed', async () => {
vi.useFakeTimers();
const { stdin } = renderDetails(true);
const { stdin } = await renderDetails(true);
await React.act(async () => {
stdin.write('\r'); // Enter
});
@@ -7,6 +7,7 @@
import React from 'react';
import { renderWithProviders } from '../../../test-utils/render.js';
import { waitFor } from '../../../test-utils/async.js';
import { makeFakeConfig } from '@google/gemini-cli-core';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { ExtensionRegistryView } from './ExtensionRegistryView.js';
import { type ExtensionManager } from '../../../config/extension-manager.js';
@@ -121,7 +122,7 @@ describe('ExtensionRegistryView', () => {
);
});
const renderView = () =>
const renderView = async () =>
renderWithProviders(
<ExtensionRegistryView
extensionManager={mockExtensionManager}
@@ -129,6 +130,7 @@ describe('ExtensionRegistryView', () => {
onClose={mockOnClose}
/>,
{
config: makeFakeConfig(),
uiState: {
staticExtraHeight: 5,
terminalHeight: 40,
@@ -137,7 +139,7 @@ describe('ExtensionRegistryView', () => {
);
it('should render extensions', async () => {
const { lastFrame, waitUntilReady } = renderView();
const { lastFrame, waitUntilReady } = await renderView();
await waitUntilReady();
await waitFor(() => {
@@ -146,8 +148,8 @@ describe('ExtensionRegistryView', () => {
});
});
it('should use useRegistrySearch hook', () => {
renderView();
it('should use useRegistrySearch hook', async () => {
await renderView();
expect(useRegistrySearch).toHaveBeenCalled();
});
@@ -185,7 +187,7 @@ describe('ExtensionRegistryView', () => {
},
);
renderView();
await renderView();
await waitFor(() => {
expect(useRegistrySearch).toHaveBeenCalledWith(
@@ -197,7 +199,7 @@ describe('ExtensionRegistryView', () => {
});
it('should call onSelect when extension is selected and Enter is pressed in details', async () => {
const { stdin, lastFrame } = renderView();
const { stdin, lastFrame } = await renderView();
// Select the first extension in the list (Enter opens details)
await React.act(async () => {
@@ -32,7 +32,7 @@ const mockTools: ToolDefinition[] = [
describe('<ToolsList />', () => {
it('renders correctly with descriptions', async () => {
const { lastFrame, waitUntilReady } = renderWithProviders(
const { lastFrame, waitUntilReady } = await renderWithProviders(
<ToolsList
tools={mockTools}
showDescriptions={true}
@@ -44,7 +44,7 @@ describe('<ToolsList />', () => {
});
it('renders correctly without descriptions', async () => {
const { lastFrame, waitUntilReady } = renderWithProviders(
const { lastFrame, waitUntilReady } = await renderWithProviders(
<ToolsList
tools={mockTools}
showDescriptions={false}
@@ -56,7 +56,7 @@ describe('<ToolsList />', () => {
});
it('renders correctly with no tools', async () => {
const { lastFrame, waitUntilReady } = renderWithProviders(
const { lastFrame, waitUntilReady } = await renderWithProviders(
<ToolsList tools={[]} showDescriptions={true} terminalWidth={40} />,
);
await waitUntilReady();