mirror of
https://github.com/strapi/strapi.git
synced 2025-12-24 13:43:41 +00:00
Merge pull request #13130 from strapi/fix/authenticated-app-tests
Fix / AuthenticatedApp tests
This commit is contained in:
commit
1bd821fa2f
@ -32,7 +32,7 @@ jest.mock('../utils/api', () => ({
|
||||
fetchStrapiLatestRelease: jest.fn(),
|
||||
fetchAppInfo: jest.fn(),
|
||||
fetchCurrentUserPermissions: jest.fn(),
|
||||
fetchUserRoles: jest.fn(() => [{ code: 'strapi-super-admin' }]),
|
||||
fetchUserRoles: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../PluginsInitializer', () => () => <div>PluginsInitializer</div>);
|
||||
@ -85,6 +85,10 @@ describe('Admin | components | AuthenticatedApp', () => {
|
||||
|
||||
expect(container.firstChild).toMatchInlineSnapshot(`
|
||||
.c0 {
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
@ -96,10 +100,6 @@ describe('Admin | components | AuthenticatedApp', () => {
|
||||
-webkit-justify-content: space-around;
|
||||
-ms-flex-pack: space-around;
|
||||
justify-content: space-around;
|
||||
-webkit-align-items: center;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.c2 {
|
||||
@ -152,16 +152,8 @@ describe('Admin | components | AuthenticatedApp', () => {
|
||||
expect(fetchStrapiLatestRelease).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call setGuidedTourVisibility when user is super admin', async () => {
|
||||
const setGuidedTourVisibility = jest.fn();
|
||||
useGuidedTour.mockImplementation(() => ({ setGuidedTourVisibility }));
|
||||
render(app);
|
||||
|
||||
await waitFor(() => expect(setGuidedTourVisibility).toHaveBeenCalledWith(true));
|
||||
});
|
||||
|
||||
it.only('should not setGuidedTourVisibility when user is not super admin', async () => {
|
||||
fetchUserRoles.mockImplementation(() => [{ code: 'strapi-editor' }]);
|
||||
it('should not setGuidedTourVisibility when user is not super admin', async () => {
|
||||
fetchUserRoles.mockImplementationOnce(() => [{ code: 'strapi-editor' }]);
|
||||
const setGuidedTourVisibility = jest.fn();
|
||||
useGuidedTour.mockImplementation(() => ({ setGuidedTourVisibility }));
|
||||
|
||||
@ -169,4 +161,13 @@ describe('Admin | components | AuthenticatedApp', () => {
|
||||
|
||||
await waitFor(() => expect(setGuidedTourVisibility).not.toHaveBeenCalled());
|
||||
});
|
||||
|
||||
it('should call setGuidedTourVisibility when user is super admin', async () => {
|
||||
fetchUserRoles.mockImplementationOnce(() => [{ code: 'strapi-super-admin' }]);
|
||||
const setGuidedTourVisibility = jest.fn();
|
||||
useGuidedTour.mockImplementation(() => ({ setGuidedTourVisibility }));
|
||||
render(app);
|
||||
|
||||
await waitFor(() => expect(setGuidedTourVisibility).toHaveBeenCalledWith(true));
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user