|
1 | 1 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | | -import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
| 2 | +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
3 | 3 | import { tmpdir } from "node:os"; |
4 | 4 | import { join, resolve } from "node:path"; |
5 | 5 | import { CliUsageError } from "../../utils/commandResult.js"; |
@@ -37,6 +37,42 @@ describe("createRenderPlan", () => { |
37 | 37 | expect(Object.isFrozen(plan.environment)).toBe(true); |
38 | 38 | }); |
39 | 39 |
|
| 40 | + // The catalog join reaches the render event through the plan, so a plan that |
| 41 | + // silently drops it would leave every render reporting no catalog items. |
| 42 | + it("resolves catalog usage from the project manifest and the render entry", () => { |
| 43 | + writeFileSync( |
| 44 | + join(projectDir, "index.html"), |
| 45 | + '<main data-composition-id="main" data-width="1920" data-height="1080" data-fps="24">' + |
| 46 | + '<div data-composition-src="compositions/kept.html" data-duration="2"></div></main>', |
| 47 | + ); |
| 48 | + mkdirSync(join(projectDir, "compositions"), { recursive: true }); |
| 49 | + // `<template>`-wrapped, as sub-compositions are actually authored: template |
| 50 | + // content is inert, so a DOM scan of these files would find nothing. |
| 51 | + for (const name of ["kept", "dropped"]) { |
| 52 | + writeFileSync( |
| 53 | + join(projectDir, "compositions", `${name}.html`), |
| 54 | + `<template id="${name}-template"><div data-composition-id="${name}" data-width="1920" data-height="1080"></div></template>`, |
| 55 | + ); |
| 56 | + } |
| 57 | + writeFileSync( |
| 58 | + join(projectDir, "hyperframes.json"), |
| 59 | + JSON.stringify({ |
| 60 | + registry: "https://example.test", |
| 61 | + registryItems: [ |
| 62 | + { name: "kept", type: "hyperframes:block", target: "compositions/kept.html" }, |
| 63 | + { name: "dropped", type: "hyperframes:block", target: "compositions/dropped.html" }, |
| 64 | + ], |
| 65 | + }), |
| 66 | + ); |
| 67 | + |
| 68 | + const plan = createRenderPlan({ dir: projectDir, output: "result.mp4" }); |
| 69 | + expect(plan.catalogUsage).toEqual({ |
| 70 | + installed: ["dropped", "kept"], |
| 71 | + usedBlocks: ["kept"], |
| 72 | + manifestUnreadable: false, |
| 73 | + }); |
| 74 | + }); |
| 75 | + |
40 | 76 | it("preserves an explicit strict-readiness opt-in", () => { |
41 | 77 | const plan = createRenderPlan({ dir: projectDir, "best-effort": false }); |
42 | 78 | expect(plan.bestEffort).toBe(false); |
|
0 commit comments