| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | import { groupWorkflows, isArchivedWorkflow } from "./workflow-history.ts"; |
| 4 | |
| 5 | test("only a removed file is archived, not a disabled, invalid or branch-only workflow", () => { |
| 6 | const current = [ |
| 7 | { id: "active", error: null }, |
| 8 | { id: "disabled", error: null, state: "disabled" }, |
| 9 | { id: "invalid", error: "Invalid YAML" }, |
| 10 | { id: "branch", error: "Its file is not on the default branch." }, |
| 11 | ]; |
| 12 | const removed = { id: "removed", error: "Its file is no longer on the default branch." }; |
| 13 | assert.deepEqual(groupWorkflows([current[0], removed, ...current.slice(1)]), { current, archived: [removed] }); |
| 14 | assert.equal(isArchivedWorkflow({ ...removed, error: null }), false); |
| 15 | }); |
| 16 | |
| 17 | test("an archive-only repository keeps its workflow history available", () => { |
| 18 | const removed = { id: "old", error: "Its file is no longer on the default branch." }; |
| 19 | assert.deepEqual(groupWorkflows([removed]), { current: [], archived: [removed] }); |
| 20 | assert.deepEqual(groupWorkflows([]), { current: [], archived: [] }); |
| 21 | }); |