import assert from "node:assert/strict"; import test from "node:test"; import { activeTab, availableTabs } from "../src/pages/events/lib/tab-selection.ts"; test("Events hides only capabilities explicitly disabled by the server", () => { const cases: Array<[Record | null | undefined, string[]]> = [ [null, ["events", "sources", "triggers", "inspector", "mappings"]], [undefined, ["events", "sources", "triggers", "inspector", "mappings"]], [{ captures: true, events: false }, ["inspector", "mappings"]], [{ events: false, captures: true, mappings: true }, ["inspector", "mappings"]], [{ events: true, captures: false, mappings: false }, ["events", "sources", "triggers"]], [{ events: false, captures: false, mappings: false }, []], ]; for (const [sections, expected] of cases) { assert.deepEqual(availableTabs(sections).map((tab) => tab.id), expected, JSON.stringify(sections)); } }); test("Events bookmarks select an available tab or fall back to the first", () => { const cases: Array<[Record | null, string, string]> = [ [null, "mappings", "mappings"], [{ events: false, captures: false, mappings: false }, "inspector", ""], [{ events: false, captures: false, mappings: false }, "", ""], // A bookmark for a tab this build no longer offers falls back. [{ events: true, captures: false, mappings: false }, "curators", "events"], [{ events: false, captures: false, mappings: false }, "curators", ""], ]; for (const [sections, requested, expected] of cases) { assert.equal(activeTab(requested, availableTabs(sections)), expected, `${JSON.stringify(sections)}: ${requested}`); } });