From 0faeb42f86e20c5503e0827fa18b89050663bad7 Mon Sep 17 00:00:00 2001 From: ukimsanov Date: Mon, 27 Jul 2026 22:25:27 -0700 Subject: [PATCH] test(studio): mock composition thumbnails in smoke --- scripts/studio-runtime-smoke.mjs | 8 ++++++++ scripts/studio-runtime-smoke.test.mjs | 9 +++++++++ 2 files changed, 17 insertions(+) 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 = '
Test
'; +const SMOKE_THUMBNAIL_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);