// THE JOIN's continuity (operator, 4 Nov, on mid-7 at 2357 s: "the transition from some posts hard cutting into the // same post with children should be addressed. If one post is visible in the next scene, there should be a // transition"): the item opens EXACTLY as the item before ended -- its card, what only it drew (its counts, its quote, // its clock) dissolving rather than gone at the second frame -- and the check that measures it (check-joins.mjs). import assert from "node:assert/strict"; import { test } from "node:test"; import { JOIN_CLOCK_NEAR, joinClockOf, joinFrameAt, joinOpacities } from "./post-join.mjs"; import { clockJoinExpr, concatRate, postSegmentArgs, postSegmentKey, postSegmentKeyOf, POST_JOIN_DRAW_V } from "./post-render.mjs"; import { joinCarryOf, postCardHtml, postItemPlan } from "./post-item.mjs"; import { planContext } from "./post-conversation.mjs"; const at = (h) => `2026-11-04T${String(h).padStart(2, "0")}:00:00.000Z`; const narrate = (e, parts) => ({ ...e, narration: { takes: [{ file: `narration/${e.id}.wav`, seconds: 6, parts: parts.map((p) => ({ text: p.join(" ") })) }], picked: 0 } }); const post = (id, text, h, extra = {}) => ({ type: "post", id: `p-${id}`, post: `ObviousRises-x/${id}`, platform: "x", author: "MR. OBVIOUS", handle: "ObviousRises", date: at(h), text, url: `https://x.com/ObviousRises/status/${id}`, ...extra }); const ref = (id, text, h) => ({ id, author: "MR. OBVIOUS", handle: "ObviousRises", date: at(h), text }); test("THE DISSOLVE: at the boundary the item before's card is whole and on top; this one is in under it before it starts to go; what both draw never dims", () => { // The first frames (e ~ 0): the item before, exactly. assert.deepEqual(joinOpacities(0, true), { own: 1, from: 1 }); assert.deepEqual(joinOpacities(0, false), { own: 0, from: 1 }); // Never a frame where the item before's card is gone at once (main's `same` dropped it after the first frame). const g = { A: { x: 100, y: 100, width: 968, height: 554 }, B: { x: 100, y: 0, width: 968, height: 787 }, slotA: null, slotB: null, same: true }; assert.equal(joinFrameAt(g, 1 / 18).from.op, 1, "the second frame still shows what the item before showed"); // This card is whole before the item before's starts to fade: over it, the shared post is lit throughout. for (let e = 0; e <= 1.0001; e += 0.05) { const o = joinOpacities(e, false); if (o.from < 1) assert.equal(o.own, 1, `at e ${e.toFixed(2)} this card is in before that one fades`); } assert.deepEqual(joinOpacities(1, false), { own: 1, from: 0 }); assert.ok(joinFrameAt(g, 0.9).from.op === 0, "gone well before the join ends"); }); test("THE CLOCK OVER A JOIN: near, it carries on (moved the little way); apart, the item before's is laid in its shot and dissolves, this one comes in -- never across the card's words", () => { assert.deepEqual(joinClockOf({ from: { x: 100, y: 200 }, own: { x: 110, y: 190 }, k: 1 }), { bake: false, move: { dx: -10, dy: 10 }, fadeIn: false }); // mid-7 at 2357 s: the card's foot (bottom-right) to above the card (top-right). assert.deepEqual(joinClockOf({ from: { x: 1050, y: 620 }, own: { x: 1050, y: 20 }, k: 886 / 1080 }), { bake: true, move: null, fadeIn: true }); assert.deepEqual(joinClockOf({ from: null, own: { x: 1, y: 1 } }), { bake: false, move: null, fadeIn: true }); assert.deepEqual(joinClockOf({ from: { x: 1, y: 1 }, own: null }), { bake: true, move: null, fadeIn: false }); assert.deepEqual(joinClockOf({ from: null, own: null }), { bake: false, move: null, fadeIn: false }); assert.ok(JOIN_CLOCK_NEAR > 0); // The move's expression: base + d at the start, base from the join's end. const ex = clockJoinExpr(900, -12, 0.6); // ffmpeg's expression, evaluated as ffmpeg would (if, lt, min, pow). const ev = (t) => Function("t", "min", "pow", "lt", "iff", `return ${ex.replace(/\bif\(/g, "iff(")};`)(t, Math.min, Math.pow, (a, b) => a < b, (c, a, b) => (c ? a : b)); assert.equal(ev(0), 888); assert.equal(ev(0.6), 900); assert.equal(ev(2), 900); }); test("THE SEGMENT's CLOCK over a join: moved from the item before's place (an expression on t), or faded in -- a clock with no join drawn as before", () => { const plan = { total: 10, steps: [], reading: 10 }; const base = { entry: { id: "p-1", media: [] }, box: { width: 1574, height: 886 }, plan, layout: { mode: "text", slot: null }, cards: { read: "read.png" }, files: [], render: { fps: 30 }, outPath: "out.mp4" }; const graph = (clock) => postSegmentArgs({ ...base, clock }).find((a) => String(a).includes("[clk]overlay")); const plain = graph({ list: "c.ffconcat", x: 900, y: 600, until: 10 }); assert.match(plain, /\[clk\]overlay=x=900:y=600:eof_action=repeat/); assert.doesNotMatch(plain, /fade=t=in/); const moved = graph({ list: "c.ffconcat", x: 900, y: 600, until: 10, join: { seconds: 0.6, from: { dx: 0, dy: 14 }, fadeIn: false } }); assert.match(moved, /overlay=x=900:y='600\+14\*\(1-if\(lt\(min\(1,t\/0\.6\),0\.5\)/); const faded = graph({ list: "c.ffconcat", x: 900, y: 20, until: 10, join: { seconds: 0.6, from: null, fadeIn: true } }); assert.match(faded, /fade=t=in:st=0:d=0\.6:alpha=1\[clk\]/); assert.match(faded, /overlay=x=900:y=20:/); }); test("THE CARRIED POST drawn as a PLAIN card drew it: its head at the card's size (not the words'), its words a card's gap below; after a threaded card, its head at that card's words box size", () => { const before = post("10", "I'm only giving mercy because I'm concerned for my moms.", 7); const reply = narrate(post("11", "notice how thats the exact character limit", 8, { parents: [ref("10", before.text, 7)], thread: { group: "limit" } }), [["notice how thats the exact character limit"]]); const tl = [narrate(before, [[before.text]]), reply]; const ctx = planContext(tl, 1); const plan = postItemPlan(reply, undefined, ctx); const html = (plain, headSize = null) => postCardHtml(reply, { width: 1574, height: 886, follow: true, thread: plan.follow.thread, join: { A: { x: 10, y: 10, width: 800, height: 500 }, size: 38, plain, headSize } }); assert.match(html(true), /class="tile tpost tcarry tplain"/); assert.match(html(true), /\.tplain > \.head \{ font-size: 16px; line-height: normal; \}/); assert.match(html(false), /class="tile tpost tcarry" /); // A threaded card before: its head at its own words box's size, not this card's. assert.match(html(false, 41), /data-join-anchor="">
/); assert.doesNotMatch(html(true, 41), /font-size:41px/); }); test("THE KEY: a joined item's key carries the join's drawing and the clock the item before ran -- its key changes; an item with no join keeps the key it had", () => { const entry = post("11", "notice how", 8); const plan = { narration: null, follow: null, total: 5, steps: [] }; const common = { entry, box: { width: 1574, height: 886 }, render: { fps: 30, palette: {} }, plan }; const none = postSegmentKeyOf(common); assert.equal(none.joinFrom, undefined); const from = { entry: post("10", "mercy", 7), plan: { follow: null, total: 15.9 }, media: [], fadeIn: false, clock: { to: 1, from: null, mode: "none", zone: "America/New_York", gap: 0, forced: false } }; const joined = postSegmentKeyOf({ ...common, from }); assert.equal(joined.joinFrom.jv, POST_JOIN_DRAW_V); assert.deepEqual(joined.joinFrom.clock, from.clock); const other = postSegmentKeyOf({ ...common, from: { ...from, clock: { ...from.clock, to: 2 } } }); assert.notEqual(postSegmentKey(joined), postSegmentKey(other), "the item before's clock is in the key"); assert.notEqual(postSegmentKey(joined), postSegmentKey(none)); }); test("A FRAMES LIST reads each shot at the item's rate (ffconcat `option framerate`): no shot in six dropped and its neighbour held", () => { assert.deepEqual(concatRate(30), ["option framerate 30"]); }); test("HOW AN ITEM DRAWS ITS POST (joinCarryOf): a plain card's words and head; a threaded card's post tile size and its words box's head -- the build draws the item before's page with its own join this way, as its segment drew it", () => { const box = { width: 1574, height: 886 }; const before = narrate(post("10", "I'm only giving mercy because I'm concerned for my moms.", 7), [["I'm only giving mercy because I'm concerned for my moms."]]); const reply = narrate(post("11", "notice how thats the exact character limit", 8, { parents: [ref("10", before.text, 7)], thread: { group: "limit" } }), [["notice how thats the exact character limit"]]); const plain = joinCarryOf(before, postItemPlan(before), box); assert.equal(plain.plain, true); assert.equal(plain.headSize, null); const tl = [before, reply]; const threaded = joinCarryOf(reply, postItemPlan(reply, undefined, planContext(tl, 1)), box); assert.equal(threaded.plain, false); assert.ok(threaded.size > 0 && threaded.headSize > 0); });