Migrate console to coreEvents.emitFeedback or debugLogger (#15219)

This commit is contained in:
Adib234
2025-12-29 15:46:10 -05:00
committed by GitHub
parent dcd2449b1a
commit 10ae84869a
66 changed files with 564 additions and 425 deletions
@@ -5,12 +5,27 @@
*/
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { render } from 'ink-testing-library';
import { render } from '../../test-utils/render.js';
import { act } from 'react';
import { AuthInProgress } from './AuthInProgress.js';
import { useKeypress, type Key } from '../hooks/useKeypress.js';
import { debugLogger } from '@google/gemini-cli-core';
// Mock dependencies
vi.mock('@google/gemini-cli-core', async (importOriginal) => {
const actual =
await importOriginal<typeof import('@google/gemini-cli-core')>();
return {
...actual,
debugLogger: {
log: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
debug: vi.fn(),
},
};
});
vi.mock('../hooks/useKeypress.js', () => ({
useKeypress: vi.fn(),
}));
@@ -22,24 +37,20 @@ vi.mock('../components/CliSpinner.js', () => ({
describe('AuthInProgress', () => {
const onTimeout = vi.fn();
const originalError = console.error;
beforeEach(() => {
vi.clearAllMocks();
vi.useFakeTimers();
console.error = (...args) => {
vi.mocked(debugLogger.error).mockImplementation((...args) => {
if (
typeof args[0] === 'string' &&
args[0].includes('was not wrapped in act')
) {
return;
}
originalError.call(console, ...args);
};
});
});
afterEach(() => {
console.error = originalError;
vi.useRealTimers();
});