Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/test/status-message.test.mjs
iris 0547081138 swarm ui: the agent's status message shows how long ago it was set
The card and its detail showed the message alone, so a message from an hour
ago read like the current one. Both now add the age, (5m ago), which ticks
like the other relative times. An agent with no message still shows a dash.
2026-11-11 01:25:15 +01:00

32 lines
1 KiB
JavaScript

// The agent status message and its age. Run by `npm test`, which Node runs
// with its built-in test runner and type stripping, so the `.ts` module is
// imported as it is.
import assert from "node:assert/strict";
import { test } from "node:test";
import {
statusSetAtMs,
statusText,
} from "../src/agent/detail/statusMessage.ts";
const snap = (status_text, status_set_at) => ({
status_text,
status_set_at,
running: true,
});
test("the set time is read from seconds to ms, or is nothing", () => {
assert.equal(
statusSetAtMs(snap("working", 1_731_000_000)),
1_731_000_000_000,
);
assert.equal(statusSetAtMs(snap("working", null)), null);
assert.equal(statusSetAtMs(snap("working", 0)), null);
assert.equal(statusSetAtMs(null), null);
});
test("an agent with no message shows a dash", () => {
assert.equal(statusText(snap("fixing a bug", 1)), "fixing a bug");
assert.equal(statusText(snap(null, 1)), "—");
assert.equal(statusText(snap("", 1)), "—");
assert.equal(statusText(null), "—");
});