Files
fusion/packages/dashboard/src/__tests__/branch-selection.test.ts
Fusion 5ee049b834 feat(FN-3214): add branch selection contract to planning routes and subtask
Adds branch selection and assignment to the planning workflow: defines a branch selection contract, wires it through subtask creation in SubtaskBreakdownModal, and applies the contract in planning route handlers, with corresponding test coverage. A minor typing fix in the bundled plugin views loader

Fusion-Task-Id: FN-3214
2026-05-09 22:11:09 -07:00

37 lines
1.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
derivePerTaskBranch,
resolveBranchAssignmentContext,
resolveBranchSelection,
} from "../routes/branch-selection.js";
describe("branch-selection", () => {
it("resolves project-default and auto-new without branch", () => {
expect(resolveBranchSelection({ mode: "project-default", baseBranch: "main" }, undefined, undefined)).toEqual({
branch: undefined,
baseBranch: "main",
});
expect(resolveBranchSelection({ mode: "auto-new" }, undefined, "develop")).toEqual({
branch: undefined,
baseBranch: undefined,
});
});
it("requires branchName for existing/custom-new", () => {
expect(() => resolveBranchSelection({ mode: "existing" }, undefined, undefined)).toThrow(
"branchSelection.branchName is required",
);
});
it("resolves assignment context", () => {
expect(resolveBranchAssignmentContext(undefined)).toEqual({ mode: "shared" });
expect(resolveBranchAssignmentContext({ mode: "per-task-derived" })).toEqual({ mode: "per-task-derived" });
expect(() => resolveBranchAssignmentContext({ mode: "bad" })).toThrow("branchAssignment.mode must be one of");
});
it("derives a per-task branch suffix", () => {
expect(derivePerTaskBranch("feature/planning", "FN-123 add parser")).toBe("feature/planning/fn-123-add-parser");
expect(derivePerTaskBranch(undefined, "FN-123")).toBeUndefined();
});
});