refactor: format markdown files using prettier, fix spelling concerns, reduce Taskfile bloat
This commit is contained in:
608 files changed
+63317
-10219
No files matched your search
@@ -1,11 +1,17 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { groupActivity, groupKey } = await import("../src/dashboard/activity-group.ts");
|
||||
const { groupActivity, groupKey } =
|
||||
await import("../src/dashboard/activity-group.ts");
|
||||
|
||||
import type { ActivityEvent } from "../src/dashboard/state.ts";
|
||||
|
||||
function ev(kind: string, taskID: number | undefined, detail: string, at = 1000): ActivityEvent {
|
||||
function ev(
|
||||
kind: string,
|
||||
taskID: number | undefined,
|
||||
detail: string,
|
||||
at = 1000,
|
||||
): ActivityEvent {
|
||||
return { kind, task_id: taskID, detail, at };
|
||||
}
|
||||
|
||||
@@ -98,4 +104,4 @@ test("groupKey separates detail and task", () => {
|
||||
assert.notEqual(groupKey("runner_run", 7), groupKey("runner_run", 9));
|
||||
assert.equal(groupKey("runner_run", 7), groupKey("runner_run", 7));
|
||||
assert.equal(groupKey("runner_run", 0), groupKey("runner_run", undefined));
|
||||
});
|
||||
});
|
||||
@@ -18,7 +18,10 @@ class MemoryStorage {
|
||||
|
||||
function browser(matchesDark = false): MemoryStorage {
|
||||
const storage = new MemoryStorage();
|
||||
Object.defineProperty(globalThis, "localStorage", { configurable: true, value: storage });
|
||||
Object.defineProperty(globalThis, "localStorage", {
|
||||
configurable: true,
|
||||
value: storage,
|
||||
});
|
||||
Object.defineProperty(globalThis, "document", {
|
||||
configurable: true,
|
||||
value: { documentElement: { dataset: {} as Record<string, string> } },
|
||||
@@ -30,18 +33,30 @@ function browser(matchesDark = false): MemoryStorage {
|
||||
return storage;
|
||||
}
|
||||
|
||||
Object.defineProperty(globalThis, "localStorage", { configurable: true, value: new MemoryStorage() });
|
||||
Object.defineProperty(globalThis, "localStorage", {
|
||||
configurable: true,
|
||||
value: new MemoryStorage(),
|
||||
});
|
||||
const appearance = await import("../src/stores/appearance.ts");
|
||||
|
||||
function freshStore(matchesDark = false): { storage: MemoryStorage; store: ReturnType<typeof appearance.useAppearanceStore> } {
|
||||
function freshStore(matchesDark = false): {
|
||||
storage: MemoryStorage;
|
||||
store: ReturnType<typeof appearance.useAppearanceStore>;
|
||||
} {
|
||||
const storage = browser(matchesDark);
|
||||
setActivePinia(createPinia());
|
||||
return { storage, store: appearance.useAppearanceStore() };
|
||||
}
|
||||
|
||||
test("appearance preferences are owned by Pinia and stay close to their labels", async () => {
|
||||
const page = await readFile(new URL("../src/settings/SystemAppearancePage.vue", import.meta.url), "utf8");
|
||||
const tooltip = await readFile(new URL("../src/components/ui/tooltip/Tooltip.vue", import.meta.url), "utf8");
|
||||
const page = await readFile(
|
||||
new URL("../src/settings/SystemAppearancePage.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const tooltip = await readFile(
|
||||
new URL("../src/components/ui/tooltip/Tooltip.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
assert.match(page, /useAppearanceStore/);
|
||||
assert.match(tooltip, /useAppearanceStore/);
|
||||
|
||||
@@ -2,12 +2,18 @@ import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { eventTypeLabel } = await import("../src/captures/event-types.ts");
|
||||
const { bindingPayload, draftFromBinding, emptyDraft, mappingsForEventType } = await import("../src/bindings/binding-draft.ts");
|
||||
const { bindingPayload, draftFromBinding, emptyDraft, mappingsForEventType } =
|
||||
await import("../src/bindings/binding-draft.ts");
|
||||
const { matchCountLabel } = await import("../src/mappings/match-count.ts");
|
||||
|
||||
const types = [
|
||||
{ id: "et1", source: "gh", name: "push", rule: { headers: [], payload: [] } },
|
||||
{ id: "et2", source: "fw", name: "blocked", rule: { headers: [], payload: [] } },
|
||||
{
|
||||
id: "et2",
|
||||
source: "fw",
|
||||
name: "blocked",
|
||||
rule: { headers: [], payload: [] },
|
||||
},
|
||||
];
|
||||
const mappings = [
|
||||
{ id: "m1", name: "push fields", event_type_id: "et1" },
|
||||
@@ -32,7 +38,13 @@ test("the mapping picker offers only the chosen event type's mappings", () => {
|
||||
|
||||
test("an edited binding opens on its mapping's event type and keeps its filter", () => {
|
||||
const draft = draftFromBinding(
|
||||
{ id: "b1", name: "n", matcher: { source: "fw" }, mapping_id: "m2", filter: 'severity == "high"' },
|
||||
{
|
||||
id: "b1",
|
||||
name: "n",
|
||||
matcher: { source: "fw" },
|
||||
mapping_id: "m2",
|
||||
filter: 'severity == "high"',
|
||||
},
|
||||
mappings,
|
||||
);
|
||||
assert.equal(draft.eventTypeId, "et2");
|
||||
@@ -40,7 +52,14 @@ test("an edited binding opens on its mapping's event type and keeps its filter",
|
||||
});
|
||||
|
||||
test("a binding is sent with the source of its event type and its filter", () => {
|
||||
const draft = { ...emptyDraft(), name: "n", eventTypeId: "et2", mappingId: "m2", workflow: "w", filter: " severity == 'high' " };
|
||||
const draft = {
|
||||
...emptyDraft(),
|
||||
name: "n",
|
||||
eventTypeId: "et2",
|
||||
mappingId: "m2",
|
||||
workflow: "w",
|
||||
filter: " severity == 'high' ",
|
||||
};
|
||||
const body = bindingPayload(draft, types);
|
||||
assert.deepEqual(body.matcher, { source: "fw" });
|
||||
assert.equal(body.mapping_id, "m2");
|
||||
@@ -56,12 +75,17 @@ test("a mapping's match count reads as a number of events or as never matched",
|
||||
});
|
||||
|
||||
test("a binding's inputs go out typed, and a no-repository workflow names no repo", async () => {
|
||||
const { constantValue, paramsForType, takesRepository } = await import("../src/bindings/binding-draft.ts");
|
||||
const { constantValue, paramsForType, takesRepository } =
|
||||
await import("../src/bindings/binding-draft.ts");
|
||||
const workflow = {
|
||||
id: "investigate",
|
||||
name: "investigate",
|
||||
repository: "none",
|
||||
inputs: { src_ip: { type: "string", required: true }, severity: { type: "number" }, note: { type: "string" } },
|
||||
inputs: {
|
||||
src_ip: { type: "string", required: true },
|
||||
severity: { type: "number" },
|
||||
note: { type: "string" },
|
||||
},
|
||||
};
|
||||
const draft = {
|
||||
...emptyDraft(),
|
||||
@@ -69,10 +93,17 @@ test("a binding's inputs go out typed, and a no-repository workflow names no rep
|
||||
workflow: "investigate",
|
||||
owner: "acme",
|
||||
repo: "api",
|
||||
inputs: { src_ip: { param: "ip", value: "" }, severity: { param: "", value: "3" }, note: { param: "", value: "" } },
|
||||
inputs: {
|
||||
src_ip: { param: "ip", value: "" },
|
||||
severity: { param: "", value: "3" },
|
||||
note: { param: "", value: "" },
|
||||
},
|
||||
};
|
||||
const payload = bindingPayload(draft, types, workflow);
|
||||
assert.deepEqual(payload.inputs, { src_ip: { param: "ip" }, severity: { value: 3 } });
|
||||
assert.deepEqual(payload.inputs, {
|
||||
src_ip: { param: "ip" },
|
||||
severity: { value: 3 },
|
||||
});
|
||||
assert.equal(payload.owner, "");
|
||||
assert.equal(payload.repo_param, "");
|
||||
assert.equal(takesRepository(workflow), false);
|
||||
@@ -82,16 +113,33 @@ test("a binding's inputs go out typed, and a no-repository workflow names no rep
|
||||
assert.equal(constantValue("high", "number"), "high");
|
||||
assert.deepEqual(constantValue('{"a":1}', "object"), { a: 1 });
|
||||
assert.deepEqual(
|
||||
paramsForType([{ name: "ip", type: "string" }, { name: "n", type: "number" }, { name: "x", type: "any" }], "string").map((f) => f.name),
|
||||
paramsForType(
|
||||
[
|
||||
{ name: "ip", type: "string" },
|
||||
{ name: "n", type: "number" },
|
||||
{ name: "x", type: "any" },
|
||||
],
|
||||
"string",
|
||||
).map((f) => f.name),
|
||||
["ip", "x"],
|
||||
);
|
||||
});
|
||||
|
||||
test("an edited binding's assignments come back into the draft", () => {
|
||||
const draft = draftFromBinding(
|
||||
{ id: "b", name: "b", mapping_id: "m2", repo_param: "full", inputs: { a: { param: "ip" }, b: { value: 3 }, c: { value: "x" } } },
|
||||
{
|
||||
id: "b",
|
||||
name: "b",
|
||||
mapping_id: "m2",
|
||||
repo_param: "full",
|
||||
inputs: { a: { param: "ip" }, b: { value: 3 }, c: { value: "x" } },
|
||||
},
|
||||
mappings,
|
||||
);
|
||||
assert.equal(draft.repoParam, "full");
|
||||
assert.deepEqual(draft.inputs, { a: { param: "ip", value: "" }, b: { param: "", value: "3" }, c: { param: "", value: "x" } });
|
||||
assert.deepEqual(draft.inputs, {
|
||||
a: { param: "ip", value: "" },
|
||||
b: { param: "", value: "3" },
|
||||
c: { param: "", value: "x" },
|
||||
});
|
||||
});
|
||||
+136
-38
@@ -10,48 +10,100 @@ import {
|
||||
} from "../src/stores/control-plane.ts";
|
||||
|
||||
test("control-plane commands keep the edited version and typed values", () => {
|
||||
assert.deepEqual(JSON.parse(commandBody({
|
||||
max_model_tool_steps: 12,
|
||||
max_runtime_seconds: 900,
|
||||
max_consecutive_gate_failures: 3,
|
||||
}, 7)), {
|
||||
value: {
|
||||
max_model_tool_steps: 12,
|
||||
max_runtime_seconds: 900,
|
||||
max_consecutive_gate_failures: 3,
|
||||
assert.deepEqual(
|
||||
JSON.parse(
|
||||
commandBody(
|
||||
{
|
||||
max_model_tool_steps: 12,
|
||||
max_runtime_seconds: 900,
|
||||
max_consecutive_gate_failures: 3,
|
||||
},
|
||||
7,
|
||||
),
|
||||
),
|
||||
{
|
||||
value: {
|
||||
max_model_tool_steps: 12,
|
||||
max_runtime_seconds: 900,
|
||||
max_consecutive_gate_failures: 3,
|
||||
},
|
||||
expected_version: 7,
|
||||
},
|
||||
expected_version: 7,
|
||||
});
|
||||
);
|
||||
});
|
||||
|
||||
test("control-plane resources belong to one settings narrative", () => {
|
||||
const catalog = [
|
||||
"workflow-execution-settings", "provider-settings", "model-role-assignments",
|
||||
"repository-policies", "channel-settings", "scheduling-policy", "tool-settings",
|
||||
"plugin-settings", "container-runtime-policies", "workflow-definitions",
|
||||
].map((kind) => ({ kind, title: kind, schema_json: "{}", commands: ["replace"] }));
|
||||
"workflow-execution-settings",
|
||||
"provider-settings",
|
||||
"model-role-assignments",
|
||||
"repository-policies",
|
||||
"channel-settings",
|
||||
"scheduling-policy",
|
||||
"tool-settings",
|
||||
"plugin-settings",
|
||||
"container-runtime-policies",
|
||||
"workflow-definitions",
|
||||
].map((kind) => ({
|
||||
kind,
|
||||
title: kind,
|
||||
schema_json: "{}",
|
||||
commands: ["replace"],
|
||||
}));
|
||||
|
||||
assert.deepEqual(resourcesForPage(catalog, "tasks").map(({ kind }) => kind), ["workflow-execution-settings"]);
|
||||
assert.deepEqual(resourcesForPage(catalog, "models").map(({ kind }) => kind), ["provider-settings", "model-role-assignments"]);
|
||||
assert.deepEqual(resourcesForPage(catalog, "repositories").map(({ kind }) => kind), ["repository-policies"]);
|
||||
assert.deepEqual(resourcesForPage(catalog, "channels").map(({ kind }) => kind), ["channel-settings"]);
|
||||
assert.deepEqual(resourcesForPage(catalog, "advanced").map(({ kind }) => kind), [
|
||||
"scheduling-policy", "tool-settings", "plugin-settings", "container-runtime-policies",
|
||||
]);
|
||||
assert.deepEqual(resourcesForPage(catalog, "workflows").map(({ kind }) => kind), ["workflow-definitions"]);
|
||||
assert.deepEqual(
|
||||
resourcesForPage(catalog, "tasks").map(({ kind }) => kind),
|
||||
["workflow-execution-settings"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
resourcesForPage(catalog, "models").map(({ kind }) => kind),
|
||||
["provider-settings", "model-role-assignments"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
resourcesForPage(catalog, "repositories").map(({ kind }) => kind),
|
||||
["repository-policies"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
resourcesForPage(catalog, "channels").map(({ kind }) => kind),
|
||||
["channel-settings"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
resourcesForPage(catalog, "advanced").map(({ kind }) => kind),
|
||||
[
|
||||
"scheduling-policy",
|
||||
"tool-settings",
|
||||
"plugin-settings",
|
||||
"container-runtime-policies",
|
||||
],
|
||||
);
|
||||
assert.deepEqual(
|
||||
resourcesForPage(catalog, "workflows").map(({ kind }) => kind),
|
||||
["workflow-definitions"],
|
||||
);
|
||||
});
|
||||
|
||||
test("workflow edits replace by id without dropping sibling definitions", () => {
|
||||
const original = { definitions: [
|
||||
{ id: "implement", yaml: "id: implement\nsteps: []\n" },
|
||||
{ id: "tdd", yaml: "id: tdd\nsteps: []\n" },
|
||||
] };
|
||||
assert.deepEqual(upsertWorkflowDefinition(original, { id: "implement", yaml: "id: implement\nsteps:\n - type: implement.code\n" }), {
|
||||
const original = {
|
||||
definitions: [
|
||||
{ id: "implement", yaml: "id: implement\nsteps:\n - type: implement.code\n" },
|
||||
{ id: "implement", yaml: "id: implement\nsteps: []\n" },
|
||||
{ id: "tdd", yaml: "id: tdd\nsteps: []\n" },
|
||||
],
|
||||
});
|
||||
};
|
||||
assert.deepEqual(
|
||||
upsertWorkflowDefinition(original, {
|
||||
id: "implement",
|
||||
yaml: "id: implement\nsteps:\n - type: implement.code\n",
|
||||
}),
|
||||
{
|
||||
definitions: [
|
||||
{
|
||||
id: "implement",
|
||||
yaml: "id: implement\nsteps:\n - type: implement.code\n",
|
||||
},
|
||||
{ id: "tdd", yaml: "id: tdd\nsteps: []\n" },
|
||||
],
|
||||
},
|
||||
);
|
||||
assert.deepEqual(removeWorkflowDefinition(original, "implement"), {
|
||||
definitions: [{ id: "tdd", yaml: "id: tdd\nsteps: []\n" }],
|
||||
});
|
||||
@@ -59,16 +111,45 @@ test("workflow edits replace by id without dropping sibling definitions", () =>
|
||||
|
||||
test("apply status names a process behind the stored version and one that stopped reporting", () => {
|
||||
const records = [
|
||||
{ process: "archied", kind: "tool-settings", applied_version: 7, reported_at: "", state: "current" },
|
||||
{ process: "archie-gateway", kind: "tool-settings", applied_version: 6, reported_at: "", state: "current" },
|
||||
{ process: "archie-messaging", kind: "tool-settings", applied_version: 7, reported_at: "", state: "unknown" },
|
||||
{ process: "archied", kind: "plugin-settings", applied_version: 2, reported_at: "", state: "current" },
|
||||
{
|
||||
process: "archied",
|
||||
kind: "tool-settings",
|
||||
applied_version: 7,
|
||||
reported_at: "",
|
||||
state: "current",
|
||||
},
|
||||
{
|
||||
process: "archie-gateway",
|
||||
kind: "tool-settings",
|
||||
applied_version: 6,
|
||||
reported_at: "",
|
||||
state: "current",
|
||||
},
|
||||
{
|
||||
process: "archie-messaging",
|
||||
kind: "tool-settings",
|
||||
applied_version: 7,
|
||||
reported_at: "",
|
||||
state: "unknown",
|
||||
},
|
||||
{
|
||||
process: "archied",
|
||||
kind: "plugin-settings",
|
||||
applied_version: 2,
|
||||
reported_at: "",
|
||||
state: "current",
|
||||
},
|
||||
];
|
||||
const processes = ["archied", "archie-gateway", "archie-messaging"];
|
||||
|
||||
assert.deepEqual(applyStatusForKind(records, processes, "tool-settings", 7), [
|
||||
{ process: "archied", state: "running", version: 7, error: "" },
|
||||
{ process: "archie-gateway", state: "pending-restart", version: 6, error: "" },
|
||||
{
|
||||
process: "archie-gateway",
|
||||
state: "pending-restart",
|
||||
version: 6,
|
||||
error: "",
|
||||
},
|
||||
{ process: "archie-messaging", state: "unknown", version: 7, error: "" },
|
||||
]);
|
||||
});
|
||||
@@ -76,11 +157,28 @@ test("apply status names a process behind the stored version and one that stoppe
|
||||
test("apply status shows a process that has never reported, and one that rejected the edit", () => {
|
||||
const processes = ["archied", "archie-gateway"];
|
||||
const records = [
|
||||
{ process: "archied", kind: "tool-settings", applied_version: 6, reported_at: "", state: "failed", error: "validate database settings: bad policy" },
|
||||
{
|
||||
process: "archied",
|
||||
kind: "tool-settings",
|
||||
applied_version: 6,
|
||||
reported_at: "",
|
||||
state: "failed",
|
||||
error: "validate database settings: bad policy",
|
||||
},
|
||||
];
|
||||
|
||||
assert.deepEqual(applyStatusForKind(records, processes, "tool-settings", 7), [
|
||||
{ process: "archied", state: "failed", version: 6, error: "validate database settings: bad policy" },
|
||||
{ process: "archie-gateway", state: "not-reporting", version: 0, error: "" },
|
||||
{
|
||||
process: "archied",
|
||||
state: "failed",
|
||||
version: 6,
|
||||
error: "validate database settings: bad policy",
|
||||
},
|
||||
{
|
||||
process: "archie-gateway",
|
||||
state: "not-reporting",
|
||||
version: 0,
|
||||
error: "",
|
||||
},
|
||||
]);
|
||||
});
|
||||
+39
-11
@@ -1,22 +1,47 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { captureIdentity, cleanRule, parseHeaderLines, ruleSummary } = await import("../src/captures/event-types.ts");
|
||||
const { captureIdentity, cleanRule, parseHeaderLines, ruleSummary } =
|
||||
await import("../src/captures/event-types.ts");
|
||||
|
||||
test("pasted header lines become a name-to-value map", () => {
|
||||
assert.deepEqual(parseHeaderLines("X-GitHub-Event: pull_request\n\nContent-Type: application/json; charset=utf-8\nnot a header"), {
|
||||
"X-GitHub-Event": "pull_request",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
});
|
||||
assert.deepEqual(
|
||||
parseHeaderLines(
|
||||
"X-GitHub-Event: pull_request\n\nContent-Type: application/json; charset=utf-8\nnot a header",
|
||||
),
|
||||
{
|
||||
"X-GitHub-Event": "pull_request",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
},
|
||||
);
|
||||
assert.deepEqual(parseHeaderLines(""), {});
|
||||
});
|
||||
|
||||
test("a capture reads as its type's name, as unidentified, or as a type since deleted", () => {
|
||||
const types = [{ id: "et1", source: "gh", name: "push", rule: { headers: [], payload: [] } }];
|
||||
assert.deepEqual(captureIdentity({ id: 1, event_type: "et1" }, types), { label: "push", identified: true });
|
||||
assert.deepEqual(captureIdentity({ id: 2, event_type: "" }, types), { label: "Unidentified", identified: false });
|
||||
assert.deepEqual(captureIdentity({ id: 3 }, types), { label: "Unidentified", identified: false });
|
||||
assert.deepEqual(captureIdentity({ id: 4, event_type: "gone" }, types), { label: "Deleted type", identified: true });
|
||||
const types = [
|
||||
{
|
||||
id: "et1",
|
||||
source: "gh",
|
||||
name: "push",
|
||||
rule: { headers: [], payload: [] },
|
||||
},
|
||||
];
|
||||
assert.deepEqual(captureIdentity({ id: 1, event_type: "et1" }, types), {
|
||||
label: "push",
|
||||
identified: true,
|
||||
});
|
||||
assert.deepEqual(captureIdentity({ id: 2, event_type: "" }, types), {
|
||||
label: "Unidentified",
|
||||
identified: false,
|
||||
});
|
||||
assert.deepEqual(captureIdentity({ id: 3 }, types), {
|
||||
label: "Unidentified",
|
||||
identified: false,
|
||||
});
|
||||
assert.deepEqual(captureIdentity({ id: 4, event_type: "gone" }, types), {
|
||||
label: "Deleted type",
|
||||
identified: true,
|
||||
});
|
||||
});
|
||||
|
||||
test("a rule reads as its conditions joined", () => {
|
||||
@@ -37,7 +62,10 @@ test("a rule reads as its conditions joined", () => {
|
||||
test("blank editor rows are dropped before a rule is saved", () => {
|
||||
assert.deepEqual(
|
||||
cleanRule({
|
||||
headers: [{ name: " ", value: "x" }, { name: "X-A", value: "1" }],
|
||||
headers: [
|
||||
{ name: " ", value: "x" },
|
||||
{ name: "X-A", value: "1" },
|
||||
],
|
||||
payload: [
|
||||
{ path: "", op: "present" },
|
||||
{ path: "a", op: "present", value: "stale" },
|
||||
|
||||
+50
-12
@@ -8,32 +8,70 @@ import test from "node:test";
|
||||
* 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");
|
||||
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 are gone", () => {
|
||||
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");
|
||||
|
||||
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",
|
||||
);
|
||||
|
||||
for (const path of ["/captures", "/mappings", "/bindings"]) {
|
||||
assert.ok(!router.includes(`path: "${path}"`), `${path} is routed again; the Events tabs replaced it`);
|
||||
assert.ok(
|
||||
!router.includes(`path: "${path}"`),
|
||||
`${path} is routed again; the Events tabs 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");
|
||||
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");
|
||||
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`);
|
||||
assert.doesNotMatch(
|
||||
registry,
|
||||
new RegExp(`Path: "${path}"`),
|
||||
`${path} is still a registered page`,
|
||||
);
|
||||
}
|
||||
});
|
||||
+55
-12
@@ -1,36 +1,75 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { EVENTS_TABS, activeTab, availableTabs } = await import("../src/events/tab-selection.ts");
|
||||
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"]);
|
||||
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");
|
||||
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");
|
||||
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 });
|
||||
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");
|
||||
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 });
|
||||
const available = availableTabs({
|
||||
captures: false,
|
||||
bindings: false,
|
||||
mappings: false,
|
||||
});
|
||||
assert.equal(available.length, 0);
|
||||
assert.equal(activeTab("bindings", available), "");
|
||||
});
|
||||
@@ -38,6 +77,10 @@ test("nothing backed reports no tab rather than guessing one", () => {
|
||||
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"]],
|
||||
[
|
||||
["inspector", "captures"],
|
||||
["bindings", "bindings"],
|
||||
["mappings", "mappings"],
|
||||
],
|
||||
);
|
||||
});
|
||||
@@ -9,7 +9,11 @@ test("a valid JSON document tokenizes into typed spans", () => {
|
||||
const kinds = tokens.map((t) => t.kind);
|
||||
assert.ok(tokens.some((t) => t.kind === "key" && t.text === '"name"'));
|
||||
assert.ok(tokens.some((t) => t.kind === "string" && t.text === '"archie"'));
|
||||
assert.ok(tokens.some((t) => t.kind === "number" && t.text === "3" || t.text.endsWith("3")));
|
||||
assert.ok(
|
||||
tokens.some(
|
||||
(t) => (t.kind === "number" && t.text === "3") || t.text.endsWith("3"),
|
||||
),
|
||||
);
|
||||
assert.ok(tokens.some((t) => t.kind === "punct" && t.text.includes("{")));
|
||||
});
|
||||
|
||||
@@ -35,4 +39,4 @@ test("a non-JSON payload yields null, and the caller renders it plain", () => {
|
||||
|
||||
test("an empty string is not JSON", () => {
|
||||
assert.equal(tokenizeJson(""), null);
|
||||
});
|
||||
});
|
||||
@@ -32,20 +32,31 @@ test("pages do not expose passive refresh controls", async () => {
|
||||
});
|
||||
|
||||
test("a 401 does not offer a reload that cannot restore authentication", async () => {
|
||||
const source = await readFile(new URL("../src/tasks/TaskRowActions.vue", import.meta.url), "utf8");
|
||||
const source = await readFile(
|
||||
new URL("../src/tasks/TaskRowActions.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.doesNotMatch(source, /Reload to sign in|window\.location\.reload/);
|
||||
});
|
||||
|
||||
test("the application starts one Pinia-owned live update stream", async () => {
|
||||
const main = await readFile(new URL("../src/main.ts", import.meta.url), "utf8");
|
||||
const main = await readFile(
|
||||
new URL("../src/main.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(main, /useLiveUpdatesStore\(pinia\)\.initialize\(\)/);
|
||||
});
|
||||
|
||||
test("backend events invalidate only their owning projections", () => {
|
||||
assert.deepEqual(resourcesForEvent({ kind: "stage_finish", task_id: 42 }), ["tasks"]);
|
||||
assert.deepEqual(resourcesForEvent({ kind: "stage_finish", task_id: 42 }), [
|
||||
"tasks",
|
||||
]);
|
||||
assert.deepEqual(resourcesForEvent({ kind: "task_queued" }), ["tasks"]);
|
||||
assert.deepEqual(resourcesForEvent({ kind: "capture" }), ["captures"]);
|
||||
assert.deepEqual(resourcesForEvent({ kind: "curator_action" }), ["curators", "skills"]);
|
||||
assert.deepEqual(resourcesForEvent({ kind: "curator_action" }), [
|
||||
"curators",
|
||||
"skills",
|
||||
]);
|
||||
assert.deepEqual(resourcesForEvent({ kind: "update_report" }), ["updates"]);
|
||||
assert.deepEqual(resourcesForEvent({ kind: "log" }), []);
|
||||
});
|
||||
@@ -3,27 +3,45 @@ import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
test("page headings do not narrate their own labels", async () => {
|
||||
const header = await readFile(new URL("../src/base/PageHeader.vue", import.meta.url), "utf8");
|
||||
const header = await readFile(
|
||||
new URL("../src/base/PageHeader.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.doesNotMatch(header, /subtitle/);
|
||||
});
|
||||
|
||||
test("labeled navigation does not repeat itself in tooltips", async () => {
|
||||
for (const path of ["../src/components/topbar/Nav.vue", "../src/components/topbar/NavItem.vue"]) {
|
||||
for (const path of [
|
||||
"../src/components/topbar/Nav.vue",
|
||||
"../src/components/topbar/NavItem.vue",
|
||||
]) {
|
||||
const source = await readFile(new URL(path, import.meta.url), "utf8");
|
||||
assert.doesNotMatch(source, /Tooltip(Content|Trigger)?/u, path);
|
||||
}
|
||||
});
|
||||
|
||||
test("Status shows runtime state instead of configuration summaries", async () => {
|
||||
const page = await readFile(new URL("../src/settings/SystemStatusPage.vue", import.meta.url), "utf8");
|
||||
const page = await readFile(
|
||||
new URL("../src/settings/SystemStatusPage.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(page, /HealthStatusCard/);
|
||||
assert.doesNotMatch(page, /ReadOnlyNotice|ConfigSections|ProvenanceCard|UpdateStatusCard|UpdateActionsCard/);
|
||||
assert.doesNotMatch(
|
||||
page,
|
||||
/ReadOnlyNotice|ConfigSections|ProvenanceCard|UpdateStatusCard|UpdateActionsCard/,
|
||||
);
|
||||
});
|
||||
|
||||
test("Task settings shows settings instead of lifecycle reference data", async () => {
|
||||
const page = await readFile(new URL("../src/settings/SystemTasksPage.vue", import.meta.url), "utf8");
|
||||
const page = await readFile(
|
||||
new URL("../src/settings/SystemTasksPage.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.doesNotMatch(page, /LifecycleCard|ReadOnlyNotice/);
|
||||
|
||||
const sections = await readFile(new URL("../src/settings/ConfigSections.vue", import.meta.url), "utf8");
|
||||
const sections = await readFile(
|
||||
new URL("../src/settings/ConfigSections.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.doesNotMatch(sections, /section\.description/);
|
||||
});
|
||||
+119
-28
@@ -2,30 +2,51 @@ import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
const { blankFromSchema, fieldHint, fieldPlaceholder, fieldTitle, isKeyedCollection, parseSchema, schemaAt } = await import(
|
||||
"../src/settings/resource-schema.ts"
|
||||
);
|
||||
const {
|
||||
blankFromSchema,
|
||||
fieldHint,
|
||||
fieldPlaceholder,
|
||||
fieldTitle,
|
||||
isKeyedCollection,
|
||||
parseSchema,
|
||||
schemaAt,
|
||||
} = await import("../src/settings/resource-schema.ts");
|
||||
|
||||
// The shapes the control-plane descriptors actually advertise (derived in
|
||||
// internal/app/controlplane/schema.go), plus the two degenerate ones.
|
||||
const objectSchema = {
|
||||
type: "object",
|
||||
properties: {
|
||||
email: { type: "object", properties: { listen_addr: { type: "string", title: "Listen address" } } },
|
||||
email: {
|
||||
type: "object",
|
||||
properties: { listen_addr: { type: "string", title: "Listen address" } },
|
||||
},
|
||||
rate_limit: {
|
||||
type: "object",
|
||||
properties: {
|
||||
window: { type: "string", format: "duration" },
|
||||
max_requests: { type: "integer", description: "0 disables rate limiting." },
|
||||
max_requests: {
|
||||
type: "integer",
|
||||
description: "0 disables rate limiting.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const arraySchema = {
|
||||
type: "array",
|
||||
items: { type: "object", properties: { owner: { type: "string" }, base: { type: "string" } } },
|
||||
items: {
|
||||
type: "object",
|
||||
properties: { owner: { type: "string" }, base: { type: "string" } },
|
||||
},
|
||||
};
|
||||
const keyedSchema = {
|
||||
type: "object",
|
||||
additionalProperties: {
|
||||
type: "object",
|
||||
properties: { class: { type: "string" } },
|
||||
},
|
||||
};
|
||||
const keyedSchema = { type: "object", additionalProperties: { type: "object", properties: { class: { type: "string" } } } };
|
||||
const bareSchema = { type: "object" };
|
||||
|
||||
test("parseSchema tolerates a missing or unparseable schema", () => {
|
||||
@@ -36,37 +57,82 @@ test("parseSchema tolerates a missing or unparseable schema", () => {
|
||||
});
|
||||
|
||||
test("schemaAt walks nested fields, array items and keyed-collection values", () => {
|
||||
assert.deepEqual(schemaAt(objectSchema, "channel-settings.rate_limit.window", "channel-settings"), {
|
||||
type: "string",
|
||||
format: "duration",
|
||||
});
|
||||
assert.deepEqual(schemaAt(arraySchema, "repositories.0.owner", "repositories"), { type: "string" });
|
||||
assert.deepEqual(schemaAt(keyedSchema, "providers.anything.class", "providers"), { type: "string" });
|
||||
assert.deepEqual(schemaAt(objectSchema, "channel-settings", "channel-settings"), objectSchema);
|
||||
assert.deepEqual(
|
||||
schemaAt(
|
||||
objectSchema,
|
||||
"channel-settings.rate_limit.window",
|
||||
"channel-settings",
|
||||
),
|
||||
{
|
||||
type: "string",
|
||||
format: "duration",
|
||||
},
|
||||
);
|
||||
assert.deepEqual(
|
||||
schemaAt(arraySchema, "repositories.0.owner", "repositories"),
|
||||
{ type: "string" },
|
||||
);
|
||||
assert.deepEqual(
|
||||
schemaAt(keyedSchema, "providers.anything.class", "providers"),
|
||||
{ type: "string" },
|
||||
);
|
||||
assert.deepEqual(
|
||||
schemaAt(objectSchema, "channel-settings", "channel-settings"),
|
||||
objectSchema,
|
||||
);
|
||||
});
|
||||
|
||||
test("schemaAt answers nothing for a path the schema does not describe", () => {
|
||||
assert.equal(schemaAt(objectSchema, "channel-settings.telegram.token", "channel-settings"), null);
|
||||
assert.equal(schemaAt(null, "channel-settings.email", "channel-settings"), null);
|
||||
assert.equal(schemaAt(bareSchema, "channel-settings.email.listen_addr", "channel-settings"), null);
|
||||
assert.equal(
|
||||
schemaAt(
|
||||
objectSchema,
|
||||
"channel-settings.telegram.token",
|
||||
"channel-settings",
|
||||
),
|
||||
null,
|
||||
);
|
||||
assert.equal(
|
||||
schemaAt(null, "channel-settings.email", "channel-settings"),
|
||||
null,
|
||||
);
|
||||
assert.equal(
|
||||
schemaAt(
|
||||
bareSchema,
|
||||
"channel-settings.email.listen_addr",
|
||||
"channel-settings",
|
||||
),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test("fieldTitle prefers the schema title over the dashed-key fallback", () => {
|
||||
assert.equal(fieldTitle("listen_addr", { title: "Listen address" }), "Listen address");
|
||||
assert.equal(
|
||||
fieldTitle("listen_addr", { title: "Listen address" }),
|
||||
"Listen address",
|
||||
);
|
||||
assert.equal(fieldTitle("listen_addr", { type: "string" }), "Listen addr");
|
||||
assert.equal(fieldTitle("listen_addr", null), "Listen addr");
|
||||
});
|
||||
|
||||
test("fieldPlaceholder offers a duration only where the schema says duration", () => {
|
||||
assert.equal(fieldPlaceholder({ type: "string", format: "duration" }), "1m0s");
|
||||
assert.equal(fieldPlaceholder({ type: "string", format: "date-time" }), "2026-01-01T00:00:00Z");
|
||||
assert.equal(
|
||||
fieldPlaceholder({ type: "string", format: "duration" }),
|
||||
"1m0s",
|
||||
);
|
||||
assert.equal(
|
||||
fieldPlaceholder({ type: "string", format: "date-time" }),
|
||||
"2026-01-01T00:00:00Z",
|
||||
);
|
||||
assert.equal(fieldPlaceholder({ type: "string" }), undefined);
|
||||
assert.equal(fieldPlaceholder({ type: "integer" }), undefined);
|
||||
assert.equal(fieldPlaceholder(null), undefined);
|
||||
});
|
||||
|
||||
test("fieldHint carries the schema's own prose, and nothing when it has none", () => {
|
||||
assert.equal(fieldHint({ description: "0 disables rate limiting." }), "0 disables rate limiting.");
|
||||
assert.equal(
|
||||
fieldHint({ description: "0 disables rate limiting." }),
|
||||
"0 disables rate limiting.",
|
||||
);
|
||||
assert.equal(fieldHint({ type: "integer" }), "");
|
||||
assert.equal(fieldHint(null), "");
|
||||
});
|
||||
@@ -81,7 +147,10 @@ test("isKeyedCollection is the schema signal that keys are the operator's", () =
|
||||
test("blankFromSchema synthesises a new row from the schema, not from a path", () => {
|
||||
assert.deepEqual(blankFromSchema(arraySchema.items), { owner: "", base: "" });
|
||||
assert.deepEqual(blankFromSchema(keyedSchema), {});
|
||||
assert.deepEqual(blankFromSchema({ type: "array", items: { type: "string" } }), []);
|
||||
assert.deepEqual(
|
||||
blankFromSchema({ type: "array", items: { type: "string" } }),
|
||||
[],
|
||||
);
|
||||
assert.equal(blankFromSchema({ type: "boolean" }), false);
|
||||
assert.equal(blankFromSchema({ type: "integer" }), 0);
|
||||
assert.equal(blankFromSchema({ type: "string", format: "duration" }), "");
|
||||
@@ -89,17 +158,39 @@ test("blankFromSchema synthesises a new row from the schema, not from a path", (
|
||||
});
|
||||
|
||||
test("the live editor reads the schema, and no longer hardcodes document shapes", async () => {
|
||||
const editor = await readFile(new URL("../src/settings/StructuredValueEditor.vue", import.meta.url), "utf8");
|
||||
assert.match(editor, /fieldPlaceholder/, "the editor offers the duration placeholder from the schema");
|
||||
const editor = await readFile(
|
||||
new URL("../src/settings/StructuredValueEditor.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(
|
||||
editor,
|
||||
/fieldPlaceholder/,
|
||||
"the editor offers the duration placeholder from the schema",
|
||||
);
|
||||
assert.match(editor, /fieldTitle/, "labels come from the schema title");
|
||||
assert.match(editor, /blankFromSchema/, "a new row is synthesised from the schema");
|
||||
for (const stale of ["base: \"main\"", "ecosystem: \"go\"", "transport: \"stdio\"", "interval: 3600000000000"]) {
|
||||
assert.ok(!editor.includes(stale), `the editor still hardcodes a document shape: ${stale}`);
|
||||
assert.match(
|
||||
editor,
|
||||
/blankFromSchema/,
|
||||
"a new row is synthesised from the schema",
|
||||
);
|
||||
for (const stale of [
|
||||
'base: "main"',
|
||||
'ecosystem: "go"',
|
||||
'transport: "stdio"',
|
||||
"interval: 3600000000000",
|
||||
]) {
|
||||
assert.ok(
|
||||
!editor.includes(stale),
|
||||
`the editor still hardcodes a document shape: ${stale}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("the resource card hands the derived schema to the editor", async () => {
|
||||
const card = await readFile(new URL("../src/settings/StructuredResourceCard.vue", import.meta.url), "utf8");
|
||||
const card = await readFile(
|
||||
new URL("../src/settings/StructuredResourceCard.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(card, /parseSchema/, "the card parses the descriptor's schema");
|
||||
assert.match(card, /:schema=/, "the card passes it down");
|
||||
});
|
||||
@@ -21,7 +21,11 @@ test("session retry awaits every load before settling", async () => {
|
||||
|
||||
const done = retry();
|
||||
await Promise.resolve();
|
||||
assert.deepEqual(order, ["first"], "the retry settled before the second read finished");
|
||||
assert.deepEqual(
|
||||
order,
|
||||
["first"],
|
||||
"the retry settled before the second read finished",
|
||||
);
|
||||
release?.();
|
||||
await done;
|
||||
assert.deepEqual(order, ["first", "second"]);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { setupPanelState } = await import("../src/dashboard/setup-preference.ts");
|
||||
const { setupPanelState } =
|
||||
await import("../src/dashboard/setup-preference.ts");
|
||||
|
||||
import type { Setup } from "../src/dashboard/setup-preference.ts";
|
||||
|
||||
@@ -36,4 +37,4 @@ test("the checklist returns when setup regresses", () => {
|
||||
const state = setupPanelState(setupWith(true, false));
|
||||
assert.equal(state.kind, "incomplete");
|
||||
assert.equal(state.remaining.length, 1);
|
||||
});
|
||||
});
|
||||
@@ -3,18 +3,28 @@ import test from "node:test";
|
||||
|
||||
import { bindingPayload, emptyDraft } from "../src/bindings/binding-draft.ts";
|
||||
import { captureSignature } from "../src/captures/capture-signature.ts";
|
||||
import { signingKind, signingLabel, sourceURL } from "../src/sources/source-signing.ts";
|
||||
import {
|
||||
signingKind,
|
||||
signingLabel,
|
||||
sourceURL,
|
||||
} from "../src/sources/source-signing.ts";
|
||||
import { describeTimelineEvent } from "../src/tasks/timeline-event.ts";
|
||||
|
||||
test("a capture shows how it may dispatch", () => {
|
||||
const cases: Array<[{ authenticated?: boolean; unsigned?: boolean }, string, string]> = [
|
||||
const cases: Array<
|
||||
[{ authenticated?: boolean; unsigned?: boolean }, string, string]
|
||||
> = [
|
||||
[{ authenticated: true }, "Signed", "ok"],
|
||||
[{ unsigned: true }, "Unsigned", "warn"],
|
||||
[{}, "Unverified", "idle"],
|
||||
[{ authenticated: false, unsigned: false }, "Unverified", "idle"],
|
||||
];
|
||||
for (const [capture, label, kind] of cases) {
|
||||
assert.deepEqual(captureSignature(capture), { label, kind }, JSON.stringify(capture));
|
||||
assert.deepEqual(
|
||||
captureSignature(capture),
|
||||
{ label, kind },
|
||||
JSON.stringify(capture),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -41,9 +51,19 @@ test("a source's URL escapes nothing a valid path can hold", () => {
|
||||
});
|
||||
|
||||
test("a task started by an unsigned event says so on its timeline", () => {
|
||||
const line = describeTimelineEvent({ kind: "unsigned_event", data: { source: "firewall" } });
|
||||
assert.deepEqual(line, { title: "Started by an unsigned event", detail: "source firewall", tone: "warn" });
|
||||
assert.equal(describeTimelineEvent({ kind: "stage_start", stage: "plan" }).tone, undefined);
|
||||
const line = describeTimelineEvent({
|
||||
kind: "unsigned_event",
|
||||
data: { source: "firewall" },
|
||||
});
|
||||
assert.deepEqual(line, {
|
||||
title: "Started by an unsigned event",
|
||||
detail: "source firewall",
|
||||
tone: "warn",
|
||||
});
|
||||
assert.equal(
|
||||
describeTimelineEvent({ kind: "stage_start", stage: "plan" }).tone,
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
test("a binding no longer carries a signing secret", () => {
|
||||
|
||||
@@ -2,8 +2,14 @@ import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
const navModel = await readFile(new URL("../src/lib/nav.ts", import.meta.url), "utf8");
|
||||
const navGroup = await readFile(new URL("../src/components/topbar/NavGroup.vue", import.meta.url), "utf8");
|
||||
const navModel = await readFile(
|
||||
new URL("../src/lib/nav.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const navGroup = await readFile(
|
||||
new URL("../src/components/topbar/NavGroup.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
test("System separates operational pages from settings before Task settings", () => {
|
||||
assert.match(
|
||||
|
||||
+49
-10
@@ -4,10 +4,20 @@ import test from "node:test";
|
||||
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
import { boardStatus, initialTaskFilter, taskMatchesStatus, taskStatuses } from "../src/tasks/task-filter.ts";
|
||||
import {
|
||||
boardStatus,
|
||||
initialTaskFilter,
|
||||
taskMatchesStatus,
|
||||
taskStatuses,
|
||||
} from "../src/tasks/task-filter.ts";
|
||||
|
||||
const QUEUED = { id: "queued", label: "Queued", kind: "idle" };
|
||||
const WAITING = { id: "waiting_human", label: "Waiting for you", kind: "warn", needs_you: true };
|
||||
const WAITING = {
|
||||
id: "waiting_human",
|
||||
label: "Waiting for you",
|
||||
kind: "warn",
|
||||
needs_you: true,
|
||||
};
|
||||
const TRIAGING = { id: "triaging", label: "Triaging", kind: "info" };
|
||||
|
||||
test("only a status the served catalog knows becomes a filter", () => {
|
||||
@@ -23,13 +33,20 @@ test("only a status the served catalog knows becomes a filter", () => {
|
||||
[undefined, ""],
|
||||
];
|
||||
for (const [requested, expected] of cases) {
|
||||
assert.equal(initialTaskFilter(requested, catalog), expected, JSON.stringify(requested));
|
||||
assert.equal(
|
||||
initialTaskFilter(requested, catalog),
|
||||
expected,
|
||||
JSON.stringify(requested),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("needs_you groups exactly the statuses the catalog marks for a human", () => {
|
||||
const catalog = [QUEUED, WAITING, TRIAGING];
|
||||
assert.deepEqual([...taskStatuses(catalog)], ["needs_you", "queued", "waiting_human", "triaging"]);
|
||||
assert.deepEqual(
|
||||
[...taskStatuses(catalog)],
|
||||
["needs_you", "queued", "waiting_human", "triaging"],
|
||||
);
|
||||
|
||||
const cases: Array<[{ status?: string }, string, boolean]> = [
|
||||
[{ status: "waiting_human" }, "needs_you", true],
|
||||
@@ -40,7 +57,11 @@ test("needs_you groups exactly the statuses the catalog marks for a human", () =
|
||||
[{}, "queued", false],
|
||||
];
|
||||
for (const [task, status, expected] of cases) {
|
||||
assert.equal(taskMatchesStatus(task, status, catalog), expected, `${task.status} against ${status}`);
|
||||
assert.equal(
|
||||
taskMatchesStatus(task, status, catalog),
|
||||
expected,
|
||||
`${task.status} against ${status}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -58,9 +79,17 @@ test("a filter is re-derived when the served catalog lands", () => {
|
||||
|
||||
assert.equal(status.value, "", "an id no catalog has held yet is dropped");
|
||||
catalog.value = [...catalog.value, TRIAGING];
|
||||
assert.equal(status.value, "triaging", "the served id becomes the filter once it arrives");
|
||||
assert.equal(
|
||||
status.value,
|
||||
"triaging",
|
||||
"the served id becomes the filter once it arrives",
|
||||
);
|
||||
query.value = "queued";
|
||||
assert.equal(status.value, "queued", "a back-button step still moves the filter");
|
||||
assert.equal(
|
||||
status.value,
|
||||
"queued",
|
||||
"a back-button step still moves the filter",
|
||||
);
|
||||
query.value = "";
|
||||
assert.equal(status.value, "", "clearing the query clears the filter");
|
||||
});
|
||||
@@ -74,7 +103,17 @@ test("a filter is re-derived when the served catalog lands", () => {
|
||||
// here and never executable, which is why the derivation itself is a function
|
||||
// in task-filter.ts with its own behavioural coverage above.
|
||||
test("the task board reads the served catalog when the filter re-derives", async () => {
|
||||
const page = await readFile(new URL("../src/tasks/TasksPage.vue", import.meta.url), "utf8");
|
||||
const wiring = /const status = computed\(\(\) => boardStatus\((.+?)\)\);/.exec(page.replace(/\s+/g, " "));
|
||||
assert.equal(wiring?.[1], "statusQuery.value, statusList()", "the filter must be derived, not captured");
|
||||
const page = await readFile(
|
||||
new URL("../src/tasks/TasksPage.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const wiring =
|
||||
/const status = computed\(\(\) => boardStatus\((.+?)\)\);/.exec(
|
||||
page.replace(/\s+/g, " "),
|
||||
);
|
||||
assert.equal(
|
||||
wiring?.[1],
|
||||
"statusQuery.value, statusList()",
|
||||
"the filter must be derived, not captured",
|
||||
);
|
||||
});
|
||||
@@ -9,13 +9,20 @@ const snapshot = await import("../src/lib/task-meta-snapshot.ts");
|
||||
// first-paint snapshot against it means a one-sided rename of any vocabulary
|
||||
// fails on whichever side was not updated.
|
||||
const fixture = JSON.parse(
|
||||
await readFile(new URL("../../internal/webui/testdata/task_meta.json", import.meta.url), "utf8"),
|
||||
await readFile(
|
||||
new URL("../../internal/webui/testdata/task_meta.json", import.meta.url),
|
||||
"utf8",
|
||||
),
|
||||
);
|
||||
|
||||
// The server emits an unset optional field (needs_you, confirm) as its zero
|
||||
// value; the snapshot omits it.
|
||||
const dropZero = (rows: Record<string, unknown>[]) =>
|
||||
rows.map((row) => Object.fromEntries(Object.entries(row).filter(([, v]) => v !== false && v !== "")));
|
||||
rows.map((row) =>
|
||||
Object.fromEntries(
|
||||
Object.entries(row).filter(([, v]) => v !== false && v !== ""),
|
||||
),
|
||||
);
|
||||
|
||||
test("the status snapshot matches the served catalog", () => {
|
||||
assert.deepEqual(snapshot.DEFAULT_STATUSES, dropZero(fixture.statuses));
|
||||
|
||||
+106
-26
@@ -4,7 +4,8 @@ import test from "node:test";
|
||||
// The model context is read at registration time, so each test installs its own
|
||||
// fake `document` before calling. The tool list takes its API client as a
|
||||
// parameter, so these tests never load the real fetch client.
|
||||
const { registerWebMcpTools, createWebMcpRegistrar } = await import("../src/lib/webmcp.ts");
|
||||
const { registerWebMcpTools, createWebMcpRegistrar } =
|
||||
await import("../src/lib/webmcp.ts");
|
||||
const { archieWebMcpTools } = await import("../src/lib/webmcp-tools.ts");
|
||||
|
||||
interface FakeRegistered {
|
||||
@@ -35,7 +36,10 @@ function installModelContext(): { registered: FakeRegistered[] } {
|
||||
}
|
||||
|
||||
function installNoModelContext(): void {
|
||||
Object.defineProperty(globalThis, "document", { configurable: true, value: {} });
|
||||
Object.defineProperty(globalThis, "document", {
|
||||
configurable: true,
|
||||
value: {},
|
||||
});
|
||||
}
|
||||
|
||||
interface Call {
|
||||
@@ -43,7 +47,10 @@ interface Call {
|
||||
args: unknown[];
|
||||
}
|
||||
|
||||
function fakeClient(): { calls: Call[]; client: Parameters<typeof archieWebMcpTools>[0] } {
|
||||
function fakeClient(): {
|
||||
calls: Call[];
|
||||
client: Parameters<typeof archieWebMcpTools>[0];
|
||||
} {
|
||||
const calls: Call[] = [];
|
||||
const reply = (method: string, args: unknown[]) => {
|
||||
calls.push({ method, args });
|
||||
@@ -56,20 +63,28 @@ function fakeClient(): { calls: Call[]; client: Parameters<typeof archieWebMcpTo
|
||||
tasks: async () => reply("tasks", []),
|
||||
task: async (id: string) => reply("task", [id]),
|
||||
captures: async (limit?: number) => reply("captures", [limit]),
|
||||
taskAction: async (id: string, action: string) => reply("taskAction", [id, action]),
|
||||
taskAction: async (id: string, action: string) =>
|
||||
reply("taskAction", [id, action]),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function toolNamed(client: Parameters<typeof archieWebMcpTools>[0], name: string) {
|
||||
const tool = archieWebMcpTools(client).find((candidate) => candidate.name === name);
|
||||
function toolNamed(
|
||||
client: Parameters<typeof archieWebMcpTools>[0],
|
||||
name: string,
|
||||
) {
|
||||
const tool = archieWebMcpTools(client).find(
|
||||
(candidate) => candidate.name === name,
|
||||
);
|
||||
assert.ok(tool, `no tool named ${name}`);
|
||||
return tool;
|
||||
}
|
||||
|
||||
test("registration no-ops without document.modelContext instead of throwing", async () => {
|
||||
installNoModelContext();
|
||||
const registration = await registerWebMcpTools(archieWebMcpTools(fakeClient().client));
|
||||
const registration = await registerWebMcpTools(
|
||||
archieWebMcpTools(fakeClient().client),
|
||||
);
|
||||
assert.equal(registration.registered, false);
|
||||
assert.doesNotThrow(() => registration.dispose());
|
||||
});
|
||||
@@ -87,37 +102,75 @@ test("registration passes each tool's schema and annotations, and disposes via t
|
||||
for (const tool of registered) {
|
||||
assert.ok(tool.description.length > 0, `${tool.name} has no description`);
|
||||
assert.equal(typeof tool.inputSchema, "object");
|
||||
assert.ok(tool.signal instanceof AbortSignal, `${tool.name} has no abort signal`);
|
||||
assert.ok(
|
||||
tool.signal instanceof AbortSignal,
|
||||
`${tool.name} has no abort signal`,
|
||||
);
|
||||
assert.equal(tool.signal.aborted, false);
|
||||
}
|
||||
|
||||
registration.dispose();
|
||||
for (const tool of registered) {
|
||||
assert.equal(tool.signal?.aborted, true, `${tool.name} was not unregistered`);
|
||||
assert.equal(
|
||||
tool.signal?.aborted,
|
||||
true,
|
||||
`${tool.name} was not unregistered`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("read-only tools are read-only; recovery tools are consequential", () => {
|
||||
const annotations = new Map(
|
||||
archieWebMcpTools(fakeClient().client).map((tool) => [tool.name, tool.annotations]),
|
||||
archieWebMcpTools(fakeClient().client).map((tool) => [
|
||||
tool.name,
|
||||
tool.annotations,
|
||||
]),
|
||||
);
|
||||
|
||||
for (const name of ["list_tasks", "get_task", "recent_events", "daemon_health"]) {
|
||||
assert.equal(annotations.get(name)?.readOnlyHint, true, `${name} should be read-only`);
|
||||
assert.notEqual(annotations.get(name)?.consequentialHint, true, `${name} must not be consequential`);
|
||||
for (const name of [
|
||||
"list_tasks",
|
||||
"get_task",
|
||||
"recent_events",
|
||||
"daemon_health",
|
||||
]) {
|
||||
assert.equal(
|
||||
annotations.get(name)?.readOnlyHint,
|
||||
true,
|
||||
`${name} should be read-only`,
|
||||
);
|
||||
assert.notEqual(
|
||||
annotations.get(name)?.consequentialHint,
|
||||
true,
|
||||
`${name} must not be consequential`,
|
||||
);
|
||||
}
|
||||
for (const name of ["retry_task", "stop_task", "cancel_task"]) {
|
||||
assert.equal(annotations.get(name)?.consequentialHint, true, `${name} needs a confirmation`);
|
||||
assert.notEqual(annotations.get(name)?.readOnlyHint, true, `${name} must not be read-only`);
|
||||
assert.equal(
|
||||
annotations.get(name)?.consequentialHint,
|
||||
true,
|
||||
`${name} needs a confirmation`,
|
||||
);
|
||||
assert.notEqual(
|
||||
annotations.get(name)?.readOnlyHint,
|
||||
true,
|
||||
`${name} must not be read-only`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("tools returning agent, operator or inbound content carry untrustedContentHint", () => {
|
||||
const annotations = new Map(
|
||||
archieWebMcpTools(fakeClient().client).map((tool) => [tool.name, tool.annotations]),
|
||||
archieWebMcpTools(fakeClient().client).map((tool) => [
|
||||
tool.name,
|
||||
tool.annotations,
|
||||
]),
|
||||
);
|
||||
for (const name of ["list_tasks", "get_task", "recent_events"]) {
|
||||
assert.equal(annotations.get(name)?.untrustedContentHint, true, `${name} returns untrusted content`);
|
||||
assert.equal(
|
||||
annotations.get(name)?.untrustedContentHint,
|
||||
true,
|
||||
`${name} returns untrusted content`,
|
||||
);
|
||||
}
|
||||
assert.equal(annotations.get("daemon_health")?.untrustedContentHint, false);
|
||||
assert.equal(annotations.get("list_tasks")?.consequentialHint, undefined);
|
||||
@@ -131,7 +184,11 @@ test("execute returns the envelope and calls the dashboard's own client methods"
|
||||
};
|
||||
assert.equal(calls[0].method, "tasks");
|
||||
assert.equal(listed.content[0].type, "text");
|
||||
assert.deepEqual(JSON.parse(listed.content[0].text), { ok: true, method: "tasks", args: [] });
|
||||
assert.deepEqual(JSON.parse(listed.content[0].text), {
|
||||
ok: true,
|
||||
method: "tasks",
|
||||
args: [],
|
||||
});
|
||||
|
||||
await toolNamed(client, "get_task").execute({ task_id: "42" });
|
||||
assert.deepEqual(calls[1], { method: "task", args: ["42"] });
|
||||
@@ -145,9 +202,15 @@ test("execute returns the envelope and calls the dashboard's own client methods"
|
||||
|
||||
test("recovery tools post the dashboard's own action verbs", async () => {
|
||||
const { calls, client } = fakeClient();
|
||||
await toolNamed(client, "retry_task").execute({ task_id: "9", confirm: true });
|
||||
await toolNamed(client, "retry_task").execute({
|
||||
task_id: "9",
|
||||
confirm: true,
|
||||
});
|
||||
await toolNamed(client, "stop_task").execute({ task_id: "9", confirm: true });
|
||||
await toolNamed(client, "cancel_task").execute({ task_id: "9", confirm: true });
|
||||
await toolNamed(client, "cancel_task").execute({
|
||||
task_id: "9",
|
||||
confirm: true,
|
||||
});
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
{ method: "taskAction", args: ["9", "retry"] },
|
||||
@@ -160,8 +223,14 @@ test("recovery tools require an explicit confirm flag before touching the API",
|
||||
const { calls, client } = fakeClient();
|
||||
const retry = toolNamed(client, "retry_task");
|
||||
|
||||
await assert.rejects(() => Promise.resolve(retry.execute({ task_id: "9" })), /confirm must be true/);
|
||||
await assert.rejects(() => Promise.resolve(retry.execute({ task_id: "9", confirm: false })), /confirm must be true/);
|
||||
await assert.rejects(
|
||||
() => Promise.resolve(retry.execute({ task_id: "9" })),
|
||||
/confirm must be true/,
|
||||
);
|
||||
await assert.rejects(
|
||||
() => Promise.resolve(retry.execute({ task_id: "9", confirm: false })),
|
||||
/confirm must be true/,
|
||||
);
|
||||
assert.equal(calls.length, 0, "a call without confirm reached the API");
|
||||
|
||||
await retry.execute({ task_id: "9", confirm: true });
|
||||
@@ -169,7 +238,9 @@ test("recovery tools require an explicit confirm flag before touching the API",
|
||||
});
|
||||
|
||||
test("the recovery schema requires both task_id and confirm", () => {
|
||||
const schema = archieWebMcpTools(fakeClient().client).find((tool) => tool.name === "stop_task")!.inputSchema as {
|
||||
const schema = archieWebMcpTools(fakeClient().client).find(
|
||||
(tool) => tool.name === "stop_task",
|
||||
)!.inputSchema as {
|
||||
required?: string[];
|
||||
};
|
||||
assert.deepEqual(schema.required, ["task_id", "confirm"]);
|
||||
@@ -177,13 +248,18 @@ test("the recovery schema requires both task_id and confirm", () => {
|
||||
|
||||
test("a recovery tool without a task id fails before touching the API", async () => {
|
||||
const { calls, client } = fakeClient();
|
||||
await assert.rejects(() => Promise.resolve(toolNamed(client, "retry_task").execute({})), /task_id is required/);
|
||||
await assert.rejects(
|
||||
() => Promise.resolve(toolNamed(client, "retry_task").execute({})),
|
||||
/task_id is required/,
|
||||
);
|
||||
assert.equal(calls.length, 0);
|
||||
});
|
||||
|
||||
test("re-registering replaces the previous registration", async () => {
|
||||
const { registered } = installModelContext();
|
||||
const register = createWebMcpRegistrar(archieWebMcpTools(fakeClient().client));
|
||||
const register = createWebMcpRegistrar(
|
||||
archieWebMcpTools(fakeClient().client),
|
||||
);
|
||||
const count = archieWebMcpTools(fakeClient().client).length;
|
||||
|
||||
const first = await register();
|
||||
@@ -192,6 +268,10 @@ test("re-registering replaces the previous registration", async () => {
|
||||
assert.notEqual(first, second);
|
||||
assert.equal(registered.length, count * 2);
|
||||
for (const tool of registered.slice(0, count)) {
|
||||
assert.equal(tool.signal?.aborted, true, "the first registration was left live");
|
||||
assert.equal(
|
||||
tool.signal?.aborted,
|
||||
true,
|
||||
"the first registration was left live",
|
||||
);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user