// Tests for the deck composition (chrome-deck.mjs) and compose-chrome's deck // path: the page has every segment's nodes, the timeline's times are // deckChoreography's, nothing leaves the machine, and the render cache skips // what it should. // // Run with: pnpm test:scripts import assert from "node:assert/strict"; import { spawnSync } from "node:child_process"; import { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import path from "node:path"; import test from "node:test"; import { fileURLToPath } from "node:url"; import { deckCues, deckHtml, GSAP_FILE, hostOf, mix, subtitleMarkup } from "./chrome-deck.mjs"; import { deckChoreography, deckLayout } from "./deck.mjs"; const HERE = path.dirname(fileURLToPath(import.meta.url)); const RENDER = { width: 1920, height: 1080, fps: 30, transition: 0.5, palette: { bg: "#12101a", fg: "#f4f1ea", muted: "#9a93ad", accent: "#a97bff", amber: "#ffc860" }, chrome: { engine: "hyperframes", layout: "deck", deck: {} }, }; /** A cut that opens and closes on a card, with an untitled clip and a hostile title. */ function schedule() { const seg = (id, type, start, duration, extra = {}) => ({ id, type, start, duration, end: start + duration, title: "", subtitle: "", qrUrl: null, hideDeck: false, ...extra, }); return { version: 1, kind: "deck", estimated: true, fps: 30, transition: 0.5, total: 40, multiChannel: false, segments: [ seg("t00", "card", 0, 5, { title: "Opening", subtitle: "a card", hideDeck: true }), seg("c01", "clip", 4.5, 10, { title: 'He said "largest" ', subtitle: "Ferret Rescue · Sep 5, 2024", qrUrl: "https://jasolyzer.pages.dev/?v=a&t=51" }), seg("c02", "clip", 14, 8, { title: "A sanctuary", subtitle: "Ferret Rescue · Sep 5, 2024", qrUrl: "https://jasolyzer.pages.dev/?v=a&t=62" }), seg("c03", "clip", 21.5, 13, { subtitle: "Untitled source · Sep 29, 2024", qrUrl: "https://www.youtube.com/watch?v=b" }), seg("end", "card", 34, 6, { title: "Close", subtitle: "", hideDeck: true }), ], }; } const QRS = { c01: "assets/qr00.png", c02: "assets/qr01.png", c03: "assets/qr02.png" }; const FONTS = { regular: "assets/DeckSans.ttf", bold: "assets/DeckSansBold.ttf" }; const dataOf = (html) => JSON.parse(/