// PL6: the React side (src/react.tsx): a plan read from a source that changes, and the components drawn as plain // elements. Run by the app's vitest, which has react-dom (apps/app vite.config.ts test.include). import { renderToStaticMarkup } from "react-dom/server" import { describe, expect, test } from "vitest" import { readPlan } from "../src" import { Agenda, BoardLanes, memorySource, PlanOutline, TaskLine, toggled, usePlan } from "../src/react" const TEXT = "* Act one\n** TODO [#A] Rome storyboard [0/1]\n:PROPERTIES:\n:ID: t-rome\n:END:\n*** TODO The forum\nDEADLINE: <2026-11-14 Sat>\n:PROPERTIES:\n:ID: t-forum\n:END:\n** DONE Cast\n" describe("PL6: React", () => { test("TaskLine: a checkbox, the words, priority, progress, deadline; a heading has no checkbox", () => { const p = readPlan(TEXT) const html = renderToStaticMarkup( {}} />) expect(html).toContain('data-task="t-rome"') expect(html).toContain('role="checkbox" aria-checked="false"') expect(html).toContain('A') expect(html).toContain('Rome storyboard') expect(html).toContain('0/1') expect(renderToStaticMarkup()).not.toContain("checkbox") }) test("the outline nests, the board has its lanes, the agenda its days", () => { const p = readPlan(TEXT) const outline = renderToStaticMarkup() expect(outline.indexOf("The forum")).toBeGreaterThan(outline.indexOf("Rome storyboard")) expect(outline.match(/
    ) expect(board).toMatch(/data-state="todo">

    Next 2<\/span>/) expect(board).toMatch(/data-state="done">

    Done 1<\/span>/) const agenda = renderToStaticMarkup() expect(agenda).toMatch(/data-date="2026-11-14">

    2026-11-14<\/h3>
    • .*The forum/) }) test("usePlan reads a source and edits it by id; a source of text alone is read-only", () => { const src = memorySource(TEXT) let seen: ReturnType | undefined const Probe = () => { seen = usePlan(src) return null } renderToStaticMarkup() expect(seen!.plan.tasks.length).toBe(3) seen!.edit([toggled(seen!.plan.tasks[1])]) expect(readPlan(src.read()!).tasks[1].state).toBe("done") expect(src.read()).toContain("** TODO [#A] Rome storyboard [1/1]") renderToStaticMarkup() expect(seen!.plan.tasks[1].state).toBe("done") const Fixed = () => { seen = usePlan(TEXT) return null } renderToStaticMarkup() expect(() => seen!.edit([])).toThrow(/read-only/) }) })