test(cli): refine settings and tool action mocks to resolve test rig regressions

This update addresses incomplete settings store contracts and default state mismatches that caused snapshot runtime errors and verification failures in compact tool output tests.

1. Settings Mock Completeness:
- Updated `createMockSettings` in `mockConfig.ts` to include required functional methods (`subscribe`, `getSnapshot`, `setValue`) to satisfy React's `useSyncExternalStore` contract. This resolves "store.getSnapshot is not a function" errors in snapshot tests.

2. Tool Actions Provider Configuration:
- Modified `renderWithProviders` to accept a `toolActions` options object, allowing individual tests to inject specific tool expansion states.
- Changed the default mock for `isExpanded` from `true` to `false` to align with the application's default behavior (collapsed outputs) in alternate buffer mode.

3. Test Refactoring:
- Refactored `ToolGroupMessage.compact.test.tsx` to use the standardized `createMockSettings` utility rather than a manual generic object, ensuring proper context evaluation during rendering.
This commit is contained in:
Jarrod Whelan
2026-03-24 23:50:46 -07:00
parent 7cd7d67e7d
commit 7d786f5f58
3 changed files with 38 additions and 36 deletions
@@ -5,6 +5,7 @@
*/
import { renderWithProviders } from '../../../test-utils/render.js';
import { createMockSettings } from '../../../test-utils/mockConfig.js';
import { ToolGroupMessage } from './ToolGroupMessage.js';
import {
CoreToolCallStatus,
@@ -13,7 +14,6 @@ import {
} from '@google/gemini-cli-core';
import { expect, it, describe } from 'vitest';
import type { IndividualToolCallDisplay } from '../../types.js';
import type { LoadedSettings } from '../../../config/settings.js';
describe('ToolGroupMessage Compact Rendering', () => {
const defaultProps = {
@@ -27,14 +27,13 @@ describe('ToolGroupMessage Compact Rendering', () => {
terminalWidth: 80,
};
const compactSettings: LoadedSettings = {
const compactSettings = createMockSettings({
merged: {
ui: {
compactToolOutput: true,
},
},
sources: [],
} as unknown as LoadedSettings; // Test mock of settings
});
it('renders consecutive compact tools without empty lines between them', async () => {
const toolCalls: IndividualToolCallDisplay[] = [