// A TEASER THAT COUNTS (lane counter-zero): a post shown as a text card may // carry marks as a clip does -- `claim` / `claims`, `at` in seconds from the // card's start -- stamped and counted over the card, with the deck kept up // so the count is seen to step. A teaser without marks is the teaser it was. // // Run with: pnpm test:scripts import assert from "node:assert/strict"; import test from "node:test"; import { estimateSchedule, hidesDeck, resolveDeck, teaserCounts, teaserLead, teaserMarkClock, deckChoreography } from "./deck.mjs"; import { tallyOf, tallySteps, validateClaims } from "./factcheck.mjs"; import { deckHtml } from "./chrome-deck.mjs"; const PALETTE = { bg: "#101219", fg: "#f2f0ea", muted: "#979caa", accent: "#e5534b", amber: "#ffc860" }; const SIDES = [ { id: "LEFT", label: "Left", color: "#5b9bd5" }, { id: "CENTER", label: "Center", color: "#e8d27a" }, ]; const render = { width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE, chrome: { engine: "hyperframes", layout: "deck", deck: { counter: { series: SIDES, showAt: "always" } } } }; const card = (extra = {}) => ({ type: "teaser", id: "x-d28", seconds: 5, lines: [{ text: "@Leaflit on X · 1 Feb 2026", role: "overline" }, { text: "“… as a moderate.”", role: "kicker" }], ...extra, }); const manifest = (teaser) => ({ provenance: {}, posts: [], render, timeline: [ { type: "clip", id: "d2", video: "v1", start: 0, end: 10, claim: { id: "d2", verdict: "CENTER", at: 5 } }, teaser, { type: "clip", id: "d3", video: "v2", start: 0, end: 10 }, ], }); test("a teaser without a mark is as it was: the deck slides away over it, named by its lines", () => { const s = estimateSchedule(manifest(card())); const seg = s.segments[1]; assert.equal(seg.hideDeck, true); assert.equal(teaserCounts(card()), false); assert.match(seg.title, /@Leaflit on X/); assert.equal(seg.claim, undefined); assert.deepEqual(s.factcheck.stamps.map((x) => x.claim), ["d2"]); }); test("a teaser's mark lands at the card's second, counts, and keeps the deck up with no words of its own", () => { const t = card({ claim: { id: "x-d28", verdict: "CENTER", at: 2.15 } }); assert.deepEqual(validateClaims(manifest(t)), []); assert.equal(teaserCounts(t), true); assert.equal(hidesDeck(t, resolveDeck(render)), false); const s = estimateSchedule(manifest(t)); const seg = s.segments[1]; assert.equal(seg.hideDeck, false); assert.equal(seg.title, "", "its words are on the card"); assert.equal(seg.subtitle, ""); assert.equal(seg.sourceFrom, 0, "the card's own clock"); const stamp = s.factcheck.stamps.find((x) => x.claim === "x-d28"); assert.equal(stamp.segment, "x-d28"); assert.equal(stamp.landed, Math.round((seg.start + 2.15) * 1000) / 1000); // The count steps there: CENTER 1 on the clip, 2 on the card. assert.deepEqual(tallySteps(s.factcheck.stamps).map((x) => [x.verdict, x.count, x.at]), [["CENTER", 1, s.factcheck.stamps[0].landed], ["CENTER", 2, stamp.landed]]); // The deck stays up through the card: no slide away into it or back after it. assert.deepEqual(deckChoreography(s, render).visibility, []); assert.deepEqual(tallyOf(s, render), ["LEFT", "CENTER"]); const html = deckHtml(s, render, {}); assert.match(html, /data-seg="x-d28"/); }); test("a teaser that dips still hides the deck at the black; its mark counts on the card's clock after the lead", () => { const t = card({ dip: { fade: 1, black: 0.5 }, claim: { id: "x-d28", verdict: "CENTER", at: 1 } }); assert.equal(teaserCounts(t), false); const s = estimateSchedule(manifest(t)); const seg = s.segments[1]; assert.equal(seg.hideDeck, true); const lead = teaserLead(t, 0.5, 30); assert.equal(teaserMarkClock(t, 0.5, 30), -lead); assert.equal(seg.sourceFrom, -lead); const stamp = s.factcheck.stamps.find((x) => x.claim === "x-d28"); assert.equal(stamp.landed, Math.round((seg.start + lead + 1) * 1000) / 1000); }); test("a teaser's untimed mark lands as a clip's does, before the card leaves; two marks keep their hold apart", () => { const s = estimateSchedule(manifest(card({ claim: { id: "x-d28", verdict: "CENTER" } }))); const seg = s.segments[1]; const stamp = s.factcheck.stamps.find((x) => x.claim === "x-d28"); assert.ok(stamp.landed > seg.start && stamp.landed <= seg.end, JSON.stringify({ stamp, seg })); const close = card({ claims: [{ id: "a", verdict: "CENTER", at: 1 }, { id: "b", verdict: "LEFT", at: 2 }] }); assert.match(validateClaims(manifest(close))[0], /timeline\[1\] \(x-d28\)\.claims: the marks a \(at 1\) and b \(at 2\) overlap/); });