This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / web / src / lib / components / comment / CommentBox.stories.svelte
1.3 kB 42 lines
1<script module lang="ts"> 2 import { defineMeta } from "@storybook/addon-svelte-csf"; 3 import { expect, userEvent, waitFor, within } from "storybook/test"; 4 import CommentBox from "./CommentBox.svelte"; 5 import MockAuthProvider from "$lib/components/testing/MockAuthProvider.svelte"; 6 7 const { Story } = defineMeta({ 8 title: "Comment/CommentBox", 9 component: CommentBox, 10 tags: ["autodocs"], 11 args: { 12 subjectUri: "at://did:plc:alice/sh.tangled.repo.issue/aaa", 13 subjectCid: "bafyreib2rxk3rh6kzwq6yhkp6bd4vjxj3xj2xj2xj2xj2xj2xj2xj2xj2", 14 authorDid: "did:plc:alice", 15 authorHandle: "alice.pds.tngl.boltless.dev", 16 markup: { repo: "tangled.org/core", ref: "main", host: "tangled.org" } 17 } 18 }); 19</script> 20 21<Story name="Default" /> 22 23<!-- types a comment and submits with ctrl+enter against a fake agent that rejects, showing the error alert --> 24<Story 25 name="Failed submission" 26 play={async ({ canvasElement }) => { 27 const canvas = within(canvasElement); 28 await userEvent.type( 29 canvas.getByPlaceholderText(/add to the discussion/i), 30 "This will fail{Control>}{Enter}{/Control}" 31 ); 32 await waitFor(() => 33 expect(canvas.getByRole("alert")).toHaveTextContent(/network request failed/i) 34 ); 35 }} 36> 37 {#snippet template(args)} 38 <MockAuthProvider> 39 <CommentBox {...args} /> 40 </MockAuthProvider> 41 {/snippet} 42</Story>