Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/test/tidy-helpers.test.mjs
iris 5d5df29687 swarm-ui: shared code leaves page folders; SectionHeading and Preformatted replace per-page copies
durationLabel moves to util.ts, termPaths to agent/terminal/term-paths.ts,
StateBadges and tokenTotal to agent/state, and TryOutResult to
pages/review-common, so the builds, runs and agent pages no longer import
across page folders. SectionHeading is the body-size section heading the
create form and the egress card each styled; Preformatted is the scrolling
text block of the builds tail and the AGENTS.md view, which now share one
chrome and are both keyboard-scrollable. The components page shows both.
2026-11-06 19:09:18 +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 "../src/util.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);
});