Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

28 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { SESSION_STATES, WAITING_ON_YOU, hostedState, sessionChip } from "./session-card.ts";
5
6test("a session card's state reads as what is happening", () => {
7 assert.deepEqual(sessionChip("Working"), { tone: "accent", live: false });
8 assert.deepEqual(sessionChip("Needs approval"), { tone: "warn", live: false });
9 assert.deepEqual(sessionChip("Done"), { tone: "success", live: false });
10 assert.deepEqual(sessionChip("Failed"), { tone: "danger", live: false });
11 assert.deepEqual(sessionChip("Stopped"), { tone: "neutral", live: false });
12 assert.deepEqual(sessionChip("Queued"), { tone: "neutral", live: false });
13 assert.equal(sessionChip("Waiting on helpers").live, false);
14});
15
16test("every state has a chip, whatever its case; an unknown one is quiet", () => {
17 for (const state of SESSION_STATES) assert.ok(sessionChip(state.toUpperCase()));
18 assert.deepEqual(sessionChip("Exploding"), { tone: "neutral", live: false });
19 assert.deepEqual(sessionChip(null), { tone: "neutral", live: false });
20});
21
22test("g1t's card for a hosted session says Working, Waiting on you while a call waits on the viewer, then Done", () => {
23 assert.equal(hostedState({ running: true, waiting: false }), "Working");
24 assert.equal(hostedState({ running: true }), "Working", "a follow route that did not say");
25 assert.equal(hostedState({ running: true, waiting: true }), WAITING_ON_YOU);
26 assert.equal(hostedState({ running: false, waiting: true }), "Done", "an ended session waits on nobody");
27 assert.deepEqual(sessionChip(WAITING_ON_YOU), { tone: "warn", live: false });
28});