// buildSteps' `chromeOnly`: the deck re-rendered over the segments on disk. // // Run with: pnpm test:scripts import assert from "node:assert/strict"; import test from "node:test"; import { buildSteps, editorFullSourceSteps } from "./driver.mjs"; const project = { id: "p", dir: "/r/p" }; test("chromeOnly: no preflight, --chrome-only on the build, labelled, then the verify", () => { const steps = buildSteps(project, { preset: "final", options: { chromeOnly: true, variant: "full" } }); assert.deepEqual(steps.map((s) => s.label), ["re-render on-screen", "verify the file that came out"]); const argv = steps[0].argv; assert.ok(argv.includes("--chrome-only")); assert.deepEqual(argv.slice(argv.indexOf("--variant"), argv.indexOf("--variant") + 2), ["--variant", "full"]); assert.ok(!argv.includes("--chapters-only")); // A render plus a concat of the whole cut: the build's timeout, not the quick cap. assert.ok(steps[0].timeoutMs > 5 * 60_000); }); test("without chromeOnly nothing changes: the preflight leads and no --chrome-only", () => { const steps = buildSteps(project, { preset: "final" }); assert.equal(steps[0].label, "check every source is still fetchable"); assert.ok(steps.every((s) => !s.argv.includes("--chrome-only"))); }); test("the verify is told when the build joined without crossfades", () => { const verifyOf = (steps) => steps.at(-1).argv; const fast = buildSteps(project, { preset: "fast" }); assert.ok(fast.some((s) => s.argv.includes("--no-xfade") && !s.argv.some((a) => a.endsWith("verify-build.mjs")))); assert.ok(verifyOf(fast).includes("--no-xfade")); assert.ok(verifyOf(buildSteps(project, { preset: "final", options: { xfade: false } })).includes("--no-xfade")); assert.ok(!verifyOf(buildSteps(project, { preset: "final" })).includes("--no-xfade")); }); test("a whole-source fetch asks at the manifest's maxHeightSource, unless told a height", () => { const argvOf = (opts) => editorFullSourceSteps(project, "c01", opts)[0].argv; const heightOf = (argv) => (argv.includes("--max-height") ? argv[argv.indexOf("--max-height") + 1] : null); const manifest = { render: { maxHeightSource: 720 } }; assert.equal(heightOf(argvOf({ manifest })), "720"); assert.ok(argvOf({ manifest }).includes("--full")); // An explicit height beats the manifest's. assert.equal(heightOf(argvOf({ manifest, maxHeight: 1080 })), "1080"); // Neither, or neither valid: no flag, so the channel's own quality applies. assert.equal(heightOf(argvOf()), null); assert.equal(heightOf(argvOf({ manifest: { render: {} } })), null); assert.equal(heightOf(argvOf({ manifest: { render: { maxHeightSource: 4320 } } })), null); // A bad explicit height falls through to the manifest's. assert.equal(heightOf(argvOf({ manifest, maxHeight: "tall" })), "720"); });