From 40657fe02e4f54508d4574e3f0e1e24c46ff62be Mon Sep 17 00:00:00 2001 From: eti Date: Wed, 2 Sep 2026 23:52:37 +0200 Subject: [PATCH] web: make the stories that render nothing assert something Signed-off-by: eti --- web/src/fixtures/pipelines.ts | 8 +++---- .../components/comment/Comment.stories.svelte | 3 ++- .../comment/CommentCard.stories.svelte | 12 +++++++++- .../profile/VouchButton.stories.svelte | 7 +++++- .../profile/tabs/OverviewTab.stories.svelte | 23 ++++++++++++++++--- .../components/repo/BlobView.stories.svelte | 4 ++-- .../NotificationsPreview.stories.svelte | 7 ++++-- .../timeline/Timeline.stories.svelte | 10 +++++++- .../email-did/email-did.server.test.ts | 4 ++-- 9 files changed, 61 insertions(+), 17 deletions(-) diff --git a/web/src/fixtures/pipelines.ts b/web/src/fixtures/pipelines.ts index 73ede6062..156bf7b59 100644 --- a/web/src/fixtures/pipelines.ts +++ b/web/src/fixtures/pipelines.ts @@ -230,18 +230,18 @@ const tailFrames: LogFrame[] = [ output(-1, "starting microVM image alpine\n"), finish(-1, 3), control(0, "install dependencies", { command: "pnpm install --frozen-lockfile" }), - ...Array.from({ length: 30 }, (_, index) => + ...Array.from({ length: 3 }, (_, index) => output(0, `\u001b[90m+\u001b[0m package-${index} \u001b[32m1.${index}.0\u001b[0m\n`) ), finish(0, 41), control(1, "run tests", { command: "pnpm test" }), output(1, "\u001b[1mRUN\u001b[0m v4.1.10\n"), - ...Array.from({ length: 40 }, (_, index) => + ...Array.from({ length: 3 }, (_, index) => output(1, `\u001b[32m✓\u001b[0m src/lib/suite-${index}.test.ts (${index + 2})\n`) ), finish(1, 96), control(2, "build the site", { command: "pnpm build" }), - ...Array.from({ length: 40 }, (_, index) => + ...Array.from({ length: 3 }, (_, index) => output(2, `[${index}] \u001b[36mbundle\u001b[0m src/module-${index}.ts\n`) ) ]; @@ -279,7 +279,7 @@ export const createLogTail = (): { advance: () => LogStep[]; exhausted: () => bo /** a step big enough that the viewport can only hold a slice of it */ export const longWorkflowLog: LogStep[] = drain([ control(1, "build everything", { command: "make -j8" }), - ...Array.from({ length: 4_000 }, (_, index) => + ...Array.from({ length: 300 }, (_, index) => output(1, `[${index}] \u001b[36mCC\u001b[0m src/module-${index}.c\n`) ) ]); diff --git a/web/src/lib/components/comment/Comment.stories.svelte b/web/src/lib/components/comment/Comment.stories.svelte index 898b1157f..0a9eb7dd6 100644 --- a/web/src/lib/components/comment/Comment.stories.svelte +++ b/web/src/lib/components/comment/Comment.stories.svelte @@ -33,6 +33,7 @@ authorDid: samuel.authorDid, createdAt: samuel.createdAt, body: samuel.body, - bodyHtml: samuel.bodyHtml + bodyHtml: samuel.bodyHtml, + subjectUri: samuel.uri }} /> diff --git a/web/src/lib/components/comment/CommentCard.stories.svelte b/web/src/lib/components/comment/CommentCard.stories.svelte index 376d9d818..86348c040 100644 --- a/web/src/lib/components/comment/CommentCard.stories.svelte +++ b/web/src/lib/components/comment/CommentCard.stories.svelte @@ -78,6 +78,7 @@ { const canvas = within(canvasElement); - await userEvent.click(canvas.getByRole("button", { name: /more actions for/i })); + await userEvent.click( + canvas.getByRole("button", { name: /more actions for camsmith\.dev's reply/i }) + ); // the actions row fades in on real hover, which a synthetic pointer cannot do, so // assert the menu is in the tree rather than painted await expect( @@ -94,6 +97,13 @@ ).toBeInTheDocument(); await expect(canvas.getByRole("menuitem", { name: /report user/i })).toBeInTheDocument(); expect(canvas.queryByRole("button", { name: "Edit comment" })).toBeNull(); + + await userEvent.click( + canvas.getByRole("button", { name: /more actions for byjp\.me's comment/i }) + ); + await expect( + await canvas.findByRole("menuitem", { name: /report comment/i }) + ).toBeInTheDocument(); }} /> diff --git a/web/src/lib/components/profile/VouchButton.stories.svelte b/web/src/lib/components/profile/VouchButton.stories.svelte index 31e20e9de..a7bca3eb8 100644 --- a/web/src/lib/components/profile/VouchButton.stories.svelte +++ b/web/src/lib/components/profile/VouchButton.stories.svelte @@ -42,6 +42,11 @@ ); }; + const signedOutCta = async ({ canvas }: PlayContext) => { + const link = await canvas.findByRole("link", { name: "Vouch" }); + expect(link.getAttribute("href")).toContain("/login"); + }; + // none of the per-story dids match the mock user's did (did:plc:alice), so the // button always shows — except the "Self" story. const { Story } = defineMeta({ @@ -179,7 +184,7 @@ - + {#snippet template(args)}
diff --git a/web/src/lib/components/profile/tabs/OverviewTab.stories.svelte b/web/src/lib/components/profile/tabs/OverviewTab.stories.svelte index 0121155f9..697b910a6 100644 --- a/web/src/lib/components/profile/tabs/OverviewTab.stories.svelte +++ b/web/src/lib/components/profile/tabs/OverviewTab.stories.svelte @@ -1,5 +1,6 @@ - + { + await expect(canvas.getByRole("link", { name: "dawn.tngl.sh/pinned-0" })).toBeVisible(); + }} +/> + + { + await expect(canvas.getByRole("link", { name: "pinned-0" })).toBeVisible(); + await expect(canvas.queryByRole("link", { name: "dawn.tngl.sh/pinned-0" })).toBeNull(); + }} +/> diff --git a/web/src/lib/components/repo/BlobView.stories.svelte b/web/src/lib/components/repo/BlobView.stories.svelte index d7ba8d4e2..c42e943a5 100644 --- a/web/src/lib/components/repo/BlobView.stories.svelte +++ b/web/src/lib/components/repo/BlobView.stories.svelte @@ -164,7 +164,7 @@ here.

