mirror of
https://github.com/google-gemini/gemini-cli
synced 2026-04-21 13:37:17 +00:00
Merge 07a950a9c0 into a38e2f0048
This commit is contained in:
commit
2b51214805
1 changed files with 45 additions and 0 deletions
|
|
@ -61,6 +61,19 @@ const terminalNotificationsMocks = vi.hoisted(() => ({
|
|||
})),
|
||||
}));
|
||||
|
||||
// Hoisted mock for generateSummary so it survives vi.clearAllMocks()
|
||||
const mockGenerateSummary = vi.hoisted(() =>
|
||||
vi.fn(() => Promise.resolve(undefined)),
|
||||
);
|
||||
|
||||
// Hoisted no-op debugLogger to silence console output from debugLogger calls
|
||||
const mockDebugLogger = vi.hoisted(() => ({
|
||||
log: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
debug: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
||||
const actual =
|
||||
await importOriginal<typeof import('@google/gemini-cli-core')>();
|
||||
|
|
@ -93,6 +106,10 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
|
|||
start: vi.fn(),
|
||||
end: vi.fn(),
|
||||
},
|
||||
// Silence "[SessionSummary] Error finding previous session" noise
|
||||
generateSummary: mockGenerateSummary,
|
||||
// Silence all debugLogger output (debug, log, warn, error) during tests
|
||||
debugLogger: mockDebugLogger,
|
||||
};
|
||||
});
|
||||
import ansiEscapes from 'ansi-escapes';
|
||||
|
|
@ -213,6 +230,15 @@ vi.mock('../utils/events.js');
|
|||
vi.mock('../utils/handleAutoUpdate.js');
|
||||
vi.mock('./utils/ConsolePatcher.js');
|
||||
vi.mock('../utils/cleanup.js');
|
||||
// Silence "Failed to read or parse keybindings" noise from real fs reads
|
||||
vi.mock('./utils/terminalSetup.js', async (importOriginal) => {
|
||||
const actual =
|
||||
await importOriginal<typeof import('./utils/terminalSetup.js')>();
|
||||
return {
|
||||
...actual,
|
||||
useTerminalSetupPrompt: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
import { useHistory } from './hooks/useHistoryManager.js';
|
||||
import { useThemeCommand } from './hooks/useThemeCommand.js';
|
||||
|
|
@ -350,6 +376,25 @@ describe('AppContainer State Management', () => {
|
|||
persistentStateMock.reset();
|
||||
vi.clearAllMocks();
|
||||
|
||||
// Suppress console noise from unmocked code paths (e.g. debugLogger
|
||||
// calls that slip through, React act() warnings, etc.).
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {});
|
||||
vi.spyOn(console, 'debug').mockImplementation(() => {});
|
||||
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
// Suppress the well-known React "act(...)" environment warning that fires
|
||||
// on every render in a non-browser test environment, while still letting
|
||||
// unexpected errors through.
|
||||
// eslint-disable-next-line no-console
|
||||
const originalError = console.error;
|
||||
vi.spyOn(console, 'error').mockImplementation((...args: unknown[]) => {
|
||||
const msg = String(args[0] ?? '');
|
||||
if (msg.includes('not configured to support act')) return;
|
||||
originalError.call(console, ...args);
|
||||
});
|
||||
|
||||
// Re-set after clearAllMocks so generateSummary().catch() doesn't blow up
|
||||
mockGenerateSummary.mockImplementation(() => Promise.resolve(undefined));
|
||||
|
||||
mockIdeClient.getInstance.mockReturnValue(new Promise(() => {}));
|
||||
|
||||
// Initialize mock stdout for terminal title tests
|
||||
|
|
|
|||
Loading…
Reference in a new issue