Files
remanso/src/modules/macroplan/runMacroplan.spec.ts
Julien Calixte 1b6c7542d7
All checks were successful
CI / verify (push) Successful in 2m9s
feat(notes): render macroplan code blocks as a delivery plan grid
Follows the tikz pattern: the fence emits a base64 placeholder, then
the post-render hook lazily imports the parser and grid (separate
chunks) and mounts the grid only when a placeholder exists. Mono font
forced on the block because the flag-stacking math assumes Fira Code.
2026-07-08 00:01:21 +02:00

41 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest"
import { encodeUTF8ToBase64 } from "@/utils/decodeBase64ToUTF8"
import { runMacroplan } from "./runMacroplan"
const placeholder = (source: string): HTMLElement => {
const el = document.createElement("div")
el.className = "macroplan-block"
el.dataset.macroplanSource = encodeUTF8ToBase64(source)
document.body.appendChild(el)
return el
}
describe("runMacroplan", () => {
it("mounts the grid onto a valid placeholder", async () => {
const el = placeholder(
'title = "Plan"\n\n[[feature]]\nname = "Auth"\nstart = 2026-06-01\noriginal = 2026-06-15\n'
)
await runMacroplan(".macroplan-block")
expect(el.dataset.macroplanRendered).toBe("true")
expect(el.querySelector(".macroplan")).not.toBeNull()
expect(el.textContent).toContain("Auth")
el.remove()
})
it("renders the parse error inline for malformed sources", async () => {
const el = placeholder('[[feature]]\nname = "No dates"')
await runMacroplan(".macroplan-block")
expect(el.dataset.macroplanRendered).toBe("error")
expect(el.querySelector(".macroplan-error")?.textContent).toContain(
"missing `start`"
)
el.remove()
})
})