Skip to content

Commit 670aa28

Browse files
committed
test: useEvent intead of fireEvent
1 parent a554cb6 commit 670aa28

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/authz-module/libraries-manager/ErrorPage/index.test.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import {
2-
screen, fireEvent, waitFor,
3-
} from '@testing-library/react';
1+
import { screen } from '@testing-library/react';
2+
import userEvent from '@testing-library/user-event';
43
import { ErrorBoundary } from 'react-error-boundary';
54
import { renderWrapper } from '@src/setupTest';
65
import LibrariesErrorFallback from './index';
@@ -67,9 +66,8 @@ describe('LibrariesErrorFallback', () => {
6766
<ThrowError error={error} />
6867
</ErrorBoundary>,
6968
);
70-
const reloadBtn = screen.getByText(/Reload Page/i);
71-
fireEvent.click(reloadBtn);
72-
// If your ErrorPage uses error.refetch, this will be called
73-
await waitFor(() => expect(refetch).toHaveBeenCalled());
69+
const user = userEvent.setup();
70+
await user.click(screen.getByText(/Reload Page/i));
71+
expect(refetch).toHaveBeenCalled();
7472
});
7573
});

src/authz-module/libraries-manager/context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { AppContext } from '@edx/frontend-platform/react';
66
import { useValidateUserPermissions } from '@src/data/hooks';
77
import { usePermissionsByRole } from '@src/authz-module/data/hooks';
88
import { PermissionMetadata, ResourceMetadata, Role } from 'types';
9-
import { libraryPermissions, libraryResourceTypes, libraryRolesMetadata } from './constants';
109
import { CustomErrors } from '@src/constants';
10+
import { libraryPermissions, libraryResourceTypes, libraryRolesMetadata } from './constants';
1111

1212
const LIBRARY_TEAM_PERMISSIONS = ['view_library_team', 'manage_library_team'];
1313

0 commit comments

Comments
 (0)