import assert from "node:assert/strict"; import { dirname, join } from "node:path"; import { test } from "node:test"; import { fileURLToPath } from "node:url"; import * as ejs from "ejs"; const navTree = join(dirname(fileURLToPath(import.meta.url)), "..", "views", "partials", "nav-tree.ejs"); const render = (data: Record = {}): Promise => ejs.renderFile(navTree, data); const flat = (s: string): string => s.replace(/>\s+<").replace(/\s+/g, " ").trim(); const nodes = [ { label: "Overview", href: "/overview", icon: "i-grid" }, // leaf · clickable · icon { label: "Workspace", open: true, // header · static · open children: [ { label: "Directory", href: "/dir", icon: "i-users", count: 4, open: true, // header · clickable · icon · count children: [ { label: "People", href: "/people", count: "1,284", current: true }, // leaf · clickable · current { label: "Webhooks (soon)" }, // leaf · static ], }, { label: "Roles & Access", children: [{ label: "Roles", href: "/roles" }] }, // header · static · closed ], }, ]; test("nav-tree renders the header/leaf × clickable/static matrix with counts, icons and aria-current", async () => { const html = flat(await render({ nodes })); // Root list vs. recursive child lists. assert.match(html, /