The prior two changes gave every component an InstallType/Reference and a way to observe what's actually running (installtype.Type(), daemon.AgentStatus, [nats] config), but nothing consumed any of it -- an operator still had no single place to see whether a component's actual running state agrees with what the update-check command claims. Add GET /api/version: per component, install type, observed running version, the check command's installed/available claims, and a computed status -- ok / update_available / drift / unknown. drift takes priority over update_available (a claim the running system contradicts is worse than a newer release merely existing), and a component with no installed claim at all reports unknown rather than guessing "ok" or "update_available" from a comparison that was never actually made. Surface it as an "Update status" card above the Configuration page's existing config view, sourced independently so its own failure (or a 501 on deployments with no update-check command configured, which renders nothing rather than an error) never blocks the config view that's already there. Closes archie-core-1786751948782-3-837a8fd0.3 and, with it, archie-core-1786751948782-3-837a8fd0 (all 5 design points landed).
38 lines
1.7 KiB
JavaScript
38 lines
1.7 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import "./shim.js";
|
|
import { updateStatusCard } from "../src/settings/update-status.js";
|
|
|
|
test("update status card shows an empty state with no components", () => {
|
|
const card = updateStatusCard([]);
|
|
assert.equal(card.querySelector("table"), null);
|
|
});
|
|
|
|
test("update status card renders one row per component with its status pill", () => {
|
|
const card = updateStatusCard([
|
|
{ id: "daemon", label: "Gateway", install_type: "binary", running_version: "1.0.0", latest_available: "1.1.0", status: "update_available" },
|
|
{ id: "agent", label: "Runtime", install_type: "container", running_version: "1.0.0", status: "ok" },
|
|
]);
|
|
const rows = card.querySelector("tbody").children;
|
|
assert.equal(rows.length, 2);
|
|
assert.match(rows[0].textContent, /Gateway/);
|
|
assert.match(rows[0].textContent, /Update available/);
|
|
assert.match(rows[1].textContent, /OK/);
|
|
});
|
|
|
|
test("update status card's row title carries the comparison basis", () => {
|
|
const card = updateStatusCard([
|
|
{ id: "agent", label: "Runtime", installed_claim: "1.1.0", running_version: "1.0.0", reference: "img@sha256:abc", status: "drift" },
|
|
]);
|
|
const row = card.querySelector("tbody").children[0];
|
|
assert.match(row.attrs.title, /Installed claim: 1\.1\.0/);
|
|
assert.match(row.attrs.title, /Running: 1\.0\.0/);
|
|
assert.match(row.attrs.title, /Reference: img@sha256:abc/);
|
|
});
|
|
|
|
test("update status card shows an unrecognised status as its own label rather than crashing", () => {
|
|
const card = updateStatusCard([{ id: "x", status: "something-new" }]);
|
|
const row = card.querySelector("tbody").children[0];
|
|
assert.match(row.textContent, /something-new/);
|
|
});
|