Files
kandev/apps/web/lib/kanban/auto-hide-empty-columns.test.ts
2026-09-04 04:04:19 +00:00

29 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { areAllEmptyStepsAutoHidden, deriveAutoHiddenStepIds } from "./auto-hide-empty-columns";
const steps = [{ id: "backlog" }, { id: "doing" }, { id: "done" }];
describe("deriveAutoHiddenStepIds", () => {
it("hides only unoccupied live steps when enabled", () => {
const result = deriveAutoHiddenStepIds(steps, [{ workflowStepId: "doing" }], true, []);
expect([...result]).toEqual(["backlog", "done"]);
});
it("returns no automatic hidden steps when disabled", () => {
expect([...deriveAutoHiddenStepIds(steps, [], false, [])]).toEqual([]);
});
it("leaves manually hidden steps to the manual visibility contract", () => {
const result = deriveAutoHiddenStepIds(steps, [], true, ["backlog"]);
expect([...result]).toEqual(["doing", "done"]);
});
});
describe("areAllEmptyStepsAutoHidden", () => {
it("distinguishes auto-hidden steps from a workflow with no configured steps", () => {
expect(areAllEmptyStepsAutoHidden([], [{ id: "todo" }])).toBe(true);
expect(areAllEmptyStepsAutoHidden([], [])).toBe(false);
expect(areAllEmptyStepsAutoHidden([{ id: "todo" }], [{ id: "todo" }])).toBe(false);
});
});