fix(cli): Enable typechecking for more test files (#11455)

This commit is contained in:
Sandy Tao
2025-10-18 20:43:19 -07:00
committed by GitHub
parent f22aa72c62
commit d065c3ca53
6 changed files with 103 additions and 80 deletions

View File

@@ -4,17 +4,14 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { describe, it, expect, vi } from 'vitest';
import { describe, it, expect, vi, type Mock } from 'vitest';
import { render } from 'ink-testing-library';
import { Text, useIsScreenReaderEnabled } from 'ink';
import { makeFakeConfig } from '@google/gemini-cli-core';
import { App } from './App.js';
import { UIStateContext, type UIState } from './contexts/UIStateContext.js';
import { StreamingState } from './types.js';
import {
ConfigContext,
type Config,
type Telemetry,
} from './contexts/ConfigContext.js';
import { ConfigContext } from './contexts/ConfigContext.js';
vi.mock('ink', async (importOriginal) => {
const original = await importOriginal<typeof import('ink')>();
@@ -64,9 +61,7 @@ describe('App', () => {
},
};
const mockConfig = {
telemetry: {} as Telemetry,
} as Config;
const mockConfig = makeFakeConfig();
const renderWithProviders = (ui: React.ReactElement, state: UIState) =>
render(
@@ -132,7 +127,7 @@ describe('App', () => {
});
it('should render ScreenReaderAppLayout when screen reader is enabled', () => {
(useIsScreenReaderEnabled as vi.Mock).mockReturnValue(true);
(useIsScreenReaderEnabled as Mock).mockReturnValue(true);
const { lastFrame } = renderWithProviders(<App />, mockUIState as UIState);
@@ -142,7 +137,7 @@ describe('App', () => {
});
it('should render DefaultAppLayout when screen reader is not enabled', () => {
(useIsScreenReaderEnabled as vi.Mock).mockReturnValue(false);
(useIsScreenReaderEnabled as Mock).mockReturnValue(false);
const { lastFrame } = renderWithProviders(<App />, mockUIState as UIState);

View File

@@ -84,6 +84,7 @@ describe('SessionStatsContext', () => {
accept: 1,
reject: 0,
modify: 0,
auto_accept: 0,
},
byName: {
'test-tool': {
@@ -95,10 +96,15 @@ describe('SessionStatsContext', () => {
accept: 1,
reject: 0,
modify: 0,
auto_accept: 0,
},
},
},
},
files: {
totalLinesAdded: 0,
totalLinesRemoved: 0,
},
};
act(() => {
@@ -152,9 +158,13 @@ describe('SessionStatsContext', () => {
totalSuccess: 0,
totalFail: 0,
totalDurationMs: 0,
totalDecisions: { accept: 0, reject: 0, modify: 0 },
totalDecisions: { accept: 0, reject: 0, modify: 0, auto_accept: 0 },
byName: {},
},
files: {
totalLinesAdded: 0,
totalLinesRemoved: 0,
},
};
act(() => {

View File

@@ -86,7 +86,9 @@ describe('themeManager.loadCustomThemes', () => {
delete legacyTheme.DiffAdded;
delete legacyTheme.DiffRemoved;
themeManager.loadCustomThemes({ 'Legacy Custom Theme': legacyTheme });
themeManager.loadCustomThemes({
'Legacy Custom Theme': legacyTheme as CustomTheme,
});
const result = themeManager.getTheme('Legacy Custom Theme')!;
expect(result.colors.DiffAdded).toBe(darkTheme.DiffAdded);