Skip to content

Commit 8b9a1b8

Browse files
committed
storybook play を試してみる
1 parent 122b5f4 commit 8b9a1b8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sample/src/pages/product-list.stories.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ProductList from '@/pages/product-list'
22
import type { Meta, StoryObj } from '@storybook/react'
3+
import { userEvent, within } from '@storybook/test'
34
import { MemoryRouter, Route, Routes } from 'react-router-dom'
45

56
const meta: Meta<typeof ProductList> = {
@@ -29,4 +30,18 @@ export const Default: Story = {
2930
</MemoryRouter>
3031
)
3132
},
33+
play: async ({ canvasElement }) => {
34+
const canvas = within(canvasElement)
35+
36+
const deleteButton = (
37+
await canvas.findAllByRole('button', { name: '削除' })
38+
)[0]
39+
await userEvent.click(deleteButton)
40+
41+
const confirmButton = (
42+
await canvas.findAllByRole('button', { name: '削除する' })
43+
)[0]
44+
45+
await userEvent.click(confirmButton)
46+
},
3247
}

0 commit comments

Comments
 (0)