const showsCode = async ({ canvas, canvasElement }: PlayContext) => { await expect(canvas.getByText("main.ts")).toBeVisible(); await expect(canvas.getByText(`${codeLineCount} lines`)).toBeVisible(); - await expect(canvas.getByRole("link", { name: "main" })).toBeVisible(); + await expect(canvas.getByRole("link", { name: "Browse main" })).toBeVisible(); await expect(canvas.getByText("TypeScript")).toBeVisible(); await expect(canvas.getByRole("link", { name: "Download" })).toBeVisible(); await waitFor(() => @@ -190,7 +190,7 @@ here.

play={async ({ canvas, canvasElement, userEvent }: PlayContext) => { await expect(canvas.getByRole("heading", { level: 1, name: /Tangled/ })).toBeVisible(); await expect(canvas.getByRole("link", { name: "spindle" })).toBeVisible(); - await userEvent.click(canvas.getByRole("button", { name: "Source" })); + await userEvent.click(canvas.getByRole("button", { name: "View source" })); await waitFor(() => expect(shadowText(canvasElement)).toContain("## Contributing")); }} /> diff --git a/web/src/lib/components/timeline/NotificationsPreview.stories.svelte b/web/src/lib/components/timeline/NotificationsPreview.stories.svelte index 1c78cd61f..e4c933bcf 100644 --- a/web/src/lib/components/timeline/NotificationsPreview.stories.svelte +++ b/web/src/lib/components/timeline/NotificationsPreview.stories.svelte @@ -1,5 +1,6 @@