| 1 | import assert from "node:assert/strict"; |
| 2 | import { readFileSync } from "node:fs"; |
| 3 | import { test } from "node:test"; |
| 4 | |
| 5 | import type { RepoMirror } from "@g1t/contracts"; |
| 6 | |
| 7 | import { tabsFor } from "./project-nav.ts"; |
| 8 | import { ROADMAP } from "./roadmap.ts"; |
| 9 | |
| 10 | const mirror = (state: RepoMirror["state"]): RepoMirror => ({ state, remote: "github.com/acme/web", url: "https://github.com/acme/web", since: "2026-10-08T10:00:00Z" }); |
| 11 | const can = { security_alerts: true }; |
| 12 | |
| 13 | test("a mirror has tabs only for the pages it offers", () => { |
| 14 | const labels = (tabs: ReturnType<typeof tabsFor>) => tabs?.map((tab) => tab.label) ?? null; |
| 15 | // Code and Security read the same whoever leads. |
| 16 | assert.deepEqual(labels(tabsFor("commits", true, can, mirror("standby"))), labels(tabsFor("commits", true, can, null))); |
| 17 | assert.deepEqual(labels(tabsFor("security/vulnerabilities", true, can, mirror("standby"))), labels(tabsFor("security/vulnerabilities", true, can, null))); |
| 18 | // Issues, Agents and the pull requests' tabs come with a takeover. |
| 19 | assert.equal(tabsFor("issues", true, can, mirror("standby")), null); |
| 20 | assert.equal(tabsFor("sessions", true, can, mirror("ci")), null); |
| 21 | assert.equal(tabsFor("queue", true, can, mirror("handing_back")), null); |
| 22 | assert.ok(tabsFor("issues", true, can, mirror("takeover"))); |
| 23 | assert.ok(tabsFor("queue", true, can, mirror("takeover"))); |
| 24 | }); |
| 25 | |
| 26 | test("code is not docs: a project never gets a Docs tab", () => { |
| 27 | // Docs is its own workspace mode, filtered by project there. |
| 28 | assert.equal(ROADMAP.some((item) => item.section !== "Workspace" && /docs/i.test(item.key)), false); |
| 29 | const nav = readFileSync(new URL("./project-nav.ts", import.meta.url), "utf8"); |
| 30 | assert.doesNotMatch(nav, /label: "Docs"|soon\("Code"\)/); |
| 31 | }); |