Skip to content

Write HTML. Render video. Built for agents.

test(studio): mock composition thumbnails in smoke

ukimsanov0faeb42f86e2
diff --git a/scripts/studio-runtime-smoke.mjs b/scripts/studio-runtime-smoke.mjs
index bfe0640e00..eb1c1a4019 100644
--- a/scripts/studio-runtime-smoke.mjs
+++ b/scripts/studio-runtime-smoke.mjs
@@ -10,6 +10,8 @@ export const SMOKE_COMPOSITION_HTML =
'<!doctype html><html><body><div data-composition-id="root" data-width="1920" ' +
'data-height="1080" data-duration="1" data-start="0"><div class="clip" ' +
'data-hf-id="title" data-start="0" data-duration="1">Test</div></div></body></html>';
+const SMOKE_THUMBNAIL_SVG =
+ '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="9"><rect width="16" height="9"/></svg>';
function json(body, status = 200) {
return { status, contentType: "application/json", body: JSON.stringify(body) };
@@ -75,6 +77,11 @@ function projectPreviewResponse(pathname) {
: text(SMOKE_COMPOSITION_HTML, "text/html");
}
+function projectThumbnailResponse(pathname) {
+ if (!pathname.startsWith(`${PROJECT_PATH}/thumbnail/`)) return undefined;
+ return text(SMOKE_THUMBNAIL_SVG, "image/svg+xml");
+}
+
function gsapAnimationsResponse(pathname) {
if (!pathname.startsWith(`${PROJECT_PATH}/gsap-animations/`)) return undefined;
return json({ animations: [], timelineVar: "tl", preamble: "", postamble: "" });
@@ -85,6 +92,7 @@ function getStudioSmokeResponse(pathname) {
GET_RESPONSES.get(pathname) ??
projectFileResponse(pathname) ??
projectPreviewResponse(pathname) ??
+ projectThumbnailResponse(pathname) ??
gsapAnimationsResponse(pathname)
);
}
diff --git a/scripts/studio-runtime-smoke.test.mjs b/scripts/studio-runtime-smoke.test.mjs
index a686b48e93..adf1991db6 100644
--- a/scripts/studio-runtime-smoke.test.mjs
+++ b/scripts/studio-runtime-smoke.test.mjs
@@ -44,6 +44,15 @@ describe("Studio runtime smoke fixtures", () => {
assert.deepEqual(bodyOf("GET", "/api/projects/smoke-test/lint"), { findings: [] });
});
+ it("returns an image for composition thumbnail requests", () => {
+ const response = studioSmokeApiResponse(
+ "GET",
+ "http://localhost:5199/api/projects/smoke-test/thumbnail/index.html?t=3",
+ );
+ assert.ok(response && response !== null);
+ assert.equal(response.contentType, "image/svg+xml");
+ });
+
it("marks unknown API requests as fixture failures", () => {
assert.equal(studioSmokeApiResponse("GET", "http://localhost:5199/api/new-endpoint"), null);
assert.equal(studioSmokeApiResponse("GET", "http://localhost:5199/src/main.tsx"), undefined);