@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
|
@@ -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 datetime widget component', async () => {
|
|
16
23
|
const store = mockStore({
|
|
@@ -19,6 +26,7 @@ test('renders a datetime widget component', async () => {
|
|
|
19
26
|
messages: {},
|
|
20
27
|
},
|
|
21
28
|
});
|
|
29
|
+
|
|
22
30
|
const isoDate = new Date('2019-10-21').toISOString();
|
|
23
31
|
const { container } = render(
|
|
24
32
|
<Provider store={store}>
|
|
@@ -28,20 +36,24 @@ test('renders a datetime widget component', async () => {
|
|
|
28
36
|
fieldSet="default"
|
|
29
37
|
onChange={() => {}}
|
|
30
38
|
value={isoDate}
|
|
39
|
+
showTime={true}
|
|
31
40
|
/>
|
|
32
41
|
</Provider>,
|
|
33
42
|
);
|
|
43
|
+
|
|
34
44
|
await waitFor(() => screen.getByText(/My field/));
|
|
45
|
+
await waitFor(() => screen.getByPlaceholderText('Time'));
|
|
35
46
|
expect(container).toMatchSnapshot();
|
|
36
47
|
});
|
|
37
48
|
|
|
38
|
-
test('datetime widget converts UTC date and
|
|
49
|
+
test('datetime widget converts UTC date and adapts to local datetime', async () => {
|
|
39
50
|
const store = mockStore({
|
|
40
51
|
intl: {
|
|
41
52
|
locale: 'en',
|
|
42
53
|
messages: {},
|
|
43
54
|
},
|
|
44
55
|
});
|
|
56
|
+
|
|
45
57
|
const date = '2020-02-10T15:01:00.000Z';
|
|
46
58
|
const { container } = render(
|
|
47
59
|
<Provider store={store}>
|
|
@@ -50,9 +62,12 @@ test('datetime widget converts UTC date and adapt to local datetime', async () =
|
|
|
50
62
|
title="My field"
|
|
51
63
|
onChange={() => {}}
|
|
52
64
|
value={date}
|
|
65
|
+
showTime={true}
|
|
53
66
|
/>
|
|
54
67
|
</Provider>,
|
|
55
68
|
);
|
|
69
|
+
|
|
56
70
|
await waitFor(() => screen.getByText(/My field/));
|
|
71
|
+
await waitFor(() => screen.getByPlaceholderText('Time'));
|
|
57
72
|
expect(container).toMatchSnapshot();
|
|
58
73
|
});
|
|
@@ -131,7 +131,10 @@ const UnconnectedImageInput = (props) => {
|
|
|
131
131
|
const file = eventOrFile.target
|
|
132
132
|
? eventOrFile.target.files[0]
|
|
133
133
|
: eventOrFile[0];
|
|
134
|
-
if (!validateFileUploadSize(file, intl.formatMessage))
|
|
134
|
+
if (!validateFileUploadSize(file, intl.formatMessage)) {
|
|
135
|
+
setUploading(false);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
135
138
|
readAsDataURL(file).then((fileData) => {
|
|
136
139
|
const fields = fileData.match(/^data:(.*);(.*),(.*)$/);
|
|
137
140
|
dispatch(
|
|
@@ -196,10 +199,10 @@ const UnconnectedImageInput = (props) => {
|
|
|
196
199
|
noClick
|
|
197
200
|
accept="image/*"
|
|
198
201
|
onDrop={(acceptedFiles) => {
|
|
202
|
+
setDragging(false);
|
|
199
203
|
if (acceptedFiles.length > 0) {
|
|
200
204
|
handleUpload(acceptedFiles);
|
|
201
205
|
} else {
|
|
202
|
-
setDragging(false);
|
|
203
206
|
toast.error(
|
|
204
207
|
<Toast
|
|
205
208
|
error
|
|
@@ -16,13 +16,14 @@ test('renders a number widget component', () => {
|
|
|
16
16
|
});
|
|
17
17
|
const component = renderer.create(
|
|
18
18
|
<Provider store={store}>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
<>
|
|
20
|
+
<NumberWidget
|
|
21
|
+
id="my-field"
|
|
22
|
+
title="My field"
|
|
23
|
+
fieldSet="default"
|
|
24
|
+
onChange={() => {}}
|
|
25
|
+
/>
|
|
26
|
+
</>
|
|
26
27
|
</Provider>,
|
|
27
28
|
);
|
|
28
29
|
const json = component.toJSON();
|
|
@@ -14,6 +14,7 @@ import deleteSVG from '@plone/volto/icons/delete.svg';
|
|
|
14
14
|
import addSVG from '@plone/volto/icons/add.svg';
|
|
15
15
|
import dragSVG from '@plone/volto/icons/drag.svg';
|
|
16
16
|
import { v4 as uuid } from 'uuid';
|
|
17
|
+
import config from '@plone/volto/registry';
|
|
17
18
|
|
|
18
19
|
const messages = defineMessages({
|
|
19
20
|
labelRemoveItem: {
|
|
@@ -71,11 +72,20 @@ const ObjectListWidget = (props) => {
|
|
|
71
72
|
block,
|
|
72
73
|
fieldSet,
|
|
73
74
|
id,
|
|
74
|
-
schema,
|
|
75
75
|
value = [],
|
|
76
76
|
onChange,
|
|
77
77
|
schemaExtender,
|
|
78
|
+
schemaName,
|
|
78
79
|
} = props;
|
|
80
|
+
|
|
81
|
+
// This allows to use a `schemaName` prop defined as source of the schema
|
|
82
|
+
// if not present, it will use the schema defined in the schema prop
|
|
83
|
+
const schema =
|
|
84
|
+
config.getUtility({
|
|
85
|
+
type: 'schema',
|
|
86
|
+
name: schemaName,
|
|
87
|
+
}).method || props.schema;
|
|
88
|
+
|
|
79
89
|
const [localActiveObject, setLocalActiveObject] = React.useState(
|
|
80
90
|
props.activeObject ?? value.length - 1,
|
|
81
91
|
);
|
|
@@ -4,20 +4,30 @@ import { render } from '@testing-library/react';
|
|
|
4
4
|
import configureStore from 'redux-mock-store';
|
|
5
5
|
import ObjectListWidget from './ObjectListWidget';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
});
|
|
9
17
|
|
|
10
|
-
beforeAll(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
);
|
|
18
|
+
beforeAll(async () => {
|
|
19
|
+
const { __setLoadables } = await import(
|
|
20
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
21
|
+
);
|
|
22
|
+
await __setLoadables();
|
|
23
|
+
});
|
|
14
24
|
|
|
15
25
|
let mockSerial = 0;
|
|
16
26
|
const mockStore = configureStore();
|
|
17
27
|
|
|
18
|
-
|
|
28
|
+
vi.mock('uuid', () => {
|
|
19
29
|
return {
|
|
20
|
-
v4:
|
|
30
|
+
v4: vi.fn().mockImplementation(() => `id-${mockSerial++}`),
|
|
21
31
|
};
|
|
22
32
|
});
|
|
23
33
|
|
|
@@ -5,7 +5,11 @@ import { Provider } from 'react-intl-redux';
|
|
|
5
5
|
import { render, fireEvent } from '@testing-library/react';
|
|
6
6
|
import ObjectWidget from './ObjectWidget';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
vi.mock('@plone/volto/components/manage/Form', async () => {
|
|
9
|
+
return await import(
|
|
10
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
11
|
+
);
|
|
12
|
+
});
|
|
9
13
|
|
|
10
14
|
const mockStore = configureStore();
|
|
11
15
|
|
|
@@ -7,11 +7,18 @@ import RadioGroupWidget from './RadioGroupWidget';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
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
|
+
});
|
|
15
22
|
|
|
16
23
|
test('renders a radio group widget component', async () => {
|
|
17
24
|
const store = mockStore({
|
|
@@ -3,14 +3,20 @@ 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 RecurrenceWidget from './RecurrenceWidget';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
);
|
|
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
|
+
});
|
|
14
20
|
|
|
15
21
|
const mockStore = configureStore();
|
|
16
22
|
|
|
@@ -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"
|
|
55
72
|
onChange={() => {}}
|
|
56
73
|
value={
|
|
57
|
-
'filenameb64:bG9nby5jYWI5NDVkOC5zdmc=;datab64:PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9Ij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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:PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjE1OC4yNTNweCIgaGVpZ2h0PSI0MC42ODZweCIgdmlld0JveD0iMCAwIDE1OC4yNTMgNDAuNjg2IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAxNTguMjUzIDQwLjY4NiIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CiAgICAgICAgICAgICAgICAgICAgPGc+PHBhdGggZmlsbD0iIzAwODZDMyIgZD0iTTY1LjMyNywyMy4yMDhoLTYuNTg5djExLjM4OGgtNC4zOTNWNS42MzhoMTAuOTgxYz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Ljc5NiwwLjMxMywwLjc5NiwwLjc1ICAgICAgICAgICAgICAgICAgICAgYzAsMC4zNjctMC4yMjQsMC42MDItMC41MTMsMC42OGwwLjU5MiwxLjEzNkwxNTQuNTA3LDEzLjQwOUwxNTQuNTA3LDEzLjQwOXogTTE1NC4wNTYsMTEuMTk1aC0wLjU3NXYwLjgwM2gwLjU3NSBjMC4yNjEsMCwwLjQzNy0wLjE0NywwLjQzNy0wLjM5OVMxNTQuMzE3LDExLjE5NSwxNTQuMDU2LDExLjE5NXoiLz48L2c+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({
|
|
@@ -128,6 +128,7 @@ class SelectWidget extends Component {
|
|
|
128
128
|
isMulti: PropTypes.bool,
|
|
129
129
|
placeholder: PropTypes.string,
|
|
130
130
|
sort: PropTypes.bool,
|
|
131
|
+
isClearable: PropTypes.bool,
|
|
131
132
|
};
|
|
132
133
|
|
|
133
134
|
/**
|
|
@@ -156,6 +157,7 @@ class SelectWidget extends Component {
|
|
|
156
157
|
noValueOption: true,
|
|
157
158
|
customOptionStyling: null,
|
|
158
159
|
sort: false,
|
|
160
|
+
isClearable: true,
|
|
159
161
|
};
|
|
160
162
|
|
|
161
163
|
/**
|
|
@@ -302,7 +304,7 @@ class SelectWidget extends Component {
|
|
|
302
304
|
: undefined,
|
|
303
305
|
);
|
|
304
306
|
}}
|
|
305
|
-
isClearable
|
|
307
|
+
isClearable={this.props.isClearable}
|
|
306
308
|
/>
|
|
307
309
|
</FormFieldWrapper>
|
|
308
310
|
);
|
|
@@ -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" />);
|