// deck.mjs deckLayout: a crowded band (two rows of marker labels and the // section title) keeps its title and byline INSIDE the band -- the byline was // cut off at the frame's foot in the mr-obvious cut (2 Nov) -- and the // section title's line keeps clear of them; an uncrowded band is as it was. import assert from "node:assert/strict"; import { test } from "node:test"; import { deckLayout, deckSchedule, estimatedDuration, markerRowsOf } from "./deck.mjs"; const post = (i) => ({ type: "post", id: `p-${i}`, post: `c-x/${i}`, platform: "x", author: "A", handle: "a", date: "2026-10-30T04:00:00Z", text: "six words of a short post" }); const timeline = Array.from({ length: 40 }, (_, i) => post(i + 1)); const render = (deck) => ({ width: 1920, height: 1080, fps: 30, transition: 0.4, palette: { bg: "#000", fg: "#fff", muted: "#888", accent: "#c8752a" }, chrome: { engine: "hyperframes", layout: "deck", deck }, }); // Five sections whose labels crowd each other: they stagger into two rows. const markers = [["p-3", "Joins the story"], ["p-6", "Strawb, Kirsche's fans"], ["p-8", "A Dox for a Dox"], ["p-10", "Answering critics"], ["p-12", "One Dox away"]].map(([after, label]) => ({ after, label })); test("a crowded band: two rows of labels and the section title -- the byline stays inside the band, the line clear of it", () => { const r = render({ markers, sectionTitle: { first: "Before the story" } }); const durs = timeline.map((e) => estimatedDuration(e, r)); const schedule = deckSchedule({ entries: timeline, durs, D: 0.4, render: r, estimated: true }); assert.equal(markerRowsOf(schedule, r), 2); const L = deckLayout(r, { schedule }); assert.ok(L.text.subtitleY + L.text.subtitleBox <= L.height, `${L.text.subtitleY + L.text.subtitleBox} > ${L.height}`); assert.ok(L.text.titleY > L.pipTrack.y); // The line stands right of the title column (at most 36% of the width) and keeps centred. assert.ok(L.sectionTitle.x >= L.text.x + Math.round(1920 * 0.36), JSON.stringify(L.sectionTitle)); assert.equal(L.sectionTitle.x + L.sectionTitle.width / 2, 960); }); test("an uncrowded band lays out as it did", () => { const r = render({ markers: [], sectionTitle: { first: "Before the story" } }); const L = deckLayout(r, {}); assert.equal(L.sectionTitle.x, 268); assert.equal(L.sectionTitle.width, 1384); const plain = deckLayout(render({}), {}); assert.equal(plain.text.titleY, 49); });