import { expect, test } from "bun:test"; import { renderToStaticMarkup } from "react-dom/server"; import { SessionWaitStatus } from "./session-wait-status"; import type { Session } from "@opengeni/sdk"; const session = { status: "idle", effectiveControl: { state: "active" }, inputWait: { reason: "Waiting for the build checks to finish.", deadlineAt: "2099-09-09T14:00:00Z", }, } as Session; test("pre-execution startup never creates a composer strip", () => { expect( renderToStaticMarkup( , ), ).toBe(""); }); test("active wait lives near composer and exposes its next check", () => { const html = renderToStaticMarkup(); expect(html).toContain(session.inputWait!.reason); expect(html).toContain("Checks again at"); expect(html).toContain("resumes sooner"); }); test("running, paused, and cleared waits do not display stale status", () => { for (const next of [ { ...session, status: "running" as const }, { ...session, inputWait: null }, { ...session, effectiveControl: { ...session.effectiveControl, state: "paused" as const } }, ]) { expect(renderToStaticMarkup()).toBe(""); } }); test("expired deadline remains a wait until durable state changes", () => { expect( renderToStaticMarkup( , ), ).toContain("Recheck due"); }); test("legacy internal notes are preserved in disclosure", () => { const reason = "Raw internal bookkeeping ".repeat(20); const html = renderToStaticMarkup( , ); expect(html).toContain("Waiting for work in progress"); expect(html).toContain("