// lane/thread-scenes: whole-thread reads (every ancestor read, oldest first), the read in DATE order, context // posts with attachments, manual threads (`thread.group`), the join between items, the branch map, link visits. import assert from "node:assert/strict"; import { test } from "node:test"; import { postCardHtml, postItemPlan, validatePostItem } from "./post-item.mjs"; import { followPath, readInViewErrors, shotStateAt } from "./read-follow.mjs"; import { partRoles, roleOrderOf, threadLayout, threadReadErrors } from "./post-thread.mjs"; const at = (h) => `2026-11-02T${String(h).padStart(2, "0")}:00:00.000Z`; const ref = (id, handle, text, h, o = {}) => ({ id, author: handle, handle, date: at(h), text, ...o }); const base = (o = {}) => ({ type: "post", id: "p-1", post: "acct-x/1001", platform: "x", author: "Subject", handle: "subject", date: at(20), text: "I was simply offering advice to everyone in the community today.", ...o }); /** A take of pieces in order (para = piece * 100 + paragraph), each paragraph a part. */ export function take(pieces, { roles = false } = {}) { const parts = []; let t = 0; pieces.forEach(([text, role], pi) => { text.split(/\n\n/).forEach((para, k) => { const seconds = Math.round((para.split(/\s+/).length / 3) * 100) / 100; t += parts.length ? (k === 0 ? 0.8 : 0.6) : 0; parts.push({ n: parts.length + 1, para: pi * 100 + k, text: para, start: Math.round(t * 100) / 100, seconds, ...(roles && role ? { role } : {}) }); t += seconds; }); }); return { file: "narration/posts/1001/take-1.wav", engine: "orpheus", voice: "leo+zac", seconds: Math.round(t * 100) / 100, script: pieces.map((p) => p[0]).join("\n\n"), parts }; } export const narrate = (e, pieces, o) => ({ ...e, narration: { script: e.text, takes: [take(pieces, o)], pick: 0 } }); export function fakeGeo(plan, { H = 520, line = 44 } = {}) { const blocks = {}; const tiles = {}; let y = 0; for (const scope of plan.follow.thread.tiles.map((t) => t.scope)) { const top = y; y += 70; for (const b of plan.follow.blocks.filter((x) => x.scope === scope)) { const h = Math.max(1, Math.ceil((b.to - b.from + 1) / 6)) * line; blocks[b.k] = { top: y, bottom: y + h }; y += h + line; } tiles[scope] = { top, height: y - top }; y += 22; } return { H, C: y, blocks, tiles }; } const ROOT = "I was hit by my own brother and it hurt. I am real close to going atomic."; const Q = "Lol what? You playing games with all of us again tonight?"; const G = "Yes, that phrasing can be viewed as a threat under the law in most places."; test("WHOLE-THREAD READ: three ancestors read oldest first, then his words -- roles parent:2, parent:1, parent:0, post; each tile in full while read, then shrunk; the invariant holds", () => { const parents = [ref("3", "grok", G, 19), ref("2", "asker", Q, 18), ref("1", "subject", ROOT, 17)]; const e = narrate(base({ parents }), [[ROOT], [Q], [G], [base().text]]); assert.deepEqual(partRoles(e).map((r) => r.role), ["parent:2", "parent:1", "parent:0", "post"]); assert.deepEqual(validatePostItem(e), []); const L = threadLayout(e); assert.deepEqual(L.tiles.map((t) => [t.scope, t.mode]), [["parent:2", "full"], ["parent:1", "full"], ["parent:0", "full"], ["post", "full"]]); assert.deepEqual(threadReadErrors(e), []); const plan = postItemPlan(e, { postNarration: { lead: 0.4 } }); const th = plan.follow.thread; // The oldest opens the card; each later one revealed as its piece starts, each earlier one shrunk as the next starts. const row = (sc) => th.tiles.find((t) => t.scope === sc); assert.deepEqual(row("parent:2").from, [1, 1]); assert.deepEqual(row("parent:1").from, [1, 0]); assert.ok(row("parent:1").then, "parent:1 shrinks once parent:0 is read"); const geo = fakeGeo(plan, { H: 400 }); const path = followPath(plan.follow, geo); assert.deepEqual(readInViewErrors(plan.follow, geo, shotStateAt(plan.follow, path, 30), { total: plan.total, id: e.id }), []); }); test("THE READ IN DATE ORDER (operator, 4 Nov: D): a quoted take older than the post he answers is read first and drawn first -- the quote, the parent, his words", () => { const take0 = "Here is my take on the whole situation, in two points."; const kirsche = "I hate watching people defend the very tactics that lead to that happening."; const e0 = base({ date: at(19), quoted: { author: "Subject", handle: "subject", date: at(16), text: take0 }, parents: [ref("2115500212617703691", "kirsche", kirsche, 17)] }); assert.deepEqual(["quoted", "parent:0", "post"].map(roleOrderOf(e0)), [1, 2, 3]); const e = narrate(e0, [[take0], [kirsche], [e0.text]]); assert.deepEqual(partRoles(e).map((r) => r.role), ["quoted", "parent:0", "post"]); const L = threadLayout(e); assert.deepEqual(L.tiles.map((t) => t.scope), ["quoted", "parent:0", "post"]); assert.equal(L.quotedAt, "above"); const plan = postItemPlan(e, { postNarration: { lead: 0.4 } }); const html = postCardHtml(e, { width: 1600, height: 900, follow: true, thread: plan.follow.thread }); assert.ok(html.indexOf('data-thread-slot="quoted"') < html.indexOf('data-thread-slot="parent:0"'), "the quote drawn above the parent"); const geo = fakeGeo(plan, { H: 400 }); assert.deepEqual(readInViewErrors(plan.follow, geo, shotStateAt(plan.follow, followPath(plan.follow, geo), 30), { total: plan.total, id: e.id }), []); }); test("AN IMAGE-ONLY REPLY is a tile, never read -- picture-only (post-picture.mjs): its picture in its tile, in full; `pictureOnly: false`: its head and a chip, as context; a parent's attachment is a file the lint checks", () => { const e = narrate(base({ parents: [ref("9", "furri", "", 19, { media: [{ src: "posts-media/f/9/9_1.jpg", kind: "image", width: 600, height: 800 }] }), ref("1", "subject", ROOT, 17)] }), [[base().text]]); assert.deepEqual(validatePostItem(e), []); const L = threadLayout(e); assert.deepEqual(L.tiles.map((t) => [t.scope, t.mode]), [["parent:1", "context"], ["parent:0", "full"], ["post", "full"]]); assert.match(postCardHtml(e, { width: 1600, height: 900, follow: true, thread: L }), /data-post-parent="0"[^>]*>.*data-post-pic="parent:0"/s); const off = { ...e, parents: [{ ...e.parents[0], pictureOnly: false }, e.parents[1]] }; const L0 = threadLayout(off); assert.deepEqual(L0.tiles.map((t) => [t.scope, t.mode]), [["parent:1", "context"], ["parent:0", "context"], ["post", "full"]]); const html = postCardHtml(off, { width: 1600, height: 900, follow: true, thread: L0 }); assert.match(html, /data-post-parent="0"[^>]*>.*data-thread-media="1">photo 0, true); }); import { conversationRuns, gatheredOrder, planContext } from "./post-conversation.mjs"; const said = (id, text, h, o = {}) => narrate(base({ id: `p-${id}`, post: `subj-x/${id}`, text, date: at(h), ...o }), [[text]]); test("A MANUAL THREAD (thread.group): consecutive items of one group are one run -- the opening post shown (not read) and three of his, unlinked on X -- every earlier post kept on screen, oldest first, each reply saying what it answers", () => { const g = { group: "jiggle" }; const movail = base({ id: "p-m", post: "mov-x/2117295478345998503", author: "Movail", handle: "Movail2", text: "Ready for more lessons?", date: at(16), thread: g }); const tl = [ { type: "clip", id: "c-0" }, movail, said("6841", "Phat ass jiggle, oh my god.", 22, { thread: g, post: "subj-x/2117379977360326841" }), said("4063", "It jiggle.", 22, { thread: g, parents: [ref("2117379977360326841", "subject", "Phat ass jiggle, oh my god.", 22)] }), said("0390", "it jiggle, oh my god, i literally cannot, hypnotism", 23, { thread: g, parents: [ref("2117295478345998503", "Movail2", "Ready for more lessons?", 16)] }), said("9999", "Something else entirely.", 23), ]; const { runOf } = conversationRuns(tl); assert.deepEqual(runOf, [-1, 0, 0, 0, 0, 1]); const last = planContext(tl, 4); assert.equal(last.scene.group, "jiggle"); assert.deepEqual(last.scene.tiles.map((t) => [t.id, t.action]), [["2117295478345998503", "keep"], ["2117379977360326841", "keep"], ["4063", "keep"]]); // His last message draws the stack: Movail2's post (its own parent:0 -- one tile), the two before, his words. const L = threadLayout(tl[4], undefined, last); assert.deepEqual(L.tiles.map((t) => t.scope), ["parent:0", "conv:2117379977360326841", "conv:4063", "post"]); // The relations: "It jiggle." answers the post above; his last answers Movail2's post, three tiles up. const L3 = threadLayout(tl[3], undefined, planContext(tl, 3)); assert.deepEqual(L3.tiles.find((t) => t.scope === "post").rel, { to: "subject", above: true, id: "2117379977360326841" }); assert.deepEqual(L.tiles.find((t) => t.scope === "post").rel, { to: "Movail2", above: false, id: "2117295478345998503" }); const html = postCardHtml(tl[4], { width: 1600, height: 900, follow: true, thread: postItemPlan(tl[4], undefined, last).follow.thread }); assert.match(html, /data-thread-rel="branch">replying to @xxxxxxxx<\/span>/); }); test("A MANUAL THREAD is gathered in DATE order (timeline threads --write): the group at its first item's place, the other conversations after it in their order", () => { const g = { group: "grok" }; const tl = [ said("72", "She better watch her back.", 10, { thread: g }), said("73", "I meant it as advice.", 12, { thread: g }), said("74", "Another conversation.", 11), said("75", "And another one.", 13), said("78", "I was simply offering advice.", 14, { thread: g }), said("80", "Last word.", 16, { thread: g }), said("79", "Do you agree?", 15, { thread: g }), ]; const { ids } = gatheredOrder(tl); assert.deepEqual(ids, ["p-72", "p-73", "p-78", "p-79", "p-80", "p-74", "p-75"]); }); import { panelEntry, panelOf, postLayout, validatePostItems } from "./post-item.mjs"; test("A WIDE ATTACHMENT (operator, 4 Nov: \"a top-bottom layout would be better\"): 692×141 is laid at full width above the card; the cut's rule (wide, place) and the item's panel override", () => { const wide = base({ media: [{ src: "posts-media/a/1.png", kind: "image", width: 692, height: 141 }] }); const box = { width: 1920, height: 1080 }; assert.equal(panelOf(wide), "top"); const L = postLayout(wide, box); assert.equal(L.mode, "side"); assert.equal(L.panel, "top"); assert.ok(L.slot.width > 1800 && L.slot.y < L.card.y, "the picture across the top, the card under it"); assert.ok(L.slot.height <= Math.round(1080 * 0.42) && L.card.y + L.card.height <= 1080); // A picture that is not wide stays beside the card; `panel` overrides either way. assert.equal(panelOf(base({ media: [{ src: "a.png", kind: "image", width: 800, height: 600 }] })), "side"); assert.equal(postLayout({ ...wide, panel: "side" }, box).panel, "side"); assert.equal(postLayout({ ...wide, panel: "bottom" }, box).slot.y > 500, true); // The cut's rule: a stricter threshold keeps it beside; place bottom. assert.equal(postLayout(panelEntry(wide, { posts: { panel: { wide: 6 } } }), box).panel, "side"); assert.equal(postLayout(panelEntry(wide, { posts: { panel: { place: "bottom" } } }), box).panel, "bottom"); assert.match(validatePostItems({ render: { posts: { panel: { wide: 0.5 } } }, timeline: [] }).join(" "), /panel\.wide must be/); // The card is drawn in its box under the picture. const html = postCardHtml(wide, { width: 1920, height: 1080 }); assert.match(html, new RegExp(`data-post-slot="" style="left:${L.slot.x}px;top:${L.slot.y}px;width:${L.slot.width}px`)); }); import { panelReadErrors, panelSchedule, scrollAt, showOpacityAt } from "./post-thread.mjs"; import { postSegmentArgs, scrollExpr } from "./post-render.mjs"; test("THE PANEL: a context post's picture over the slot while it is read; an image-only reply shown at least a beat; with no attachment of his own the last one held; a slot laid out for it", () => { const pic = { src: "posts-media/b/1/baby.mp4", kind: "video", width: 720, height: 1280, seconds: 9 }; const root = ref("1", "subject", "a video of my baby girl, pretty sure she's trying to eat me", 17, { media: [pic] }); const e = narrate(base({ parents: [ref("2", "panda", "There is an acceptable level of crazy cat behaviour and this is it.", 18), root] }), [[root.text], ["There is an acceptable level of crazy cat behaviour and this is it."], [base().text]]); const L = postLayout(e, { width: 1920, height: 1080 }); assert.equal(L.mode, "side", "his reply has no attachment: the slot is for the root's video"); const plan = postItemPlan(e, { postNarration: { lead: 0.4 } }); assert.equal(plan.panel.shows.length, 1); const sh = plan.panel.shows[0]; assert.equal(sh.scope, "parent:1"); assert.equal(sh.t0, 0); assert.equal(sh.t1, plan.total, "held to the end: he carries none"); assert.equal(showOpacityAt(sh, 0.1), 1); // Over his own attachment: from its piece until his words come. const own = { ...e, media: [{ src: "posts-media/b/2/own.jpg", kind: "image", width: 800, height: 800 }] }; const p2 = postItemPlan(own, { postNarration: { lead: 0.4 } }); const post = p2.follow.blocks.find((b) => b.scope === "post"); assert.ok(Math.abs(p2.panel.shows[0].t1 - (post.start - 0.4)) < 0.01); // The build lays it over the slot, crossfaded out. const argv = postSegmentArgs({ entry: own, box: { width: 1920, height: 1080 }, plan: p2, layout: postLayout(own, { width: 1920, height: 1080 }), cards: { read: "r.png" }, files: ["own.jpg"], render: { fps: 30 }, outPath: "o.mp4", panelFiles: [["baby.mp4"]] }); const fc = argv[argv.indexOf("-filter_complex") + 1]; assert.match(fc, /fade=t=out:st=[\d.]+:d=0\.3:alpha=1\[pn0_0\]/); assert.ok(argv.includes("baby.mp4")); }); test("A LINKED POST's PICTURE READ THROUGH (H): its transcript's parts are picture blocks; the tall screenshot scrolls top to foot as they are read; the guard names a part read while the panel is elsewhere", () => { const dm = "first line of the messages he sent\n\nsecond line of the messages he sent\n\nthird and last line of them"; const link = { id: "2116805001309823299", handle: "Infinity_Virus_", author: "Infinity", date: at(8), text: "Ya try to be civil and they go insane", transcript: dm, media: [{ src: "posts-media/iv/1.jpg", kind: "image", width: 600, height: 4029 }] }; const saber = ref("5", "SaberXVeritas", "this you? https://x.com/Infinity_Virus_/status/2116805001309823299", 9); const e = narrate(base({ parents: [saber], links: [link] }), [["this you?", "parent:0"], ["Ya try to be civil and they go insane", "linked:0"], [dm, "linked:0"], [base().text, "post"]], { roles: true }); assert.deepEqual(validatePostItem(e), []); const plan = postItemPlan(e, { postNarration: { lead: 0.4 } }); const pics = plan.follow.blocks.filter((b) => b.pic); assert.equal(pics.length, 3); const sh = plan.panel.shows.find((x) => x.scope === "linked:0"); assert.ok(sh.scroll.length >= 4); assert.equal(scrollAt(sh.scroll, sh.t0), 0); assert.equal(scrollAt(sh.scroll, plan.total), 1); assert.ok(scrollAt(sh.scroll, pics[1].start + 0.5) > 0.2 && scrollAt(sh.scroll, pics[1].start + 0.5) < 0.8); assert.match(scrollExpr(sh.scroll), /^if\(lt\(t,/); assert.deepEqual(panelReadErrors(plan.follow, plan.panel, { id: e.id }), []); assert.match(panelReadErrors(plan.follow, { shows: [] }, { id: e.id }).join(" "), /reads the picture of linked:0/); }); import { joinFrameAt, joinKnobs, endMediaOf } from "./post-join.mjs"; import { followStateAt, isDrawnState } from "./read-follow.mjs"; import { mediaTimeAt, stepAt } from "./post-item.mjs"; test("THE JOIN (operator, 4 Nov: \"a thread-like smooth transition here rather than a cut\"): an item of a run opens on the item before as it ended -- its read after the join's seconds, the card morphing from that item's box, the post it ended on carried in drawn as it was", () => { const root = said("1", "You all have low testosterone, if I go an entire week I become bestial.", 10); const ryobi = ref("2", "Ryobi_404", "Three days is enough to make me feel like a completely different person.", 11); const reply = narrate(base({ id: "p-2", post: "subj-x/2", date: at(12), parents: [ryobi, ref("1", "subject", root.text, 10)] }), [[ryobi.text], [base().text]]); const tl = [root, reply]; const ctx = planContext(tl, 1, { postNarration: { lead: 0.25 } }); assert.deepEqual(ctx.join, { seconds: 0.6 }); assert.equal(planContext(tl, 0).join, null, "the first of a run cuts in"); const plain = postItemPlan(reply, { postNarration: { lead: 0.25 } }, { ...ctx, join: null }); const plan = postItemPlan(reply, { postNarration: { lead: 0.25 } }, ctx); assert.equal(plan.narration.at, 0.85, "the read starts after the join"); assert.ok(Math.abs(plan.total - plain.total - 0.6) < 0.01, "the item a join longer"); assert.equal(plan.follow.join.seconds, 0.6); assert.equal(followStateAt(plan.follow, null, 0.3).join, 0.5); assert.equal(followStateAt(plan.follow, null, 0.7).join, undefined); assert.equal(isDrawnState({ op: {}, offset: 0, join: 0 }), false); // The carried post is drawn as his post was (head and words), marked as the join's anchor. const html = postCardHtml(reply, { width: 1600, height: 900, follow: true, thread: plan.follow.thread, join: { A: { x: 10, y: 10, width: 800, height: 500 }, size: 40 } }); assert.match(html, /class="tile tpost tcarry" data-thread-tile="parent:1" data-thread-mode="carry" data-post-parent="1" data-join-anchor="">/); assert.match(html, /data-join="\{/); // The frame: at 0 the item before's box and its card; at 1 its own; the content cross-fades. const g = { A: { x: 0, y: 100, width: 800, height: 400 }, B: { x: 400, y: 0, width: 1200, height: 900 }, slotA: { x: 900, y: 0, width: 900, height: 900 }, slotB: null }; const f0 = joinFrameAt(g, 0); assert.deepEqual([f0.R, f0.from.op, f0.own.op, f0.slotFrom], [g.A, 1, 0, 1]); const f1 = joinFrameAt(g, 1); assert.deepEqual([f1.R, f1.from.op, f1.own.op, f1.own.s, f1.slotFrom], [g.B, 0, 1, 1, 0]); assert.equal(joinKnobs({ join: false }).on, false); assert.equal(joinKnobs({}, { posts: { join: { seconds: 1 } } }).seconds, 1); // What the item before ended on: a video held on its last frame, sought a little before its end. const vplan = { total: 10, steps: [{ kind: "video", at: 0, seconds: 9.6, srcFrom: 0, srcTo: 9.6, items: [{ i: 0, src: "v.mp4", kind: "video", seconds: 9.6 }] }] }; assert.deepEqual(endMediaOf(vplan, { stepAt, mediaTimeAt }).map((x) => [x.m.src, x.t]), [["v.mp4", 9.48]]); }); import { linkVisits, visitStateAt } from "./post-link-visit.mjs"; test("A LINK VISIT: his reply ends \"Here's my take on it. \" to his own take, read first (in date order) -- once the link is read the pointer clicks it and the take is lit again, full, for its hold; the item holds it", () => { const takeText = "Here is my take on the whole situation, in two points."; const kirsche = "I hate watching people defend the very tactics that lead to that happening."; const words = "Kirsche you're wrong on this one, strawb seems like a traitor.\n\nHere's my take on it.\n\nhttps://x.com/subject/status/2115473673671020640"; const e = narrate(base({ date: at(19), text: words, quoted: { author: "Subject", handle: "subject", date: at(16), text: takeText }, parents: [ref("2115500212617703691", "kirsche", kirsche, 17)] }), [[takeText], [kirsche], ["Kirsche you're wrong on this one, strawb seems like a traitor.\n\nHere's my take on it."]]); const plan = postItemPlan(e, { postNarration: { lead: 0.4 } }); assert.deepEqual(plan.follow.visits.map((v) => [v.from, v.to, v.id, v.open]), [["post", "quoted", "2115473673671020640", false]]); const v = plan.follow.visits[0]; assert.ok(plan.total >= v.at + v.hold, "the item holds the visit"); const st = visitStateAt(plan.follow.visits, v.at + 0.6); assert.equal(st.ring, 1); const row = plan.follow.thread.tiles.find((t) => t.scope === "quoted"); assert.deepEqual(followStateAt(plan.follow, null, v.at + 0.6).tiles.quoted.slice(0, 2), [1, 1]); assert.ok(row.pulse); const html = postCardHtml(e, { width: 1600, height: 900, follow: true, thread: plan.follow.thread }); assert.match(html, //); const geo = fakeGeo(plan, { H: 400 }); assert.deepEqual(readInViewErrors(plan.follow, geo, shotStateAt(plan.follow, followPath(plan.follow, geo), 30), { total: plan.total, id: e.id }), []); }); test("A LINK VISIT that OPENS: SaberXVeritas's \"this you? \", then the linked post read -- the click lands as it comes in", () => { const link = { id: "2116805001309823299", handle: "Infinity_Virus_", author: "Infinity", date: at(8), text: "Ya try to be civil and they go insane" }; const saber = ref("5", "SaberXVeritas", "this you? https://x.com/Infinity_Virus_/status/2116805001309823299", 9); const e = narrate(base({ parents: [saber], links: [link] }), [["this you?", "parent:0"], ["Ya try to be civil and they go insane", "linked:0"], [base().text, "post"]], { roles: true }); const plan = postItemPlan(e, { postNarration: { lead: 0.4 } }); assert.deepEqual(plan.follow.visits.map((v) => [v.from, v.to, v.open]), [["parent:0", "linked:0", true]]); const row = plan.follow.thread.tiles.find((t) => t.scope === "linked:0"); assert.equal(plan.follow.visits[0].at, row.t0); }); import { mapPageHtml, mapPlace, mapSize, mapStateAt } from "./post-branch-map.mjs"; test("THE BRANCH MAP (operator, 4 Nov: \"a specific visual for changing thread branches\"): the sibling swap draws the run's posts as a tree, the light travelling from the post the item before ended on up to his root and down to the new reply; the label says it", () => { const ROOTP = ref("771", "subject", "Many have questioned my methods in dealing with the whole mess.", 6); const FOX = ref("834", "fox_one", "Far as people should be concerned you are no better than them.", 7); const DRAC = ref("775", "drac_two", "Oh please, you were never going to change anything here.", 6); const p11 = narrate(base({ id: "p-11", post: "subj-x/11", date: at(10), text: "I feel like I've failed everyone.", parents: [ROOTP] }), [["I feel like I've failed everyone."]]); const p12 = narrate(base({ id: "p-12", post: "subj-x/12", date: at(11), text: "You are nobody at all.", parents: [FOX, ref("11", "subject", p11.text, 10)] }), [[FOX.text], ["You are nobody at all."]]); const p13 = narrate(base({ id: "p-13", post: "subj-x/13", date: at(12), text: "Who are you to tell me.", parents: [DRAC, ROOTP] }), [[DRAC.text], ["Who are you to tell me."]]); const tl = [p11, p12, p13]; const L = threadLayout(p13, undefined, planContext(tl, 2)); assert.deepEqual(L.map.path, ["12", "834", "11", "771", "775"]); assert.equal(L.map.label, "another reply to his post"); // No map where the scene does not change branch (p-12 reads the reply to the post the item before ended on). assert.equal(threadLayout(p12, undefined, planContext(tl, 1)).map, undefined); const plan = postItemPlan(p13, undefined, planContext(tl, 2)); const m = plan.follow.thread.map; assert.ok(m.times.t0 >= 0.6 - 1e-6, "after the join"); assert.deepEqual(mapStateAt(m, m.times.travel), { op: 1, p: 0 }); assert.equal(mapStateAt(m, m.times.travel + 1.1).p, 1); assert.equal(followStateAt(plan.follow, null, m.times.travel + 0.5).map.op, 1); // Its own layer, never over words being read: over the slot, else beside a card alone. const html = mapPageHtml(m, { width: 300, height: 200 }); assert.match(html, /data-thread-map="both"/); assert.match(html, /another reply to his post/); assert.doesNotMatch(postCardHtml(p13, { width: 1600, height: 900, follow: true, thread: plan.follow.thread }), /data-thread-map/); const size = mapSize(m); const side = { mode: "side", card: { x: 36, y: 36, width: 700, height: 1008 }, slot: { x: 772, y: 36, width: 1112, height: 1008 } }; assert.deepEqual(mapPlace(side, { width: 1920, height: 1080 }, size), { x: 788, y: 52 }); const alone = { mode: "text", card: { x: 370, y: 36, width: 1180, height: 1008 }, slot: null }; assert.equal(mapPlace(alone, { width: 1920, height: 1080 }, size).x, 370 + 1180 + 32); // Off for the item, or a label only. assert.equal(threadLayout({ ...p13, thread: { map: false } }, undefined, planContext(tl, 2)).map, undefined); assert.equal(threadLayout({ ...p13, thread: { map: "label" } }, undefined, planContext(tl, 2)).map.style, "label"); }); import { chronoPieces } from "./post-thread.mjs"; test("chronoPieces: what a batch reads, oldest first -- his take (16:00), Kirsche (17:45), his reply (19:03); a carried post skipped", () => { const e = base({ date: at(19), text: "Kirsche you're wrong on this one.", quoted: { author: "Subject", handle: "subject", date: at(16), text: "Here is my take." }, parents: [ref("2", "kirsche", "I hate watching it.", 17)] }); assert.deepEqual(chronoPieces(e).map((p) => p.role), ["quoted", "parent:0", "post"]); assert.deepEqual(chronoPieces(e, { skip: ["parent:0"] }).map((p) => p.role), ["quoted", "post"]); });