Files
archie/ui/test/events-tabs.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.0 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
const { EVENTS_TABS, activeTab, availableTabs } = await import("../src/events/tab-selection.ts");
test("every tab stays when the composition reports nothing", () => {
assert.deepEqual(availableTabs(null).map((t) => t.id), ["inspector", "bindings", "mappings"]);
assert.deepEqual(availableTabs(undefined).map((t) => t.id), ["inspector", "bindings", "mappings"]);
});
test("a tab is offered only when its own capability is backed", () => {
const ids = availableTabs({ captures: true, bindings: false, mappings: true }).map((t) => t.id);
assert.deepEqual(ids, ["inspector", "mappings"], "a capability the server refuses still shows its tab");
});
test("a section the server never mentioned stays visible", () => {
const ids = availableTabs({ captures: true }).map((t) => t.id);
assert.deepEqual(ids, ["inspector", "bindings", "mappings"], "an unreported section hid its tab");
});
test("the requested tab wins when it is available", () => {
const available = availableTabs({ captures: true, bindings: true, mappings: true });
assert.equal(activeTab("mappings", available), "mappings");
});
test("a tab this composition cannot back falls back to the first it can", () => {
const available = availableTabs({ captures: false, bindings: true, mappings: false });
assert.equal(activeTab("inspector", available), "bindings", "a bookmark from a fuller deployment showed nothing");
assert.equal(activeTab("", available), "bindings", "no tab named did not land on the first available one");
});
test("nothing backed reports no tab rather than guessing one", () => {
const available = availableTabs({ captures: false, bindings: false, mappings: false });
assert.equal(available.length, 0);
assert.equal(activeTab("bindings", available), "");
});
test("the tabs are the three Events surfaces, in reading order", () => {
assert.deepEqual(
EVENTS_TABS.map(({ id, section }) => [id, section]),
[["inspector", "captures"], ["bindings", "bindings"], ["mappings", "mappings"]],
);
});