Something went wrong. Try again.
Monorepo for Tangled forked from tangled.org/core
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113<script module lang="ts"> import { defineMeta } from "@storybook/addon-svelte-csf"; import { expect, userEvent, waitFor, within } from "storybook/test"; import CommentList from "#lib/components/comment/CommentList.svelte"; import CommentArrivalFixture from "#lib/components/comment/CommentArrivalFixture.svelte"; import { expectSmoothArrival } from "#storybook/arrival.ts"; import { freshComment, longThread, multiReplyThread, sampleComments, sampleMarkup, sampleSubjectCid, sampleSubjectUri, sampleThreads, soloThread } from "#fixtures/comments.ts";
const { Story } = defineMeta({ title: "Comment/CommentList", component: CommentList, tags: ["autodocs"], args: { threads: sampleThreads, subjectUri: sampleSubjectUri, subjectCid: sampleSubjectCid, markup: sampleMarkup } });</script>
<Story name="Populated" /><Story name="Empty" args={{ threads: [] }} /><Story name="Multiple replies" args={{ threads: [multiReplyThread] }} />
<!-- logged in as alice: her reply in the middle of the thread is being edited inline --><Story name="Editing a mid-thread reply" args={{ threads: [longThread] }} parameters={{ auth: true }} play={async ({ canvasElement }) => { const canvas = within(canvasElement); // only alice's (middle) reply exposes an edit control await userEvent.click( canvas.getByRole("button", { name: /more actions for alice\.tngl\.sh's reply/i }) ); await userEvent.click(await canvas.findByRole("menuitem", { name: "Edit reply" })); const textarea = await waitFor(() => canvas.getByPlaceholderText(/edit your comment/i)); await expect(textarea).toHaveValue(sampleComments.mine.body); await expect(canvas.getByRole("button", { name: "Save" })).toBeInTheDocument(); await expect(canvas.getByRole("button", { name: "Cancel" })).toBeInTheDocument(); }}/>
<Story name="New comment arrives" asChild play={({ canvasElement }) => expectSmoothArrival(canvasElement, { button: "Add comment", item: '[data-testid="arrival-list"] > div > div', edge: "arrival-end" })}> <CommentArrivalFixture threads={sampleThreads} subjectUri={sampleSubjectUri} subjectCid={sampleSubjectCid} markup={sampleMarkup} create={freshComment} /></Story>
<Story name="New reply arrives" asChild play={({ canvasElement }) => expectSmoothArrival(canvasElement, { button: "Reply to thread 1", item: '[data-testid="replies"] > div', edge: "arrival-end" })}> <CommentArrivalFixture threads={[multiReplyThread]} subjectUri={sampleSubjectUri} subjectCid={sampleSubjectCid} markup={sampleMarkup} create={freshComment} /></Story>
<Story name="First reply arrives" asChild play={({ canvasElement }) => expectSmoothArrival(canvasElement, { button: "Reply to thread 1", item: '[data-testid="replies"] > div', edge: "arrival-end" })}> <CommentArrivalFixture threads={[soloThread]} subjectUri={sampleSubjectUri} subjectCid={sampleSubjectCid} markup={sampleMarkup} create={freshComment} /></Story>