@plone/volto 19.0.0-alpha.0 → 19.0.0-alpha.1
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 +46 -2
- package/package.json +14 -7
- 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/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.test.jsx +5 -1
- 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.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/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/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/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
|
@@ -4,10 +4,9 @@ import { render, waitFor } from '@testing-library/react';
|
|
|
4
4
|
import configureStore from 'redux-mock-store';
|
|
5
5
|
|
|
6
6
|
import RegistryImageWidget from './RegistryImageWidget';
|
|
7
|
-
|
|
8
7
|
import config from '@plone/volto/registry';
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
vi.spyOn(global.Date, 'now').mockImplementation(() => 1234567890);
|
|
11
10
|
|
|
12
11
|
const mockStore = configureStore();
|
|
13
12
|
|
|
@@ -15,14 +14,30 @@ beforeAll(() => {
|
|
|
15
14
|
config.settings.publicURL = 'http://localhost:3000';
|
|
16
15
|
});
|
|
17
16
|
|
|
17
|
+
const createStore = () =>
|
|
18
|
+
mockStore({
|
|
19
|
+
intl: {
|
|
20
|
+
locale: 'en',
|
|
21
|
+
messages: {},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
18
25
|
describe('RegistryImageWidget', () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
vi.clearAllTimers();
|
|
28
|
+
Object.defineProperty(global.Image.prototype, 'complete', {
|
|
29
|
+
get() {
|
|
30
|
+
return true;
|
|
24
31
|
},
|
|
25
32
|
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
vi.clearAllMocks();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('renders an empty file widget component', async () => {
|
|
40
|
+
const store = createStore();
|
|
26
41
|
|
|
27
42
|
const { container } = render(
|
|
28
43
|
<Provider store={store}>
|
|
@@ -35,16 +50,18 @@ describe('RegistryImageWidget', () => {
|
|
|
35
50
|
</Provider>,
|
|
36
51
|
);
|
|
37
52
|
|
|
38
|
-
await waitFor(
|
|
53
|
+
await waitFor(
|
|
54
|
+
() => {
|
|
55
|
+
expect(container.querySelector('.file-widget-dropzone')).toBeTruthy();
|
|
56
|
+
},
|
|
57
|
+
{ timeout: 1000 },
|
|
58
|
+
);
|
|
59
|
+
|
|
39
60
|
expect(container).toMatchSnapshot();
|
|
40
61
|
});
|
|
62
|
+
|
|
41
63
|
test('renders a file widget component with value', async () => {
|
|
42
|
-
const store =
|
|
43
|
-
intl: {
|
|
44
|
-
locale: 'en',
|
|
45
|
-
messages: {},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
64
|
+
const store = createStore();
|
|
48
65
|
|
|
49
66
|
const { container } = render(
|
|
50
67
|
<Provider store={store}>
|
|
@@ -54,38 +71,23 @@ describe('RegistryImageWidget', () => {
|
|
|
54
71
|
fieldSet="default"
|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sOS41ODNoLTYuMzQ1djkuNjM5aDYuMzQ1YzMuMDUsMCw1LjEyNC0xLjc0OSw1LjEyNC00Ljc5OSAgICAgICAgICAgICAgICAgQzcwLjIwNiwxMS4zNzIsNjguMTMyLDkuNTgzLDY1LjA4Miw5LjU4M3oiLz48L3c+'
|
|
58
75
|
}
|
|
59
76
|
/>
|
|
60
77
|
</Provider>,
|
|
61
78
|
);
|
|
62
79
|
|
|
63
|
-
await waitFor(
|
|
80
|
+
await waitFor(
|
|
81
|
+
() => {
|
|
82
|
+
const dropzone = container.querySelector('.file-widget-dropzone');
|
|
83
|
+
const preview = container.querySelector('.image-preview');
|
|
84
|
+
const filename = container.querySelector('.field-file-name');
|
|
85
|
+
|
|
86
|
+
return dropzone && preview && filename;
|
|
87
|
+
},
|
|
88
|
+
{ timeout: 1000 },
|
|
89
|
+
);
|
|
90
|
+
|
|
64
91
|
expect(container).toMatchSnapshot();
|
|
65
92
|
});
|
|
66
|
-
// test('renders a file widget component with value in raw data', async () => {
|
|
67
|
-
// const store = mockStore({
|
|
68
|
-
// intl: {
|
|
69
|
-
// locale: 'en',
|
|
70
|
-
// messages: {},
|
|
71
|
-
// },
|
|
72
|
-
// });
|
|
73
|
-
|
|
74
|
-
// const { container } = render(
|
|
75
|
-
// <Provider store={store}>
|
|
76
|
-
// <RegistryImageWidget
|
|
77
|
-
// id="my-field"
|
|
78
|
-
// title="My field"
|
|
79
|
-
// fieldSet="default"
|
|
80
|
-
// onChange={() => {}}
|
|
81
|
-
// value={
|
|
82
|
-
// 'filenameb64:bG9nby5jYWI5NDVkOC5zdmc=;datab64:PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjE1OC4yNTNweCIgaGVpZ2h0PSI0M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DYtMS44NTFjMS4wMjMsMC4wMDIsMS44NTIsMC44MjgsMS44NTQsMS44NTFDMTU1LjgzNiwxMy4xNDEsMTU1LjAwOCwxMy45NjYsMTUzLjk4NSwxMy45Njh6Ii8+PC9nPjxnPjxwYXRoIGZpbGw9IiMwMDg2QzMiIGQ9Ik0xNTQuNTA3LDEzLjQwOWwtMC41NC0xLjA4aC0wLjQ4NnYxLjA4aC0wLjM4OXYtMi41NjRoMC45OTRjMC40ODQsMCwwLjc5NiwwLjMxMywwLjc5NiwwLjc1ICAgICAgICAgICAgICAgICAgICAgYzAsMC4zNjctMC4yMjQsMC42MDItMC41MTMsMC42OGwwLjU5MiwxLjEzNkwxNTQuNTA3LDEzLjQwOUwxNTQuNTA3LDEzLjQwOXogTTE1NC4wNTYsMTEuMTk1aC0wLjU3NXYwLjgwM2gwLjU3NSBjMC4yNjEsMCwwLjQzNy0wLjE0NywwLjQzNy0wLjM5OVMxNTQuMzE3LDExLjE5NSwxNTQuMDU2LDExLjE5NXoiLz48L2c+PC9nPgogICAgICAgICAgICAgICAgICA8L3N2Zz4=}'
|
|
83
|
-
// }
|
|
84
|
-
// />
|
|
85
|
-
// </Provider>,
|
|
86
|
-
// );
|
|
87
|
-
|
|
88
|
-
// await waitFor(() => {});
|
|
89
|
-
// expect(container).toMatchSnapshot();
|
|
90
|
-
// });
|
|
91
93
|
});
|
|
@@ -5,11 +5,18 @@ import { Provider } from 'react-intl-redux';
|
|
|
5
5
|
|
|
6
6
|
import SchemaWidget from './SchemaWidget';
|
|
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 mockStore = configureStore();
|
|
15
22
|
|
|
@@ -3,11 +3,18 @@ import { DragDropContext, Droppable } from 'react-beautiful-dnd';
|
|
|
3
3
|
import { render } from '@testing-library/react';
|
|
4
4
|
import SchemaWidgetFieldsetComponent from './SchemaWidgetFieldset';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
6
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
7
|
+
return await import(
|
|
8
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
9
|
+
);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
beforeAll(async () => {
|
|
13
|
+
const { __setLoadables } = await import(
|
|
14
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
15
|
+
);
|
|
16
|
+
await __setLoadables();
|
|
17
|
+
});
|
|
11
18
|
|
|
12
19
|
test('renders a contents item component', () => {
|
|
13
20
|
const { container } = render(
|
|
@@ -2,16 +2,22 @@ import React from 'react';
|
|
|
2
2
|
import configureStore from 'redux-mock-store';
|
|
3
3
|
import { Provider } from 'react-intl-redux';
|
|
4
4
|
import { waitFor, render, screen } from '@testing-library/react';
|
|
5
|
-
|
|
6
5
|
import SelectAutoComplete from './SelectAutoComplete';
|
|
7
6
|
|
|
8
7
|
const mockStore = configureStore();
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
9
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
10
|
+
return await import(
|
|
11
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
beforeAll(async () => {
|
|
16
|
+
const { __setLoadables } = await import(
|
|
17
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
18
|
+
);
|
|
19
|
+
await __setLoadables();
|
|
20
|
+
});
|
|
15
21
|
|
|
16
22
|
test('renders a select widget component', async () => {
|
|
17
23
|
const store = mockStore({
|
|
@@ -2,16 +2,22 @@ import React from 'react';
|
|
|
2
2
|
import configureStore from 'redux-mock-store';
|
|
3
3
|
import { Provider } from 'react-intl-redux';
|
|
4
4
|
import { waitFor, render, screen, fireEvent } from '@testing-library/react';
|
|
5
|
-
|
|
6
5
|
import SelectWidget from './SelectWidget';
|
|
7
6
|
|
|
8
7
|
const mockStore = configureStore();
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
9
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
10
|
+
return await import(
|
|
11
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
beforeAll(async () => {
|
|
16
|
+
const { __setLoadables } = await import(
|
|
17
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
18
|
+
);
|
|
19
|
+
await __setLoadables();
|
|
20
|
+
});
|
|
15
21
|
|
|
16
22
|
test('renders a select widget component', async () => {
|
|
17
23
|
const store = mockStore({
|
|
@@ -6,11 +6,18 @@ import { waitFor, render, screen } from '@testing-library/react';
|
|
|
6
6
|
|
|
7
7
|
const mockStore = configureStore();
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
);
|
|
9
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
10
|
+
return await import(
|
|
11
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
beforeAll(async () => {
|
|
16
|
+
const { __setLoadables } = await import(
|
|
17
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
18
|
+
);
|
|
19
|
+
await __setLoadables();
|
|
20
|
+
});
|
|
14
21
|
|
|
15
22
|
test('renders a time widget component', async () => {
|
|
16
23
|
const store = mockStore({
|
|
@@ -31,5 +38,6 @@ test('renders a time widget component', async () => {
|
|
|
31
38
|
</Provider>,
|
|
32
39
|
);
|
|
33
40
|
await waitFor(() => screen.getByText(/My field/));
|
|
41
|
+
await waitFor(() => screen.getByPlaceholderText('Time'));
|
|
34
42
|
expect(container).toMatchSnapshot();
|
|
35
43
|
});
|
|
@@ -3,16 +3,22 @@ import renderer from 'react-test-renderer';
|
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
5
|
import { waitFor } from '@testing-library/react';
|
|
6
|
-
|
|
7
6
|
import TokenWidget from './TokenWidget';
|
|
8
7
|
|
|
9
8
|
const mockStore = configureStore();
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
);
|
|
10
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
11
|
+
return await import(
|
|
12
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
const { __setLoadables } = await import(
|
|
18
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
19
|
+
);
|
|
20
|
+
await __setLoadables();
|
|
21
|
+
});
|
|
16
22
|
|
|
17
23
|
test('renders a token widget component', async () => {
|
|
18
24
|
const store = mockStore({
|
|
@@ -2,23 +2,32 @@ import React from 'react';
|
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
|
-
|
|
6
5
|
import VocabularyTermsWidget from './VocabularyTermsWidget';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
8
|
+
return await import(
|
|
9
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
10
|
+
);
|
|
11
|
+
});
|
|
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
|
+
});
|
|
10
17
|
|
|
11
|
-
beforeAll(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
18
|
+
beforeAll(async () => {
|
|
19
|
+
const { __setLoadables } = await import(
|
|
20
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
21
|
+
);
|
|
22
|
+
await __setLoadables();
|
|
23
|
+
});
|
|
15
24
|
|
|
16
25
|
let mockSerial = 0;
|
|
17
26
|
const mockStore = configureStore();
|
|
18
27
|
|
|
19
|
-
|
|
28
|
+
vi.mock('uuid', () => {
|
|
20
29
|
return {
|
|
21
|
-
v4:
|
|
30
|
+
v4: vi.fn().mockImplementation(() => `id-${mockSerial++}`),
|
|
22
31
|
};
|
|
23
32
|
});
|
|
24
33
|
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/* TODO: When the Volto Team removes Jest configuration support from Volto core, update this file with the Vitest version of the mock.
|
|
2
|
+
Then, in the tests, we need to replace:
|
|
3
|
+
|
|
4
|
+
vi.mock('@plone/volto/components/manage/Widgets', async () => {
|
|
5
|
+
return await import(
|
|
6
|
+
'@plone/volto/components/manage/Widgets/__mocks__/index.vitest.tsx'
|
|
7
|
+
);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
with the following:
|
|
11
|
+
|
|
12
|
+
vi.mock('@plone/volto/components/manage/Widgets');
|
|
13
|
+
|
|
14
|
+
Finally, remove this comment.
|
|
15
|
+
*/
|
|
16
|
+
|
|
1
17
|
export const AlignWidget = jest.fn(() => <div id="AlignWidget" />);
|
|
2
18
|
export const ButtonsWidget = jest.fn(() => <div id="ButtonsWidget" />);
|
|
3
19
|
export const ArrayWidget = jest.fn(() => <div id="ArrayWidget" />);
|
|
@@ -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', () => {
|