From 2556083b688ee3d3a356e87d007c46ec671026c4 Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Tue, 18 Aug 2026 21:14:26 -0700 Subject: [PATCH] test: restore the four workspace-merge tests broken by a stale mock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit project-engine.test.ts hand-writes a factory for ../merge/merger-ai.js, and it had drifted from the module: WorkspaceMergeDispatchSupersededError was missing. Production imports that class, so the merge-queue drain threw "No is defined on the mock" before the code under test ran — the four Phase C hardening cases then failed on a resolved promise and an absent updateTask call, for a reason unrelated to what they assert. No product change. All 114 tests in the file pass. Co-Authored-By: Claude Opus 5 --- .changeset/workspace-merge-test-mock-export.md | 7 +++++++ .../engine/src/__tests__/project-engine.test.ts | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 .changeset/workspace-merge-test-mock-export.md diff --git a/.changeset/workspace-merge-test-mock-export.md b/.changeset/workspace-merge-test-mock-export.md new file mode 100644 index 0000000000..8dc86cf892 --- /dev/null +++ b/.changeset/workspace-merge-test-mock-export.md @@ -0,0 +1,7 @@ +--- +"@runfusion/fusion": patch +--- + +summary: Repair four red workspace-merge tests caused by a stale module mock. +category: internal +dev: `project-engine.test.ts` mocks `../merge/merger-ai.js` with a hand-written factory that had not kept up with the module's exports: `WorkspaceMergeDispatchSupersededError` was missing. Production imports it, so the merge-queue drain threw "No is defined on the mock" before reaching the behaviour under test, and the four Phase C hardening cases failed on a resolved promise and a missing `updateTask` call rather than on what they assert. No product change; the factory now provides the class and carries a note to keep it in step with merger-ai's exported errors. diff --git a/packages/engine/src/__tests__/project-engine.test.ts b/packages/engine/src/__tests__/project-engine.test.ts index bf136ae54f..866dc89392 100644 --- a/packages/engine/src/__tests__/project-engine.test.ts +++ b/packages/engine/src/__tests__/project-engine.test.ts @@ -136,12 +136,26 @@ vi.mock("../merge/merger-ai.js", () => { this.name = "WorkspaceFinalizeBlockedError"; } } + /* + FNXC:WorkspaceMerge 2026-08-19-04:00: + Production imports this error from merger-ai, so a factory that omits it makes the merge-queue + drain throw "No is defined on the mock" BEFORE reaching the behaviour under test — the + four Phase C hardening cases then saw a resolved promise and no updateTask call, failing for a + reason unrelated to what they assert. Keep this list in step with merger-ai's exported errors. + */ + class WorkspaceMergeDispatchSupersededError extends Error { + constructor(public readonly taskId: string) { + super(`Workspace merge dispatch lease was superseded before finalization for ${taskId}`); + this.name = "WorkspaceMergeDispatchSupersededError"; + } + } return { runAiMerge: mocks.runAiMerge, landWorkspaceTask: mocks.landWorkspaceTask, WorkspaceRepoLandBusyError, WorkspacePartialLandError, WorkspaceFinalizeBlockedError, + WorkspaceMergeDispatchSupersededError, }; });