The dashboard is embedded in the single binary, which serves api/openapi.yaml. It was still calling the old services' routes, so pages that read them answered with a not-found: the task board, its activity feed and setup panel, logs, alerts, audit and its export, bindings, schedules, channels, repositories, skills, curators, the control-plane settings pages, identities and org agents, the org switcher, secret-reference checks, task metadata, and the audit, usage, summary and version reads. Each of those surfaces is removed, and a test compares every /api path in the dashboard's source with api/openapi.yaml so the next one fails the gate instead of the browser. Settings that the binary does serve (model providers, instructions, policies, members) keep their pages.
33 lines
1.4 KiB
TypeScript
33 lines
1.4 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { api, ApiError, describeError } from "../src/lib/api.ts";
|
|
import { errors } from "../src/copy/errors/index.ts";
|
|
|
|
// Guards the one place a caught error becomes text: a dropped connection must
|
|
// read as the catalogue's network copy (not "TypeError: Failed to fetch"), an
|
|
// expired session as sign-in copy, and a thrown non-Error never as
|
|
// "[object Object]".
|
|
test("describeError turns a failure into operator copy", async () => {
|
|
const fallback = "Could not load runs";
|
|
const realFetch = globalThis.fetch;
|
|
globalThis.fetch = () => Promise.reject(new TypeError("Failed to fetch"));
|
|
let dropped: unknown;
|
|
try {
|
|
await api.runs();
|
|
} catch (err) {
|
|
dropped = err;
|
|
} finally {
|
|
globalThis.fetch = realFetch;
|
|
}
|
|
|
|
const cases: { name: string; err: unknown; want: string }[] = [
|
|
{ name: "dropped connection", err: dropped, want: errors.common.network },
|
|
{ name: "expired session", err: new ApiError("unauthorized", 401), want: errors.common.sessionExpired },
|
|
{ name: "server reason", err: new ApiError("task is not awaiting approval", 409), want: "task is not awaiting approval" },
|
|
{ name: "plain object", err: { code: 1 }, want: fallback },
|
|
{ name: "empty message", err: new Error(""), want: fallback },
|
|
];
|
|
for (const c of cases) assert.equal(describeError(c.err, fallback), c.want, c.name);
|
|
});
|