Skip to content

Commit 596bb2e

Browse files
jsell-rhAmbient Code Botclaude
authored
fix(frontend): widen mock return type for useProject in tests (#1579)
## Summary - Fix TypeScript type error in two test files introduced by #1544 - The `mockUseProject` mock was initialized with `{ data: undefined }`, which locked the inferred type so that `.mockReturnValue()` calls with actual project data (`{ displayName, name }`) failed `tsc --noEmit` - This has been breaking `Frontend Lint and Type Check` CI on every PR since #1544 merged (e.g. #1564) ## Changes One-line fix in each file — widen the type via `as` cast on the initial `undefined`: ```ts // Before const mockUseProject = vi.fn(() => ({ data: undefined })); // After const mockUseProject = vi.fn(() => ({ data: undefined as { displayName: string; name: string } | undefined })); ``` **Files:** - `components/frontend/src/components/__tests__/session-details-modal.test.tsx` - `components/frontend/src/components/workspace-sections/__tests__/sessions-section.test.tsx` ## Test plan - [x] `npx tsc --noEmit` passes locally (was failing before) - [x] No logic changes — only type narrowing fix 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Enhanced test mock type definitions to better validate component behavior under various data conditions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Ambient Code Bot <bot@ambient-code.local> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 333aeb1 commit 596bb2e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

components/frontend/src/components/__tests__/session-details-modal.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react';
33
import { SessionDetailsModal } from '../session-details-modal';
44
import type { AgenticSession } from '@/types/agentic-session';
55

6-
const mockUseProject = vi.fn(() => ({ data: undefined }));
6+
const mockUseProject = vi.fn(() => ({ data: undefined as { displayName: string; name: string } | undefined }));
77
vi.mock('@/services/queries', () => ({
88
useProject: () => mockUseProject(),
99
}));

components/frontend/src/components/workspace-sections/__tests__/sessions-section.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ vi.mock('next/link', () => ({
88
),
99
}));
1010

11-
const mockUseProject = vi.fn(() => ({ data: undefined }));
11+
const mockUseProject = vi.fn(() => ({ data: undefined as { displayName: string; name: string } | undefined }));
1212
vi.mock('@/services/queries', () => ({
1313
useSessionsPaginated: () => ({ data: { items: [], totalCount: 0, hasMore: false }, isFetching: false, refetch: vi.fn() }),
1414
useStopSession: () => ({ mutate: vi.fn(), isPending: false }),

0 commit comments

Comments
 (0)