-
-
Notifications
You must be signed in to change notification settings - Fork 734
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: grouping of project level roles in autocomplete (#9046)
- Loading branch information
Showing
2 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
frontend/src/component/common/MultipleRoleSelect/MultipleRoleSelect.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
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( | ||
<MultipleRoleSelect | ||
roles={[ | ||
{ | ||
id: 0, | ||
name: 'Owner', | ||
project: null, | ||
description: 'Owner description', | ||
type: 'project', | ||
}, | ||
{ | ||
id: 1, | ||
name: 'B Custom Role', | ||
project: null, | ||
description: 'Custom role description A', | ||
type: 'custom', | ||
}, | ||
{ | ||
id: 2, | ||
name: 'A Custom Role', | ||
project: null, | ||
description: 'Custom role description B', | ||
type: 'custom', | ||
}, | ||
]} | ||
value={[]} | ||
setValue={() => {}} | ||
/>, | ||
); | ||
|
||
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters