mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 03:17:11 +00:00
Merge branch 'feature/guided-tour' of github.com:strapi/strapi into feature/guided-tour
This commit is contained in:
commit
1c9422eac8
@ -1,8 +1,14 @@
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { render, waitFor } from '@testing-library/react';
|
||||
import { QueryClientProvider, QueryClient } from 'react-query';
|
||||
import { useGuidedTour } from '@strapi/helper-plugin';
|
||||
import { ConfigurationsContext } from '../../../contexts';
|
||||
import { fetchAppInfo, fetchCurrentUserPermissions, fetchStrapiLatestRelease } from '../utils/api';
|
||||
import {
|
||||
fetchAppInfo,
|
||||
fetchCurrentUserPermissions,
|
||||
fetchStrapiLatestRelease,
|
||||
fetchUserRoles,
|
||||
} from '../utils/api';
|
||||
import packageJSON from '../../../../../package.json';
|
||||
import Theme from '../../Theme';
|
||||
import AuthenticatedApp from '..';
|
||||
@ -21,7 +27,7 @@ jest.mock('../utils/api', () => ({
|
||||
fetchStrapiLatestRelease: jest.fn(),
|
||||
fetchAppInfo: jest.fn(),
|
||||
fetchCurrentUserPermissions: jest.fn(),
|
||||
fetchUserRoles: jest.fn(() => [{ name: 'Super Admin' }]),
|
||||
fetchUserRoles: jest.fn(() => [{ code: 'strapi-super-admin' }]),
|
||||
}));
|
||||
|
||||
jest.mock('../../PluginsInitializer', () => () => <div>PluginsInitializer</div>);
|
||||
@ -138,4 +144,22 @@ 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' }]);
|
||||
const setGuidedTourVisibility = jest.fn();
|
||||
useGuidedTour.mockImplementation(() => ({ setGuidedTourVisibility }));
|
||||
|
||||
render(app);
|
||||
|
||||
await waitFor(() => expect(setGuidedTourVisibility).not.toHaveBeenCalled());
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user