import { render } from 'utils/testRenderer'; import { MultipleRoleSelect } from './MultipleRoleSelect'; import { fireEvent, screen } from '@testing-library/react'; test('Display grouped project roles with names and descriptions', async () => { render( {}} />, ); const multiselect = await screen.findByLabelText('Role'); fireEvent.click(multiselect); expect(screen.getByText('Predefined project roles')).toBeInTheDocument(); expect(screen.getByText('Owner')).toBeInTheDocument(); expect(screen.getByText('Owner description')).toBeInTheDocument(); expect(screen.getByText('Custom project roles')).toBeInTheDocument(); const customRoleA = screen.getByText('A Custom Role'); const customRoleB = screen.getByText('B Custom Role'); expect(customRoleA).toBeInTheDocument(); expect(customRoleB).toBeInTheDocument(); expect(customRoleA.compareDocumentPosition(customRoleB)).toBe( Node.DOCUMENT_POSITION_FOLLOWING, ); expect(screen.getByText('Custom role description A')).toBeInTheDocument(); expect(screen.getByText('Custom role description B')).toBeInTheDocument(); });