import { describe, it, expect } from "vitest"; import { nextTaskTitle, carryApproval } from "./preview"; describe("nextTaskTitle", () => { it("swaps an existing version suffix", () => { expect(nextTaskTitle("UNG_102_019_010_cmp_TT_v004", "v005")).toBe( "UNG_102_019_010_cmp_TT_v005" ); }); it("is idempotent when the title already matches", () => { expect(nextTaskTitle("UNG_102_019_010_cmp_TT_v005", "v005")).toBe( "UNG_102_019_010_cmp_TT_v005" ); }); it("appends when the title carries no version yet", () => { expect(nextTaskTitle("UNG_102_019_010_cmp_TT", "v005")).toBe( "UNG_102_019_010_cmp_TT_v005" ); }); it("only touches a trailing suffix, not a version inside the name", () => { expect(nextTaskTitle("UNG_v001_019_010_cmp_TT_v004", "v005")).toBe( "UNG_v001_019_010_cmp_TT_v005" ); }); it("handles double-digit and uppercase suffixes", () => { expect(nextTaskTitle("SHOT_cmp_TT_V12", "v013")).toBe("SHOT_cmp_TT_v013"); }); }); describe("carryApproval", () => { it("carries an approval forward, so a re-export does not reopen a signed-off shot", () => { expect(carryApproval("APPROVED")).toBe("APPROVED"); }); // The regression: a render queued to address a note used to arrive already // wearing that note, so nothing registered that the work had been redone. it("resets NEEDS_CHANGES — this render is the fix for it", () => { expect(carryApproval("NEEDS_CHANGES")).toBe("PENDING_REVIEW"); }); it("resets REJECTED for the same reason", () => { expect(carryApproval("REJECTED")).toBe("PENDING_REVIEW"); }); it("leaves an unreviewed version pending", () => { expect(carryApproval("PENDING_REVIEW")).toBe("PENDING_REVIEW"); }); it("defaults to pending when there is no previous version", () => { expect(carryApproval(null)).toBe("PENDING_REVIEW"); expect(carryApproval(undefined)).toBe("PENDING_REVIEW"); }); });