Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
2.7 kB · 87 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788import { test, expect, describe } from "bun:test";import { workstreamStateLabel } from "./workstreamState";
const tab = (connected: boolean) => ({ connected });
describe("workstreamStateLabel", () => { test("basic + ready: shows only N/M Connected (base is omitted)", () => { const { label, color } = workstreamStateLabel({ overallState: "active - basic.ready", kind: "basic", checkoutState: "ready", connected: true, tabs: [tab(true), tab(false), tab(true)], }); expect(label).toBe("2/3 Connected"); expect(color).toBe("#22C55E"); });
test("basic + ready with no agents: 0/0 Connected, gray (nothing connected)", () => { const { label, color } = workstreamStateLabel({ overallState: "active - basic.ready", kind: "basic", checkoutState: "ready", connected: false, tabs: [], }); expect(label).toBe("0/0 Connected"); expect(color).toBe("#6B7280"); });
test("initialized-without-checkout: base label only, amber (provisioning-adjacent)", () => { const { label, color } = workstreamStateLabel({ overallState: "active - basic.initialized-without-checkout", kind: "basic", checkoutState: "initialized-without-checkout", connected: false, tabs: [], }); expect(label).toBe("active - basic.initialized-without-checkout"); expect(color).toBe("#FBBF24"); });
test("pending: base label only, amber", () => { const { label, color } = workstreamStateLabel({ overallState: "active - basic.pending", kind: "basic", checkoutState: "pending", connected: false, tabs: [], }); expect(label).toBe("active - basic.pending"); expect(color).toBe("#FBBF24"); });
test("failed: base label only, red — even if a session is connected", () => { const { label, color } = workstreamStateLabel({ overallState: "active - basic.failed", kind: "basic", checkoutState: "failed", connected: true, tabs: [tab(true)], }); expect(label).toBe("active - basic.failed"); expect(color).toBe("#EF4444"); });
test("non-basic kind that is ready: no N/M suffix", () => { const { label } = workstreamStateLabel({ overallState: "active - basic-external", kind: "basic-external", checkoutState: "ready", connected: true, tabs: [tab(true)], }); expect(label).toBe("active - basic-external"); });
test("missing overallState: degrades gracefully (no leading space)", () => { const { label } = workstreamStateLabel({ kind: "basic", checkoutState: "ready", connected: true, tabs: [tab(true), tab(true)], }); expect(label).toBe("2/2 Connected"); });});