Integrate OpenHandoff factory workspace (#212)

This commit is contained in:
Nathan Flurry 2026-03-09 14:00:20 -07:00 committed by GitHub
parent 3d9476ed0b
commit bf282199b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
251 changed files with 42824 additions and 692 deletions

View file

@ -0,0 +1,44 @@
import { describe, expect, it } from "vitest";
import {
normalizeParentBranch,
parentLookupFromStack,
sortBranchesForOverview,
} from "../src/actors/project/stack-model.js";
describe("stack-model", () => {
it("normalizes self-parent references to null", () => {
expect(normalizeParentBranch("feature/a", "feature/a")).toBeNull();
expect(normalizeParentBranch("feature/a", "main")).toBe("main");
expect(normalizeParentBranch("feature/a", null)).toBeNull();
});
it("builds parent lookup with sanitized entries", () => {
const lookup = parentLookupFromStack([
{ branchName: "feature/a", parentBranch: "main" },
{ branchName: "feature/b", parentBranch: "feature/b" },
{ branchName: " ", parentBranch: "main" },
]);
expect(lookup.get("feature/a")).toBe("main");
expect(lookup.get("feature/b")).toBeNull();
expect(lookup.has(" ")).toBe(false);
});
it("orders branches by graph depth and handles cycles safely", () => {
const rows = sortBranchesForOverview([
{ branchName: "feature/b", parentBranch: "feature/a", updatedAt: 200 },
{ branchName: "feature/a", parentBranch: "main", updatedAt: 100 },
{ branchName: "main", parentBranch: null, updatedAt: 50 },
{ branchName: "cycle-a", parentBranch: "cycle-b", updatedAt: 300 },
{ branchName: "cycle-b", parentBranch: "cycle-a", updatedAt: 250 },
]);
expect(rows.map((row) => row.branchName)).toEqual([
"main",
"feature/a",
"feature/b",
"cycle-a",
"cycle-b",
]);
});
});