import { expect, test } from "bun:test"; import { readFileSync } from "node:fs"; import { join } from "node:path"; import { webFeatures } from "./features"; import { visibleNav } from "./nav"; const labels = (roles: ("owner" | "author" | "learner")[] | null) => visibleNav(webFeatures, roles ? { roles } : null).map((r) => r.nav!.label); test("nav items are limited by role", () => { expect(labels(null)).toEqual([]); expect(labels(["learner"])).toEqual([]); expect(labels(["author"])).toEqual(["Studio"]); expect(labels(["owner"])).toEqual(["Studio", "Import", "AI"]); }); test("features.ts imports only browser entries, by package name", () => { const src = readFileSync(join(import.meta.dir, "features.ts"), "utf8"); const specs = [...src.matchAll(/from\s+"([^"]+)"/g)].map((m) => m[1]!); for (const s of specs) expect(s === "@stc/contracts" || /^@stc\/feature-[a-z]+\/web$/.test(s)).toBe(true); expect(specs.filter((s) => s.endsWith("/web")).length).toBe(4); });