mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 21:03:47 -10:00
The rules are raea/goal's (sdk/goal), run by `raea goal check` at four moments: the hook after a save, every render's end, raea cloud's publish, and the Stop hook. Rust's cut and goal gates and the box's word, sound, frame and place checks are packs (MK30-MK39); runtime/cut-plan, runtime/goal-plan, raea make status and the box's check code are gone with no alias (MK41). brief.ts is the one registered root (MK43): raea runs it, and every file that imports raea must be reached from it (the registered check, an error at publish and done). Its tasks are its `plan` (MK44), read from its run and written back where each is written by `raea goal tasks`, the one path for the app, agents and the box. Its `goal` is one goal or a workflow of several (MK46), each with its step, after and rules, checked and reported alone. Taste lines and signed asks run inside the loop (MK47). `raea goal check|tasks|seen|judge|gates|next` is the loop; `raea make clothes|motion|solid|wear|splat|physics|bake| sao|tokensynth|sounds|component|blockout|...` the asset tools (MK45). Old names are refused with where they went. docs/make.feature is docs/goal.feature; tools/legacy-names.sh holds the old names out. raea's Node mode on JavaScriptCore now gives a CommonJS package's names as named exports (React's jsx), loads a file a tool imports by URL, keeps process.exit's code from a promise callback, and reads stdin as fd 0, so the goal runner runs on the shipped binary.
61 lines
3.0 KiB
TypeScript
61 lines
3.0 KiB
TypeScript
// 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 { Agenda, BoardLanes, memorySource, PlanOutline, TaskLine, toggled, usePlan } from "../src/react"
|
|
import { readPlan as readValue } from "../src/model"
|
|
import { readPlan, value } from "./text"
|
|
|
|
const TEXT = `export default plan({ tasks: [{ title: "Act one", tasks: [
|
|
{ id: "t-rome", keyword: "TODO", priority: "A", title: "Rome storyboard", tasks: [{ id: "t-forum", keyword: "TODO", title: "The forum", deadline: "2026-11-14" }] },
|
|
{ keyword: "DONE", title: "Cast" },
|
|
] }] })`
|
|
|
|
describe("PL6: React", () => {
|
|
test("TaskLine: a checkbox, the words, priority, progress, deadline; a heading has no checkbox", () => {
|
|
const p = readPlan(TEXT)
|
|
const html = renderToStaticMarkup(<TaskLine task={p.entries[1]} onToggle={() => {}} />)
|
|
expect(html).toContain('data-task="t-rome"')
|
|
expect(html).toContain('role="checkbox" aria-checked="false"')
|
|
expect(html).toContain('<span data-part="priority">A</span>')
|
|
expect(html).toContain('<span data-part="text">Rome storyboard</span>')
|
|
expect(html).toContain('<span data-part="progress">0/1</span>')
|
|
expect(renderToStaticMarkup(<TaskLine task={p.entries[0]} />)).not.toContain("checkbox")
|
|
})
|
|
|
|
test("the outline nests, the board has its lanes, the agenda its days", () => {
|
|
const p = readPlan(TEXT)
|
|
const outline = renderToStaticMarkup(<PlanOutline plan={p} />)
|
|
expect(outline.indexOf("The forum")).toBeGreaterThan(outline.indexOf("Rome storyboard"))
|
|
expect(outline.match(/<ul/g)!.length).toBe(3)
|
|
const board = renderToStaticMarkup(<BoardLanes plan={p} labels={{ todo: "Next" }} />)
|
|
expect(board).toMatch(/data-state="todo"><h3>Next <span data-part="count">2<\/span>/)
|
|
expect(board).toMatch(/data-state="done"><h3>Done <span data-part="count">1<\/span>/)
|
|
const agenda = renderToStaticMarkup(<Agenda plan={p} from="2026-11-14" days={2} />)
|
|
expect(agenda).toMatch(/data-date="2026-11-14"><h3>2026-11-14<\/h3><ul><li data-why="deadline">.*The forum/)
|
|
})
|
|
|
|
test("usePlan reads a source and edits it by id; a plan value alone is read-only", () => {
|
|
const src = memorySource(value(TEXT))
|
|
let seen: ReturnType<typeof usePlan> | undefined
|
|
const Probe = () => {
|
|
seen = usePlan(src)
|
|
return null
|
|
}
|
|
renderToStaticMarkup(<Probe />)
|
|
expect(seen!.plan.tasks.length).toBe(3)
|
|
seen!.edit([toggled(seen!.plan.tasks[1])])
|
|
expect(readValue(src.read()).tasks[1].state).toBe("done")
|
|
expect(readValue(src.read()).tasks[0].progress).toEqual({ done: 1, total: 1 })
|
|
renderToStaticMarkup(<Probe />)
|
|
expect(seen!.plan.tasks[1].state).toBe("done")
|
|
const Fixed = () => {
|
|
seen = usePlan(value(TEXT))
|
|
return null
|
|
}
|
|
renderToStaticMarkup(<Fixed />)
|
|
expect(() => seen!.edit([])).toThrow(/read-only/)
|
|
})
|
|
})
|