From 03fb9e76138f32b4d7096a8d1c04fd1e53bec569 Mon Sep 17 00:00:00 2001 From: "juancarlos.cavero" Date: Thu, 20 Aug 2026 18:39:43 +0200 Subject: [PATCH] test(render-service): pin the composition metadata contract for per-render props --- render-service/package.json | 1 + .../src/composition-metadata.test.ts | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 render-service/src/composition-metadata.test.ts diff --git a/render-service/package.json b/render-service/package.json index 1835264..18e377a 100644 --- a/render-service/package.json +++ b/render-service/package.json @@ -5,6 +5,7 @@ "type": "module", "scripts": { "dev": "tsx watch src/server.ts", + "test": "node --import tsx --test src/composition-metadata.test.ts", "build": "tsc", "start": "node dist/server.js" }, diff --git a/render-service/src/composition-metadata.test.ts b/render-service/src/composition-metadata.test.ts new file mode 100644 index 0000000..eadb777 --- /dev/null +++ b/render-service/src/composition-metadata.test.ts @@ -0,0 +1,62 @@ +import { before, test } from "node:test"; +import assert from "node:assert/strict"; +import { selectComposition } from "@remotion/renderer"; +import { initBundle, getBundleLocation } from "./bundle.js"; + +/** + * Contract test for the render pipeline's composition metadata. + * + * render-worker.ts passes durationInFrames/fps/width/height via inputProps and + * renders whatever selectComposition() reports. Without calculateMetadata on + * the ShortVideo Composition, Remotion ignores those inputProps and always + * reports the static DEFAULT_PROPS metadata (900 frames / 30fps / 1080x1920), + * so every clip renders at 30s regardless of its real length. + */ + +const BUNDLE_TIMEOUT_MS = 5 * 60 * 1000; + +before(async () => { + await initBundle(); +}, { timeout: BUNDLE_TIMEOUT_MS }); + +test( + "selectComposition honors per-render duration/fps/dimensions from inputProps", + { timeout: BUNDLE_TIMEOUT_MS }, + async () => { + const composition = await selectComposition({ + serveUrl: getBundleLocation(), + id: "ShortVideo", + inputProps: { + videoUrl: "", + durationInFrames: 300, + fps: 25, + width: 720, + height: 1280, + }, + logLevel: "error", + }); + + assert.equal(composition.durationInFrames, 300); + assert.equal(composition.fps, 25); + assert.equal(composition.width, 720); + assert.equal(composition.height, 1280); + } +); + +test( + "selectComposition falls back to DEFAULT_PROPS metadata when inputProps omit it", + { timeout: BUNDLE_TIMEOUT_MS }, + async () => { + const composition = await selectComposition({ + serveUrl: getBundleLocation(), + id: "ShortVideo", + inputProps: { videoUrl: "" }, + logLevel: "error", + }); + + assert.equal(composition.durationInFrames, 900); + assert.equal(composition.fps, 30); + assert.equal(composition.width, 1080); + assert.equal(composition.height, 1920); + } +);