File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 11import type { Meta , StoryObj } from '@storybook/react-vite'
22import { Tooltip } from '../../components/ui/tooltip.tsx'
33import { Button } from '../../components/ui/button.tsx'
4- import { expect , within } from 'storybook/test'
4+ import { expect , userEvent , within } from 'storybook/test'
55
66const 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}
You can’t perform that action at this time.
0 commit comments