Production typecheck (tsconfig.json + tsconfig.app.json) was already
clean, but a third config that includes test files surfaced 661 errors
across 60+ test files — accumulated drift between mock fixtures and
production types. Six parallel typescript-pro agents fixed every one
without touching production code.
Per-scope before/after (errors → 0):
ChatView 183
Mailbox + Agent suite (5 files) 156
Task / Modal suite (6 files) 127
App + small components (12 files) 96
Hooks + api/auth (8 files) 48
Long tail (32 files) 51
-----------------------------------------------------------------
Total 661
Major fix categories:
- Untyped state objects inferring `never[]` / `null` literals (root
cause of ~120 errors in ChatView alone — added a single
`UseChatReturn` annotation)
- Mock objects missing fields that became required: `WorkflowStep.mode`,
`ChatMessage.thinkingOutput / metadata`, `ChatSession.projectId`,
`Task.log`, `ProjectHealth` fields, `PtyTerminalSessionInfo.createdAt`,
`Agent.metadata`, `InboxResponse.total`, etc.
- Mock objects with stale fields that no longer exist:
`AgentBudgetStatus.budgetPeriod`, `truncated` on log responses,
`OutboxResponse.unreadCount`, `MergeResult.source/target/details`
- Modal props that became required (e.g. `PlanningModeModal.onTasksCreated`)
- String literals not in narrowed unions (`Column`, `WorkflowStepPhase`,
`InsightStatus`, `AgentLogType`, etc.)
- `querySelector` returning `Element` cast to `HTMLElement` for
`@testing-library/react`'s `within()`
- Vitest mock typing: `.mock.calls` access needing `vi.mocked(...)`,
zero-param tuple handling, generic `vi.fn(() => [])` inferring
`never[]`
Helpers introduced in test files (no shared infra):
- `makeSettings(overrides)` in ModelSelectorTab.test.tsx
- `makePromptOverrides(overrides)` in AgentPromptsManager.test.tsx
- `FileBrowserTestOverrides` type alias in FileBrowser.test.tsx
- `makeInboxResponse / makeOutboxResponse` in MailboxView.test.tsx
Verification:
- tsc -p tsconfig.json: exit 0
- tsc -p tsconfig.app.json: exit 0
- tsc -p tsconfig.test-check.json (new — includes test files): exit 0
- vitest run: 9639 / 9641 (2 pre-existing failures
in terminal-mobile-keyboard-layout.test.ts
unrelated to this work; verified via
`git stash` + run on clean HEAD)
Adds packages/dashboard/tsconfig.test-check.json to keep this regression
guard available locally — same as tsconfig.app.json minus the test
exclude.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
110 lines
3.4 KiB
TypeScript
110 lines
3.4 KiB
TypeScript
import { act, renderHook } from "@testing-library/react";
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { useTaskHandlers } from "../useTaskHandlers";
|
|
import type { Task, TaskCreateInput } from "@fusion/core";
|
|
|
|
const CREATED_TASK: Task = {
|
|
id: "FN-123",
|
|
title: "Test",
|
|
description: "Created task",
|
|
status: "pending",
|
|
column: "triage",
|
|
steps: [],
|
|
currentStep: 0,
|
|
dependencies: [],
|
|
log: [],
|
|
attachments: [],
|
|
createdAt: "",
|
|
updatedAt: "",
|
|
size: "M",
|
|
reviewLevel: 0,
|
|
};
|
|
|
|
function createOptions(overrides: Partial<Parameters<typeof useTaskHandlers>[0]> = {}): Parameters<typeof useTaskHandlers>[0] {
|
|
return {
|
|
createTask: vi.fn().mockResolvedValue(CREATED_TASK),
|
|
onPlanningTaskCreated: vi.fn(),
|
|
onPlanningTasksCreated: vi.fn(),
|
|
onSubtaskTasksCreated: vi.fn(),
|
|
addToast: vi.fn(),
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe("useTaskHandlers", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("handleBoardQuickCreate calls createTask with triage column and returns task", async () => {
|
|
const options = createOptions();
|
|
const { result } = renderHook(() => useTaskHandlers(options));
|
|
const input: TaskCreateInput = { description: "Do work" };
|
|
|
|
let created: Task | null = null;
|
|
await act(async () => {
|
|
created = await result.current.handleBoardQuickCreate(input);
|
|
});
|
|
|
|
expect(options.createTask).toHaveBeenCalledWith({ description: "Do work", column: "triage" });
|
|
expect(created).toEqual(CREATED_TASK);
|
|
});
|
|
|
|
it("handleModalCreate calls createTask with triage column and returns task", async () => {
|
|
const options = createOptions();
|
|
const { result } = renderHook(() => useTaskHandlers(options));
|
|
|
|
let created: Task | null = null;
|
|
await act(async () => {
|
|
created = await result.current.handleModalCreate({ description: "From modal" });
|
|
});
|
|
|
|
expect(options.createTask).toHaveBeenCalledWith({ description: "From modal", column: "triage" });
|
|
expect(created).toEqual(CREATED_TASK);
|
|
});
|
|
|
|
it("handlePlanningTaskCreated delegates with addToast", () => {
|
|
const options = createOptions();
|
|
const { result } = renderHook(() => useTaskHandlers(options));
|
|
|
|
act(() => {
|
|
result.current.handlePlanningTaskCreated(CREATED_TASK);
|
|
});
|
|
|
|
expect(options.onPlanningTaskCreated).toHaveBeenCalledWith(CREATED_TASK, options.addToast);
|
|
});
|
|
|
|
it("handlePlanningTasksCreated delegates with addToast", () => {
|
|
const options = createOptions();
|
|
const { result } = renderHook(() => useTaskHandlers(options));
|
|
|
|
act(() => {
|
|
result.current.handlePlanningTasksCreated([CREATED_TASK]);
|
|
});
|
|
|
|
expect(options.onPlanningTasksCreated).toHaveBeenCalledWith([CREATED_TASK], options.addToast);
|
|
});
|
|
|
|
it("handleSubtaskTasksCreated delegates with addToast", () => {
|
|
const options = createOptions();
|
|
const { result } = renderHook(() => useTaskHandlers(options));
|
|
|
|
act(() => {
|
|
result.current.handleSubtaskTasksCreated([CREATED_TASK]);
|
|
});
|
|
|
|
expect(options.onSubtaskTasksCreated).toHaveBeenCalledWith([CREATED_TASK], options.addToast);
|
|
});
|
|
|
|
it("handleGitHubImport shows success toast with task ID", () => {
|
|
const options = createOptions();
|
|
const { result } = renderHook(() => useTaskHandlers(options));
|
|
|
|
act(() => {
|
|
result.current.handleGitHubImport(CREATED_TASK);
|
|
});
|
|
|
|
expect(options.addToast).toHaveBeenCalledWith("Imported FN-123 from GitHub", "success");
|
|
});
|
|
});
|