Fix TypeScript transpile errors in test files

- Add jest.d.ts to include @testing-library/jest-dom types
- Fix dashboard test mock to include all required props (isAuthenticated, authLoading, isLoading, hasContainers)
- Fix authSlice test by properly typing the Redux store
- Fix useInteractiveTerminal test by adding type annotation to props parameter
- Update tsconfig.json to include jest.d.ts

All TypeScript errors are now resolved and the build passes successfully.

https://claude.ai/code/session_01KrwCxjP4joh9CFAtreiBFu
This commit is contained in:
Claude
2026-02-01 17:53:41 +00:00
parent 7b534531af
commit 77b8d0fa7a
5 changed files with 33 additions and 9 deletions

View File

@@ -46,18 +46,29 @@ const mockUseDashboard = useDashboard as jest.MockedFunction<typeof useDashboard
describe('Dashboard Page', () => {
const defaultDashboardState = {
// Authentication
isAuthenticated: true,
authLoading: false,
handleLogout: jest.fn(),
// Container list
containers: [],
isRefreshing: false,
error: null,
isLoading: false,
error: '',
refreshContainers: jest.fn(),
// Terminal modal
selectedContainer: null,
isTerminalOpen: false,
openTerminal: jest.fn(),
closeTerminal: jest.fn(),
// UI state
isMobile: false,
isInitialLoading: false,
hasContainers: false,
showEmptyState: false,
handleLogout: jest.fn(),
};
beforeEach(() => {

1
frontend/jest.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="@testing-library/jest-dom" />

View File

@@ -1,6 +1,14 @@
import { renderHook, act } from '@testing-library/react';
import { useInteractiveTerminal } from '../useInteractiveTerminal';
type UseInteractiveTerminalProps = {
open: boolean;
containerId: string;
containerName: string;
isMobile: boolean;
onFallback: (reason: string) => void;
};
// Suppress console output during tests (terminal initialization logs)
const originalConsoleLog = console.log;
const originalConsoleWarn = console.warn;
@@ -113,7 +121,7 @@ describe('useInteractiveTerminal', () => {
const mockDiv = document.createElement('div');
const { rerender } = renderHook(
(props) => {
(props: UseInteractiveTerminalProps) => {
const hook = useInteractiveTerminal(props);
// Simulate ref being available
if (hook.terminalRef.current === null) {

View File

@@ -11,14 +11,17 @@ import * as apiClient from '@/lib/api';
jest.mock('@/lib/api');
describe('authSlice', () => {
let store: ReturnType<typeof configureStore>;
type TestStore = ReturnType<typeof createTestStore>;
let store: TestStore;
const createTestStore = () => configureStore({
reducer: {
auth: authReducer,
},
});
beforeEach(() => {
store = configureStore({
reducer: {
auth: authReducer,
},
});
store = createTestStore();
jest.clearAllMocks();
localStorage.clear();
});

View File

@@ -24,6 +24,7 @@
},
"include": [
"next-env.d.ts",
"jest.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",