test(ui): prune brittle checks and document agent rules
This commit is contained in:
1 parent
a49e939609
commit
1eb05f0d24
30 files changed
+255
-1126
No files matched your search
@@ -0,0 +1,81 @@
|
||||
# UI agent rules
|
||||
|
||||
These rules supplement the repository root's AGENTS.md. Its authority, service
|
||||
boundaries, security invariants, Beads workflow and commit gate still apply.
|
||||
CLAUDE.md points here so both agents use one policy.
|
||||
|
||||
## Scope
|
||||
|
||||
The dashboard is Vue 3, TypeScript, Pinia and Vue Router, with Tailwind and
|
||||
vendored shadcn-vue components backed by Reka UI. It talks to the control plane
|
||||
through src/lib/api.ts. The server owns contracts, authorization and durable
|
||||
state; the UI presents them and submits operator choices.
|
||||
|
||||
- Fix broken behavior with the smallest complete change. Finish existing
|
||||
features before adding new ones. Do not add an abstraction or dependency for
|
||||
a few lines of code.
|
||||
- Read the affected callers and existing components before editing. Keep
|
||||
feature state and behavior in its feature folder; shared code must have real
|
||||
consumers. Do not extract production helpers solely to make them testable.
|
||||
- Preserve server vocabulary and typed wire values. Do not invent local status,
|
||||
action or model catalogs when the server supplies them.
|
||||
- Keep requests in src/lib/api.ts and shared live updates in the existing store.
|
||||
Preserve its authentication, CSRF, timeout and error handling.
|
||||
- Keep unavailable, loading, empty and failed states distinct. Show failures
|
||||
where they occur; an unreadable list must not look like an empty one.
|
||||
- Async views must discard stale responses after their task, attempt or route
|
||||
changes. A setting must save through the API and show its applied state.
|
||||
|
||||
## Components and interaction
|
||||
|
||||
- Reuse components/ui and surrounding composition patterns before writing new
|
||||
markup. Keep vendored components local; use npx shadcn-vue@latest for CLI work
|
||||
instead of adding the generator and its dependency tree to the application.
|
||||
- Use semantic theme tokens, existing variants and cn() for conditional classes.
|
||||
Support both themes, compact density and reduced motion.
|
||||
- Keep controls compact and contextual. Use on-demand panels and inline
|
||||
hover/focus icon actions rather than permanent chrome. Do not repeat labels
|
||||
in explanatory text or add controls without working behavior.
|
||||
- Preserve keyboard operation, visible focus, accessible names, dialog titles
|
||||
and table semantics. A hover action must also be reachable by keyboard.
|
||||
- Keep filtering and pagination consistent with the server. State limitations
|
||||
such as sorting only loaded rows when they affect the operator's decision.
|
||||
|
||||
## Tests
|
||||
|
||||
The default is no new test. Add one for a reproduced bug or a change to a
|
||||
security boundary or workflow contract, following the root policy. A regression
|
||||
must fail on the relevant assertion before the fix.
|
||||
|
||||
- Test observable behavior with realistic inputs. Do not test source text,
|
||||
imports, wiring, constants, defaults, type shapes, CSS classes, copied labels,
|
||||
fakes or call order. A fake may support a behavior test; it is not the subject.
|
||||
- Use one table-driven test per behavior. Extend its cases rather than adding
|
||||
tests for each branch. Retain meaningful edge cases; reducing the count alone
|
||||
is not a cleanup.
|
||||
- Keep tests fast and cheap to maintain. Test helpers and fixtures belong in
|
||||
test/, never in production code solely for tests.
|
||||
- For mirrored control-plane validators, extend the shared fixture at
|
||||
internal/app/controlplane/testdata/dashboard-validators.json rather than
|
||||
duplicating accept/reject cases in UI-only tests.
|
||||
- Use browser checks for rendered behavior. Matching a Vue file with a regex
|
||||
does not verify what the user sees. Mocked API checks verify UI behavior, not
|
||||
live service integration; report that distinction.
|
||||
|
||||
## Verification and delivery
|
||||
|
||||
```bash
|
||||
npm test # behavior tests
|
||||
npm run typecheck # TypeScript and Vue checks
|
||||
npm run build # rebuild the embedded dashboard
|
||||
npm audit # after dependency changes
|
||||
```
|
||||
|
||||
- Run task check from the repository root before committing; stage only the
|
||||
task's own paths. Follow the root's commit and push rules.
|
||||
- ui/dist is embedded and committed. Regenerate it for source changes; never
|
||||
edit it by hand. Test-only edits do not need new dashboard assets.
|
||||
- Reuse a running dev server for browser checks. Verify changed interactions,
|
||||
not just a screenshot or successful HTTP response.
|
||||
- Track work and follow-ups in Beads. Keep rules here only when they change a
|
||||
decision; do not add task history or Markdown TODO lists.
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
AGENTS.md
|
||||
+20
-100
@@ -1,107 +1,27 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { groupActivity, groupKey } =
|
||||
await import("../src/dashboard/activity-group.ts");
|
||||
|
||||
import { groupActivity } from "../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 {
|
||||
return { kind, task_id: taskID, detail, at };
|
||||
}
|
||||
const event = (kind: string, task_id: number | undefined, detail: string): ActivityEvent =>
|
||||
({ kind, task_id, detail, at: 1000 });
|
||||
|
||||
test("consecutive events sharing detail and task collapse into one group", () => {
|
||||
const events = [
|
||||
ev("session-memory", undefined, "cycle 9"),
|
||||
ev("session-memory", undefined, "cycle 9"),
|
||||
ev("session-memory", undefined, "cycle 9"),
|
||||
test("activity groups only consecutive events with the same detail and task", () => {
|
||||
const cases: Array<{ name: string; events: ActivityEvent[]; counts: number[] }> = [
|
||||
{ name: "repeated detail", events: [event("memory", undefined, "cycle"), event("memory", undefined, "cycle")], counts: [2] },
|
||||
{ name: "different details", events: [event("stage", 7, "build"), event("stage", 7, "plan")], counts: [1, 1] },
|
||||
{ name: "singleton", events: [event("stage", 7, "build")], counts: [1] },
|
||||
{ name: "different tasks", events: [event("stage", 7, "build"), event("stage", 9, "build")], counts: [1, 1] },
|
||||
{ name: "interleaved kinds", events: [event("curator", 7, "cycle"), event("memory", 7, "cycle")], counts: [2] },
|
||||
{ name: "separated repeats", events: [event("stage", 7, "build"), event("stage", 9, "build"), event("stage", 7, "build")], counts: [1, 1, 1] },
|
||||
{ name: "missing kind", events: [{ detail: "a", at: 1000 }, { detail: "a", at: 1001 }], counts: [2] },
|
||||
];
|
||||
const groups = groupActivity(events);
|
||||
assert.equal(groups.length, 1);
|
||||
assert.equal(groups[0].count, 3);
|
||||
// The newest event (first in the feed) represents the group.
|
||||
assert.equal(groups[0].representative.detail, "cycle 9");
|
||||
assert.equal(groups[0].events.length, 3);
|
||||
});
|
||||
|
||||
test("the same kind with different details does not collapse", () => {
|
||||
const events = [
|
||||
ev("stage_finished", 7, "build"),
|
||||
ev("stage_finished", 7, "plan"),
|
||||
];
|
||||
const groups = groupActivity(events);
|
||||
assert.equal(groups.length, 2);
|
||||
});
|
||||
|
||||
test("a singleton stays a plain one-count group", () => {
|
||||
const groups = groupActivity([ev("stage_finished", 7, "build")]);
|
||||
assert.equal(groups.length, 1);
|
||||
assert.equal(groups[0].count, 1);
|
||||
assert.equal(groups[0].events.length, 1);
|
||||
});
|
||||
|
||||
test("a different task breaks the run", () => {
|
||||
const events = [
|
||||
ev("runner_run", 7, "a"),
|
||||
ev("runner_run", 9, "b"),
|
||||
ev("runner_run", 7, "c"),
|
||||
];
|
||||
const groups = groupActivity(events);
|
||||
assert.equal(groups.length, 3);
|
||||
for (const group of groups) assert.equal(group.count, 1);
|
||||
});
|
||||
|
||||
test("a different kind breaks the run when the detail differs", () => {
|
||||
const events = [
|
||||
ev("session-memory", undefined, "a"),
|
||||
ev("runner_run", undefined, "b"),
|
||||
ev("session-memory", undefined, "c"),
|
||||
];
|
||||
const groups = groupActivity(events);
|
||||
assert.equal(groups.length, 3);
|
||||
});
|
||||
|
||||
test("an interleave of kinds sharing one detail and task collapses", () => {
|
||||
// A background cycle emits one event per internal step; the kinds differ
|
||||
// but the cycle is one run of noise.
|
||||
const events = [
|
||||
ev("curator_action", undefined, "session-memory"),
|
||||
ev("session-memory", undefined, "session-memory"),
|
||||
ev("curator_run", undefined, "session-memory"),
|
||||
ev("curator_action", undefined, "session-memory"),
|
||||
];
|
||||
const groups = groupActivity(events);
|
||||
assert.equal(groups.length, 1);
|
||||
assert.equal(groups[0].count, 4);
|
||||
assert.equal(groups[0].label, "curator_action");
|
||||
});
|
||||
|
||||
test("the same detail on a different task breaks the run", () => {
|
||||
const events = [
|
||||
ev("runner_run", 7, "building"),
|
||||
ev("runner_run", 9, "building"),
|
||||
];
|
||||
const groups = groupActivity(events);
|
||||
assert.equal(groups.length, 2);
|
||||
});
|
||||
|
||||
test("a missing kind resolves to the same label an unset row shows", () => {
|
||||
const events: ActivityEvent[] = [
|
||||
{ detail: "a", at: 1000 },
|
||||
{ detail: "a", at: 1001 },
|
||||
];
|
||||
const groups = groupActivity(events);
|
||||
assert.equal(groups.length, 1);
|
||||
assert.equal(groups[0].label, "event");
|
||||
});
|
||||
|
||||
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));
|
||||
for (const { name, events, counts } of cases) {
|
||||
const groups = groupActivity(events);
|
||||
assert.deepEqual(groups.map((group) => group.count), counts, name);
|
||||
assert.deepEqual(groups.flatMap((group) => group.events), events, `${name}: preserve order and every event`);
|
||||
for (const group of groups) {
|
||||
assert.equal(group.representative, group.events[0], `${name}: newest event represents its group`);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -2,7 +2,6 @@ import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import {
|
||||
BYTES_PER_MB,
|
||||
bytesToMB,
|
||||
mbToBytes,
|
||||
} from "../src/components/ui/byte-size-input/bytes.ts";
|
||||
@@ -11,7 +10,6 @@ import {
|
||||
// as whole bytes. A binary interpretation (2^20) would inflate every stored
|
||||
// value by ~4.9%: ten entered megabytes would become 10_485_760 bytes.
|
||||
test("entered megabytes store as whole decimal bytes", () => {
|
||||
assert.equal(BYTES_PER_MB, 1_000_000);
|
||||
assert.equal(mbToBytes(10), 10_000_000);
|
||||
assert.equal(mbToBytes(0.1), 100_000);
|
||||
assert.equal(mbToBytes(1.5), 1_500_000);
|
||||
@@ -39,4 +37,4 @@ test("the byte count survives a display round trip unchanged", () => {
|
||||
for (const bytes of stored) {
|
||||
assert.equal(mbToBytes(bytesToMB(bytes)), bytes, `round trip of ${bytes}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,13 +1,8 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
import { mediaDetail, mediaLabel, type ChatMedia } from "../src/chat/attachment.ts";
|
||||
|
||||
// The transcript cannot show an attachment's bytes -- they are turn-scoped and
|
||||
// never reach a browser -- so the label is the entire rendering. It reuses the
|
||||
// placeholder vocabulary the channels write into a message's text, so a photo
|
||||
// reads the same whether its metadata survived or only its note did.
|
||||
test("an attachment is labelled in the channel's own placeholder vocabulary", () => {
|
||||
const cases: Array<[ChatMedia, string]> = [
|
||||
[{ type: "image", mime_type: "image/jpeg" }, "[photo]"],
|
||||
@@ -23,9 +18,6 @@ test("an attachment is labelled in the channel's own placeholder vocabulary", ()
|
||||
}
|
||||
});
|
||||
|
||||
// The label says what arrived; the detail says what is known about it, which
|
||||
// is the metadata persistence kept. Nothing here is fetchable, and nothing
|
||||
// here is invented from a file id.
|
||||
test("the detail names the metadata that survived persistence", () => {
|
||||
assert.equal(
|
||||
mediaDetail({
|
||||
@@ -41,33 +33,3 @@ test("the detail names the metadata that survived persistence", () => {
|
||||
assert.equal(mediaDetail({ type: "audio", duration: 12 }), "12 s");
|
||||
assert.equal(mediaDetail({ type: "document" }), "");
|
||||
});
|
||||
|
||||
// A file id is a platform download handle, not an address: a chip that linked
|
||||
// it would 404. The chip links out only when the attachment itself carried a
|
||||
// URL, and the transcript reaches the label and the URL through this module.
|
||||
test("the transcript renders attachments from metadata, never from a file id", async () => {
|
||||
const chip = await readFile(
|
||||
new URL("../src/chat/ChatAttachment.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(chip, /mediaLabel\(attachment\)/, "the chip shows the label");
|
||||
assert.match(chip, /mediaDetail\(attachment\)/, "the chip carries the metadata detail");
|
||||
assert.match(chip, /:href="attachment\.url"/, "the only link target is a URL the attachment had");
|
||||
assert.doesNotMatch(chip, /file_?id/i, "a file id is a handle, not a link target");
|
||||
|
||||
const bubble = await readFile(
|
||||
new URL("../src/chat/ChatBubble.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(bubble, /ChatAttachment/, "the bubble renders the attachment chips");
|
||||
|
||||
const transcript = await readFile(
|
||||
new URL("../src/chat/ChatTranscript.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(
|
||||
transcript,
|
||||
/media: message\.media \|\| \[\]/,
|
||||
"a recorded message's attachments reach the bubble",
|
||||
);
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { connectionStatus } from "../src/lib/connection.ts";
|
||||
|
||||
test("the connection pill names the stream state", () => {
|
||||
for (const [state, label, tone] of [
|
||||
["live", "Connected", "ok"],
|
||||
["connecting", "Connecting", "warn"],
|
||||
["reconnecting", "Connecting", "warn"],
|
||||
["unavailable", "Disconnected", "danger"],
|
||||
] as const) {
|
||||
assert.deepEqual(connectionStatus(state), { label, tone }, state);
|
||||
}
|
||||
});
|
||||
@@ -1,54 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
/**
|
||||
* The keys of the container-runtime-policies document.
|
||||
*
|
||||
* internal/app/controlplane/containerRuntimePolicies owns this shape and
|
||||
* normalises every stored document to it (archie-core-qna6). These are the keys
|
||||
* the control plane serves, so they are the keys the page must bind.
|
||||
*/
|
||||
const documentKeys = [
|
||||
"image",
|
||||
"max_concurrency",
|
||||
"max_uptime",
|
||||
"volume_ttl",
|
||||
"pull_policy",
|
||||
"network",
|
||||
];
|
||||
|
||||
/** The Go-cased spellings the wire carried before archie-core-qna6. */
|
||||
const retiredKeys = ["Image", "MaxConcurrency", "MaxUptime", "VolumeTTL", "PullPolicy", "Network"];
|
||||
|
||||
test("the container runtime page binds the document's own keys", async () => {
|
||||
const page = await readFile(
|
||||
new URL("../src/settings/ContainerRuntimePage.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
// Only the template binds fields; the script's own reads go through the
|
||||
// `runtime` ref, whose `.value` is not a document key.
|
||||
const template = page.slice(page.indexOf("<template>"));
|
||||
const bound = [...template.matchAll(/runtime\.([A-Za-z_]+)/g)].map((m) => m[1]);
|
||||
assert.ok(bound.length > 0, "the page binds no fields at all");
|
||||
for (const key of new Set(bound)) {
|
||||
assert.ok(
|
||||
documentKeys.includes(key),
|
||||
`runtime.${key} is not a container-runtime-policies key`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("the container runtime page does not bind a retired Go-cased key", async () => {
|
||||
const page = await readFile(
|
||||
new URL("../src/settings/ContainerRuntimePage.vue", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
for (const key of retiredKeys) {
|
||||
assert.doesNotMatch(
|
||||
page,
|
||||
new RegExp(`\\.${key}\\b`),
|
||||
`the document no longer carries ${key}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -3,7 +3,6 @@ import test from "node:test";
|
||||
|
||||
import {
|
||||
commandBody,
|
||||
resourcesForPage,
|
||||
upsertWorkflowDefinition,
|
||||
restoreShippedDefinitions,
|
||||
removeWorkflowDefinition,
|
||||
@@ -33,74 +32,6 @@ test("control-plane commands keep the edited version and typed values", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("control-plane resources belong to one settings narrative", () => {
|
||||
const catalog = [
|
||||
"workflow-execution-settings",
|
||||
"task-policy",
|
||||
"provider-settings",
|
||||
"model-role-assignments",
|
||||
"repository-policies",
|
||||
"channel-settings",
|
||||
"personas",
|
||||
"schedules",
|
||||
"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", "task-policy"],
|
||||
);
|
||||
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, "scheduling").map(({ kind }) => kind),
|
||||
["scheduling-policy"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
resourcesForPage(catalog, "tools").map(({ kind }) => kind),
|
||||
["tool-settings"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
resourcesForPage(catalog, "personas").map(({ kind }) => kind),
|
||||
["personas"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
resourcesForPage(catalog, "schedules").map(({ kind }) => kind),
|
||||
["schedules"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
resourcesForPage(catalog, "plugins").map(({ kind }) => kind),
|
||||
["plugin-settings"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
resourcesForPage(catalog, "containers").map(({ kind }) => kind),
|
||||
["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: [
|
||||
@@ -126,7 +57,6 @@ test("workflow edits replace by id without dropping sibling definitions", () =>
|
||||
assert.deepEqual(removeWorkflowDefinition(original, "implement"), {
|
||||
definitions: [{ id: "tdd", yaml: "id: tdd\nsteps: []\n" }],
|
||||
});
|
||||
// Restoring shipped resets shipped ids and keeps a custom workflow.
|
||||
assert.deepEqual(
|
||||
restoreShippedDefinitions(
|
||||
{ definitions: [...original.definitions, { id: "mine", yaml: "id: mine\n" }] },
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { headline } from "../src/dashboard/headline.ts";
|
||||
|
||||
test("the headline names what is running and what needs a human", () => {
|
||||
const cases: [number, number, { running: string; attention: string }][] = [
|
||||
[0, 0, { running: "Nothing is running", attention: "Nothing needs you" }],
|
||||
[1, 0, { running: "1 task running", attention: "Nothing needs you" }],
|
||||
[4, 1, { running: "4 tasks running", attention: "1 task needs you" }],
|
||||
[0, 3, { running: "Nothing is running", attention: "3 tasks need you" }],
|
||||
];
|
||||
for (const [running, attention, want] of cases) {
|
||||
assert.deepEqual(headline(running, attention), want, `${running}/${attention}`);
|
||||
}
|
||||
});
|
||||
@@ -1,15 +1,8 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { filterActivity, matchesActivityFilter } from "../src/dashboard/activity-filter.ts";
|
||||
import { passBar, type PassBar } from "../src/dashboard/pass-bar.ts";
|
||||
|
||||
const {
|
||||
ACTIVITY_FILTERS,
|
||||
activityEmptyTitle,
|
||||
filterActivity,
|
||||
matchesActivityFilter,
|
||||
} = await import("../src/dashboard/activity-filter.ts");
|
||||
const { passBar } = await import("../src/dashboard/pass-bar.ts");
|
||||
|
||||
/** A feed with both kinds in it: task events and the daemon's own telemetry. */
|
||||
const feed = [
|
||||
{ kind: "task_started", task_id: 41 },
|
||||
{ kind: "curator_run" },
|
||||
@@ -17,80 +10,30 @@ const feed = [
|
||||
{ kind: "agent_finish", task_id: "42" },
|
||||
];
|
||||
|
||||
test("All keeps the whole feed, in the order it arrived", () => {
|
||||
assert.deepEqual(filterActivity(feed, "all"), feed);
|
||||
});
|
||||
|
||||
test("Tasks keeps the events a task owns, in arrival order", () => {
|
||||
assert.deepEqual(
|
||||
filterActivity(feed, "tasks").map((event) => event.kind),
|
||||
["task_started", "agent_finish"],
|
||||
);
|
||||
});
|
||||
|
||||
test("the two views account for every event exactly once", () => {
|
||||
const tasks = filterActivity(feed, "tasks");
|
||||
const system = filterActivity(feed, "system");
|
||||
assert.equal(
|
||||
tasks.length + system.length,
|
||||
feed.length,
|
||||
"an event showed in neither view, or in both",
|
||||
);
|
||||
});
|
||||
|
||||
test("an event with no task id is system, whatever the id looks like", () => {
|
||||
test("activity filters partition task and system events without reordering", () => {
|
||||
for (const [filter, expected] of [
|
||||
["all", feed],
|
||||
["tasks", [feed[0], feed[3]]],
|
||||
["system", [feed[1], feed[2]]],
|
||||
] as const) {
|
||||
assert.deepEqual(filterActivity(feed, filter), expected, filter);
|
||||
}
|
||||
for (const task_id of [0, "", "abc", -1, null, undefined]) {
|
||||
assert.equal(
|
||||
matchesActivityFilter({ task_id }, "tasks"),
|
||||
false,
|
||||
`task_id=${String(task_id)} read as a task event`,
|
||||
);
|
||||
assert.equal(matchesActivityFilter({ task_id }, "system"), true);
|
||||
assert.equal(matchesActivityFilter({ task_id }, "tasks"), false, String(task_id));
|
||||
assert.equal(matchesActivityFilter({ task_id }, "system"), true, String(task_id));
|
||||
}
|
||||
assert.equal(matchesActivityFilter({ task_id: "7" }, "tasks"), true);
|
||||
});
|
||||
|
||||
test("the filter offers the three views the header renders", () => {
|
||||
assert.deepEqual(
|
||||
ACTIVITY_FILTERS.map((option) => [option.value, option.label]),
|
||||
[
|
||||
["all", "All"],
|
||||
["tasks", "Tasks"],
|
||||
["system", "System"],
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
test("an emptied feed says which view emptied it", () => {
|
||||
assert.equal(activityEmptyTitle(0, "all"), "Waiting for activity");
|
||||
assert.equal(activityEmptyTitle(0, "tasks"), "No task events yet");
|
||||
assert.equal(activityEmptyTitle(0, "system"), "No system events yet");
|
||||
assert.equal(activityEmptyTitle(2, "tasks"), "", "a feed with rows said it was empty");
|
||||
});
|
||||
|
||||
test("a gate that passed every run draws full, in the passing colour", () => {
|
||||
assert.deepEqual(passBar(3, 3), { pct: 100, kind: "ok", track: "idle" });
|
||||
});
|
||||
|
||||
test("a failing gate draws red at the share that passed", () => {
|
||||
assert.deepEqual(passBar(1, 4), { pct: 25, kind: "danger", track: "danger" });
|
||||
});
|
||||
|
||||
test("a gate that delivered nothing still reads as failing", () => {
|
||||
const bar = passBar(0, 3);
|
||||
assert.equal(bar.pct, 0);
|
||||
assert.equal(bar.kind, "danger");
|
||||
assert.equal(
|
||||
bar.track,
|
||||
"danger",
|
||||
"a zero-width red bar on a plain track reads as a blank row",
|
||||
);
|
||||
});
|
||||
|
||||
test("a gate with no runs has nothing to draw", () => {
|
||||
assert.deepEqual(passBar(0, 0), { pct: 0, kind: "idle", track: "idle" });
|
||||
});
|
||||
|
||||
test("a count larger than the runs it came from does not overflow the bar", () => {
|
||||
assert.deepEqual(passBar(4, 3), { pct: 100, kind: "ok", track: "idle" });
|
||||
test("gate bars show the delivered share and keep zero-pass failures visible", () => {
|
||||
const cases: Array<[number, number, PassBar]> = [
|
||||
[3, 3, { pct: 100, kind: "ok", track: "idle" }],
|
||||
[1, 4, { pct: 25, kind: "danger", track: "danger" }],
|
||||
[0, 3, { pct: 0, kind: "danger", track: "danger" }],
|
||||
[0, 0, { pct: 0, kind: "idle", track: "idle" }],
|
||||
[4, 3, { pct: 100, kind: "ok", track: "idle" }],
|
||||
];
|
||||
for (const [delivered, runs, expected] of cases) {
|
||||
assert.deepEqual(passBar(delivered, runs), expected, `${delivered}/${runs}`);
|
||||
}
|
||||
});
|
||||
@@ -1,15 +1,10 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
import { delivered, type DeliveredCounts } from "../src/lib/delivered.ts";
|
||||
|
||||
// A workflow now ends a run without a pull request (`completed`) as often as
|
||||
// it merges one: a no-change build and a triage that needed no code both
|
||||
// finish with nothing to merge. A surface that counts `merged` alone therefore
|
||||
// renders zero for those runs -- which is what the two surfaces below did,
|
||||
// beside three siblings that already counted both.
|
||||
test("a run that ended completed is delivered like a merge", () => {
|
||||
const tally: Record<string, number> = { merged: 1, completed: 2, pr_open: 5, running: 3 };
|
||||
const cases: [DeliveredCounts | undefined, number][] = [
|
||||
[undefined, 0],
|
||||
[{}, 0],
|
||||
@@ -18,59 +13,9 @@ test("a run that ended completed is delivered like a merge", () => {
|
||||
[{ merged: 2, completed: 0 }, 2],
|
||||
[{ merged: 0, completed: 4 }, 4],
|
||||
[{ merged: 2, completed: 3 }, 5],
|
||||
[tally, 3],
|
||||
];
|
||||
for (const [counts, want] of cases) {
|
||||
assert.equal(delivered(counts), want, JSON.stringify(counts));
|
||||
}
|
||||
});
|
||||
|
||||
// The tiles count a status tally rather than a stats row. `pr_open` is work in
|
||||
// review, not delivered, so it stays out of this count and each tile adds it
|
||||
// where it needs it.
|
||||
test("a status tally is counted the same way", () => {
|
||||
const tally: Record<string, number> = { merged: 1, completed: 2, pr_open: 5, running: 3 };
|
||||
assert.equal(delivered(tally), 3);
|
||||
});
|
||||
|
||||
// Every surface that reports delivered work reads the shared count. This is
|
||||
// the guard: a surface that reads `merged` alone renders a finished no-change
|
||||
// run as zero, and the two that did are asserted by expression below.
|
||||
const deliveredSurfaces = [
|
||||
"../src/dashboard/GatePulseCard.vue",
|
||||
"../src/dashboard/ThroughputTiles.vue",
|
||||
"../src/tasks/TasksSummary.vue",
|
||||
"../src/tasks/NewTaskForm.vue",
|
||||
"../src/workflows/WorkflowsPage.vue",
|
||||
];
|
||||
|
||||
test("every surface that reports delivered work counts completed runs", async () => {
|
||||
for (const path of deliveredSurfaces) {
|
||||
const source = await readFile(new URL(path, import.meta.url), "utf8");
|
||||
assert.match(source, /from "@\/lib\/delivered"/, path);
|
||||
assert.doesNotMatch(
|
||||
source,
|
||||
/\.merged\s*(\|\||\?\?)\s*0/,
|
||||
`${path} counts merged alone, so a run that ended completed reads as zero`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// The two read sites the defect named. Asserted as the expressions that render
|
||||
// the number, not the file's contents: the bar and the "N of M" text are what
|
||||
// an operator reads when a workflow shows no deliverable work.
|
||||
test("the per-workflow bar and count show delivered runs", async () => {
|
||||
const page = flat(await readFile(new URL("../src/workflows/WorkflowsPage.vue", import.meta.url), "utf8"));
|
||||
assert.match(page, /rate\(delivered\(row\), row\.runs\)/, "the bar's share is the delivered share");
|
||||
assert.match(page, /\{\{ delivered\(row\) \}\} of \{\{ row\.runs \|\| 0 \}\}/, "the count is delivered of runs");
|
||||
});
|
||||
|
||||
test("the workflow picker's percent is delivered, not merged", async () => {
|
||||
const form = flat(await readFile(new URL("../src/tasks/NewTaskForm.vue", import.meta.url), "utf8"));
|
||||
assert.match(form, /delivered\(statFor\(d\.id\)\) \/ \(statFor\(d\.id\)\?\.runs \|\| 1\)/, "the percent counts delivered runs");
|
||||
assert.doesNotMatch(form, /% merged/, "a run that ends completed is not merged");
|
||||
});
|
||||
|
||||
/** flat collapses whitespace so a multi-line template expression still matches. */
|
||||
function flat(source: string): string {
|
||||
return source.replace(/\s+/g, " ");
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import {
|
||||
DURATION_UNITS,
|
||||
formatGoDuration,
|
||||
joinDuration,
|
||||
parseGoDuration,
|
||||
@@ -99,5 +98,4 @@ test("unit arithmetic reassembles the stored milliseconds", () => {
|
||||
for (const [value, unit, ms] of cases) {
|
||||
assert.equal(joinDuration(value, unit), ms, `${value}${unit}`);
|
||||
}
|
||||
assert.deepEqual(DURATION_UNITS, ["ms", "s", "m", "h"]);
|
||||
});
|
||||
});
|
||||
@@ -3,10 +3,7 @@ import test from "node:test";
|
||||
|
||||
import type { EventsCountReaders } from "../src/events/counts.ts";
|
||||
|
||||
const { COUNT_SOURCES, loadEventCounts } = await import(
|
||||
"../src/events/counts.ts"
|
||||
);
|
||||
const { EVENTS_TABS } = await import("../src/events/tab-selection.ts");
|
||||
const { loadEventCounts } = await import("../src/events/counts.ts");
|
||||
|
||||
/** Readers standing in for api.captures / api.mappings / api.bindings. */
|
||||
function readers(overrides: Partial<EventsCountReaders> = {}): EventsCountReaders {
|
||||
@@ -26,22 +23,6 @@ test("each count is the length of what its own read answered with", async () =>
|
||||
});
|
||||
});
|
||||
|
||||
test("a load reads each list once", async () => {
|
||||
const called: string[] = [];
|
||||
const record = (name: string, response: unknown) => async () => {
|
||||
called.push(name);
|
||||
return response;
|
||||
};
|
||||
await loadEventCounts(
|
||||
readers({
|
||||
captures: record("captures", { captures: [] }),
|
||||
mappings: record("mappings", { mappings: [] }),
|
||||
bindings: record("bindings", { bindings: [] }),
|
||||
}),
|
||||
);
|
||||
assert.deepEqual(called.sort(), ["bindings", "captures", "mappings"]);
|
||||
});
|
||||
|
||||
test("a count that could not be read stays blank, not zero", async () => {
|
||||
const counts = await loadEventCounts(
|
||||
readers({
|
||||
@@ -65,11 +46,3 @@ test("a response without its list counts as an empty list", async () => {
|
||||
assert.equal(counts.inspector, 0);
|
||||
assert.equal(counts.mappings, 0);
|
||||
});
|
||||
|
||||
test("every tab of the chain has one source, and the strip reads them in order", () => {
|
||||
assert.deepEqual(
|
||||
COUNT_SOURCES.map((source) => source.tab),
|
||||
EVENTS_TABS.map((tab) => tab.id),
|
||||
"a tab whose count nothing reads shows a chip that can never fill",
|
||||
);
|
||||
});
|
||||
+22
-112
@@ -1,118 +1,28 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { activeTab, availableTabs } from "../src/events/tab-selection.ts";
|
||||
|
||||
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("Events hides only capabilities explicitly disabled by the server", () => {
|
||||
const cases: Array<[Record<string, boolean> | null | undefined, string[]]> = [
|
||||
[null, ["inspector", "mappings", "bindings"]],
|
||||
[undefined, ["inspector", "mappings", "bindings"]],
|
||||
[{ captures: true }, ["inspector", "mappings", "bindings"]],
|
||||
[{ captures: true, mappings: true, bindings: false }, ["inspector", "mappings"]],
|
||||
[{ 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("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 })),
|
||||
[],
|
||||
);
|
||||
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"],
|
||||
[{ captures: false, mappings: false, bindings: true }, "inspector", "bindings"],
|
||||
[{ captures: false, mappings: false, bindings: true }, "", "bindings"],
|
||||
[{ 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}`);
|
||||
}
|
||||
});
|
||||
+19
-55
@@ -15,61 +15,25 @@ function binding(overrides: Partial<HarnessBinding> = {}): HarnessBinding {
|
||||
return { service: "github", captured: false, ...overrides };
|
||||
}
|
||||
|
||||
test("an uncaptured binding reads as unconfigured", () => {
|
||||
assert.equal(bindingStatus(binding(), now), "unconfigured");
|
||||
test("credential status distinguishes uncaptured, ready, expiring and expired bindings", () => {
|
||||
const cases: Array<[Partial<HarnessBinding>, string]> = [
|
||||
[{}, "unconfigured"],
|
||||
[{ captured: true, expires_at: "2026-10-02T13:00:00Z" }, "ready"],
|
||||
[{ captured: true, expires_at: new Date(now + EXPIRING_WINDOW_MS - 1000).toISOString() }, "expiring"],
|
||||
[{ captured: true, expires_at: "2026-10-02T11:00:00Z" }, "expired"],
|
||||
[{ captured: true }, "ready"],
|
||||
[{ captured: true, expires_at: "not-a-date" }, "ready"],
|
||||
];
|
||||
for (const [overrides, expected] of cases) {
|
||||
assert.equal(bindingStatus(binding(overrides), now), expected, JSON.stringify(overrides));
|
||||
}
|
||||
});
|
||||
|
||||
test("a captured binding with a future expiry reads as ready", () => {
|
||||
assert.equal(
|
||||
bindingStatus(
|
||||
binding({ captured: true, expires_at: "2026-10-02T13:00:00Z" }),
|
||||
now,
|
||||
),
|
||||
"ready",
|
||||
);
|
||||
});
|
||||
|
||||
test("a captured binding inside the expiring window reads as expiring", () => {
|
||||
const almost = new Date(now + EXPIRING_WINDOW_MS - 1000).toISOString();
|
||||
assert.equal(
|
||||
bindingStatus(binding({ captured: true, expires_at: almost }), now),
|
||||
"expiring",
|
||||
);
|
||||
});
|
||||
|
||||
test("a captured binding past its expiry reads as expired", () => {
|
||||
assert.equal(
|
||||
bindingStatus(
|
||||
binding({ captured: true, expires_at: "2026-10-02T11:00:00Z" }),
|
||||
now,
|
||||
),
|
||||
"expired",
|
||||
);
|
||||
});
|
||||
|
||||
test("a capture with no parseable expiry counts as ready, not expired", () => {
|
||||
// The provider did not tell archie when the token lapses; treating that as
|
||||
// expired would be a guess, and the wrong one.
|
||||
assert.equal(
|
||||
bindingStatus(binding({ captured: true }), now),
|
||||
"ready",
|
||||
);
|
||||
assert.equal(
|
||||
bindingStatus(binding({ captured: true, expires_at: "not-a-date" }), now),
|
||||
"ready",
|
||||
);
|
||||
});
|
||||
|
||||
test("the terminal URL upgrades the scheme and carries the profile", () => {
|
||||
assert.equal(
|
||||
setupTerminalURL("claude-kit", { protocol: "http:", host: "127.0.0.1:8484" }),
|
||||
"ws://127.0.0.1:8484/api/harness/terminal?profile=claude-kit",
|
||||
);
|
||||
});
|
||||
|
||||
test("an https dashboard opens awss terminal", () => {
|
||||
assert.equal(
|
||||
setupTerminalURL("claude kit", { protocol: "https:", host: "archie.example" }),
|
||||
"wss://archie.example/api/harness/terminal?profile=claude+kit",
|
||||
);
|
||||
test("setup terminals preserve secure transport and encode the profile", () => {
|
||||
for (const [profile, location, expected] of [
|
||||
["claude-kit", { protocol: "http:", host: "127.0.0.1:8484" }, "ws://127.0.0.1:8484/api/harness/terminal?profile=claude-kit"],
|
||||
["claude kit", { protocol: "https:", host: "archie.example" }, "wss://archie.example/api/harness/terminal?profile=claude+kit"],
|
||||
] as const) {
|
||||
assert.equal(setupTerminalURL(profile, location), expected, profile);
|
||||
}
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { tokenizeJson, tokenClass } = await import("../src/lib/json-tokens.ts");
|
||||
const { tokenizeJson } = await import("../src/lib/json-tokens.ts");
|
||||
|
||||
test("a valid JSON document tokenizes into typed spans", () => {
|
||||
const tokens = tokenizeJson('{"name":"archie","count":3}');
|
||||
@@ -24,19 +24,8 @@ test("every character of the source survives, verbatim", () => {
|
||||
assert.equal(tokens.map((t) => t.text).join(""), source);
|
||||
});
|
||||
|
||||
test("nested structures keep their punctuation", () => {
|
||||
const tokens = tokenizeJson('{"k":{"n":[1,2]}}');
|
||||
assert.ok(tokens);
|
||||
const open = tokens.filter((t) => t.kind === "punct" && t.text.includes("{"));
|
||||
assert.equal(open.length >= 1, true);
|
||||
});
|
||||
|
||||
test("a non-JSON payload yields null, and the caller renders it plain", () => {
|
||||
assert.equal(tokenizeJson("not json at all"), null);
|
||||
assert.equal(tokenizeJson(""), null);
|
||||
assert.equal(tokenizeJson("{broken"), null);
|
||||
});
|
||||
|
||||
test("an empty string is not JSON", () => {
|
||||
assert.equal(tokenizeJson(""), null);
|
||||
});
|
||||
@@ -1,52 +1,8 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
const { resourcesForEvent } = await import("../src/stores/live-events.ts");
|
||||
|
||||
const passiveRefreshSurfaces = [
|
||||
"../src/dashboard/DashboardHero.vue",
|
||||
"../src/dashboard/NeedsYouCard.vue",
|
||||
"../src/tasks/TasksPage.vue",
|
||||
"../src/tasks/TaskHeader.vue",
|
||||
"../src/tasks/TasksState.vue",
|
||||
"../src/workflows/WorkflowsPage.vue",
|
||||
"../src/skills/SkillsPage.vue",
|
||||
"../src/curators/CuratorsPage.vue",
|
||||
"../src/channels/ChannelsPage.vue",
|
||||
"../src/bindings/BindingsPage.vue",
|
||||
"../src/logs/LogActions.vue",
|
||||
"../src/settings/SystemStatusPage.vue",
|
||||
"../src/settings/SystemTasksPage.vue",
|
||||
"../src/settings/SystemModelsPage.vue",
|
||||
"../src/settings/SystemReposPage.vue",
|
||||
"../src/tasks/PanelError.vue",
|
||||
"../src/tasks/TaskLogs.vue",
|
||||
];
|
||||
|
||||
test("pages do not expose passive refresh controls", async () => {
|
||||
for (const path of passiveRefreshSurfaces) {
|
||||
const source = await readFile(new URL(path, import.meta.url), "utf8");
|
||||
assert.doesNotMatch(source, />\s*(Refresh|Retry)\s*</, path);
|
||||
}
|
||||
});
|
||||
|
||||
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",
|
||||
);
|
||||
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",
|
||||
);
|
||||
assert.match(main, /useLiveUpdatesStore\(pinia\)\.initialize\(\)/);
|
||||
});
|
||||
|
||||
test("backend events invalidate only their owning projections", () => {
|
||||
assert.deepEqual(resourcesForEvent({ kind: "stage_finish", task_id: 42 }), [
|
||||
"tasks",
|
||||
|
||||
@@ -2,7 +2,6 @@ import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { streamURL } from "../src/lib/stream-url.ts";
|
||||
import { logsEmptyDetail } from "../src/logs/logs-empty.ts";
|
||||
|
||||
test("deliberate topic reconnect carries the last cursor rather than starting over", () => {
|
||||
const token = "eyJ0YXNrcyI6IjIwMjYtMDEtMDEiLCJsb2dzIjoyfQ";
|
||||
@@ -14,7 +13,3 @@ test("deliberate topic reconnect carries the last cursor rather than starting ov
|
||||
assert.equal(new URL(offLogs, "http://archie-ui").searchParams.get("topics"), null);
|
||||
assert.equal(new URL(offLogs, "http://archie-ui").searchParams.get("since"), token);
|
||||
});
|
||||
|
||||
test("unavailable logs do not promise an automatic reconnect when no feed exists", () => {
|
||||
assert.equal(logsEmptyDetail(true, "unavailable"), "This process is not delivering live daemon logs.");
|
||||
});
|
||||
@@ -1,31 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { attemptFooter, rowClass } = await import("../src/lib/log.ts");
|
||||
|
||||
test("an ERROR row is a block, not only red text", () => {
|
||||
const classes = rowClass("ERROR");
|
||||
assert.match(classes, /bg-danger-soft/);
|
||||
assert.match(classes, /border-l-danger/);
|
||||
});
|
||||
|
||||
test("every other level keeps the plain row, still carrying its left edge", () => {
|
||||
for (const level of ["WARN", "INFO", "DEBUG", "info", "", null, undefined]) {
|
||||
const classes = rowClass(level);
|
||||
assert.doesNotMatch(classes, /danger/, `${String(level)} wore the error row`);
|
||||
assert.match(
|
||||
classes,
|
||||
/border-l-transparent/,
|
||||
`${String(level)} lost the left border every row carries, so its columns shift`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("the footer names the attempt and counts its lines", () => {
|
||||
assert.equal(attemptFooter(1, 1), "End of attempt 1 · 1 line");
|
||||
assert.equal(attemptFooter(2, 14), "End of attempt 2 · 14 lines");
|
||||
});
|
||||
|
||||
test("an attempt with no lines still reports itself", () => {
|
||||
assert.equal(attemptFooter(1, 0), "End of attempt 1 · 0 lines");
|
||||
});
|
||||
@@ -1,41 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
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",
|
||||
);
|
||||
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",
|
||||
]) {
|
||||
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",
|
||||
);
|
||||
assert.match(page, /HealthStatusCard/);
|
||||
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",
|
||||
);
|
||||
assert.doesNotMatch(page, /LifecycleCard|ReadOnlyNotice/);
|
||||
});
|
||||
+21
-40
@@ -1,7 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { initialRetryChoice, initialRetryMode, retryChoices, retryPayload } =
|
||||
const { initialRetryChoice, initialRetryMode, retryChoices } =
|
||||
await import("../src/tasks/retry-mode.ts");
|
||||
|
||||
const MODES = [
|
||||
@@ -19,45 +19,26 @@ const MODES = [
|
||||
},
|
||||
];
|
||||
|
||||
test("continue is disabled when the task has no pushed branch", () => {
|
||||
const choices = retryChoices(MODES, "");
|
||||
assert.equal(choices[0].disabled, false);
|
||||
assert.equal(choices[1].disabled, true);
|
||||
test("retry modes requiring a branch are disabled without one", () => {
|
||||
for (const [branch, disabled] of [["", true], [" ", true], ["fix/7-thing", false]] as const) {
|
||||
const choices = retryChoices(MODES, branch);
|
||||
assert.equal(choices[0].disabled, false, branch);
|
||||
assert.equal(choices[1].disabled, disabled, branch);
|
||||
}
|
||||
});
|
||||
|
||||
test("continue is offered when the task has a pushed branch", () => {
|
||||
const choices = retryChoices(MODES, "fix/7-thing");
|
||||
assert.equal(choices[1].disabled, false);
|
||||
});
|
||||
|
||||
test("a whitespace branch is no branch", () => {
|
||||
assert.equal(retryChoices(MODES, " ")[1].disabled, true);
|
||||
});
|
||||
|
||||
test("the dialog opens on the task's persisted mode", () => {
|
||||
assert.equal(initialRetryMode(MODES, "continue_pushed_work"), "continue_pushed_work");
|
||||
});
|
||||
|
||||
test("an unknown persisted mode falls back to the explicit server default", () => {
|
||||
assert.equal(initialRetryMode(MODES, "reset_to_head"), "refresh_onto_base");
|
||||
assert.equal(initialRetryMode(MODES, ""), "refresh_onto_base");
|
||||
});
|
||||
|
||||
test("the payload carries the chosen mode under the wire key", () => {
|
||||
assert.deepEqual(retryPayload("continue_pushed_work"), {
|
||||
retry_mode: "continue_pushed_work",
|
||||
});
|
||||
});
|
||||
|
||||
test("a persisted mode the task can no longer use is not preselected", () => {
|
||||
const choices = retryChoices(MODES, "");
|
||||
assert.equal(initialRetryChoice(choices, "continue_pushed_work"), "refresh_onto_base");
|
||||
});
|
||||
|
||||
test("a persisted enabled mode is preselected", () => {
|
||||
const choices = retryChoices(MODES, "fix/7-thing");
|
||||
assert.equal(
|
||||
initialRetryChoice(choices, "continue_pushed_work"),
|
||||
"continue_pushed_work",
|
||||
);
|
||||
test("retry selection preserves usable persisted modes and otherwise falls back", () => {
|
||||
for (const [persisted, expected] of [
|
||||
["continue_pushed_work", "continue_pushed_work"],
|
||||
["reset_to_head", "refresh_onto_base"],
|
||||
["", "refresh_onto_base"],
|
||||
]) {
|
||||
assert.equal(initialRetryMode(MODES, persisted), expected, persisted);
|
||||
}
|
||||
for (const [branch, persisted, expected] of [
|
||||
["", "continue_pushed_work", "refresh_onto_base"],
|
||||
["fix/7-thing", "continue_pushed_work", "continue_pushed_work"],
|
||||
]) {
|
||||
assert.equal(initialRetryChoice(retryChoices(MODES, branch), persisted), expected, branch);
|
||||
}
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { filterHistory, historyEmptyTitle } from "../src/settings/history.ts";
|
||||
import { filterHistory } from "../src/settings/history.ts";
|
||||
|
||||
const entry = (id: number, record_key: string, actor: string, at?: string) => ({
|
||||
id, table: "resources", record_key, field: "f", old_value: 1, new_value: 2,
|
||||
@@ -30,10 +30,3 @@ test("an entry with no time is dropped only when a time window is set", () => {
|
||||
assert.equal(filterHistory([entry(9, "k", "a")], {}, now).length, 1);
|
||||
assert.equal(filterHistory([entry(9, "k", "a")], { sinceMs: 1000 }, now).length, 0);
|
||||
});
|
||||
|
||||
test("the history table names which it has, filtered changes or none recorded", () => {
|
||||
// A history with entries whose filters match nothing sends the reader to the
|
||||
// filters; a history with nothing recorded does not.
|
||||
assert.equal(historyEmptyTitle(true), "No matching changes.");
|
||||
assert.equal(historyEmptyTitle(false), "No changes recorded yet.");
|
||||
});
|
||||
@@ -1,52 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import {
|
||||
collectIssues,
|
||||
draftValidators,
|
||||
validateModelRoles,
|
||||
validateSchedules,
|
||||
validateSchedulingPolicy,
|
||||
type DraftValidator,
|
||||
} from "../src/settings/validation.ts";
|
||||
|
||||
test("scheduling policy refuses a non-positive interval and accepts a positive one", () => {
|
||||
assert.deepEqual(
|
||||
validateSchedulingPolicy({
|
||||
poll_interval: "0s",
|
||||
label: "archie",
|
||||
dispatch: { trigger: "assignee" },
|
||||
}),
|
||||
[{ path: "poll_interval", label: "Poll interval", message: "Must be longer than zero." }],
|
||||
);
|
||||
assert.deepEqual(
|
||||
validateSchedulingPolicy({
|
||||
poll_interval: "1m0s",
|
||||
label: "archie",
|
||||
dispatch: { trigger: "assignee" },
|
||||
}),
|
||||
[],
|
||||
);
|
||||
});
|
||||
|
||||
test("scheduling policy requires a label only for a label-matching trigger", () => {
|
||||
const missing = validateSchedulingPolicy({
|
||||
poll_interval: "30s",
|
||||
label: "",
|
||||
dispatch: { trigger: "either" },
|
||||
});
|
||||
assert.deepEqual(missing, [
|
||||
{ path: "label", label: "Label", message: "Required when the trigger is label or either." },
|
||||
]);
|
||||
assert.deepEqual(
|
||||
validateSchedulingPolicy({
|
||||
poll_interval: "30s",
|
||||
label: "",
|
||||
dispatch: { trigger: "assignee" },
|
||||
}),
|
||||
[],
|
||||
);
|
||||
});
|
||||
import { validateSchedules } from "../src/settings/validation.ts";
|
||||
|
||||
test("schedules refuse an empty id and a duplicate, keeping each row's path", () => {
|
||||
const issues = validateSchedules([
|
||||
@@ -60,47 +15,3 @@ test("schedules refuse an empty id and a duplicate, keeping each row's path", ()
|
||||
]);
|
||||
assert.deepEqual(validateSchedules([{ id: "daily" }, { id: "weekly" }]), []);
|
||||
});
|
||||
|
||||
test("model roles require provider/model", () => {
|
||||
assert.deepEqual(validateModelRoles({ builder: "gpt-4o" }), [
|
||||
{ path: "builder", label: "builder", message: "Use provider/model." },
|
||||
]);
|
||||
assert.deepEqual(validateModelRoles({ builder: "openai/gpt-4o" }), []);
|
||||
// An empty value is refused, not treated as unset: the server refuses it too
|
||||
// (SystemModelsPage deletes the key rather than storing one).
|
||||
assert.deepEqual(validateModelRoles({ planner: "" }), [
|
||||
{ path: "planner", label: "planner", message: "Use provider/model." },
|
||||
]);
|
||||
});
|
||||
|
||||
test("collectIssues runs only dirty sections' validators and stamps the kind", () => {
|
||||
const validators: Record<string, DraftValidator | undefined> = {
|
||||
a: () => [{ path: "x", label: "X", message: "bad" }],
|
||||
b: () => [{ path: "y", label: "Y", message: "also bad" }],
|
||||
};
|
||||
const values: Record<string, unknown> = { a: { x: 1 }, b: { y: 2 } };
|
||||
const issues = collectIssues(["a", "b"], (kind) => values[kind], validators);
|
||||
assert.deepEqual(issues, [
|
||||
{ path: "x", label: "X", message: "bad", kind: "a" },
|
||||
{ path: "y", label: "Y", message: "also bad", kind: "b" },
|
||||
]);
|
||||
// A dirty section with no validator contributes nothing; a clean section is
|
||||
// never asked.
|
||||
assert.deepEqual(collectIssues(["a"], (kind) => values[kind], {}), []);
|
||||
});
|
||||
|
||||
test("a dirty scheduling draft is blocked through the real validator map", () => {
|
||||
const issues = collectIssues(
|
||||
["scheduling-policy"],
|
||||
() => ({ poll_interval: "0s", label: "archie", dispatch: { trigger: "assignee" } }),
|
||||
draftValidators,
|
||||
);
|
||||
assert.deepEqual(issues, [
|
||||
{
|
||||
path: "poll_interval",
|
||||
label: "Poll interval",
|
||||
message: "Must be longer than zero.",
|
||||
kind: "scheduling-policy",
|
||||
},
|
||||
]);
|
||||
});
|
||||
+15
-36
@@ -1,40 +1,19 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { setupPanelState, type Setup } from "../src/dashboard/setup-preference.ts";
|
||||
|
||||
const { setupPanelState } =
|
||||
await import("../src/dashboard/setup-preference.ts");
|
||||
|
||||
import type { Setup } from "../src/dashboard/setup-preference.ts";
|
||||
|
||||
function setupWith(...done: boolean[]): Setup {
|
||||
return { steps: done.map((d, i) => ({ title: `step ${i}`, done: d })) };
|
||||
}
|
||||
type Setup = ReturnType<typeof setupWith>;
|
||||
|
||||
// The completed setup renders no panel: a configured daemon is the absence of
|
||||
// a problem, not a card announcing it. The state machine only distinguishes
|
||||
// "nothing to show" from "there is work left".
|
||||
test("no setup steps omits the panel", () => {
|
||||
assert.equal(setupPanelState(null).kind, "omit");
|
||||
assert.equal(setupPanelState(setupWith()).kind, "omit");
|
||||
});
|
||||
|
||||
test("remaining steps render the checklist", () => {
|
||||
const state = setupPanelState(setupWith(true, false, false));
|
||||
assert.equal(state.kind, "incomplete");
|
||||
assert.equal(state.remaining.length, 2);
|
||||
});
|
||||
|
||||
// The old contract celebrated completion with a "Setup complete" card the
|
||||
// operator had to dismiss. The celebration is gone: all steps done is omit.
|
||||
test("a fully completed setup omits the panel", () => {
|
||||
assert.equal(setupPanelState(setupWith(true, true)).kind, "omit");
|
||||
});
|
||||
|
||||
// If setup later becomes incomplete again, the checklist returns regardless
|
||||
// of anything the operator did while it was complete.
|
||||
test("the checklist returns when setup regresses", () => {
|
||||
const state = setupPanelState(setupWith(true, false));
|
||||
assert.equal(state.kind, "incomplete");
|
||||
assert.equal(state.remaining.length, 1);
|
||||
test("the setup panel shows only unfinished steps", () => {
|
||||
const cases: Array<[boolean[] | null, string, number]> = [
|
||||
[null, "omit", 0],
|
||||
[[], "omit", 0],
|
||||
[[true, true], "omit", 0],
|
||||
[[true, false, false], "incomplete", 2],
|
||||
];
|
||||
for (const [done, kind, remaining] of cases) {
|
||||
const setup: Setup | null = done === null ? null : { steps: done.map((done, i) => ({ title: `step ${i}`, done })) };
|
||||
const state = setupPanelState(setup);
|
||||
assert.equal(state.kind, kind, JSON.stringify(done));
|
||||
assert.equal(state.remaining.length, remaining, JSON.stringify(done));
|
||||
assert.ok(state.remaining.every((step) => !step.done));
|
||||
}
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { bindingPayload, emptyDraft } from "../src/bindings/binding-draft.ts";
|
||||
import { captureSignature } from "../src/captures/capture-signature.ts";
|
||||
import {
|
||||
signingKind,
|
||||
@@ -69,8 +68,3 @@ test("a task started by an unsigned event says so on its timeline", () => {
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
test("a binding no longer carries a signing secret", () => {
|
||||
const payload = bindingPayload(emptyDraft(), []);
|
||||
assert.equal("secret" in payload, false);
|
||||
});
|
||||
@@ -1,36 +1,18 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { shownActionIds } from "../src/tasks/task-actions.ts";
|
||||
|
||||
const { shownActionIds } = await import("../src/tasks/task-actions.ts");
|
||||
|
||||
test("a surface renders every control the server offers when it does not narrow", () => {
|
||||
assert.deepEqual(shownActionIds(["retry", "abandon", "reject"]), [
|
||||
"retry",
|
||||
"abandon",
|
||||
"reject",
|
||||
]);
|
||||
});
|
||||
|
||||
test("a surface that narrows renders only the control it named", () => {
|
||||
assert.deepEqual(shownActionIds(["archive", "open_pr"], ["archive"]), [
|
||||
"archive",
|
||||
]);
|
||||
});
|
||||
|
||||
test("a narrowed surface never invents a control the server did not offer", () => {
|
||||
assert.deepEqual(
|
||||
shownActionIds(["retry", "reject"], ["archive"]),
|
||||
[],
|
||||
"the head offered Archive for a task the server does not let it archive",
|
||||
);
|
||||
});
|
||||
|
||||
test("a task with no action list offers nothing", () => {
|
||||
assert.deepEqual(shownActionIds(undefined, ["archive"]), []);
|
||||
assert.deepEqual(shownActionIds(null), []);
|
||||
assert.deepEqual(shownActionIds([], ["archive"]), []);
|
||||
});
|
||||
|
||||
test("the server's order is kept, never the surface's", () => {
|
||||
assert.deepEqual(shownActionIds(["b", "a"], ["a", "b"]), ["b", "a"]);
|
||||
test("task surfaces preserve server-authorized actions and their order", () => {
|
||||
const cases: Array<[string[] | null | undefined, string[] | undefined, string[]]> = [
|
||||
[["retry", "abandon", "reject"], undefined, ["retry", "abandon", "reject"]],
|
||||
[["archive", "open_pr"], ["archive"], ["archive"]],
|
||||
[["retry", "reject"], ["archive"], []],
|
||||
[undefined, ["archive"], []],
|
||||
[null, undefined, []],
|
||||
[[], ["archive"], []],
|
||||
[["b", "a"], ["a", "b"], ["b", "a"]],
|
||||
];
|
||||
for (const [offered, only, expected] of cases) {
|
||||
assert.deepEqual(shownActionIds(offered, only), expected, JSON.stringify({ offered, only }));
|
||||
}
|
||||
});
|
||||
@@ -1,5 +1,4 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
import { computed, ref } from "vue";
|
||||
@@ -7,7 +6,6 @@ import { computed, ref } from "vue";
|
||||
import {
|
||||
boardStatus,
|
||||
initialTaskFilter,
|
||||
taskStatuses,
|
||||
} from "../src/tasks/task-filter.ts";
|
||||
|
||||
const QUEUED = { id: "queued", label: "Queued", kind: "idle" };
|
||||
@@ -40,13 +38,6 @@ test("only a status the served catalog knows becomes a filter", () => {
|
||||
}
|
||||
});
|
||||
|
||||
// The defect: the board captured the filter at setup, before loadTaskMeta()
|
||||
// replaced the freeze-dried defaults, and the only re-derivation watched the
|
||||
// query string. A status the server serves but the defaults do not know was
|
||||
// therefore dropped, and the whole board rendered in place of the shared view.
|
||||
// Deriving the filter from the catalog instead makes the late catalog a
|
||||
// re-derivation, and the served id becomes the filter without a reload. This
|
||||
// runs the board's own derivation -- the page adds only the two arguments.
|
||||
test("a filter is re-derived when the served catalog lands", () => {
|
||||
const catalog = ref([QUEUED]);
|
||||
const query = ref("triaging");
|
||||
@@ -68,27 +59,3 @@ test("a filter is re-derived when the served catalog lands", () => {
|
||||
query.value = "";
|
||||
assert.equal(status.value, "", "clearing the query clears the filter");
|
||||
});
|
||||
|
||||
// The page owns only the wiring: which query, and which catalog, the derivation
|
||||
// is handed. This is therefore asserted as the whole argument list rather than
|
||||
// the expression's prefix -- a prefix anchor accepted any trailing argument, so
|
||||
// `const catalog = statusList()` captured at setup and passed to the same call
|
||||
// kept the old guard green while reintroducing the defect. The check is
|
||||
// source-level because node --test ships no SFC loader: a .vue file is readable
|
||||
// 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",
|
||||
);
|
||||
});
|
||||
@@ -1,9 +1,6 @@
|
||||
import assert from "node:assert/strict";
|
||||
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 { archieWebMcpTools } = await import("../src/lib/webmcp-tools.ts");
|
||||
@@ -176,30 +173,6 @@ test("tools returning agent, operator or inbound content carry untrustedContentH
|
||||
assert.equal(annotations.get("list_tasks")?.consequentialHint, undefined);
|
||||
});
|
||||
|
||||
test("execute returns the envelope and calls the dashboard's own client methods", async () => {
|
||||
const { calls, client } = fakeClient();
|
||||
|
||||
const listed = (await toolNamed(client, "list_tasks").execute({})) as {
|
||||
content: { type: string; text: string }[];
|
||||
};
|
||||
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: [],
|
||||
});
|
||||
|
||||
await toolNamed(client, "get_task").execute({ task_id: "42" });
|
||||
assert.deepEqual(calls[1], { method: "task", args: ["42"] });
|
||||
|
||||
await toolNamed(client, "recent_events").execute({ limit: 10 });
|
||||
assert.deepEqual(calls[2], { method: "captures", args: [10] });
|
||||
|
||||
await toolNamed(client, "daemon_health").execute({});
|
||||
assert.deepEqual(calls[3], { method: "health", args: [] });
|
||||
});
|
||||
|
||||
test("recovery tools post the dashboard's own action verbs", async () => {
|
||||
const { calls, client } = fakeClient();
|
||||
await toolNamed(client, "retry_task").execute({
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
declaredInputs,
|
||||
inputValues,
|
||||
missingRequiredInputs,
|
||||
type DeclaredInput,
|
||||
} from "../src/workflows/work-request.ts";
|
||||
|
||||
// The shape GET /api/workflows reports for a definition, as far as the
|
||||
@@ -20,45 +19,33 @@ const prReview = {
|
||||
},
|
||||
};
|
||||
|
||||
test("the form renders one field per declared input, in a stable order", () => {
|
||||
test("declared workflow inputs produce stable fields, including an empty form", () => {
|
||||
assert.deepEqual(declaredInputs(prReview), [
|
||||
{ name: "depth", type: "string", required: false },
|
||||
{ name: "pr_number", type: "number", required: true },
|
||||
]);
|
||||
});
|
||||
|
||||
test("a workflow that declares no inputs renders no fields", () => {
|
||||
assert.deepEqual(declaredInputs({ id: "implement" }), []);
|
||||
assert.deepEqual(declaredInputs(undefined), []);
|
||||
});
|
||||
|
||||
test("a declared number is sent as a number, not as the typed text", () => {
|
||||
assert.deepEqual(
|
||||
inputValues(declaredInputs(prReview), { pr_number: "77", depth: "deep" }),
|
||||
{ pr_number: 77, depth: "deep" },
|
||||
);
|
||||
test("workflow input payloads convert declared types and omit empty inputs", () => {
|
||||
const cases: Array<[Record<string, string>, Record<string, unknown>]> = [
|
||||
[{ pr_number: "77", depth: "deep" }, { pr_number: 77, depth: "deep" }],
|
||||
[{ pr_number: "77" }, { pr_number: 77 }],
|
||||
[{ pr_number: "seventy-seven" }, { pr_number: "seventy-seven" }],
|
||||
];
|
||||
for (const [values, expected] of cases) {
|
||||
assert.deepEqual(inputValues(declaredInputs(prReview), values), expected, JSON.stringify(values));
|
||||
}
|
||||
});
|
||||
|
||||
test("an input left empty is absent rather than an empty string", () => {
|
||||
assert.deepEqual(inputValues(declaredInputs(prReview), { pr_number: "77" }), {
|
||||
pr_number: 77,
|
||||
});
|
||||
});
|
||||
|
||||
test("text that is not the declared type is sent as typed, for the server to name", () => {
|
||||
assert.deepEqual(inputValues(declaredInputs(prReview), { pr_number: "seventy-seven" }), {
|
||||
pr_number: "seventy-seven",
|
||||
});
|
||||
});
|
||||
|
||||
test("required inputs that are still empty are named", () => {
|
||||
const declared = declaredInputs(prReview);
|
||||
assert.deepEqual(missingRequiredInputs(declared, {}), ["pr_number"]);
|
||||
assert.deepEqual(missingRequiredInputs(declared, { pr_number: " " }), ["pr_number"]);
|
||||
assert.deepEqual(missingRequiredInputs(declared, { pr_number: "77" }), []);
|
||||
});
|
||||
|
||||
test("an optional input does not hold the form back", () => {
|
||||
const declared: DeclaredInput[] = declaredInputs(prReview);
|
||||
assert.deepEqual(missingRequiredInputs(declared, { pr_number: "1" }), []);
|
||||
test("only missing required workflow inputs block submission", () => {
|
||||
const cases: Array<[Record<string, string>, string[]]> = [
|
||||
[{}, ["pr_number"]],
|
||||
[{ pr_number: " " }, ["pr_number"]],
|
||||
[{ pr_number: "77" }, []],
|
||||
];
|
||||
for (const [values, expected] of cases) {
|
||||
assert.deepEqual(missingRequiredInputs(declaredInputs(prReview), values), expected, JSON.stringify(values));
|
||||
}
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
const { parseWorkflowYaml, validationLabel, yamlLines, yamlTokenClass } =
|
||||
const { parseWorkflowYaml, yamlLines } =
|
||||
await import("../src/workflows/workflow-yaml.ts");
|
||||
|
||||
/** A definition in the shape the server writes: id, then typed steps. */
|
||||
@@ -28,8 +28,6 @@ test("a definition parses into its id and its steps, in order", () => {
|
||||
});
|
||||
|
||||
test("the preview reads the YAML as typed, not a regex over it", () => {
|
||||
// A step whose type sits in a nested block is not a step; a real parser knows
|
||||
// the difference and a line-scanner does not.
|
||||
const parsed = parseWorkflowYaml(`id: x
|
||||
steps:
|
||||
- type: a
|
||||
@@ -46,39 +44,21 @@ steps:
|
||||
);
|
||||
});
|
||||
|
||||
test("a workflow with no id is refused, and says so", () => {
|
||||
const parsed = parseWorkflowYaml("steps:\n - type: a\n");
|
||||
assert.equal(parsed.ok, false);
|
||||
if (parsed.ok) return;
|
||||
assert.match(parsed.message, /id/);
|
||||
});
|
||||
|
||||
test("a workflow with no steps is refused", () => {
|
||||
const parsed = parseWorkflowYaml("id: x\n");
|
||||
assert.equal(parsed.ok, false);
|
||||
if (parsed.ok) return;
|
||||
assert.match(parsed.message, /steps/);
|
||||
});
|
||||
|
||||
test("a step with no type is refused by its position", () => {
|
||||
const parsed = parseWorkflowYaml("id: x\nsteps:\n - type: a\n - settings: {}\n");
|
||||
assert.equal(parsed.ok, false);
|
||||
if (parsed.ok) return;
|
||||
assert.match(parsed.message, /step 2/);
|
||||
});
|
||||
|
||||
test("a root that is not a mapping is refused", () => {
|
||||
for (const source of ["- a\n- b\n", '"just a string"\n']) {
|
||||
test("invalid workflow structures identify the field that prevents saving", () => {
|
||||
for (const [source, message] of [
|
||||
["steps:\n - type: a\n", /id/],
|
||||
["id: x\n", /steps/],
|
||||
["id: x\nsteps:\n - type: a\n - settings: {}\n", /step 2/],
|
||||
["- a\n- b\n", /mapping/],
|
||||
['"just a string"\n', /mapping/],
|
||||
["id: x\nsteps: 3\n", /steps/],
|
||||
] as const) {
|
||||
const parsed = parseWorkflowYaml(source);
|
||||
assert.equal(parsed.ok, false, `${JSON.stringify(source)} parsed as a workflow`);
|
||||
assert.equal(parsed.ok, false, source);
|
||||
if (!parsed.ok) assert.match(parsed.message, message, source);
|
||||
}
|
||||
});
|
||||
|
||||
test("steps that are not a list are refused", () => {
|
||||
const parsed = parseWorkflowYaml("id: x\nsteps: 3\n");
|
||||
assert.equal(parsed.ok, false);
|
||||
});
|
||||
|
||||
test("a YAML syntax error is reported with the line it is on", () => {
|
||||
const parsed = parseWorkflowYaml("id: x\nsteps: [unclosed\n");
|
||||
assert.equal(parsed.ok, false);
|
||||
@@ -90,13 +70,6 @@ test("a YAML syntax error is reported with the line it is on", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("the indicator reads as valid, or as the line that is wrong", () => {
|
||||
const good = parseWorkflowYaml(DEFINITION);
|
||||
assert.equal(validationLabel(good), "Valid");
|
||||
const bad = parseWorkflowYaml("id: x\nsteps: [unclosed\n");
|
||||
assert.match(validationLabel(bad), /^Line \d+: /);
|
||||
});
|
||||
|
||||
test("every character of the source survives highlighting", () => {
|
||||
const sources = [
|
||||
DEFINITION,
|
||||
@@ -163,22 +136,3 @@ test("a list marker and a key are not the same thing", () => {
|
||||
assert.equal(line.tokens[2]?.text, "type");
|
||||
assert.equal(line.tokens[2]?.kind, "key");
|
||||
});
|
||||
|
||||
test("the kinds the reader distinguishes take their own colour", () => {
|
||||
assert.match(yamlTokenClass("key"), /^text-/);
|
||||
assert.match(yamlTokenClass("string"), /^text-/);
|
||||
assert.match(yamlTokenClass("comment"), /^text-/);
|
||||
assert.match(yamlTokenClass("punct"), /^text-/);
|
||||
assert.match(yamlTokenClass("plain"), /^text-/);
|
||||
assert.notEqual(
|
||||
yamlTokenClass("key"),
|
||||
yamlTokenClass("plain"),
|
||||
"a key read as a value",
|
||||
);
|
||||
assert.notEqual(
|
||||
yamlTokenClass("string"),
|
||||
yamlTokenClass("plain"),
|
||||
"a quoted value read as plain text",
|
||||
);
|
||||
assert.notEqual(yamlTokenClass("key"), yamlTokenClass("string"));
|
||||
});
|
||||
Reference in new issue
Block a user