Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/test/tidy-helpers.test.mjs
iris 3be4ec069c frontend: one time wording for the swarm UI and the dashboard, and no HTML strings in the dashboard's busy buttons
fmtAgo, fmtUntil and durationLabel move to @hive/shared/time.js. The swarm UI's util.ts is deleted and its importers (RelativeTime, ReviewRuns, BuildsPage) read the shared module directly. The dashboard's own copies are gone: its fmtAgeSecs (a third phrasing, used for two status lines) becomes the shared fmtAgo, and the dashboard util.js lost fmtAgo, fmtElapsed, epochSec and truncate, which nothing called. asyncBtn and the bulk action buttons mark themselves busy with markBusy: a spinner node before the label and aria-busy, in place of replacing the button's innerHTML with a string (and the label, so the button changed width and lost its name). The el() helper loses its html attribute.
2026-11-20 17:02:32 +01:00

26 lines
1 KiB
JavaScript

// Two helpers that used to live in page folders: how long a run took, and the
// paths one terminal is reached at.
import assert from "node:assert/strict";
import { test } from "node:test";
import { durationLabel } from "../../shared/src/time.ts";
import { termPaths } from "../src/agent/terminal/term-paths.ts";
test("durationLabel names seconds, minutes and hours", () => {
assert.equal(durationLabel(0, 45), "45s");
assert.equal(durationLabel(0, 192), "3m 12s");
assert.equal(durationLabel(0, 3840), "1h 4m");
});
test("durationLabel reads a clock that ran backwards as 0s", () => {
assert.equal(durationLabel(100, 90), "0s");
});
test("an agent's terminal has a turn-state stream, a subagent's has none", () => {
const agent = termPaths("iris");
assert.equal(agent.page, "/agents/iris/terminal");
assert.equal(agent.state, "/api/agents/iris/state/stream");
const sub = termPaths("iris", "t 1");
assert.equal(sub.label, "iris/t 1");
assert.equal(sub.page, "/agents/iris/subagents/t%201/terminal");
assert.equal(sub.state, null);
});