test(FN-4770): complete Steps 3-4 — add tracking async coverage

Fusion-Task-Id: FN-4770
Fusion-Task-Lineage: 8c8d1786-f81b-4544-9275-595b90ea5689
This commit is contained in:
Fusion (runfusion.ai)
2026-05-16 11:34:55 -07:00
committed by gsxdsm
parent 0653d94f1c
commit db7b196462
3 changed files with 272 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import { CentralDatabase } from "../central-db.js";
import { TaskStore, TaskHasDependentsError } from "../store.js";
import type { runCommandAsync } from "../run-command.js";
import { buildResearchDocumentKey, type Task } from "../types.js";
import { setTaskCreatedHook } from "../task-creation-hooks.js";
describe("TaskStore", () => {
const harness = createTaskStoreTestHarness();
@@ -34,6 +35,37 @@ describe("TaskStore", () => {
const createSourceIssueFixture = () => harness.createSourceIssueFixture();
const insertLogEntryWithTimestamp = (...args: any[]) => (harness as any).insertLogEntryWithTimestamp(...args);
describe("createTask task-created hook options", () => {
afterEach(() => {
setTaskCreatedHook(undefined);
});
it("skips task-created hook when invokeTaskCreatedHook is false", async () => {
const hookSpy = vi.fn();
setTaskCreatedHook(hookSpy);
await store.createTask(
{ description: "Task without post-create hook" },
{ invokeTaskCreatedHook: false },
);
expect(hookSpy).not.toHaveBeenCalled();
});
it("invokes task-created hook by default", async () => {
const hookSpy = vi.fn();
setTaskCreatedHook(hookSpy);
const created = await store.createTask({ description: "Task with default post-create hook" });
expect(hookSpy).toHaveBeenCalledTimes(1);
expect(hookSpy).toHaveBeenCalledWith(
expect.objectContaining({ id: created.id }),
expect.any(TaskStore),
);
});
});
describe("duplicateTask", () => {
it("duplicates from triage column", async () => {
const task = await store.createTask({ description: "Test task" });