diff --git a/apps/web/e2e/media-card.spec.ts b/apps/web/e2e/media-card.spec.ts index e777374..26de164 100644 --- a/apps/web/e2e/media-card.spec.ts +++ b/apps/web/e2e/media-card.spec.ts @@ -4,7 +4,6 @@ import { captureScreenshot, completeOnboarding, fetchRpcEnvelope, - fulfillFetchedRpc, rpc, signup, } from "./helpers"; @@ -77,7 +76,12 @@ async function seedMediaMessage(page: Page, botId: string, block: () => MediaBlo createdAt: new Date().toISOString(), }); } - await fulfillFetchedRpc(route, fetched); + // Fresh headers: the original content length no longer matches the patched body. + await route.fulfill({ + status: fetched.status, + contentType: "application/json", + body: JSON.stringify(fetched.body), + }); }); } @@ -139,7 +143,16 @@ test("renders a media job card while it runs and when it is done", async ({ page ], }, ); + page.on("console", (message) => { + if (message.type() === "error") console.log(`browser: ${message.text()}`); + }); + const seeded = page.waitForResponse( + async (response) => + response.url().includes("/rpc/threads/get") && + (await response.text()).includes("media-job-1"), + ); await page.reload(); + await seeded; const card = page.getByTestId("media-card"); await expect(card).toBeVisible({ timeout: 30_000 }); diff --git a/apps/web/src/components/media/MediaCard.test.tsx b/apps/web/src/components/media/MediaCard.test.tsx index ff38de3..7e24923 100644 --- a/apps/web/src/components/media/MediaCard.test.tsx +++ b/apps/web/src/components/media/MediaCard.test.tsx @@ -22,7 +22,8 @@ vi.mock("./MediaPlayer", () => ({ ), })); vi.mock("../../lib/artifact-url", () => ({ - artifactUrl: (artifactId: string) => `/artifact/${artifactId}`, + artifactUrl: (artifactId: string, options?: { download?: boolean }) => + `/artifact/${artifactId}${options?.download ? "?download=1" : ""}`, })); import { exportPresetsFor, isActiveMediaStatus, MediaCardView } from "./MediaCard"; @@ -103,7 +104,7 @@ describe("media card", () => { />, ); expect(html).toContain('data-player="video"'); - expect(html).toContain('href="/artifact/video-1"'); + expect(html).toContain('href="/artifact/video-1?download=1"'); expect(html).toContain('download="clip.mp4"'); expect(html).toContain('aria-label="Download clip.mp4"'); expect(html).toContain("Export"); diff --git a/apps/web/src/components/media/MediaCard.tsx b/apps/web/src/components/media/MediaCard.tsx index e4ba52c..6134a16 100644 --- a/apps/web/src/components/media/MediaCard.tsx +++ b/apps/web/src/components/media/MediaCard.tsx @@ -125,7 +125,7 @@ function OutputActions({ return (