mirror of
https://github.com/strapi/strapi.git
synced 2025-08-23 08:09:10 +00:00
test: please work units
This commit is contained in:
parent
9ecb47b3f9
commit
00f1e17248
@ -113,6 +113,8 @@ describe('WorkflowAttributes', () => {
|
|||||||
|
|
||||||
const { getByRole, queryByRole, user } = setup();
|
const { getByRole, queryByRole, user } = setup();
|
||||||
|
|
||||||
|
await screen.findByText(/workflow name/i);
|
||||||
|
|
||||||
const contentTypesSelect = getByRole('combobox', { name: /associated to/i });
|
const contentTypesSelect = getByRole('combobox', { name: /associated to/i });
|
||||||
|
|
||||||
await user.click(contentTypesSelect);
|
await user.click(contentTypesSelect);
|
||||||
|
@ -30,7 +30,7 @@ import styled from 'styled-components';
|
|||||||
|
|
||||||
import { PERMISSIONS } from '../constants';
|
import { PERMISSIONS } from '../constants';
|
||||||
import {
|
import {
|
||||||
useGetInfosQuery,
|
useGetInfoQuery,
|
||||||
useRegenerateDocMutation,
|
useRegenerateDocMutation,
|
||||||
useDeleteVersionMutation,
|
useDeleteVersionMutation,
|
||||||
} from '../services/api';
|
} from '../services/api';
|
||||||
@ -40,7 +40,7 @@ const App = () => {
|
|||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const { toggleNotification } = useNotification();
|
const { toggleNotification } = useNotification();
|
||||||
const { formatAPIError } = useAPIErrorHandler();
|
const { formatAPIError } = useAPIErrorHandler();
|
||||||
const { data, isLoading: isLoadingInfo, isError } = useGetInfosQuery();
|
const { data, isLoading: isLoadingInfo, isError } = useGetInfoQuery();
|
||||||
const [regenerate] = useRegenerateDocMutation();
|
const [regenerate] = useRegenerateDocMutation();
|
||||||
const [deleteVersion] = useDeleteVersionMutation();
|
const [deleteVersion] = useDeleteVersionMutation();
|
||||||
const [showConfirmDelete, setShowConfirmDelete] = React.useState<boolean>(false);
|
const [showConfirmDelete, setShowConfirmDelete] = React.useState<boolean>(false);
|
||||||
|
@ -6,7 +6,7 @@ import { FormikHelpers } from 'formik';
|
|||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
|
|
||||||
import { SettingsForm } from '../components/SettingsForm';
|
import { SettingsForm } from '../components/SettingsForm';
|
||||||
import { useGetInfosQuery, useUpdateSettingsMutation } from '../services/api';
|
import { useGetInfoQuery, useUpdateSettingsMutation } from '../services/api';
|
||||||
import { getTrad, isBaseQueryError } from '../utils';
|
import { getTrad, isBaseQueryError } from '../utils';
|
||||||
|
|
||||||
import type { SettingsInput } from '../types';
|
import type { SettingsInput } from '../types';
|
||||||
@ -18,7 +18,7 @@ const SettingsPage = () => {
|
|||||||
_unstableFormatAPIError: formatAPIError,
|
_unstableFormatAPIError: formatAPIError,
|
||||||
_unstableFormatValidationErrors: formatValidationErrors,
|
_unstableFormatValidationErrors: formatValidationErrors,
|
||||||
} = useAPIErrorHandler();
|
} = useAPIErrorHandler();
|
||||||
const { data, isError, isLoading } = useGetInfosQuery();
|
const { data, isError, isLoading, isFetching } = useGetInfoQuery();
|
||||||
const [updateSettings] = useUpdateSettingsMutation();
|
const [updateSettings] = useUpdateSettingsMutation();
|
||||||
|
|
||||||
const onUpdateSettings = async (body: SettingsInput, formik: FormikHelpers<SettingsInput>) => {
|
const onUpdateSettings = async (body: SettingsInput, formik: FormikHelpers<SettingsInput>) => {
|
||||||
@ -45,7 +45,7 @@ const SettingsPage = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading || isFetching) {
|
||||||
return <Page.Loading />;
|
return <Page.Loading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,10 @@ describe('SettingsPage', () => {
|
|||||||
|
|
||||||
fireEvent.click(getByRole('button', { name: 'Save' }));
|
fireEvent.click(getByRole('button', { name: 'Save' }));
|
||||||
|
|
||||||
|
await findByText('Loading content.');
|
||||||
|
|
||||||
await findByText('Successfully updated settings');
|
await findByText('Successfully updated settings');
|
||||||
|
|
||||||
|
await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -11,12 +11,12 @@ type SettingsInput = {
|
|||||||
const api = createApi({
|
const api = createApi({
|
||||||
reducerPath: 'plugin::documentation',
|
reducerPath: 'plugin::documentation',
|
||||||
baseQuery: baseQuery(),
|
baseQuery: baseQuery(),
|
||||||
tagTypes: ['DocumentInfos'],
|
tagTypes: ['DocumentInfo'],
|
||||||
endpoints: (builder) => {
|
endpoints: (builder) => {
|
||||||
return {
|
return {
|
||||||
getInfos: builder.query<DocumentInfos, void>({
|
getInfo: builder.query<DocumentInfos, void>({
|
||||||
query: () => '/documentation/getInfos',
|
query: () => '/documentation/getInfos',
|
||||||
providesTags: ['DocumentInfos'],
|
providesTags: ['DocumentInfo'],
|
||||||
}),
|
}),
|
||||||
|
|
||||||
deleteVersion: builder.mutation<void, { version: string }>({
|
deleteVersion: builder.mutation<void, { version: string }>({
|
||||||
@ -24,7 +24,7 @@ const api = createApi({
|
|||||||
url: `/documentation/deleteDoc/${version}`,
|
url: `/documentation/deleteDoc/${version}`,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
}),
|
}),
|
||||||
invalidatesTags: ['DocumentInfos'],
|
invalidatesTags: ['DocumentInfo'],
|
||||||
}),
|
}),
|
||||||
|
|
||||||
updateSettings: builder.mutation<void, { body: SettingsInput }>({
|
updateSettings: builder.mutation<void, { body: SettingsInput }>({
|
||||||
@ -33,7 +33,7 @@ const api = createApi({
|
|||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
data: body,
|
data: body,
|
||||||
}),
|
}),
|
||||||
invalidatesTags: ['DocumentInfos'],
|
invalidatesTags: ['DocumentInfo'],
|
||||||
}),
|
}),
|
||||||
|
|
||||||
regenerateDoc: builder.mutation<void, { version: string }>({
|
regenerateDoc: builder.mutation<void, { version: string }>({
|
||||||
@ -50,7 +50,7 @@ const api = createApi({
|
|||||||
export { api };
|
export { api };
|
||||||
|
|
||||||
export const {
|
export const {
|
||||||
useGetInfosQuery,
|
useGetInfoQuery,
|
||||||
useDeleteVersionMutation,
|
useDeleteVersionMutation,
|
||||||
useUpdateSettingsMutation,
|
useUpdateSettingsMutation,
|
||||||
useRegenerateDocMutation,
|
useRegenerateDocMutation,
|
||||||
|
@ -127,6 +127,11 @@ describe('Roles – EditPage', () => {
|
|||||||
fireEvent.click(getByRole('button', { name: 'Save' }));
|
fireEvent.click(getByRole('button', { name: 'Save' }));
|
||||||
|
|
||||||
await waitFor(() => expect(getByText('Role edited')).toBeInTheDocument());
|
await waitFor(() => expect(getByText('Role edited')).toBeInTheDocument());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @note the permissions are refetched, because we're mocking calls no real update will be made.
|
||||||
|
*/
|
||||||
|
await waitFor(() => expect(getByRole('checkbox', { name: 'create' })).not.toBeChecked());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('will update the Advanced Settings panel when you click on the cog icon of a specific permission', async () => {
|
it('will update the Advanced Settings panel when you click on the cog icon of a specific permission', async () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user