test: please work units

This commit is contained in:
Josh 2024-04-29 14:18:14 +01:00
parent 9ecb47b3f9
commit 00f1e17248
6 changed files with 22 additions and 11 deletions

View File

@ -113,6 +113,8 @@ describe('WorkflowAttributes', () => {
const { getByRole, queryByRole, user } = setup();
await screen.findByText(/workflow name/i);
const contentTypesSelect = getByRole('combobox', { name: /associated to/i });
await user.click(contentTypesSelect);

View File

@ -30,7 +30,7 @@ import styled from 'styled-components';
import { PERMISSIONS } from '../constants';
import {
useGetInfosQuery,
useGetInfoQuery,
useRegenerateDocMutation,
useDeleteVersionMutation,
} from '../services/api';
@ -40,7 +40,7 @@ const App = () => {
const { formatMessage } = useIntl();
const { toggleNotification } = useNotification();
const { formatAPIError } = useAPIErrorHandler();
const { data, isLoading: isLoadingInfo, isError } = useGetInfosQuery();
const { data, isLoading: isLoadingInfo, isError } = useGetInfoQuery();
const [regenerate] = useRegenerateDocMutation();
const [deleteVersion] = useDeleteVersionMutation();
const [showConfirmDelete, setShowConfirmDelete] = React.useState<boolean>(false);

View File

@ -6,7 +6,7 @@ import { FormikHelpers } from 'formik';
import { useIntl } from 'react-intl';
import { SettingsForm } from '../components/SettingsForm';
import { useGetInfosQuery, useUpdateSettingsMutation } from '../services/api';
import { useGetInfoQuery, useUpdateSettingsMutation } from '../services/api';
import { getTrad, isBaseQueryError } from '../utils';
import type { SettingsInput } from '../types';
@ -18,7 +18,7 @@ const SettingsPage = () => {
_unstableFormatAPIError: formatAPIError,
_unstableFormatValidationErrors: formatValidationErrors,
} = useAPIErrorHandler();
const { data, isError, isLoading } = useGetInfosQuery();
const { data, isError, isLoading, isFetching } = useGetInfoQuery();
const [updateSettings] = useUpdateSettingsMutation();
const onUpdateSettings = async (body: SettingsInput, formik: FormikHelpers<SettingsInput>) => {
@ -45,7 +45,7 @@ const SettingsPage = () => {
});
};
if (isLoading) {
if (isLoading || isFetching) {
return <Page.Loading />;
}

View File

@ -84,6 +84,10 @@ describe('SettingsPage', () => {
fireEvent.click(getByRole('button', { name: 'Save' }));
await findByText('Loading content.');
await findByText('Successfully updated settings');
await waitFor(() => expect(queryByText('Loading content.')).not.toBeInTheDocument());
});
});

View File

@ -11,12 +11,12 @@ type SettingsInput = {
const api = createApi({
reducerPath: 'plugin::documentation',
baseQuery: baseQuery(),
tagTypes: ['DocumentInfos'],
tagTypes: ['DocumentInfo'],
endpoints: (builder) => {
return {
getInfos: builder.query<DocumentInfos, void>({
getInfo: builder.query<DocumentInfos, void>({
query: () => '/documentation/getInfos',
providesTags: ['DocumentInfos'],
providesTags: ['DocumentInfo'],
}),
deleteVersion: builder.mutation<void, { version: string }>({
@ -24,7 +24,7 @@ const api = createApi({
url: `/documentation/deleteDoc/${version}`,
method: 'DELETE',
}),
invalidatesTags: ['DocumentInfos'],
invalidatesTags: ['DocumentInfo'],
}),
updateSettings: builder.mutation<void, { body: SettingsInput }>({
@ -33,7 +33,7 @@ const api = createApi({
method: 'PUT',
data: body,
}),
invalidatesTags: ['DocumentInfos'],
invalidatesTags: ['DocumentInfo'],
}),
regenerateDoc: builder.mutation<void, { version: string }>({
@ -50,7 +50,7 @@ const api = createApi({
export { api };
export const {
useGetInfosQuery,
useGetInfoQuery,
useDeleteVersionMutation,
useUpdateSettingsMutation,
useRegenerateDocMutation,

View File

@ -127,6 +127,11 @@ describe('Roles EditPage', () => {
fireEvent.click(getByRole('button', { name: 'Save' }));
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 () => {