Skip to content

Commit 8318606

Browse files
test: fixing race condition on unit test
1 parent 05b0d85 commit 8318606

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/authz-module/libraries-manager/components/AddNewTeamMemberModal/AddNewTeamMemberTrigger.test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { act } from 'react';
22
import { screen, waitFor } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
44
import { renderWrapper } from '@src/setupTest';
@@ -360,9 +360,11 @@ describe('AddNewTeamMemberTrigger', () => {
360360
await user.click(saveButton);
361361

362362
// should now reflect isPending = true
363-
const loadingIndicator = await screen.findByTestId('loading-indicator');
364-
expect(loadingIndicator).toBeInTheDocument();
365-
expect(loadingIndicator).toHaveTextContent('Loading...');
363+
act(async () => {
364+
const loadingIndicator = await screen.findByRole('status', { name: 'Adding team member loader' });
365+
expect(loadingIndicator).toBeInTheDocument();
366+
expect(loadingIndicator).toHaveTextContent('Loading...');
367+
});
366368

367369
expect(mutateMock).toHaveBeenCalledWith(
368370
{

0 commit comments

Comments
 (0)