Skip to content

Commit

Permalink
test: add tests for table
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed Oct 7, 2024
1 parent 1d327a5 commit 588210e
Showing 1 changed file with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('WorkspaceCollaboratorTable', () => {
expect(getByText('group')).toBeInTheDocument();
});

it('should openModal when clicking actions', () => {
it('should openModal when clicking box actions menu', () => {
const permissionSettings = [
{
id: 0,
Expand All @@ -80,5 +80,67 @@ describe('WorkspaceCollaboratorTable', () => {
const deleteCollaborator = getByText('Delete collaborator');
fireEvent.click(deleteCollaborator);
expect(mockOverlays.openModal).toHaveBeenCalled();

const changeAccessLevel = getByText('Change access level');
fireEvent.click(changeAccessLevel);
expect(mockOverlays.openModal).toHaveBeenCalled();
});

it('should openModal when clicking multi selection delete', () => {
const permissionSettings = [
{
id: 0,
modes: ['library_write', 'write'],
type: 'user',
userId: 'admin',
},
{
id: 1,
modes: ['library_read', 'read'],
type: 'group',
group: 'group',
},
];

const { getByText, getByTestId } = render(
<Provider>
<WorkspaceCollaboratorTable {...mockProps} permissionSettings={permissionSettings} />
</Provider>
);
fireEvent.click(getByTestId('checkboxSelectRow-0'));
fireEvent.click(getByTestId('checkboxSelectRow-1'));
const deleteCollaborator = getByText('Delete 2 collaborators');
fireEvent.click(deleteCollaborator);
expect(mockOverlays.openModal).toHaveBeenCalled();
});

it('should openModal when clicking action tools when multi selection', () => {
const permissionSettings = [
{
id: 0,
modes: ['library_write', 'write'],
type: 'user',
userId: 'admin',
},
{
id: 1,
modes: ['library_read', 'read'],
type: 'group',
group: 'group',
},
];

const { getByText, getByTestId } = render(
<Provider>
<WorkspaceCollaboratorTable {...mockProps} permissionSettings={permissionSettings} />
</Provider>
);
fireEvent.click(getByTestId('checkboxSelectRow-0'));
fireEvent.click(getByTestId('checkboxSelectRow-1'));
const actions = getByTestId('workspace-detail-collaborator-table-actions');
fireEvent.click(actions);
const changeAccessLevel = getByText('Change access level');
fireEvent.click(changeAccessLevel);
expect(mockOverlays.openModal).toHaveBeenCalled();
});
});

0 comments on commit 588210e

Please sign in to comment.