diff --git a/packages/producer/src/regression-harness.ts b/packages/producer/src/regression-harness.ts index e5f919c1a..27cb2098f 100644 --- a/packages/producer/src/regression-harness.ts +++ b/packages/producer/src/regression-harness.ts @@ -36,6 +36,14 @@ type TestMetadata = { workers?: number; // Optional: auto-calculates if omitted /** Force HDR in the harness; omitted/false preserves historical SDR-only test behavior. */ hdr?: boolean; + /** + * Render-time variable overrides, equivalent to `hyperframes render + * --variables ''`. Injected as `window.__hfVariables` before any + * page script runs so the runtime helper `getVariables()` returns the + * merged result of declared defaults (`data-composition-variables`) + * and these overrides. Omit when the test doesn't exercise variables. + */ + variables?: Record; }; }; @@ -160,6 +168,12 @@ function validateMetadata(meta: unknown): TestMetadata { if (rc.hdr !== undefined && typeof rc.hdr !== "boolean") { throw new Error("meta.json: 'renderConfig.hdr' must be a boolean (or omit for false)"); } + if ( + rc.variables !== undefined && + (rc.variables === null || typeof rc.variables !== "object" || Array.isArray(rc.variables)) + ) { + throw new Error("meta.json: 'renderConfig.variables' must be a JSON object (or omitted)"); + } return m as TestMetadata; } @@ -601,6 +615,7 @@ async function runTestSuite( useGpu: false, debug: false, hdrMode: suite.meta.renderConfig.hdr ? "force-hdr" : "force-sdr", + variables: suite.meta.renderConfig.variables, }); await executeRenderJob(job, tempSrcDir, renderedOutputPath); diff --git a/packages/producer/tests/variables-prod/meta.json b/packages/producer/tests/variables-prod/meta.json new file mode 100644 index 000000000..c1d56becc --- /dev/null +++ b/packages/producer/tests/variables-prod/meta.json @@ -0,0 +1,17 @@ +{ + "name": "Variables Prod", + "description": "End-to-end regression for the variables system. Composition declares title/subtitle/bgColor in data-composition-variables and reads them via window.__hyperframes.getVariables(). renderConfig.variables provides overrides that flow CLI → producer → engine evaluateOnNewDocument → window.__hfVariables → helper merge → DOM text → rendered pixels. If any link in that chain breaks, the rendered text/background diverges from the baseline and PSNR fails.", + "tags": ["variables", "composition"], + "minPsnr": 30, + "maxFrameFailures": 0, + "minAudioCorrelation": 0.9, + "maxAudioLagWindows": 120, + "renderConfig": { + "fps": 24, + "variables": { + "title": "Override Title", + "subtitle": "Override subtitle", + "bgColor": "#0a3d62" + } + } +} diff --git a/packages/producer/tests/variables-prod/output/compiled.html b/packages/producer/tests/variables-prod/output/compiled.html new file mode 100644 index 000000000..6d7acf5b2 --- /dev/null +++ b/packages/producer/tests/variables-prod/output/compiled.html @@ -0,0 +1,137 @@ + + + + + + + + + +
+ +

+

+
+ + + + diff --git a/packages/producer/tests/variables-prod/output/output.mp4 b/packages/producer/tests/variables-prod/output/output.mp4 new file mode 100644 index 000000000..ba8eaf31e --- /dev/null +++ b/packages/producer/tests/variables-prod/output/output.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be9a5689e27272b191fa566843e45f88f728b36f677a3db49f89e9193627a667 +size 117111 diff --git a/packages/producer/tests/variables-prod/src/index.html b/packages/producer/tests/variables-prod/src/index.html new file mode 100644 index 000000000..7a3c9e489 --- /dev/null +++ b/packages/producer/tests/variables-prod/src/index.html @@ -0,0 +1,96 @@ + + + + + + + + + +
+ +

+

+
+ + + + diff --git a/packages/producer/tests/variables-prod/src/silence.wav b/packages/producer/tests/variables-prod/src/silence.wav new file mode 100644 index 000000000..b9113c424 Binary files /dev/null and b/packages/producer/tests/variables-prod/src/silence.wav differ