import React from 'react' import { render } from '../__utils/test-utils' import userEvent from '@testing-library/user-event' import { UserMenu } from './user-menu' import { NavigationBar } from './navigation-bar' import { User } from '@planview/pv-icons' import { ListItem } from '@planview/pv-uikit' import { ToolbarSectionLeft } from '../section' import { ToolbarButtonEmptyInverse } from '../button' describe('UserMenu', () => { describe('Layout', () => { it('should not render if no configuration', () => { const { queryByLabelText } = render( <> ) expect(queryByLabelText('User menu')).not.toBeInTheDocument() }) it('should render if configured', () => { const { getByRole } = render( }> ) expect( getByRole('button', { name: 'User menu', expanded: false }) ).toBeInTheDocument() }) }) describe('Interaction', () => { it('should be last item in navigation', async () => { const { getByRole, queryByLabelText } = render( }> Button 1 Button 2 ) await userEvent.keyboard('{Tab}') expect(getByRole('button', { name: 'Button 1' })).toHaveFocus() await userEvent.keyboard('{ArrowRight}{ArrowRight}') expect(queryByLabelText('User menu')).toHaveFocus() }) it('should have tooltip when focused', async () => { const { queryByLabelText, findByRole } = render( }> ) await userEvent.keyboard('{Tab}') expect(queryByLabelText('User menu')).toHaveFocus() expect( await findByRole('tooltip', { name: 'User menu' }) ).toBeInTheDocument() }) it('should expand list and render list item', async () => { const { getByRole } = render( }> ) await userEvent.keyboard('{Tab}{ArrowDown}') expect( getByRole('button', { name: 'User menu', expanded: true }) ).toBeInTheDocument() expect( getByRole('menuitemradio', { name: 'test item' }) ).toBeInTheDocument() }) }) })