Skip to content

Commit 026746d

Browse files
committed
Add interaction to Tooltip story play function
1 parent d7d4887 commit 026746d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/stories/Tooltip/Tooltip.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Meta, StoryObj } from '@storybook/react-vite'
22
import { Tooltip } from '../../components/ui/tooltip.tsx'
33
import { Button } from '../../components/ui/button.tsx'
4-
import { expect, within } from 'storybook/test'
4+
import { expect, userEvent, within } from 'storybook/test'
55

66
const meta: Meta<typeof Tooltip> = {
77
title: 'Components/Tooltip',
@@ -54,5 +54,12 @@ export const Default: Story = {
5454
const canvas = within(canvasElement)
5555
const button = canvas.getAllByRole('button', { name: 'Hover me' })[0]
5656
await expect(button).toBeInTheDocument()
57+
await userEvent.hover(button)
58+
const container = within(canvasElement.parentNode as HTMLElement)
59+
// Is component mounted twice? https://github.com/storybookjs/storybook/issues/23921
60+
const allTooltipContents = await container.findAllByText('Tooltip content', { exact: false })
61+
const tooltipContent = allTooltipContents[0]
62+
await expect(tooltipContent).toBeInTheDocument()
63+
await expect(tooltipContent).toHaveClass('bg-popover')
5764
},
5865
}

0 commit comments

Comments
 (0)