-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathRedactedBodyView.stories.tsx
More file actions
62 lines (51 loc) · 1.89 KB
/
RedactedBodyView.stories.tsx
File metadata and controls
62 lines (51 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright 2026 Element Creations Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
import React, { type JSX } from "react";
import { expect, userEvent, within } from "storybook/test";
import type { Meta, StoryObj } from "@storybook/react-vite";
import { useMockedViewModel } from "../../../../../core/viewmodel";
import { withViewDocs } from "../../../../../../.storybook/withViewDocs";
import { RedactedBodyView, type RedactedBodyViewSnapshot } from "./RedactedBodyView";
type RedactedBodyProps = RedactedBodyViewSnapshot;
const RedactedBodyViewWrapperImpl = ({
className,
...rest
}: RedactedBodyProps & { className?: string }): JSX.Element => {
const vm = useMockedViewModel(rest, {});
return <RedactedBodyView vm={vm} className={className} />;
};
const RedactedBodyViewWrapper = withViewDocs(RedactedBodyViewWrapperImpl, RedactedBodyView);
const meta = {
title: "Timeline/Timeline Body/RedactedBodyView",
component: RedactedBodyViewWrapper,
tags: ["autodocs"],
args: {
text: "Message deleted",
tooltip: "This message was deleted on Thu, 17 Nov 2022, 4:58:32 pm",
className: "",
},
} satisfies Meta<typeof RedactedBodyViewWrapper>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await userEvent.hover(canvas.getByText("Message deleted"));
await expect(within(canvasElement.ownerDocument.body).findByRole("tooltip")).resolves.toBeInTheDocument();
},
};
export const SelfRedaction: Story = {
args: {
text: "Message deleted",
tooltip: undefined,
},
};
export const RedactedByAnotherUser: Story = {
args: {
text: "Message deleted by Alice",
},
};