Commit 596bb2e
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__
- workspace-sections/__tests__
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
0 commit comments