@plone/volto 19.0.0-alpha.0 → 19.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -0
- package/.eslintrc +2 -0
- package/CHANGELOG.md +63 -2
- package/locales/ca/LC_MESSAGES/volto.po +15 -0
- package/locales/ca.json +1 -1
- package/locales/de/LC_MESSAGES/volto.po +15 -0
- package/locales/de.json +1 -1
- package/locales/en/LC_MESSAGES/volto.po +15 -0
- package/locales/en.json +1 -1
- package/locales/es/LC_MESSAGES/volto.po +15 -0
- package/locales/es.json +1 -1
- package/locales/eu/LC_MESSAGES/volto.po +15 -0
- package/locales/eu.json +1 -1
- package/locales/fi/LC_MESSAGES/volto.po +15 -0
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +15 -0
- package/locales/fr.json +1 -1
- package/locales/hi/LC_MESSAGES/volto.po +15 -0
- package/locales/hi.json +1 -1
- package/locales/it/LC_MESSAGES/volto.po +15 -0
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +15 -0
- package/locales/ja.json +1 -1
- package/locales/nl/LC_MESSAGES/volto.po +15 -0
- package/locales/nl.json +1 -1
- package/locales/pt/LC_MESSAGES/volto.po +15 -0
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +15 -0
- package/locales/pt_BR.json +1 -1
- package/locales/ro/LC_MESSAGES/volto.po +15 -0
- package/locales/ro.json +1 -1
- package/locales/ru/LC_MESSAGES/volto.po +15 -0
- package/locales/ru.json +1 -1
- package/locales/volto.pot +15 -0
- package/locales/zh_CN/LC_MESSAGES/volto.po +15 -0
- package/locales/zh_CN.json +1 -1
- package/package.json +15 -8
- package/src/actions/actions/actions.test.js +3 -3
- package/src/actions/addons/addons.test.js +15 -12
- package/src/actions/aliases/aliases.test.js +1 -1
- package/src/actions/querystring/querystring.test.js +2 -2
- package/src/actions/types/types.test.js +1 -1
- package/src/components/manage/Actions/Actions.test.jsx +5 -1
- package/src/components/manage/Add/Add.jsx +22 -20
- package/src/components/manage/Add/Add.test.jsx +6 -3
- package/src/components/manage/Aliases/Aliases.test.jsx +7 -7
- package/src/components/manage/Blocks/Block/BlocksForm.jsx +1 -0
- package/src/components/manage/Blocks/Block/BlocksForm.test.jsx +48 -16
- package/src/components/manage/Blocks/Block/Edit.jsx +2 -1
- package/src/components/manage/Blocks/Block/Settings.test.jsx +5 -1
- package/src/components/manage/Blocks/Block/StyleWrapper.jsx +11 -3
- package/src/components/manage/Blocks/Description/View.test.jsx +1 -1
- package/src/components/manage/Blocks/HTML/Edit.test.jsx +12 -5
- package/src/components/manage/Blocks/HTML/View.test.jsx +1 -1
- package/src/components/manage/Blocks/Image/ImageSidebar.test.jsx +6 -2
- package/src/components/manage/Blocks/LeadImage/LeadImageSidebar.test.jsx +8 -1
- package/src/components/manage/Blocks/Listing/View.test.jsx +3 -1
- package/src/components/manage/Blocks/Maps/MapsSidebar.test.jsx +5 -1
- package/src/components/manage/Blocks/Search/components/DateRangeFacet.test.jsx +13 -7
- package/src/components/manage/Blocks/Search/components/SelectFacet.test.jsx +12 -6
- package/src/components/manage/Blocks/Title/Edit.jsx +8 -2
- package/src/components/manage/Blocks/ToC/variations/DefaultTocRenderer.test.jsx +11 -1
- package/src/components/manage/Blocks/Video/VideoSidebar.test.jsx +5 -1
- package/src/components/manage/ConditionalLink/ConditionalLink.test.tsx +109 -0
- package/src/components/manage/ConditionalLink/ConditionalLink.tsx +36 -0
- package/src/components/manage/Contents/Contents.test.jsx +29 -13
- package/src/components/manage/Contents/ContentsPropertiesModal.test.jsx +5 -1
- package/src/components/manage/Contents/ContentsRenameModal.test.jsx +5 -1
- package/src/components/manage/Contents/ContentsTagsModal.test.jsx +5 -1
- package/src/components/manage/Contents/ContentsWorkflowModal.test.jsx +5 -1
- package/src/components/manage/Contents/__mocks__/index.tsx +16 -0
- package/src/components/manage/Contents/__mocks__/index.vitest.tsx +5 -0
- package/src/components/manage/Controlpanels/AddonsControlpanel.test.jsx +28 -3
- package/src/components/manage/Controlpanels/Aliases.test.jsx +35 -3
- package/src/components/manage/Controlpanels/ContentType.test.jsx +29 -3
- package/src/components/manage/Controlpanels/ContentTypeLayout.test.jsx +4 -2
- package/src/components/manage/Controlpanels/ContentTypes.test.jsx +25 -2
- package/src/components/manage/Controlpanels/Controlpanel.test.jsx +37 -6
- package/src/components/manage/Controlpanels/Controlpanels.test.jsx +47 -3
- package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.test.jsx +15 -9
- package/src/components/manage/Controlpanels/ModerateComments.test.jsx +31 -5
- package/src/components/manage/Controlpanels/Rules/AddRule.test.jsx +13 -4
- package/src/components/manage/Controlpanels/Rules/ConfigureRule.test.jsx +9 -5
- package/src/components/manage/Controlpanels/Rules/EditRule.test.jsx +12 -4
- package/src/components/manage/Controlpanels/Rules/Rules.test.jsx +7 -3
- package/src/components/manage/Controlpanels/UndoControlpanel.test.jsx +33 -4
- package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.test.jsx +3 -1
- package/src/components/manage/Controlpanels/Users/UsersControlpanel.test.jsx +15 -9
- package/src/components/manage/Delete/Delete.test.jsx +45 -4
- package/src/components/manage/Diff/Diff.test.jsx +15 -6
- package/src/components/manage/Diff/DiffField.test.jsx +12 -6
- package/src/components/manage/Display/Display.test.jsx +17 -6
- package/src/components/manage/Edit/Edit.test.jsx +11 -3
- package/src/components/manage/Form/BlockDataForm.test.jsx +5 -1
- package/src/components/manage/Form/Form.jsx +32 -0
- package/src/components/manage/Form/Form.test.jsx +27 -19
- package/src/components/manage/Form/InlineForm.test.jsx +5 -1
- package/src/components/manage/Form/ModalForm.test.jsx +5 -1
- package/src/components/manage/Form/__mocks__/index.tsx +17 -0
- package/src/components/manage/Form/__mocks__/index.vitest.tsx +73 -0
- package/src/components/manage/History/History.test.jsx +3 -1
- package/src/components/manage/LinksToItem/LinksToItem.test.jsx +6 -4
- package/src/components/manage/MaybeWrap/MaybeWrap.tsx +15 -0
- package/src/components/manage/Multilingual/ManageTranslations.test.jsx +3 -2
- package/src/components/manage/Preferences/ChangePassword.test.jsx +9 -2
- package/src/components/manage/Preferences/PersonalInformation.test.jsx +3 -1
- package/src/components/manage/Preferences/PersonalPreferences.test.jsx +20 -7
- package/src/components/manage/Rules/Rules.test.jsx +6 -3
- package/src/components/manage/Sharing/Sharing.test.jsx +3 -1
- package/src/components/manage/Sidebar/ObjectBrowserNav.test.jsx +3 -3
- package/src/components/manage/Toolbar/More.test.jsx +6 -7
- package/src/components/manage/UniversalLink/UniversalLink.test.jsx +196 -14
- package/src/components/manage/UniversalLink/UniversalLink.tsx +214 -0
- package/src/components/manage/Widgets/ArrayWidget.test.jsx +22 -5
- package/src/components/manage/Widgets/CheckboxGroupWidget.test.jsx +12 -5
- package/src/components/manage/Widgets/DatetimeWidget.test.jsx +21 -6
- package/src/components/manage/Widgets/ImageWidget.jsx +5 -2
- package/src/components/manage/Widgets/NumberWidget.test.jsx +8 -7
- package/src/components/manage/Widgets/ObjectListWidget.jsx +11 -1
- package/src/components/manage/Widgets/ObjectListWidget.test.jsx +18 -8
- package/src/components/manage/Widgets/ObjectWidget.test.jsx +5 -1
- package/src/components/manage/Widgets/RadioGroupWidget.test.jsx +12 -5
- package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.test.jsx +12 -6
- package/src/components/manage/Widgets/RegistryImageWidget.test.jsx +43 -41
- package/src/components/manage/Widgets/SchemaWidget.test.jsx +12 -5
- package/src/components/manage/Widgets/SchemaWidgetFieldset.test.jsx +12 -5
- package/src/components/manage/Widgets/SelectAutoComplete.test.jsx +12 -6
- package/src/components/manage/Widgets/SelectWidget.jsx +3 -1
- package/src/components/manage/Widgets/SelectWidget.test.jsx +12 -6
- package/src/components/manage/Widgets/TimeWidget.test.jsx +13 -5
- package/src/components/manage/Widgets/TokenWidget.test.jsx +12 -6
- package/src/components/manage/Widgets/VocabularyTermsWidget.test.jsx +18 -9
- package/src/components/manage/Widgets/__mocks__/index.tsx +16 -0
- package/src/components/manage/Widgets/__mocks__/index.vitest.tsx +41 -0
- package/src/components/manage/Workflow/Workflow.test.jsx +17 -7
- package/src/components/theme/App/App.test.jsx +21 -17
- package/src/components/theme/AppExtras/AppExtras.test.jsx +6 -6
- package/src/components/theme/Comments/CommentEditModal.test.jsx +5 -1
- package/src/components/theme/Comments/Comments.test.jsx +29 -12
- package/src/components/theme/ContactForm/ContactForm.test.jsx +8 -4
- package/src/components/theme/Header/Header.test.jsx +19 -13
- package/src/components/theme/Logout/Logout.test.jsx +1 -1
- package/src/components/theme/PasswordReset/PasswordReset.test.jsx +10 -1
- package/src/components/theme/PasswordReset/RequestPasswordReset.test.jsx +5 -1
- package/src/components/theme/Register/Register.test.jsx +5 -1
- package/src/components/theme/Search/Search.test.jsx +6 -4
- package/src/components/theme/TsTest/TsTest.test.tsx +0 -1
- package/src/components/theme/View/EventDatesInfo.test.jsx +12 -5
- package/src/components/theme/View/EventView.test.jsx +12 -5
- package/src/components/theme/View/ListingView.test.jsx +2 -0
- package/src/components/theme/View/SummaryView.test.jsx +10 -0
- package/src/components/theme/View/TabularView.test.jsx +1 -0
- package/src/components/theme/View/View.test.jsx +42 -23
- package/src/helpers/Api/Api.plone.rest.test.js +11 -9
- package/src/helpers/Api/Api.test.js +11 -14
- package/src/helpers/AsyncConnect/AsyncConnect.test.jsx +145 -189
- package/src/helpers/AuthToken/AuthToken.test.js +60 -22
- package/src/helpers/Blocks/Blocks.test.js +1 -1
- package/src/helpers/Html/Html.test.jsx +32 -28
- package/src/helpers/Loadable/__mocks__/Loadable.jsx +16 -1
- package/src/helpers/Loadable/__mocks__/Loadable.vitest.jsx +39 -0
- package/src/helpers/Utils/withSaveAsDraft.jsx +241 -0
- package/src/middleware/Api.test.js +47 -0
- package/src/middleware/api.js +1 -1
- package/src/middleware/storeProtectLoadUtils.test.js +90 -78
- package/test-setup-globals-vitest.js +46 -0
- package/theme/themes/pastanaga/collections/table.overrides +9 -0
- package/theme/themes/pastanaga/extras/main.less +15 -0
- package/tsconfig.declarations.json +12 -1
- package/tsconfig.json +2 -1
- package/types/components/manage/ConditionalLink/ConditionalLink.d.ts +11 -15
- package/types/components/manage/Contents/__mocks__/index.vitest.d.ts +2 -0
- package/types/components/manage/Form/__mocks__/index.vitest.d.ts +8 -0
- package/types/components/manage/MaybeWrap/MaybeWrap.d.ts +7 -5
- package/types/components/manage/UniversalLink/UniversalLink.d.ts +54 -20
- package/types/components/manage/Widgets/__mocks__/index.vitest.d.ts +33 -0
- package/types/helpers/Loadable/__mocks__/Loadable.vitest.d.ts +3 -0
- package/types/helpers/Utils/withSaveAsDraft.d.ts +1 -0
- package/types/react-router-hash-link.d.ts +12 -0
- package/types/routes.d.ts +4 -0
- package/types/server.d.ts +1 -1
- package/vite-plugins/svg.mjs +81 -0
- package/vitest.config.mjs +77 -0
- package/src/components/manage/ConditionalLink/ConditionalLink.jsx +0 -27
- package/src/components/manage/ConditionalLink/ConditionalLink.test.jsx +0 -30
- package/src/components/manage/MaybeWrap/MaybeWrap.jsx +0 -9
- package/src/components/manage/UniversalLink/UniversalLink.jsx +0 -154
- package/src/components/manage/Widgets/FileWidget.test.jsx +0 -91
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const AlignWidget = vi.fn(() => <div id="AlignWidget" />);
|
|
2
|
+
export const ButtonsWidget = vi.fn(() => <div id="ButtonsWidget" />);
|
|
3
|
+
export const ArrayWidget = vi.fn(() => <div id="ArrayWidget" />);
|
|
4
|
+
export const CheckboxWidget = vi.fn(() => <div id="CheckboxWidget" />);
|
|
5
|
+
export const FileWidget = vi.fn(() => <div id="FileWidget" />);
|
|
6
|
+
export const IdWidget = vi.fn(() => <div id="IdWidget" />);
|
|
7
|
+
export const PasswordWidget = vi.fn(() => <div id="PasswordWidget" />);
|
|
8
|
+
export const QueryWidget = vi.fn(() => <div id="QueryWidget" />);
|
|
9
|
+
export const QuerySortOnWidget = vi.fn(() => <div id="QuerySortOnWidget" />);
|
|
10
|
+
export const QuerystringWidget = vi.fn(() => <div id="QuerystringWidget" />);
|
|
11
|
+
export const SchemaWidget = vi.fn(() => <div id="SchemaWidget" />);
|
|
12
|
+
export const SelectWidget = vi.fn(() => <div id="SelectWidget" />);
|
|
13
|
+
export const TextareaWidget = vi.fn(() => <div id="TextareaWidget" />);
|
|
14
|
+
export const TextWidget = vi.fn(() => <div id="TextWidget" />);
|
|
15
|
+
export const TokenWidget = vi.fn(() => <div id="TokenWidget" />);
|
|
16
|
+
export const WysiwygWidget = vi.fn(() => <div id="WysiwygWidget" />);
|
|
17
|
+
export const UrlWidget = vi.fn(() => <div id="UrlWidget" />);
|
|
18
|
+
export const InternalUrlWidget = vi.fn(() => <div id="InternalUrlWidget" />);
|
|
19
|
+
export const EmailWidget = vi.fn(() => <div id="EmailWidget" />);
|
|
20
|
+
export const NumberWidget = vi.fn(() => <div id="NumberWidget" />);
|
|
21
|
+
export const ImageSizeWidget = vi.fn(() => <div id="ImageSizeWidget" />);
|
|
22
|
+
export const RegistryImageWidget = vi.fn(() => (
|
|
23
|
+
<div id="RegistryImageWidget" />
|
|
24
|
+
));
|
|
25
|
+
export const ReferenceWidget = vi.fn(() => <div id="ReferenceWidget" />);
|
|
26
|
+
export const ObjectBrowserWidget = vi.fn(() => (
|
|
27
|
+
<div id="ObjectBrowserWidget" />
|
|
28
|
+
));
|
|
29
|
+
export const ObjectWidget = vi.fn(() => <div id="ObjectWidget" />);
|
|
30
|
+
export const ObjectListWidget = vi.fn(() => <div id="ObjectListWidget" />);
|
|
31
|
+
export const VocabularyTermsWidget = vi.fn(() => (
|
|
32
|
+
<div id="VocabularyTermsWidget" />
|
|
33
|
+
));
|
|
34
|
+
export const SelectMetadataWidget = vi.fn(() => (
|
|
35
|
+
<div id="SelectMetadataWidget" />
|
|
36
|
+
));
|
|
37
|
+
export const SelectAutoComplete = vi.fn(() => <div id="SelectAutoComplete" />);
|
|
38
|
+
export const ColorPickerWidget = vi.fn(() => <div id="ColorPickerWidget" />);
|
|
39
|
+
export const DatetimeWidget = vi.fn(() => <div id="DatetimeWidget" />);
|
|
40
|
+
export const RecurrenceWidget = vi.fn(() => <div id="RecurrenceWidget" />);
|
|
41
|
+
export const FormFieldWrapper = vi.fn(() => <div id="FormFieldWrapper" />);
|
|
@@ -3,17 +3,27 @@ import configureStore from 'redux-mock-store';
|
|
|
3
3
|
import { Provider } from 'react-intl-redux';
|
|
4
4
|
import { render } from '@testing-library/react';
|
|
5
5
|
import config from '@plone/volto/registry';
|
|
6
|
-
|
|
7
6
|
import Workflow from './Workflow';
|
|
8
7
|
|
|
9
8
|
const mockStore = configureStore();
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
10
|
+
vi.mock('@plone/volto/components/manage/Widgets', async () => {
|
|
11
|
+
return await import(
|
|
12
|
+
'@plone/volto/components/manage/Widgets/__mocks__/index.vitest.tsx'
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
16
|
+
return await import(
|
|
17
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
beforeAll(async () => {
|
|
22
|
+
const { __setLoadables } = await import(
|
|
23
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
24
|
+
);
|
|
25
|
+
await __setLoadables();
|
|
26
|
+
});
|
|
17
27
|
|
|
18
28
|
beforeEach(() => {
|
|
19
29
|
config.settings.workflowMapping = {
|
|
@@ -16,24 +16,28 @@ beforeAll(() => {
|
|
|
16
16
|
|
|
17
17
|
const mockStore = configureStore();
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
vi.mock('../../manage/Toolbar/Toolbar', () => ({
|
|
20
|
+
default: vi.fn(() => <div id="toolbar" />),
|
|
21
|
+
}));
|
|
22
|
+
vi.mock('../Header/Header', () => ({
|
|
23
|
+
default: vi.fn(() => <div id="header" />),
|
|
24
|
+
}));
|
|
25
|
+
vi.mock('../Breadcrumbs/Breadcrumbs', () => ({
|
|
26
|
+
default: vi.fn(() => <div id="breadcrumbs" />),
|
|
27
|
+
}));
|
|
28
|
+
vi.mock('../../manage/Messages/Messages', () => ({
|
|
29
|
+
default: vi.fn(() => <div id="messages" />),
|
|
30
|
+
}));
|
|
31
|
+
vi.mock('../Navigation/Navigation', () => ({
|
|
32
|
+
default: vi.fn(() => <div id="navigation" />),
|
|
33
|
+
}));
|
|
34
|
+
vi.mock('semantic-ui-react', () => ({
|
|
35
|
+
Segment: vi.fn(() => <div id="segment" />),
|
|
36
|
+
Container: vi.fn(() => <div id="container" />),
|
|
37
|
+
}));
|
|
38
|
+
vi.mock('../Footer/Footer', () => ({
|
|
39
|
+
default: vi.fn(() => <div id="footer" />),
|
|
35
40
|
}));
|
|
36
|
-
jest.mock('../Footer/Footer', () => jest.fn(() => <div id="footer" />));
|
|
37
41
|
|
|
38
42
|
describe('App', () => {
|
|
39
43
|
it('renders a app component', () => {
|
|
@@ -9,7 +9,7 @@ beforeAll(() => {
|
|
|
9
9
|
match: {
|
|
10
10
|
path: '',
|
|
11
11
|
},
|
|
12
|
-
component:
|
|
12
|
+
component: vi.fn((props) => (
|
|
13
13
|
<div className="everywhere">{props.pathname}</div>
|
|
14
14
|
)),
|
|
15
15
|
},
|
|
@@ -17,7 +17,7 @@ beforeAll(() => {
|
|
|
17
17
|
match: {
|
|
18
18
|
path: '/all-blogs/*',
|
|
19
19
|
},
|
|
20
|
-
component:
|
|
20
|
+
component: vi.fn((props) => (
|
|
21
21
|
<div className="blog-listing" one={props.one} three={props.three} />
|
|
22
22
|
)),
|
|
23
23
|
props: {
|
|
@@ -29,27 +29,27 @@ beforeAll(() => {
|
|
|
29
29
|
match: {
|
|
30
30
|
path: '/blog/edit',
|
|
31
31
|
},
|
|
32
|
-
component:
|
|
32
|
+
component: vi.fn((props) => <div className="blog-edit" />),
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
match: {
|
|
36
36
|
path: '/blog',
|
|
37
37
|
exact: true,
|
|
38
38
|
},
|
|
39
|
-
component:
|
|
39
|
+
component: vi.fn((props) => (
|
|
40
40
|
<div className="blog-view">{JSON.stringify(props.match)}</div>
|
|
41
41
|
)),
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
match: '/something',
|
|
45
|
-
component:
|
|
45
|
+
component: vi.fn((props) => (
|
|
46
46
|
<div className="something">{JSON.stringify(props.match)}</div>
|
|
47
47
|
)),
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
match: '/frontpage',
|
|
51
51
|
ignore: '/frontpage/images',
|
|
52
|
-
component:
|
|
52
|
+
component: vi.fn((props) => (
|
|
53
53
|
<div className="frontpage-content">{JSON.stringify(props.match)}</div>
|
|
54
54
|
)),
|
|
55
55
|
},
|
|
@@ -7,7 +7,11 @@ import CommentEditModal from './CommentEditModal';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
vi.mock('@plone/volto/components/manage/Form', async () => {
|
|
11
|
+
return await import(
|
|
12
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
13
|
+
);
|
|
14
|
+
});
|
|
11
15
|
|
|
12
16
|
describe('CommentEditModal', () => {
|
|
13
17
|
it('renders a comment edit modal component', () => {
|
|
@@ -2,25 +2,40 @@ import React from 'react';
|
|
|
2
2
|
import renderer from 'react-test-renderer';
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
|
-
|
|
6
5
|
import Comments from './Comments';
|
|
7
6
|
|
|
7
|
+
vi.mock('@plone/volto/components/theme/Comments/CommentEditModal', () => ({
|
|
8
|
+
default: vi.fn(({ id, text, ...props }) => (
|
|
9
|
+
<div data-testid="comment-edit-modal">Mocked CommentEditModal</div>
|
|
10
|
+
)),
|
|
11
|
+
}));
|
|
12
|
+
|
|
8
13
|
const mockStore = configureStore();
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
format:
|
|
13
|
-
fromNow:
|
|
15
|
+
vi.mock('moment', () => ({
|
|
16
|
+
default: vi.fn(() => ({
|
|
17
|
+
format: vi.fn(() => 'Sunday, April 23, 2017 3:38 AM'),
|
|
18
|
+
fromNow: vi.fn(() => 'a few seconds ago'),
|
|
14
19
|
})),
|
|
15
|
-
);
|
|
20
|
+
}));
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
23
|
+
return await import(
|
|
24
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
vi.mock('@plone/volto/components/manage/Form', async () => {
|
|
28
|
+
return await import(
|
|
29
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
30
|
+
);
|
|
31
|
+
});
|
|
19
32
|
|
|
20
|
-
beforeAll(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
33
|
+
beforeAll(async () => {
|
|
34
|
+
const { __setLoadables } = await import(
|
|
35
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
36
|
+
);
|
|
37
|
+
await __setLoadables();
|
|
38
|
+
});
|
|
24
39
|
|
|
25
40
|
describe('Comments', () => {
|
|
26
41
|
it('renders a comments component', () => {
|
|
@@ -67,11 +82,13 @@ describe('Comments', () => {
|
|
|
67
82
|
},
|
|
68
83
|
},
|
|
69
84
|
});
|
|
85
|
+
|
|
70
86
|
const component = renderer.create(
|
|
71
87
|
<Provider store={store}>
|
|
72
88
|
<Comments pathname="/blog" />
|
|
73
89
|
</Provider>,
|
|
74
90
|
);
|
|
91
|
+
|
|
75
92
|
const json = component.toJSON();
|
|
76
93
|
expect(json).toMatchSnapshot();
|
|
77
94
|
});
|
|
@@ -5,11 +5,15 @@ import { Provider } from 'react-intl-redux';
|
|
|
5
5
|
import { MemoryRouter } from 'react-router-dom';
|
|
6
6
|
import ContactForm from './ContactForm';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
8
|
+
vi.mock('../../manage/Toolbar/Toolbar', () => ({
|
|
9
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
10
|
+
}));
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
vi.mock('@plone/volto/components/manage/Form', async () => {
|
|
13
|
+
return await import(
|
|
14
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
15
|
+
);
|
|
16
|
+
});
|
|
13
17
|
|
|
14
18
|
const mockStore = configureStore();
|
|
15
19
|
describe('Contact form', () => {
|
|
@@ -7,19 +7,25 @@ import Header from './Header';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
)
|
|
10
|
+
vi.mock('../Logo/Logo', () => ({
|
|
11
|
+
default: vi.fn(() => <div id="logo" />),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
vi.mock('../SearchWidget/SearchWidget', () => ({
|
|
15
|
+
default: vi.fn(() => <div id="searchwidget" />),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
vi.mock('../Anontools/Anontools', () => ({
|
|
19
|
+
default: vi.fn(() => <div id="anontools" />),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
vi.mock('../Navigation/Navigation', () => ({
|
|
23
|
+
default: vi.fn(() => <div id="navigation" />),
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
vi.mock('../LanguageSelector/LanguageSelector', () => ({
|
|
27
|
+
default: vi.fn(() => <div id="language-selector" />),
|
|
28
|
+
}));
|
|
23
29
|
|
|
24
30
|
describe('Header', () => {
|
|
25
31
|
it('renders a header component', () => {
|
|
@@ -9,7 +9,7 @@ import Logout from './Logout';
|
|
|
9
9
|
|
|
10
10
|
const mockStore = configureStore();
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
vi.mock('../Login/Login', () => ({ default: vi.fn(() => <div />) }));
|
|
13
13
|
|
|
14
14
|
describe('Logout', () => {
|
|
15
15
|
it('renders a logout component', () => {
|
|
@@ -7,7 +7,16 @@ import { MemoryRouter } from 'react-router-dom';
|
|
|
7
7
|
import PasswordReset from './PasswordReset';
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
|
-
|
|
10
|
+
vi.mock('./PasswordReset', () => {
|
|
11
|
+
const ActualPasswordReset = vi.importActual('./PasswordReset');
|
|
12
|
+
return {
|
|
13
|
+
...ActualPasswordReset,
|
|
14
|
+
default: vi.fn((props) => {
|
|
15
|
+
const token = props.match?.params?.token || 'default-token';
|
|
16
|
+
return <div data-testid="password-reset">Password Reset for {token}</div>;
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
});
|
|
11
20
|
describe('PasswordReset', () => {
|
|
12
21
|
it('renders a PasswordReset component', () => {
|
|
13
22
|
const store = mockStore({
|
|
@@ -6,7 +6,11 @@ import { MemoryRouter } from 'react-router-dom';
|
|
|
6
6
|
|
|
7
7
|
import RequestPasswordReset from './RequestPasswordReset';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
vi.mock('@plone/volto/components/manage/Form', async () => {
|
|
10
|
+
return await import(
|
|
11
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
12
|
+
);
|
|
13
|
+
});
|
|
10
14
|
|
|
11
15
|
const mockStore = configureStore();
|
|
12
16
|
|
|
@@ -6,7 +6,11 @@ import { MemoryRouter } from 'react-router-dom';
|
|
|
6
6
|
|
|
7
7
|
import Register from './Register';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
vi.mock('@plone/volto/components/manage/Form', async () => {
|
|
10
|
+
return await import(
|
|
11
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
12
|
+
);
|
|
13
|
+
});
|
|
10
14
|
|
|
11
15
|
const mockStore = configureStore();
|
|
12
16
|
|
|
@@ -8,11 +8,13 @@ import { __test__ as Search } from './Search';
|
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
);
|
|
11
|
+
vi.mock('../../manage/Toolbar/Toolbar', () => ({
|
|
12
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
13
|
+
}));
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
vi.mock('./SearchTags', () => ({
|
|
16
|
+
default: vi.fn(() => <div id="search-tags" />),
|
|
17
|
+
}));
|
|
16
18
|
|
|
17
19
|
describe('Search', () => {
|
|
18
20
|
it('renders an empty search component', () => {
|
|
@@ -5,11 +5,18 @@ import { When } from './EventDatesInfo';
|
|
|
5
5
|
import configureStore from 'redux-mock-store';
|
|
6
6
|
const mockStore = configureStore();
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
);
|
|
8
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
9
|
+
return await import(
|
|
10
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
11
|
+
);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
beforeAll(async () => {
|
|
15
|
+
const { __setLoadables } = await import(
|
|
16
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
17
|
+
);
|
|
18
|
+
await __setLoadables();
|
|
19
|
+
});
|
|
13
20
|
|
|
14
21
|
const store = mockStore({
|
|
15
22
|
intl: {
|
|
@@ -14,11 +14,18 @@ const store = mockStore({
|
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
17
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
18
|
+
return await import(
|
|
19
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
beforeAll(async () => {
|
|
24
|
+
const { __setLoadables } = await import(
|
|
25
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
26
|
+
);
|
|
27
|
+
await __setLoadables();
|
|
28
|
+
});
|
|
22
29
|
|
|
23
30
|
const { settings } = config;
|
|
24
31
|
|
|
@@ -29,12 +29,14 @@ describe('ListingView', () => {
|
|
|
29
29
|
description: 'My item description',
|
|
30
30
|
url: '/item',
|
|
31
31
|
'@type': 'Document',
|
|
32
|
+
'@id': 'item1',
|
|
32
33
|
},
|
|
33
34
|
{
|
|
34
35
|
title: 'Second item',
|
|
35
36
|
description: 'My second item description',
|
|
36
37
|
url: '/item2',
|
|
37
38
|
'@type': 'Document',
|
|
39
|
+
'@id': 'item2',
|
|
38
40
|
},
|
|
39
41
|
],
|
|
40
42
|
}}
|
|
@@ -7,6 +7,16 @@ import { MemoryRouter } from 'react-router-dom';
|
|
|
7
7
|
import SummaryView from './SummaryView';
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
|
+
vi.mock('@plone/volto/components/manage/UniversalLink/UniversalLink', () => ({
|
|
11
|
+
default: vi.fn(({ item, ...props }) => {
|
|
12
|
+
// Ensure @id is always present
|
|
13
|
+
const safeItem = {
|
|
14
|
+
...item,
|
|
15
|
+
'@id': item['@id'] || item.url || '/default-link',
|
|
16
|
+
};
|
|
17
|
+
return <div data-testid="universal-link">{safeItem.title}</div>;
|
|
18
|
+
}),
|
|
19
|
+
}));
|
|
10
20
|
|
|
11
21
|
describe('TabularView', () => {
|
|
12
22
|
it('renders a summary view component', () => {
|
|
@@ -26,18 +26,25 @@ global.__SERVER__ = true; // eslint-disable-line no-underscore-dangle
|
|
|
26
26
|
|
|
27
27
|
const mockStore = configureStore();
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
);
|
|
29
|
+
vi.mock('../../manage/Toolbar/Toolbar', () => ({
|
|
30
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
31
|
+
}));
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
vi.mock('../Comments/Comments', () => ({
|
|
34
|
+
default: vi.fn(() => <div id="Comments" />),
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
vi.mock('../Tags/Tags', () => ({
|
|
38
|
+
default: vi.fn(() => <div id="Tags" />),
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
vi.mock('../SlotRenderer/SlotRenderer', () => ({
|
|
42
|
+
default: vi.fn(() => <div id="SlotRenderer" />),
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
vi.mock('../ContentMetadataTags/ContentMetadataTags', () => ({
|
|
46
|
+
default: vi.fn(() => <div id="ContentMetadataTags" />),
|
|
47
|
+
}));
|
|
41
48
|
|
|
42
49
|
const actions = {
|
|
43
50
|
document_actions: [],
|
|
@@ -151,8 +158,10 @@ describe('View', () => {
|
|
|
151
158
|
});
|
|
152
159
|
const { container } = render(
|
|
153
160
|
<Provider store={store}>
|
|
154
|
-
|
|
155
|
-
|
|
161
|
+
<>
|
|
162
|
+
<View location={{ pathname: '/test' }} />
|
|
163
|
+
<div id="toolbar"></div>
|
|
164
|
+
</>
|
|
156
165
|
</Provider>,
|
|
157
166
|
);
|
|
158
167
|
|
|
@@ -172,8 +181,10 @@ describe('View', () => {
|
|
|
172
181
|
});
|
|
173
182
|
const { container } = render(
|
|
174
183
|
<Provider store={store}>
|
|
175
|
-
|
|
176
|
-
|
|
184
|
+
<>
|
|
185
|
+
<View location={{ pathname: '/test' }} />
|
|
186
|
+
<div id="toolbar"></div>
|
|
187
|
+
</>
|
|
177
188
|
</Provider>,
|
|
178
189
|
);
|
|
179
190
|
|
|
@@ -193,8 +204,10 @@ describe('View', () => {
|
|
|
193
204
|
});
|
|
194
205
|
const { container } = render(
|
|
195
206
|
<Provider store={store}>
|
|
196
|
-
|
|
197
|
-
|
|
207
|
+
<>
|
|
208
|
+
<View location={{ pathname: '/test' }} />
|
|
209
|
+
<div id="toolbar"></div>
|
|
210
|
+
</>
|
|
198
211
|
</Provider>,
|
|
199
212
|
);
|
|
200
213
|
|
|
@@ -214,8 +227,10 @@ describe('View', () => {
|
|
|
214
227
|
});
|
|
215
228
|
const { container } = render(
|
|
216
229
|
<Provider store={store}>
|
|
217
|
-
|
|
218
|
-
|
|
230
|
+
<>
|
|
231
|
+
<View location={{ pathname: '/test' }} />
|
|
232
|
+
<div id="toolbar"></div>
|
|
233
|
+
</>
|
|
219
234
|
</Provider>,
|
|
220
235
|
);
|
|
221
236
|
|
|
@@ -243,16 +258,20 @@ describe('View', () => {
|
|
|
243
258
|
});
|
|
244
259
|
const { rerender } = render(
|
|
245
260
|
<Provider store={store}>
|
|
246
|
-
|
|
247
|
-
|
|
261
|
+
<>
|
|
262
|
+
<View location={{ pathname: '/test' }} />
|
|
263
|
+
<div id="toolbar"></div>
|
|
264
|
+
</>
|
|
248
265
|
</Provider>,
|
|
249
266
|
);
|
|
250
267
|
expect(instanceCount).toBe(1);
|
|
251
268
|
store.getState().content.data['@id'] = '/b';
|
|
252
269
|
rerender(
|
|
253
270
|
<Provider store={store}>
|
|
254
|
-
|
|
255
|
-
|
|
271
|
+
<>
|
|
272
|
+
<View location={{ pathname: '/test' }} />
|
|
273
|
+
<div id="toolbar"></div>
|
|
274
|
+
</>
|
|
256
275
|
</Provider>,
|
|
257
276
|
);
|
|
258
277
|
expect(instanceCount).toBe(2);
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import config from '@plone/volto/registry';
|
|
2
2
|
import Api from './Api';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
url
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
vi.mock('superagent', () => ({
|
|
5
|
+
default: {
|
|
6
|
+
get: vi.fn((url) => ({
|
|
7
|
+
url,
|
|
8
|
+
query: vi.fn(),
|
|
9
|
+
set: vi.fn(),
|
|
10
|
+
type: vi.fn(),
|
|
11
|
+
send: vi.fn(),
|
|
12
|
+
end: vi.fn(),
|
|
13
|
+
})),
|
|
14
|
+
},
|
|
13
15
|
}));
|
|
14
16
|
|
|
15
17
|
beforeAll(() => {
|