mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 18:44:30 -07:00
Improve test coverage for cli/src/ui/components (#13598)
This commit is contained in:
@@ -107,10 +107,7 @@ describe('<ToolMessage />', () => {
|
||||
StreamingState.Idle,
|
||||
);
|
||||
const output = lastFrame();
|
||||
expect(output).toContain('✓'); // Success indicator
|
||||
expect(output).toContain('test-tool');
|
||||
expect(output).toContain('A tool for testing');
|
||||
expect(output).toContain('MockMarkdown:Test result');
|
||||
expect(output).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe('ToolStatusIndicator rendering', () => {
|
||||
@@ -119,7 +116,7 @@ describe('<ToolMessage />', () => {
|
||||
<ToolMessage {...baseProps} status={ToolCallStatus.Success} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
expect(lastFrame()).toContain('✓');
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('shows o for Pending status', () => {
|
||||
@@ -127,7 +124,7 @@ describe('<ToolMessage />', () => {
|
||||
<ToolMessage {...baseProps} status={ToolCallStatus.Pending} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
expect(lastFrame()).toContain('o');
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('shows ? for Confirming status', () => {
|
||||
@@ -135,7 +132,7 @@ describe('<ToolMessage />', () => {
|
||||
<ToolMessage {...baseProps} status={ToolCallStatus.Confirming} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
expect(lastFrame()).toContain('?');
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('shows - for Canceled status', () => {
|
||||
@@ -143,7 +140,7 @@ describe('<ToolMessage />', () => {
|
||||
<ToolMessage {...baseProps} status={ToolCallStatus.Canceled} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
expect(lastFrame()).toContain('-');
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('shows x for Error status', () => {
|
||||
@@ -151,7 +148,7 @@ describe('<ToolMessage />', () => {
|
||||
<ToolMessage {...baseProps} status={ToolCallStatus.Error} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
expect(lastFrame()).toContain('x');
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('shows paused spinner for Executing status when streamingState is Idle', () => {
|
||||
@@ -159,9 +156,7 @@ describe('<ToolMessage />', () => {
|
||||
<ToolMessage {...baseProps} status={ToolCallStatus.Executing} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
expect(lastFrame()).toContain('⊷');
|
||||
expect(lastFrame()).not.toContain('MockRespondingSpinner');
|
||||
expect(lastFrame()).not.toContain('✓');
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('shows paused spinner for Executing status when streamingState is WaitingForConfirmation', () => {
|
||||
@@ -169,9 +164,7 @@ describe('<ToolMessage />', () => {
|
||||
<ToolMessage {...baseProps} status={ToolCallStatus.Executing} />,
|
||||
StreamingState.WaitingForConfirmation,
|
||||
);
|
||||
expect(lastFrame()).toContain('⊷');
|
||||
expect(lastFrame()).not.toContain('MockRespondingSpinner');
|
||||
expect(lastFrame()).not.toContain('✓');
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('shows MockRespondingSpinner for Executing status when streamingState is Responding', () => {
|
||||
@@ -179,8 +172,7 @@ describe('<ToolMessage />', () => {
|
||||
<ToolMessage {...baseProps} status={ToolCallStatus.Executing} />,
|
||||
StreamingState.Responding, // Simulate app still responding
|
||||
);
|
||||
expect(lastFrame()).toContain('MockRespondingSpinner');
|
||||
expect(lastFrame()).not.toContain('✓');
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -196,7 +188,7 @@ describe('<ToolMessage />', () => {
|
||||
StreamingState.Idle,
|
||||
);
|
||||
// Check that the output contains the MockDiff content as part of the whole message
|
||||
expect(lastFrame()).toMatch(/MockDiff:--- a\/file\.txt/);
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders emphasis correctly', () => {
|
||||
@@ -205,7 +197,7 @@ describe('<ToolMessage />', () => {
|
||||
StreamingState.Idle,
|
||||
);
|
||||
// Check for trailing indicator or specific color if applicable (Colors are not easily testable here)
|
||||
expect(highEmphasisFrame()).toContain('←'); // Trailing indicator for high emphasis
|
||||
expect(highEmphasisFrame()).toMatchSnapshot();
|
||||
|
||||
const { lastFrame: lowEmphasisFrame } = renderWithContext(
|
||||
<ToolMessage {...baseProps} emphasis="low" />,
|
||||
@@ -214,7 +206,7 @@ describe('<ToolMessage />', () => {
|
||||
// For low emphasis, the name and description might be dimmed (check for dimColor if possible)
|
||||
// This is harder to assert directly in text output without color checks.
|
||||
// We can at least ensure it doesn't have the high emphasis indicator.
|
||||
expect(lowEmphasisFrame()).not.toContain('←');
|
||||
expect(lowEmphasisFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders AnsiOutputText for AnsiOutput results', () => {
|
||||
@@ -236,6 +228,6 @@ describe('<ToolMessage />', () => {
|
||||
<ToolMessage {...baseProps} resultDisplay={ansiResult} />,
|
||||
StreamingState.Idle,
|
||||
);
|
||||
expect(lastFrame()).toContain('MockAnsiOutput:hello');
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user