Skip to content

Commit 254a952

Browse files
feat(Simulator/screens/SendReceive): create stories
1 parent 782215b commit 254a952

File tree

3 files changed

+116
-1
lines changed

3 files changed

+116
-1
lines changed

src/components/Simulator/screens/SendReceive/ReceivedEther.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const ReceivedEther = ({
9090
initial={{ opacity: 0 }}
9191
animate={{ opacity: 1 }}
9292
exit={{ opacity: 0 }}
93+
data-testid="received-ether-toast"
9394
>
9495
<MdInfo className="text-xl" />
9596
<p className="m-0 text-xs font-bold">

src/components/Simulator/screens/SendReceive/Success.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const Success = ({
111111
{txPending ? (
112112
"Sending transaction"
113113
) : (
114-
<Text as="span">
114+
<Text as="span" data-testid="success-message">
115115
You sent{" "}
116116
<strong>
117117
<>{sentEthValue} ETH</>
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import type { Meta, StoryObj } from "@storybook/react"
2+
import { expect, fn, waitFor, within } from "@storybook/test"
3+
4+
import { Phone } from "@/components/Simulator/Phone"
5+
import { Template } from "@/components/Simulator/Template"
6+
7+
import { SendReceive } from ".."
8+
9+
const meta = {
10+
title: "Molecules / Display Content / Simulator / SendReceive Screen",
11+
component: SendReceive,
12+
parameters: {
13+
layout: "fullscreen",
14+
},
15+
args: {
16+
nav: {
17+
progressStepper: fn(),
18+
step: 0,
19+
openPath: fn(),
20+
regressStepper: fn(),
21+
totalSteps: 6,
22+
},
23+
ctaLabel: "",
24+
},
25+
decorators: [
26+
(Story) => (
27+
<div className="mx-auto mt-8">
28+
<Template>
29+
<Phone>
30+
<Story />
31+
</Phone>
32+
</Template>
33+
</div>
34+
),
35+
],
36+
} satisfies Meta<typeof SendReceive>
37+
38+
export default meta
39+
40+
type Story = StoryObj<typeof meta>
41+
42+
export const ReceiveEther: Story = {
43+
args: {
44+
nav: {
45+
...meta.args.nav,
46+
step: 1,
47+
},
48+
ctaLabel: "Share address",
49+
},
50+
}
51+
52+
export const ReceivedEther: Story = {
53+
args: {
54+
nav: {
55+
...meta.args.nav,
56+
step: 2,
57+
},
58+
},
59+
play: async ({ canvasElement }) => {
60+
const canvas = within(canvasElement)
61+
62+
await waitFor(
63+
async () => {
64+
expect(canvas.getByTestId("received-ether-toast")).toBeInTheDocument()
65+
},
66+
{ timeout: 1500 }
67+
)
68+
},
69+
}
70+
71+
export const SendEther: Story = {
72+
args: {
73+
nav: {
74+
...meta.args.nav,
75+
step: 3,
76+
},
77+
ctaLabel: "Select recipient",
78+
},
79+
}
80+
81+
export const SendFromContacts: Story = {
82+
args: {
83+
nav: {
84+
...meta.args.nav,
85+
step: 4,
86+
},
87+
},
88+
}
89+
90+
export const SendSummary: Story = {
91+
args: {
92+
nav: {
93+
...meta.args.nav,
94+
step: 5,
95+
},
96+
ctaLabel: "Send now",
97+
},
98+
}
99+
100+
export const Success: Story = {
101+
args: {
102+
nav: {
103+
...meta.args.nav,
104+
step: 6,
105+
},
106+
},
107+
play: async ({ canvasElement }) => {
108+
const canvas = within(canvasElement)
109+
110+
await waitFor(async () => {
111+
expect(canvas.getByTestId("success-message")).toBeInTheDocument()
112+
})
113+
},
114+
}

0 commit comments

Comments
 (0)