mirror of
https://github.com/strapi/strapi.git
synced 2025-09-23 07:22:51 +00:00
fix tests and lint errors
This commit is contained in:
parent
66a8e34198
commit
d1540bf7ee
@ -1,7 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { Combobox, ComboboxOption } from '@strapi/design-system';
|
import { Combobox, ComboboxOption } from '@strapi/design-system';
|
||||||
import { getDisplayName } from '@strapi/helper-plugin';
|
import { getDisplayName } from '@strapi/helper-plugin';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
|
|
||||||
import { useAdminUsers } from '../../../hooks/useAdminUsers';
|
import { useAdminUsers } from '../../../hooks/useAdminUsers';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import get from 'lodash/get';
|
|
||||||
import { useRBACProvider, findMatchingPermissions, useCollator } from '@strapi/helper-plugin';
|
import { useRBACProvider, findMatchingPermissions, useCollator } from '@strapi/helper-plugin';
|
||||||
|
import get from 'lodash/get';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
|
|
||||||
const NOT_ALLOWED_FILTERS = ['json', 'component', 'media', 'richtext', 'dynamiczone', 'password'];
|
const NOT_ALLOWED_FILTERS = ['json', 'component', 'media', 'richtext', 'dynamiczone', 'password'];
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { useQueryParams, getDisplayName } from '@strapi/helper-plugin';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import { useQueryParams, getDisplayName } from '@strapi/helper-plugin';
|
|
||||||
import { useAdminUsers } from '../../../hooks/useAdminUsers';
|
import { useAdminUsers } from '../../../hooks/useAdminUsers';
|
||||||
import useAllowedAttributes from './hooks/useAllowedAttributes';
|
|
||||||
import Filters from './Filters';
|
|
||||||
import { AdminUsersFilter } from './AdminUsersFilter';
|
import { AdminUsersFilter } from './AdminUsersFilter';
|
||||||
|
import Filters from './Filters';
|
||||||
|
import useAllowedAttributes from './hooks/useAllowedAttributes';
|
||||||
|
|
||||||
const AUTHOR_ATTRIBUTES = ['createdBy', 'updatedBy'];
|
const AUTHOR_ATTRIBUTES = ['createdBy', 'updatedBy'];
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { rest } from 'msw';
|
|
||||||
import { setupServer } from 'msw/node';
|
import { ThemeProvider, lightTheme } from '@strapi/design-system';
|
||||||
import { render, waitFor } from '@testing-library/react';
|
import { render, waitFor } from '@testing-library/react';
|
||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
import { ThemeProvider, lightTheme } from '@strapi/design-system';
|
import { rest } from 'msw';
|
||||||
|
import { setupServer } from 'msw/node';
|
||||||
import { IntlProvider } from 'react-intl';
|
import { IntlProvider } from 'react-intl';
|
||||||
import { QueryClientProvider, QueryClient } from 'react-query';
|
import { QueryClientProvider, QueryClient } from 'react-query';
|
||||||
|
|
||||||
import { AdminUsersFilter } from '../AdminUsersFilter';
|
import { AdminUsersFilter } from '../AdminUsersFilter';
|
||||||
|
|
||||||
const server = setupServer(
|
const server = setupServer(
|
||||||
|
@ -50,6 +50,7 @@ describe('CONTENT MANAGER | EditView | Information', () => {
|
|||||||
useCMEditViewDataManager.mockImplementationOnce(() => ({
|
useCMEditViewDataManager.mockImplementationOnce(() => ({
|
||||||
initialData: {},
|
initialData: {},
|
||||||
isCreatingEntry: true,
|
isCreatingEntry: true,
|
||||||
|
readActionAllowedFields: ['createdBy', 'updatedBy'],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { getByText, getAllByText } = setup();
|
const { getByText, getAllByText } = setup();
|
||||||
@ -77,6 +78,7 @@ describe('CONTENT MANAGER | EditView | Information', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
isCreatingEntry: false,
|
isCreatingEntry: false,
|
||||||
|
readActionAllowedFields: ['createdBy', 'updatedBy'],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { getAllByText } = setup();
|
const { getAllByText } = setup();
|
||||||
@ -103,6 +105,7 @@ describe('CONTENT MANAGER | EditView | Information', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
isCreatingEntry: false,
|
isCreatingEntry: false,
|
||||||
|
readActionAllowedFields: ['createdBy', 'updatedBy'],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { queryByText, getAllByText } = setup();
|
const { queryByText, getAllByText } = setup();
|
||||||
|
@ -47,6 +47,7 @@ describe('CONTENT MANAGER | EditView | InformationBoxCE', () => {
|
|||||||
useCMEditViewDataManager.mockImplementationOnce(() => ({
|
useCMEditViewDataManager.mockImplementationOnce(() => ({
|
||||||
initialData: {},
|
initialData: {},
|
||||||
isCreatingEntry: true,
|
isCreatingEntry: true,
|
||||||
|
readActionAllowedFields: [],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { getByText } = setup();
|
const { getByText } = setup();
|
||||||
|
@ -103,6 +103,7 @@ describe('EE | Content Manager | EditView | InformationBox', () => {
|
|||||||
initialData: {},
|
initialData: {},
|
||||||
isCreatingEntry: true,
|
isCreatingEntry: true,
|
||||||
layout: { uid: 'api::articles:articles', options: { reviewWorkflows: true } },
|
layout: { uid: 'api::articles:articles', options: { reviewWorkflows: true } },
|
||||||
|
readActionAllowedFields: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const { getByText } = setup();
|
const { getByText } = setup();
|
||||||
@ -127,6 +128,7 @@ describe('EE | Content Manager | EditView | InformationBox', () => {
|
|||||||
useCMEditViewDataManager.mockReturnValue({
|
useCMEditViewDataManager.mockReturnValue({
|
||||||
initialData: {},
|
initialData: {},
|
||||||
layout: { uid: 'api::articles:articles', options: { reviewWorkflows: false } },
|
layout: { uid: 'api::articles:articles', options: { reviewWorkflows: false } },
|
||||||
|
readActionAllowedFields: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const { queryByRole } = setup();
|
const { queryByRole } = setup();
|
||||||
@ -134,13 +136,29 @@ describe('EE | Content Manager | EditView | InformationBox', () => {
|
|||||||
expect(queryByRole('combobox')).not.toBeInTheDocument();
|
expect(queryByRole('combobox')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not render the select input, if the entity is being created', () => {
|
it('renders an error, if no workflow stage is assigned to the entity', () => {
|
||||||
|
useCMEditViewDataManager.mockReturnValue({
|
||||||
|
initialData: {
|
||||||
|
[STAGE_ATTRIBUTE_NAME]: null,
|
||||||
|
},
|
||||||
|
layout: { uid: 'api::articles:articles' },
|
||||||
|
readActionAllowedFields: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
const { getByText, queryByRole } = setup();
|
||||||
|
|
||||||
|
expect(getByText(/select a stage/i)).toBeInTheDocument();
|
||||||
|
expect(queryByRole('combobox')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not render the select input, if the entity is created', () => {
|
||||||
useCMEditViewDataManager.mockReturnValue({
|
useCMEditViewDataManager.mockReturnValue({
|
||||||
initialData: {
|
initialData: {
|
||||||
[STAGE_ATTRIBUTE_NAME]: STAGE_FIXTURE,
|
[STAGE_ATTRIBUTE_NAME]: STAGE_FIXTURE,
|
||||||
},
|
},
|
||||||
isCreatingEntry: true,
|
isCreatingEntry: true,
|
||||||
layout: { uid: 'api::articles:articles', options: { reviewWorkflows: true } },
|
layout: { uid: 'api::articles:articles', options: { reviewWorkflows: true } },
|
||||||
|
readActionAllowedFields: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const { queryByRole } = setup();
|
const { queryByRole } = setup();
|
||||||
@ -156,6 +174,7 @@ describe('EE | Content Manager | EditView | InformationBox', () => {
|
|||||||
},
|
},
|
||||||
isCreatingEntry: false,
|
isCreatingEntry: false,
|
||||||
layout: { uid: 'api::articles:articles', options: { reviewWorkflows: true } },
|
layout: { uid: 'api::articles:articles', options: { reviewWorkflows: true } },
|
||||||
|
readActionAllowedFields: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const { queryByRole } = setup();
|
const { queryByRole } = setup();
|
||||||
@ -171,6 +190,7 @@ describe('EE | Content Manager | EditView | InformationBox', () => {
|
|||||||
},
|
},
|
||||||
isCreatingEntry: false,
|
isCreatingEntry: false,
|
||||||
layout: { uid: 'api::articles:articles', options: { reviewWorkflows: true } },
|
layout: { uid: 'api::articles:articles', options: { reviewWorkflows: true } },
|
||||||
|
readActionAllowedFields: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const { getByRole, getByText, user } = setup();
|
const { getByRole, getByText, user } = setup();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user