import { describe, expect, test } from "bun:test";
import { assembleLiveReport } from "./assemble";
import { renderLiveReportHtml } from "./render-html";

describe("renderLiveReportHtml", () => {
  test("renders deterministic html for the same input", () => {
    const data = assembleLiveReport({
      repoRoot: "/w",
      generatedAt: "2026-08-10T06:00:00.000Z",
      sourceRevision: "deadbeef",
      existsSyncImpl: (path) => path === "/w/docs/plans/INDEX.md",
      readFileImpl: (path) => {
        if (path !== "/w/docs/plans/INDEX.md") {
          throw new Error(`unexpected read: ${path}`);
        }
        return `
| Priority | Status | Plan | Scope | Current receipt |
|---:|---|---|---|---|
| 7 | IDLE | [Live Report Synchronization](2026-08-10-live-report-sync.md) | #125 | stale |
`;
      },
      readActiveSessionsImpl: () => [],
    });

    const first = renderLiveReportHtml(data);
    const second = renderLiveReportHtml(data);
    expect(first).toBe(second);
    expect(first).toContain("Overdeck live session report");
    expect(first).toContain("Live Report Synchronization");
    expect(first).toContain("No ACTIVE plans in index.");
  });
});
