diff --git a/site/.storybook/static/tiny-thumbnail.png b/site/.storybook/static/tiny-thumbnail.png new file mode 100644 index 0000000000..5e59e255cb Binary files /dev/null and b/site/.storybook/static/tiny-thumbnail.png differ diff --git a/site/src/pages/AgentsPage/components/ChatElements/tools/RecordingPreview.stories.tsx b/site/src/pages/AgentsPage/components/ChatElements/tools/RecordingPreview.stories.tsx index 24cd6b96d0..06025adf64 100644 --- a/site/src/pages/AgentsPage/components/ChatElements/tools/RecordingPreview.stories.tsx +++ b/site/src/pages/AgentsPage/components/ChatElements/tools/RecordingPreview.stories.tsx @@ -2,8 +2,9 @@ import type { Meta, StoryObj } from "@storybook/react-vite"; import { expect, fireEvent, userEvent, waitFor, within } from "storybook/test"; import { RecordingPreview } from "./RecordingPreview"; -// The file is stored in site/.storybook/static/tiny-recording.mp4. +// Static assets stored in site/.storybook/static/. const TINY_MP4 = "/tiny-recording.mp4"; +const TINY_THUMBNAIL = "/tiny-thumbnail.png"; const meta: Meta = { title: "pages/AgentsPage/ChatElements/tools/RecordingPreview", @@ -23,10 +24,13 @@ type Story = StoryObj; export const Default: Story = { args: { recordingFileId: "dummy-recording-id", + thumbnailFileId: "dummy-thumb-id", + thumbnailSrc: TINY_THUMBNAIL, src: TINY_MP4, }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); + expect(canvas.getByRole("img")).toBeInTheDocument(); expect( canvas.getByRole("button", { name: "View recording" }), ).toBeInTheDocument(); @@ -36,6 +40,8 @@ export const Default: Story = { export const LightboxOpen: Story = { args: { recordingFileId: "dummy-recording-id", + thumbnailFileId: "dummy-thumb-id", + thumbnailSrc: TINY_THUMBNAIL, src: TINY_MP4, }, play: async ({ canvasElement }) => { @@ -55,13 +61,14 @@ export const LightboxOpen: Story = { export const ThumbnailError: Story = { args: { recordingFileId: "dummy-recording-id", + thumbnailFileId: "bad-thumb-id", src: TINY_MP4, }, play: async ({ canvasElement }) => { const canvas = within(canvasElement); - const video = canvasElement.querySelector("video"); - expect(video).not.toBeNull(); - fireEvent.error(video!); + const img = canvasElement.querySelector("img"); + expect(img).not.toBeNull(); + fireEvent.error(img!); await waitFor(() => { expect(canvas.getByText("Thumbnail unavailable")).toBeInTheDocument(); // The play button should still be available so the user can @@ -72,3 +79,43 @@ export const ThumbnailError: Story = { }); }, }; + +export const WithThumbnail: Story = { + args: { + recordingFileId: "rec-id", + thumbnailFileId: "thumb-id", + thumbnailSrc: TINY_THUMBNAIL, + }, + play: async ({ canvasElement }) => { + const canvas = within(canvasElement); + const img = canvas.getByRole("img"); + expect(img).toBeInTheDocument(); + expect(img).toHaveAttribute("src", TINY_THUMBNAIL); + // No