Files
archie/ui/test/events-tabs.test.ts
samandCopilot 264062866c feat(ui): run events, workflows, runs, controls and settings pages on the archie binary (#2023)
Events (sources, triggers), workflows (list, document, YAML publish,
read-only canvas), runs with approvals and the decision trail, controls
(policies, guards, action classes), agent models, accepted extensions,
secret engines and credentials now read the binary's API. Capabilities
name every section, so pages the binary can't back yet (the visual
workflow editor, captures, mappings, bindings, the extension catalogue,
model aliases and the rest) stay in the tree, hidden. Adds
GET /api/credential-kinds for the credentials form.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-20 01:04:29 +11:00

31 lines
1.7 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { activeTab, availableTabs } from "../src/events/tab-selection.ts";
test("Events hides only capabilities explicitly disabled by the server", () => {
const cases: Array<[Record<string, boolean> | null | undefined, string[]]> = [
[null, ["events", "sources", "triggers", "inspector", "mappings", "bindings"]],
[undefined, ["events", "sources", "triggers", "inspector", "mappings", "bindings"]],
[{ captures: true, events: false }, ["inspector", "mappings", "bindings"]],
[{ events: false, captures: true, mappings: true, bindings: false }, ["inspector", "mappings"]],
[{ events: true, captures: false, mappings: false, bindings: false }, ["events", "sources", "triggers"]],
[{ events: false, captures: false, mappings: false, bindings: 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<string, boolean> | null, string, string]> = [
[null, "mappings", "mappings"],
[{ events: false, captures: false, mappings: false, bindings: true }, "inspector", "bindings"],
[{ events: false, captures: false, mappings: false, bindings: true }, "", "bindings"],
[{ events: true, captures: false, mappings: false, bindings: false }, "bindings", "events"],
[{ events: false, captures: false, mappings: false, bindings: false }, "bindings", ""],
];
for (const [sections, requested, expected] of cases) {
assert.equal(activeTab(requested, availableTabs(sections)), expected, `${JSON.stringify(sections)}: ${requested}`);
}
});