// THE WORDS UNDER AN OUTCOME'S STAMP (a promise_outcome row's `stampNote`, 12 Nov): the promise clock wrote // "by · no video" under REFUNDED whatever the record said. A row's own note is that line; the strip over a // post's card shows its first clause; with none, the clock's words as they were. import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import path from "node:path"; import test from "node:test"; import { fileURLToPath } from "node:url"; import { promiseHtml } from "./chrome-measure-extras.mjs"; import { estimateSchedule } from "./deck.mjs"; import { lintManifest } from "./lint.mjs"; import { promiseStates, STAMP_NOTE, stampNoteClause, stampNoteLine, stampNoteWarnings } from "./measure-extras.mjs"; import { measureSlice } from "./measure-slice.mjs"; const HERE = path.dirname(fileURLToPath(import.meta.url)); const MEASURE = JSON.parse(readFileSync(path.join(HERE, "fixtures/measure-extras/measure.json"), "utf8")); const PAL = { bg: "#0F1312", fg: "#EDF0EC", muted: "#98A29B", accent: "#22AB83", amber: "#E8A33F" }; const render = (deck = {}) => ({ width: 1920, height: 1080, fps: 30, transition: 0.4, palette: PAL, chrome: { engine: "hyperframes", layout: "deck", deck } }); const schedule = (measure, extra = {}) => ({ kind: "deck", fps: 30, total: 740, transition: 0.4, segments: [{ id: "a", start: 0, duration: 740, end: 740 }], measure, ...extra }); const clone = (v) => JSON.parse(JSON.stringify(v)); const noted = (note) => { const m = clone(MEASURE); for (const s of m.state) for (const p of s.promises ?? []) if (p.outcome) p.outcome.note = note; return m; }; test("the words: the note when the row has one, the clock's own otherwise; the strip takes the first clause", () => { assert.equal(stampNoteLine({ kind: "refunded", date: "2026-10-31" }), "by 31 Oct · no video"); assert.equal(stampNoteLine({ kind: "refunded", date: null }), "no video"); assert.equal(stampNoteLine({ kind: "refunded", date: "2026-10-31", note: " her word · no receipt " }), "her word · no receipt"); assert.equal(stampNoteClause({ kind: "refunded" }), "no video"); assert.equal(stampNoteClause({ note: "her word · no receipt" }), "her word"); assert.equal(stampNoteClause({ note: "by her account, 31 Oct" }), "by her account"); assert.equal(stampNoteClause({ note: "she says -- nothing shown" }), "she says"); assert.equal(stampNoteClause({ note: "partly; the rest owed" }), "partly"); assert.equal(stampNoteClause({ note: "one clause only" }), "one clause only"); }); test("the slice carries a promise_outcome row's stampNote on the promise's outcome; a row without one is as before", () => { const schema = { kind: "measure", unit: "lb", yMin: 100, yMax: 400, bandGapDays: 60, tracks: [{ key: "weight", role: "value", label: "Weight" }], forms: ["current"] }; const row = (o) => ({ scope: "weight", scopeBasis: "x", scopeConfidence: "read", valueKind: "uttered", flags: [], asOf: null, ...o }); const ledger = (note) => [ row({ id: "p01", date: "2026-10-23", population: "promise", display: "scale video", entryId: "c1" }), row({ id: "o01", date: "2026-10-31", population: "promise_outcome", promise: "p01", outcome: "refunded", speaker: "madamsavvy", entryId: "c2", ...(note === undefined ? {} : { stampNote: note }) }), ]; const r = render({ measure: { scopes: ["weight"], asOf: "2026-11-12" } }); const timeline = Array.from({ length: 3 }, (_, i) => ({ type: "clip", id: `c${i + 1}`, video: "v", start: 10 * i, end: 10 * i + 8, cite: 1, section: 0, quote: "q", onscreen: { title: `Clip ${i + 1}` } })); const slice = (note) => { const manifest = { slug: "m", title: "M", provenance: {}, render: r, timeline, ledgerSchema: schema, ledger: ledger(note) }; return measureSlice(manifest, estimateSchedule(manifest), {}); }; assert.deepEqual(slice(" by her account ").state.at(-1).promises[0].outcome, { kind: "refunded", date: "2026-10-31", row: "o01", note: "by her account" }); assert.deepEqual(slice(undefined).state.at(-1).promises[0].outcome, { kind: "refunded", date: "2026-10-31", row: "o01" }); assert.deepEqual(slice(" ").state.at(-1).promises[0].outcome, { kind: "refunded", date: "2026-10-31", row: "o01" }); // ... and the clock's states keep it. assert.equal(promiseStates(schedule(slice("by her account")), r).find((s) => s.rows[0].outcome)?.rows[0].outcome.note, "by her account"); }); test("the page: the stamp's second line is the note (escaped); the column's compact stamp too; the strip its first clause", () => { const r = render({ promise: { speakers: { madamsavvy: { handle: "MadamSavvy" } } } }); assert.match(promiseHtml(schedule(MEASURE), r, { fonts: {} }).html, /
Refunded<\/div>
by 31 Oct · no video<\/div>/); const html = promiseHtml(schedule(noted("her word · receipt")), r, { fonts: {} }).html; assert.match(html, /
Refunded<\/div>
her word · <no> receipt<\/div>/); assert.doesNotMatch(html, /no video/); // The column's compact form (beside the instruments) draws the same stamp. const col = render({ dial: true, promise: { label: "scale video" } }); assert.match(promiseHtml(schedule(noted("her word · no receipt")), col, { fonts: {} }).html, /
her word · no receipt<\/div>/); // The strip (the footage slot, a post's card over the clock): "refunded · ". const f = render({ promise: { label: "scale video" } }); const covered = (m) => schedule(m, { covers: [{ segment: "p", from: 715, to: 739, rects: [{ x: 300, y: 100, width: 700, height: 600 }] }] }); assert.match(promiseHtml(covered(MEASURE), f, { fonts: {} }).html, /refunded · no video<\/span>/); const strip = promiseHtml(covered(noted("her word · no receipt")), f, { fonts: {} }).html; assert.match(strip, /refunded · her word<\/span>/); assert.doesNotMatch(strip, /refunded · no video<\/span>/); }); test("the lint warns when a note is longer than the stamp's line holds -- never refuses", () => { const manifest = (note) => ({ slug: "m", title: "M", provenance: {}, render: render({}), timeline: [{ type: "clip", id: "c1", video: "v", start: 0, end: 8 }], ledger: [{ id: "o01", population: "promise_outcome", outcome: "refunded", stampNote: note }, { id: "w1", population: "current", stampNote: "x".repeat(60) }] }); assert.deepEqual(stampNoteWarnings(manifest("by her account")), []); assert.deepEqual(stampNoteWarnings(manifest("x".repeat(STAMP_NOTE.fit))), []); const long = "refunded in full by her account on 31 Oct"; const w = stampNoteWarnings(manifest(long)); assert.equal(w.length, 1); assert.match(w[0], new RegExp(`ledger o01\\.stampNote "${long}" is ${long.length} characters: the promise clock's stamp holds about ${STAMP_NOTE.fit}`)); const lint = lintManifest(manifest(long), { validators: false }); assert.ok(lint.warnings.some((x) => x.startsWith("ledger o01.stampNote")), lint.warnings.join("\n")); assert.ok(!lint.errors.some((x) => /stampNote/.test(x))); assert.ok(!lintManifest(manifest("short"), { validators: false }).warnings.some((x) => /stampNote/.test(x))); });