diff --git a/packages/cli/src/test-utils/render.tsx b/packages/cli/src/test-utils/render.tsx index 69153d3d6c..817921e83a 100644 --- a/packages/cli/src/test-utils/render.tsx +++ b/packages/cli/src/test-utils/render.tsx @@ -42,6 +42,7 @@ import { type OverflowState, } from '../ui/contexts/OverflowContext.js'; +import { makeFakeConfig } from '@google/gemini-cli-core'; import { type Config } from '@google/gemini-cli-core'; import { FakePersistentState } from './persistentStateFake.js'; import { AppContext, type AppState } from '../ui/contexts/AppContext.js'; @@ -51,7 +52,6 @@ import { themeManager, DEFAULT_THEME } from '../ui/themes/theme-manager.js'; import { DefaultLight } from '../ui/themes/builtin/light/default-light.js'; import { pickDefaultThemeName } from '../ui/themes/theme.js'; import { generateSvgForTerminal } from './svg.js'; -import { loadCliConfig, type CliArgs } from '../config/config.js'; export const persistentStateMock = new FakePersistentState(); @@ -666,12 +666,11 @@ export const renderWithProviders = async ( const terminalWidth = width ?? baseState.terminalWidth; if (!config) { - config = await loadCliConfig( - settings.merged, - 'random-session-id', - {} as unknown as CliArgs, - { cwd: '/' }, - ); + config = makeFakeConfig({ + useAlternateBuffer: settings.merged.ui?.useAlternateBuffer, + showMemoryUsage: settings.merged.ui?.showMemoryUsage, + accessibility: settings.merged.ui?.accessibility, + }); } const mainAreaWidth = providedUiState?.mainAreaWidth ?? terminalWidth; diff --git a/packages/cli/test-setup.ts b/packages/cli/test-setup.ts index 1f95bfbfeb..850510cb14 100644 --- a/packages/cli/test-setup.ts +++ b/packages/cli/test-setup.ts @@ -6,7 +6,7 @@ import { vi, beforeEach, afterEach } from 'vitest'; import { format } from 'node:util'; -import { coreEvents } from '@google/gemini-cli-core'; +import { coreEvents, debugLogger } from '@google/gemini-cli-core'; import { themeManager } from './src/ui/themes/theme-manager.js'; import { mockInkSpinner } from './src/test-utils/mockSpinner.js'; @@ -42,10 +42,25 @@ import './src/test-utils/customMatchers.js'; let consoleErrorSpy: vi.SpyInstance; let actWarnings: Array<{ message: string; stack: string }> = []; +let logSpy: vi.SpyInstance; +let warnSpy: vi.SpyInstance; +let errorSpy: vi.SpyInstance; +let debugSpy: vi.SpyInstance; + beforeEach(() => { // Reset themeManager state to ensure test isolation themeManager.resetForTesting(); + // Mock debugLogger to avoid test output noise + logSpy = vi.spyOn(debugLogger, 'log').mockImplementation(() => {}); + warnSpy = vi.spyOn(debugLogger, 'warn').mockImplementation((...args) => { + console.warn(...args); + }); + errorSpy = vi.spyOn(debugLogger, 'error').mockImplementation((...args) => { + console.error(...args); + }); + debugSpy = vi.spyOn(debugLogger, 'debug').mockImplementation(() => {}); + actWarnings = []; consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation((...args) => { const firstArg = args[0]; @@ -88,8 +103,12 @@ beforeEach(() => { afterEach(() => { consoleErrorSpy.mockRestore(); - vi.unstubAllEnvs(); + logSpy?.mockRestore(); + warnSpy?.mockRestore(); + errorSpy?.mockRestore(); + debugSpy?.mockRestore(); + vi.unstubAllEnvs(); if (actWarnings.length > 0) { const messages = actWarnings .map(({ message, stack }) => `${message}\n${stack}`)