/// import * as React from 'react' import { mount } from 'cypress/react' import type { Placement } from '@floating-ui/react' import assertions from '../assertions' import Tooltip from './Tooltip' const TooltipStoryMulti = ({ color = 'light', placement, disabled, tabindex = 1, }: { color?: 'light' | 'dark' placement?: Placement disabled?: boolean tabindex?: number } = {}) => (
PopovDyn
} color={color} placement={placement} tabIndex={tabindex} disabled={disabled} >
Hover Me (dynamic: {placement?.toString()})
Popov } color={color} placement="top" forcePlacement >
Force Placement to the top
PopovInt} color={color} placement={placement} interactive >
Interactive {placement?.toString()}
{(['top', 'right', 'bottom', 'left', 'top-start'] as const).map( (placement) => ( Popover ({placement}) } >
Hover Me ({placement})
), )} ) describe('Tooltip', { viewportHeight: 800, viewportWidth: 800 }, () => { function mountStory( options: { single?: boolean } & Parameters< typeof TooltipStoryMulti >[0] = {}, ) { const { single, tabindex = 1, ...rest } = options if (single) { mount( popit: Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, voluptatum. } className="m-4 p-4 bg-red-300 w-[150px]" > Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, voluptatum. , ) } else { mount() } } assertions(mountStory, 'react') it('open', () => { mount(
make sure its open
, ) cy.findByText('should be visible').should('be.visible') }) it('arrowPadding', () => { mount(
{( [ 'bottom-start', 'bottom-end', 'left-start', 'left-end', 'right-start', 'right-end', 'top-start', 'top-end', ] as const ).map((placement) => ( H
} >
Hover Me ({placement})
))} , ) cy.percySnapshot() }) it('shiftOptions', () => { mount(
Custom shift padding of 50px
} >
Tooltip with custom shift padding
, ) cy.findByText('Custom shift padding of 50px').should('be.visible') }) it('offsetOptions', () => { mount(
Offset 40px
} >
Tooltip with offset 40px
Offset 5px } >
Tooltip with offset 5px
, ) cy.findByText('Offset 40px').should('be.visible') cy.findByText('Offset 5px').should('be.visible') cy.percySnapshot() }) })