import { Button } from '@/components/ui/button'; import { rtlRender, screen, userEvent, waitFor } from '@/testing/test-utils'; import { Drawer, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, } from '../drawer'; const openButtonText = 'Open Drawer'; const titleText = 'Drawer Title'; const cancelButtonText = 'Cancel'; const drawerContentText = 'Hello From Drawer'; const TestDrawer = () => { return (
{titleText}
{drawerContentText}
); }; test('should handle basic drawer flow', async () => { await rtlRender(); expect(screen.queryByText(titleText)).not.toBeInTheDocument(); await userEvent.click( screen.getByRole('button', { name: openButtonText, }), ); expect(await screen.findByText(titleText)).toBeInTheDocument(); await userEvent.click( screen.getByRole('button', { name: cancelButtonText, }), ); await waitFor(() => expect(screen.queryByText(titleText)).not.toBeInTheDocument(), ); });