Skip to content

Commit

Permalink
storybook play を試してみる
Browse files Browse the repository at this point in the history
  • Loading branch information
kuramapommel committed Sep 2, 2024
1 parent 122b5f4 commit 8b9a1b8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sample/src/pages/product-list.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ProductList from '@/pages/product-list'
import type { Meta, StoryObj } from '@storybook/react'
import { userEvent, within } from '@storybook/test'
import { MemoryRouter, Route, Routes } from 'react-router-dom'

const meta: Meta<typeof ProductList> = {
Expand Down Expand Up @@ -29,4 +30,18 @@ export const Default: Story = {
</MemoryRouter>
)
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement)

const deleteButton = (
await canvas.findAllByRole('button', { name: '削除' })
)[0]
await userEvent.click(deleteButton)

const confirmButton = (
await canvas.findAllByRole('button', { name: '削除する' })
)[0]

await userEvent.click(confirmButton)
},
}

0 comments on commit 8b9a1b8

Please sign in to comment.