Files
archie/ui/test/live-state.test.ts
T
sam 34482c8b0c fix(dashboard): re-read on the live stream instead of polling
Every view listing runs or approvals polled on a timer: the home page made
four requests every five seconds per open tab, two of them the same run list,
and the needs-attention card asked for 200 runs to render five.

A run or an approval request moving is now published on the hub and framed on
the dashboard stream, so those views re-read on the change. A reconnect still
re-reads everything, and the hub drops a reader that falls behind, which ends
its stream and reconnects it.
2026-11-27 19:44:21 +11:00

17 lines
621 B
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
test("a frame no view reads invalidates nothing", async () => {
const { resourcesForTopic } = await import("../src/stores/live-events.ts");
assert.deepEqual(resourcesForTopic("work"), ["work"]);
assert.deepEqual(resourcesForTopic("log"), []);
});
test("a closed stream is retried with doubling delay, capped at 30s", async () => {
const { reconnectDelay } = await import("../src/lib/stream-state.ts");
assert.deepEqual(
[0, 1, 2, 3, 4, 5, 6, 10].map(reconnectDelay),
[1000, 2000, 4000, 8000, 16000, 30000, 30000, 30000],
);
});