Files
fusion/packages/dashboard/app/hooks/__tests__/useTaskHandlers.test.ts
gsxdsm cf3fe8b485 FN-7591: make dashboard create surfaces resolve intake column from workflow instead of hard-coding triage
Fixes dashboard task creation so new cards land in the selected/default workflow's intake column instead of always forcing legacy triage, letting workflows like Coding (Ideas) park new cards in 'ideas' until an operator promotes them.

- InlineCreateCard, QuickEntryBox, and NewTaskModal no longer hard-code column:"triage"; InlineCreateCard now forwards workflowId at create time instead of applying it post-create.
- Fixed a glue-layer regression in useTaskHandlers.ts (handleBoardQuickCreate/handleModalCreate) that re-forced column:"triage" even after UI surfaces stopped sending it.
- Added/updated tests covering the store's intake-column resolution and the dashboard create surfaces/hooks.
- Documented the new manual-intake-column parking behavior in dashboard-guide.md and workflow-steps.md.
- Added a patch changeset for @runfusion/fusion.

Files changed:
 .changeset/fn-7591-coding-ideas-intake.md          |  7 +++
 docs/dashboard-guide.md                            |  4 ++
 docs/workflow-steps.md                             |  1 +
 packages/core/src/__tests__/store-create-intake-column.test.ts   | 20 ++++++++
 packages/dashboard/app/App.tsx                     |  5 +-
 packages/dashboard/app/components/InlineCreateCard.tsx  | 28 ++++------
 packages/dashboard/app/components/NewTaskModal.tsx |  5 +-
 packages/dashboard/app/components/QuickEntryBox.tsx     |  5 +-
 packages/dashboard/app/components/TodoView.tsx     |  7 ++-
 packages/dashboard/app/components/__tests__/InlineCreateCard.test.tsx | 59 +++++++++++++++++++++-
 packages/dashboard/app/components/__tests__/QuickEntryBox.test.tsx    | 14 +++--
 packages/dashboard/app/components/__tests__/TodoView.test.tsx | 10 ++--
 packages/dashboard/app/components/__tests__/board-quickcreate-workflow-lane-visibility.test.tsx | 45 ++++++++++++++++-
 packages/dashboard/app/hooks/__tests__/useTaskHandlers.test.ts    | 27 ++++++++--
 packages/dashboard/app/hooks/useTaskHandlers.ts    |  8 ++-
 15 files changed, 207 insertions(+), 38 deletions(-)

Fusion-Task-Id: FN-7591

Fusion-Task-Lineage: 510f0e6a-89e7-468f-a6df-ad6aebd5c33a

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-07-05 13:15:56 -07:00

133 lines
4.6 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),
ingestCreatedTasks: vi.fn(),
onPlanningTaskCreated: vi.fn(),
onPlanningTasksCreated: vi.fn(),
onSubtaskTasksCreated: vi.fn(),
addToast: vi.fn(),
...overrides,
};
}
describe("useTaskHandlers", () => {
beforeEach(() => {
vi.clearAllMocks();
});
// FN-7591: handleBoardQuickCreate/handleModalCreate must NOT force column:"triage" — the store resolves the
// landing column from the (selected or default) workflow's intake column, so a manual-intake workflow
// (e.g. Coding (Ideas) → "ideas") parks the card instead of being auto-triaged.
it("handleBoardQuickCreate forwards createTask without forcing a column", 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", source: { sourceType: "dashboard_ui" } });
expect(created).toEqual(CREATED_TASK);
});
it("handleBoardQuickCreate forwards an explicit workflowId without forcing a column", async () => {
const options = createOptions();
const { result } = renderHook(() => useTaskHandlers(options));
const input: TaskCreateInput = { description: "Do work", workflowId: "builtin:coding-ideas" };
await act(async () => {
await result.current.handleBoardQuickCreate(input);
});
expect(options.createTask).toHaveBeenCalledWith({
description: "Do work",
workflowId: "builtin:coding-ideas",
source: { sourceType: "dashboard_ui" },
});
});
it("handleModalCreate forwards createTask without forcing a column", 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", source: { sourceType: "dashboard_ui" } });
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.ingestCreatedTasks).toHaveBeenCalledWith([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.ingestCreatedTasks).toHaveBeenCalledWith([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.ingestCreatedTasks).toHaveBeenCalledWith([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");
});
});