Files
archie/ui/test/events-page.test.ts
T
sam 76ba97895f feat(webui): make Events one page with three tabs
Inspector, Bindings and Mappings were three sibling destinations in a
dropdown, for what is one chain read in order: an event, the mapping that
names its fields, the binding that decides what runs. They are now three
tabs on /events, and the bar carries Events as a link rather than a menu
with one child sharing its name.

The navigation entry is always live and the tabs prune themselves: each is
a separate capability, so a composition that can back only some of them
still reaches the ones it can, and an unreported section stays visible.
Which tabs exist, and which one is showing, lives in tab-selection.ts and
is unit-tested without a browser; the page owns the components and the
address bar. The old paths survive as bookmarks that redirect to their tab,
so a link or a learned URL still lands somewhere that works.

Three pages become tab panels: they lose their page-level headers -- the
page names the page -- and keep their own actions in a right-aligned row.
CapturesHeader.vue is absorbed into the Inspector panel, which is where its
stream status belongs.
2026-09-22 04:21:36 +10:00

44 lines
2.4 KiB
TypeScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import test from "node:test";
/**
* The Events surfaces are one page with three tabs, and the navigation entry is
* always live (Sam's call): the tabs behind it prune themselves per capability,
* so an operator on a composition that can only back some of them still reaches
* the ones it can. What must not come back is three sibling destinations.
*/
const router = await readFile(new URL("../src/router/index.ts", import.meta.url), "utf8");
const nav = await readFile(new URL("../src/lib/nav.ts", import.meta.url), "utf8");
const page = await readFile(new URL("../src/events/EventsPage.vue", import.meta.url), "utf8");
const registry = await readFile(new URL("../../internal/gateway/dashboard_tools.go", import.meta.url), "utf8");
test("the Events page is the tab host, and the old paths only redirect", () => {
assert.match(page, /Tabs/, "the page composes tabs");
assert.match(page, /CapturesPage/, "the Inspector tab is the captures surface");
assert.match(page, /BindingsPage/, "the Bindings tab is the bindings surface");
assert.match(page, /MappingsPage/, "the Mappings tab is the mappings surface");
// Each former destination survives as a bookmark, never as a nav entry: the
// registry test parses this table and skips exactly the lines marked so.
for (const path of ["/captures", "/mappings", "/bindings"]) {
const line = router.split("\n").find((l) => l.includes(`path: "${path}"`));
assert.ok(line, `${path} is no longer routed at all, so its bookmarks break`);
assert.match(line, /nav: false/, `${path} is still a navigation entry`);
assert.match(line, /redirect/, `${path} does not redirect to the tab that replaced it`);
}
});
test("Events is one live navigation entry, not a group of three", () => {
const entry = nav.split("\n").find((l) => l.includes('"/events"'));
assert.ok(entry, "the navigation model does not reference /events");
assert.doesNotMatch(nav, /label:\s*"Events",\s*paths:/, "Events is still a three-item group");
});
test("the page registry and the route table still agree", () => {
assert.match(registry, /Path: "\/events"/, "the agent's page registry does not know /events");
for (const path of ["/captures", "/mappings", "/bindings"]) {
assert.doesNotMatch(registry, new RegExp(`Path: "${path}"`), `${path} is still a registered page`);
}
});