mirror of
https://github.com/johndoe6345789/docker-swarm-termina.git
synced 2026-04-24 13:45:01 +00:00
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:
@@ -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
1
frontend/jest.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="@testing-library/jest-dom" />
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"jest.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts",
|
||||
|
||||
Reference in New Issue
Block a user