The page drew the same three panels twice: a numbered Capture/Map/Bind strip and, directly under it, a tab list naming Inspector/Mappings/ Bindings. Both drove the same `?tab=` through the same handler, so the page read as one wizard drawn twice and named the same three panels with two different vocabularies in a single view. The strip survives. It names each step for what the operator does to it rather than for what the panel holds, and it is the one that reads as a chain. The step words move to tab-selection.ts as stepsFor(), beside the rules they belong to; the URL keeps its ids. Making the strip the only navigation also fixes a latent fault. It listed all three steps unconditionally, so a composition the server refuses `mappings` still drew a Map step with no panel behind it, and clicking it fell back to the first available tab, which did nothing. stepsFor() returns exactly the tabs this composition can back, and the page renders an empty state when that is none of them. ui/dist rebuilt in the same commit: the Go build embeds it.
119 lines
3.1 KiB
TypeScript
119 lines
3.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
const { EVENTS_TABS, activeTab, availableTabs, stepsFor } =
|
|
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", "mappings", "bindings"],
|
|
);
|
|
assert.deepEqual(
|
|
availableTabs(undefined).map((t) => t.id),
|
|
["inspector", "mappings", "bindings"],
|
|
);
|
|
});
|
|
|
|
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", "mappings", "bindings"],
|
|
"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"],
|
|
["mappings", "mappings"],
|
|
["bindings", "bindings"],
|
|
],
|
|
);
|
|
});
|
|
|
|
test("a step carries the strip's own word, not the tab's", () => {
|
|
const steps = stepsFor(availableTabs(null));
|
|
assert.deepEqual(
|
|
steps.map(({ id, label }) => [id, label]),
|
|
[
|
|
["inspector", "Capture"],
|
|
["mappings", "Map"],
|
|
["bindings", "Bind"],
|
|
],
|
|
"the strip named a panel the way the URL does",
|
|
);
|
|
assert.equal(steps[0]?.hint, "webhooks received");
|
|
});
|
|
|
|
test("the strip offers exactly the steps this composition can back", () => {
|
|
const steps = stepsFor(
|
|
availableTabs({ captures: true, bindings: true, mappings: false }),
|
|
);
|
|
assert.deepEqual(
|
|
steps.map((s) => s.id),
|
|
["inspector", "bindings"],
|
|
"the strip showed a step whose panel is not backed, so it went nowhere",
|
|
);
|
|
});
|
|
|
|
test("no backed capability is an empty strip, not three dead steps", () => {
|
|
assert.deepEqual(
|
|
stepsFor(availableTabs({ captures: false, mappings: false, bindings: false })),
|
|
[],
|
|
);
|
|
});
|