mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 02:24:09 -07:00
refactor(cli): integrate real config loading into async test utils (#23040)
This commit is contained in:
committed by
GitHub
parent
7de0616229
commit
23264ced9a
@@ -58,7 +58,7 @@ describe('<ToolMessage />', () => {
|
||||
};
|
||||
|
||||
// Helper to render with context
|
||||
const renderWithContext = (
|
||||
const renderWithContext = async (
|
||||
ui: React.ReactElement,
|
||||
streamingState: StreamingState,
|
||||
) =>
|
||||
@@ -78,7 +78,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('renders basic tool information', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage {...baseProps} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
@@ -91,7 +91,7 @@ describe('<ToolMessage />', () => {
|
||||
describe('JSON rendering', () => {
|
||||
it('pretty prints valid JSON', async () => {
|
||||
const testJSONstring = '{"a": 1, "b": [2, 3]}';
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
resultDisplay={testJSONstring}
|
||||
@@ -113,7 +113,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('renders pretty JSON in ink frame', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage {...baseProps} resultDisplay='{"a":1,"b":2}' />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
@@ -127,7 +127,7 @@ describe('<ToolMessage />', () => {
|
||||
|
||||
it('uses JSON renderer even when renderOutputAsMarkdown=true is true', async () => {
|
||||
const testJSONstring = '{"a": 1, "b": [2, 3]}';
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
resultDisplay={testJSONstring}
|
||||
@@ -149,7 +149,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
it('falls back to plain text for malformed JSON', async () => {
|
||||
const testJSONstring = 'a": 1, "b": [2, 3]}';
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
resultDisplay={testJSONstring}
|
||||
@@ -168,7 +168,7 @@ describe('<ToolMessage />', () => {
|
||||
|
||||
it('rejects mixed text + JSON renders as plain text', async () => {
|
||||
const testJSONstring = `{"result": "count": 42,"items": ["apple", "banana"]},"meta": {"timestamp": "2025-09-28T12:34:56Z"}}End.`;
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
resultDisplay={testJSONstring}
|
||||
@@ -188,7 +188,7 @@ describe('<ToolMessage />', () => {
|
||||
it('rejects ANSI-tained JSON renders as plain text', async () => {
|
||||
const testJSONstring =
|
||||
'\u001b[32mOK\u001b[0m {"status": "success", "data": {"id": 123, "values": [10, 20, 30]}}';
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
resultDisplay={testJSONstring}
|
||||
@@ -207,7 +207,7 @@ describe('<ToolMessage />', () => {
|
||||
|
||||
it('pretty printing 10kb JSON completes in <50ms', async () => {
|
||||
const large = '{"key": "' + 'x'.repeat(10000) + '"}';
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
resultDisplay={large}
|
||||
@@ -226,7 +226,7 @@ describe('<ToolMessage />', () => {
|
||||
|
||||
describe('ToolStatusIndicator rendering', () => {
|
||||
it('shows ✓ for Success status', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage {...baseProps} status={CoreToolCallStatus.Success} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
@@ -236,7 +236,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('shows o for Pending status', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage {...baseProps} status={CoreToolCallStatus.Scheduled} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
@@ -246,7 +246,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('shows ? for Confirming status', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
status={CoreToolCallStatus.AwaitingApproval}
|
||||
@@ -259,7 +259,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('shows - for Canceled status', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage {...baseProps} status={CoreToolCallStatus.Cancelled} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
@@ -269,7 +269,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('shows x for Error status', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage {...baseProps} status={CoreToolCallStatus.Error} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
@@ -279,7 +279,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('shows paused spinner for Executing status when streamingState is Idle', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage {...baseProps} status={CoreToolCallStatus.Executing} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
@@ -289,7 +289,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('shows paused spinner for Executing status when streamingState is WaitingForConfirmation', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage {...baseProps} status={CoreToolCallStatus.Executing} />,
|
||||
StreamingState.WaitingForConfirmation,
|
||||
);
|
||||
@@ -299,7 +299,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('shows MockRespondingSpinner for Executing status when streamingState is Responding', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage {...baseProps} status={CoreToolCallStatus.Executing} />,
|
||||
StreamingState.Responding, // Simulate app still responding
|
||||
);
|
||||
@@ -317,7 +317,7 @@ describe('<ToolMessage />', () => {
|
||||
newContent: 'new',
|
||||
filePath: 'file.txt',
|
||||
};
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage {...baseProps} resultDisplay={diffResult} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
@@ -332,7 +332,7 @@ describe('<ToolMessage />', () => {
|
||||
lastFrame: highEmphasisFrame,
|
||||
waitUntilReady: waitUntilReadyHigh,
|
||||
unmount: unmountHigh,
|
||||
} = renderWithContext(
|
||||
} = await renderWithContext(
|
||||
<ToolMessage {...baseProps} emphasis="high" />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
@@ -345,7 +345,7 @@ describe('<ToolMessage />', () => {
|
||||
lastFrame: lowEmphasisFrame,
|
||||
waitUntilReady: waitUntilReadyLow,
|
||||
unmount: unmountLow,
|
||||
} = renderWithContext(
|
||||
} = await renderWithContext(
|
||||
<ToolMessage {...baseProps} emphasis="low" />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
@@ -372,7 +372,7 @@ describe('<ToolMessage />', () => {
|
||||
},
|
||||
],
|
||||
];
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage {...baseProps} resultDisplay={ansiResult} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
@@ -382,7 +382,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('renders McpProgressIndicator with percentage and message for executing tools', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
status={CoreToolCallStatus.Executing}
|
||||
@@ -404,7 +404,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('renders only percentage when progressMessage is missing', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
status={CoreToolCallStatus.Executing}
|
||||
@@ -424,7 +424,7 @@ describe('<ToolMessage />', () => {
|
||||
});
|
||||
|
||||
it('renders indeterminate progress when total is missing', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithContext(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithContext(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
status={CoreToolCallStatus.Executing}
|
||||
@@ -449,7 +449,7 @@ describe('<ToolMessage />', () => {
|
||||
(_, i) => `Line ${i + 1}`,
|
||||
).join('\n');
|
||||
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
kind={Kind.Agent}
|
||||
@@ -486,7 +486,7 @@ describe('<ToolMessage />', () => {
|
||||
(_, i) => `Line ${i + 1}`,
|
||||
).join('\n');
|
||||
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
kind={Kind.Agent}
|
||||
@@ -516,7 +516,7 @@ describe('<ToolMessage />', () => {
|
||||
(_, i) => `Line ${i + 1}`,
|
||||
).join('\n');
|
||||
|
||||
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
|
||||
const { lastFrame, waitUntilReady, unmount } = await renderWithProviders(
|
||||
<ToolMessage
|
||||
{...baseProps}
|
||||
kind={Kind.Read}
|
||||
|
||||
Reference in New Issue
Block a user