@plone/volto 18.13.0 → 18.14.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/CHANGELOG.md +12 -0
- package/package.json +4 -4
- package/src/components/manage/Actions/Actions.test.jsx +5 -1
- package/src/components/manage/Blocks/Block/BlocksForm.test.jsx +6 -2
- package/src/components/manage/Blocks/Block/Settings.test.jsx +5 -1
- package/src/components/manage/Blocks/HTML/Edit.test.jsx +6 -1
- package/src/components/manage/Blocks/Image/ImageSidebar.test.jsx +5 -1
- package/src/components/manage/Blocks/LeadImage/LeadImageSidebar.test.jsx +5 -0
- package/src/components/manage/Blocks/Maps/MapsSidebar.test.jsx +5 -1
- package/src/components/manage/Blocks/Search/components/DateRangeFacet.test.jsx +6 -1
- package/src/components/manage/Blocks/Search/components/SelectFacet.test.jsx +6 -1
- package/src/components/manage/Blocks/Video/VideoSidebar.test.jsx +5 -1
- package/src/components/manage/Contents/Contents.test.jsx +6 -1
- 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 +18 -2
- package/src/components/manage/Contents/__mocks__/index.vitest.tsx +5 -0
- package/src/components/manage/Controlpanels/Aliases.test.jsx +6 -1
- package/src/components/manage/Controlpanels/ContentType.test.jsx +5 -1
- package/src/components/manage/Controlpanels/Rules/AddRule.test.jsx +6 -1
- package/src/components/manage/Controlpanels/Rules/EditRule.test.jsx +5 -1
- package/src/components/manage/Controlpanels/UndoControlpanel.test.jsx +5 -1
- package/src/components/manage/Diff/Diff.test.jsx +6 -1
- package/src/components/manage/Diff/DiffField.test.jsx +6 -1
- package/src/components/manage/Display/Display.test.jsx +11 -2
- package/src/components/manage/Edit/Edit.test.jsx +5 -1
- 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 +27 -9
- package/src/components/manage/Form/__mocks__/index.vitest.tsx +73 -0
- package/src/components/manage/Preferences/ChangePassword.test.jsx +6 -1
- package/src/components/manage/Preferences/PersonalPreferences.test.jsx +11 -2
- package/src/components/manage/Widgets/ArrayWidget.test.jsx +5 -1
- package/src/components/manage/Widgets/CheckboxGroupWidget.test.jsx +6 -1
- package/src/components/manage/Widgets/DatetimeWidget.test.jsx +5 -1
- package/src/components/manage/Widgets/ObjectListWidget.test.jsx +10 -2
- package/src/components/manage/Widgets/ObjectWidget.test.jsx +5 -1
- package/src/components/manage/Widgets/RadioGroupWidget.test.jsx +6 -1
- package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.test.jsx +6 -1
- package/src/components/manage/Widgets/SchemaWidget.test.jsx +6 -1
- package/src/components/manage/Widgets/SchemaWidgetFieldset.test.jsx +6 -1
- package/src/components/manage/Widgets/SelectAutoComplete.test.jsx +6 -1
- package/src/components/manage/Widgets/SelectWidget.test.jsx +6 -1
- package/src/components/manage/Widgets/TimeWidget.test.jsx +6 -1
- package/src/components/manage/Widgets/TokenWidget.test.jsx +6 -1
- package/src/components/manage/Widgets/VocabularyTermsWidget.test.jsx +10 -2
- package/src/components/manage/Widgets/__mocks__/index.tsx +51 -33
- package/src/components/manage/Widgets/__mocks__/index.vitest.tsx +41 -0
- package/src/components/manage/Workflow/Workflow.test.jsx +11 -2
- package/src/components/theme/Comments/CommentEditModal.test.jsx +5 -1
- package/src/components/theme/Comments/Comments.test.jsx +10 -2
- package/src/components/theme/ContactForm/ContactForm.test.jsx +5 -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/View/EventDatesInfo.test.jsx +6 -1
- package/src/components/theme/View/EventView.test.jsx +6 -1
- package/src/helpers/Loadable/__mocks__/Loadable.jsx +22 -7
- 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/tsconfig.declarations.json +1 -1
- package/tsconfig.json +2 -1
- package/types/components/manage/Contents/__mocks__/index.d.ts +2 -2
- package/types/components/manage/Contents/__mocks__/index.vitest.d.ts +2 -0
- package/types/components/manage/Form/__mocks__/index.d.ts +8 -8
- package/types/components/manage/Form/__mocks__/index.vitest.d.ts +8 -0
- package/types/components/manage/Widgets/__mocks__/index.d.ts +33 -33
- package/types/components/manage/Widgets/__mocks__/index.vitest.d.ts +33 -0
- package/types/helpers/Loadable/__mocks__/Loadable.d.ts +2 -2
- package/types/helpers/Loadable/__mocks__/Loadable.vitest.d.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,18 @@ myst:
|
|
|
17
17
|
|
|
18
18
|
<!-- towncrier release notes start -->
|
|
19
19
|
|
|
20
|
+
## 18.14.1 (2025-04-25)
|
|
21
|
+
|
|
22
|
+
### Bugfix
|
|
23
|
+
|
|
24
|
+
- Add support for both Vitest and Jest in `__mocks__` folders of Volto core. Add-on tests using Jest relies on them. @Abhishek-17h [#7000](https://github.com/plone/volto/issues/7000)
|
|
25
|
+
|
|
26
|
+
## 18.14.0 (2025-04-23)
|
|
27
|
+
|
|
28
|
+
### Feature
|
|
29
|
+
|
|
30
|
+
- Added current evaluated `querystring` as a parameter in expander's `querystring` key when it's a function. @sneridagh [#7012](https://github.com/plone/volto/issues/7012)
|
|
31
|
+
|
|
20
32
|
## 18.13.0 (2025-04-22)
|
|
21
33
|
|
|
22
34
|
### Feature
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "18.
|
|
12
|
+
"version": "18.14.1",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git@github.com:plone/volto.git"
|
|
@@ -236,9 +236,9 @@
|
|
|
236
236
|
"url": "^0.11.3",
|
|
237
237
|
"use-deep-compare-effect": "1.8.1",
|
|
238
238
|
"uuid": "^8.3.2",
|
|
239
|
-
"@plone/volto-slate": "18.3.0",
|
|
240
239
|
"@plone/scripts": "3.9.0",
|
|
241
|
-
"@plone/
|
|
240
|
+
"@plone/volto-slate": "18.3.0",
|
|
241
|
+
"@plone/registry": "2.5.2"
|
|
242
242
|
},
|
|
243
243
|
"devDependencies": {
|
|
244
244
|
"@babel/core": "^7.0.0",
|
|
@@ -363,7 +363,7 @@
|
|
|
363
363
|
"webpack-dev-server": "4.11.1",
|
|
364
364
|
"webpack-node-externals": "3.0.0",
|
|
365
365
|
"why": "0.6.2",
|
|
366
|
-
"@plone/types": "1.4.
|
|
366
|
+
"@plone/types": "1.4.1",
|
|
367
367
|
"@plone/volto-coresandbox": "1.0.0"
|
|
368
368
|
},
|
|
369
369
|
"volta": {
|
|
@@ -8,7 +8,11 @@ import Actions from './Actions';
|
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
11
|
-
vi.mock('@plone/volto/components/manage/Contents')
|
|
11
|
+
vi.mock('@plone/volto/components/manage/Contents', async () => {
|
|
12
|
+
return await import(
|
|
13
|
+
'@plone/volto/components/manage/Contents/__mocks__/index.vitest.tsx'
|
|
14
|
+
);
|
|
15
|
+
});
|
|
12
16
|
|
|
13
17
|
describe('Actions', () => {
|
|
14
18
|
it('renders an actions component', () => {
|
|
@@ -7,7 +7,12 @@ import config from '@plone/volto/registry';
|
|
|
7
7
|
|
|
8
8
|
config.experimental = { addBlockButton: { enabled: false } };
|
|
9
9
|
|
|
10
|
-
vi.mock('@plone/volto/helpers/Loadable/Loadable')
|
|
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
|
+
|
|
11
16
|
beforeAll(async () => {
|
|
12
17
|
const { __setLoadables } = await import(
|
|
13
18
|
'@plone/volto/helpers/Loadable/Loadable'
|
|
@@ -39,7 +44,6 @@ vi.mock('react-beautiful-dnd', () => ({
|
|
|
39
44
|
}));
|
|
40
45
|
|
|
41
46
|
vi.mock('./Order/Order', () => ({
|
|
42
|
-
__esModule: true,
|
|
43
47
|
default: () => <div>Order Component</div>,
|
|
44
48
|
}));
|
|
45
49
|
|
|
@@ -5,7 +5,11 @@ import configureStore from 'redux-mock-store';
|
|
|
5
5
|
import config from '@plone/volto/registry';
|
|
6
6
|
import { Provider } from 'react-intl-redux';
|
|
7
7
|
|
|
8
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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,7 +7,12 @@ import Edit from './Edit';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
vi.mock('@plone/volto/helpers/Loadable/Loadable')
|
|
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
|
+
|
|
11
16
|
beforeAll(async () => {
|
|
12
17
|
const { __setLoadables } = await import(
|
|
13
18
|
'@plone/volto/helpers/Loadable/Loadable'
|
|
@@ -5,7 +5,11 @@ import { Provider } from 'react-intl-redux';
|
|
|
5
5
|
|
|
6
6
|
import ImageSidebar from './ImageSidebar';
|
|
7
7
|
|
|
8
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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
|
|
|
@@ -6,6 +6,11 @@ import { Provider } from 'react-intl-redux';
|
|
|
6
6
|
import LeadImageSidebar from './LeadImageSidebar';
|
|
7
7
|
|
|
8
8
|
vi.mock('@plone/volto/components/manage/Widgets');
|
|
9
|
+
vi.mock('@plone/volto/components/manage/Widgets', async () => {
|
|
10
|
+
return await import(
|
|
11
|
+
'@plone/volto/components/manage/Widgets/__mocks__/index.vitest.tsx'
|
|
12
|
+
);
|
|
13
|
+
});
|
|
9
14
|
|
|
10
15
|
const mockStore = configureStore();
|
|
11
16
|
|
|
@@ -5,7 +5,11 @@ import { Provider } from 'react-intl-redux';
|
|
|
5
5
|
|
|
6
6
|
import MapsSidebar from './MapsSidebar';
|
|
7
7
|
|
|
8
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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
|
|
|
@@ -6,7 +6,12 @@ import DateRangeFacet from './DateRangeFacet';
|
|
|
6
6
|
|
|
7
7
|
const mockStore = configureStore();
|
|
8
8
|
|
|
9
|
-
vi.mock('@plone/volto/helpers/Loadable/Loadable')
|
|
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
|
+
|
|
10
15
|
beforeAll(async () => {
|
|
11
16
|
const { __setLoadables } = await import(
|
|
12
17
|
'@plone/volto/helpers/Loadable/Loadable'
|
|
@@ -6,7 +6,12 @@ import SelectFacet from './SelectFacet';
|
|
|
6
6
|
|
|
7
7
|
const mockStore = configureStore();
|
|
8
8
|
|
|
9
|
-
vi.mock('@plone/volto/helpers/Loadable/Loadable')
|
|
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
|
+
|
|
10
15
|
beforeAll(async () => {
|
|
11
16
|
const { __setLoadables } = await import(
|
|
12
17
|
'@plone/volto/helpers/Loadable/Loadable'
|
|
@@ -5,7 +5,11 @@ import { Provider } from 'react-intl-redux';
|
|
|
5
5
|
|
|
6
6
|
import VideoSidebar from './VideoSidebar';
|
|
7
7
|
|
|
8
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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
|
|
|
@@ -8,7 +8,12 @@ import { __test__ as Contents } from './Contents';
|
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
11
|
-
vi.mock('@plone/volto/helpers/Loadable/Loadable')
|
|
11
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
12
|
+
return await import(
|
|
13
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
12
17
|
beforeAll(async () => {
|
|
13
18
|
const { __setLoadables } = await import(
|
|
14
19
|
'@plone/volto/helpers/Loadable/Loadable'
|
|
@@ -7,7 +7,11 @@ import ContentsPropertiesModal from './ContentsPropertiesModal';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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('ContentsPropertiesModal', () => {
|
|
13
17
|
it('renders a contents properties modal component', () => {
|
|
@@ -7,7 +7,11 @@ import ContentsRenameModal from './ContentsRenameModal';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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('ContentsRenameModal', () => {
|
|
13
17
|
it('renders a contents rename modal component', () => {
|
|
@@ -7,7 +7,11 @@ import ContentsTagsModal from './ContentsTagsModal';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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('ContentsTagsModal', () => {
|
|
13
17
|
it('renders a contents tags modal component', () => {
|
|
@@ -7,7 +7,11 @@ import ContentsWorkflowModal from './ContentsWorkflowModal';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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('ContentsWorkflowModal', () => {
|
|
13
17
|
it('renders a contents workflow modal component', () => {
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
|
|
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:
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
vi.mock('@plone/volto/components/manage/Contents', async () => {
|
|
5
|
+
return await import(
|
|
6
|
+
'@plone/volto/components/manage/Contents/__mocks__/index.vitest.tsx'
|
|
7
|
+
);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
with the following:
|
|
11
|
+
|
|
12
|
+
vi.mock('@plone/volto/components/manage/Contents');
|
|
13
|
+
|
|
14
|
+
Finally, remove this comment.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const Contents = jest.fn(() => <div className="Contents" />);
|
|
18
|
+
|
|
19
|
+
export const ContentsRenameModal = jest.fn(() => (
|
|
4
20
|
<div className="ContentsRenameModal" />
|
|
5
21
|
));
|
|
@@ -10,7 +10,12 @@ import { MemoryRouter } from 'react-router';
|
|
|
10
10
|
const middlewares = [thunk];
|
|
11
11
|
const mockStore = configureMockStore(middlewares);
|
|
12
12
|
|
|
13
|
-
vi.mock('@plone/volto/components/manage/Widgets')
|
|
13
|
+
vi.mock('@plone/volto/components/manage/Widgets', async () => {
|
|
14
|
+
return await import(
|
|
15
|
+
'@plone/volto/components/manage/Widgets/__mocks__/index.vitest.tsx'
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
14
19
|
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
15
20
|
default: vi.fn(() => <div id="Portal" />),
|
|
16
21
|
}));
|
|
@@ -8,7 +8,11 @@ import ContentType from './ContentType';
|
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
11
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
11
|
+
vi.mock('@plone/volto/components/manage/Form', async () => {
|
|
12
|
+
return await import(
|
|
13
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
14
|
+
);
|
|
15
|
+
});
|
|
12
16
|
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
13
17
|
default: vi.fn(() => <div id="Portal" />),
|
|
14
18
|
}));
|
|
@@ -9,7 +9,12 @@ import AddRule from './AddRule';
|
|
|
9
9
|
const middlewares = [thunk];
|
|
10
10
|
const mockStore = configureMockStore(middlewares);
|
|
11
11
|
|
|
12
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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
|
+
});
|
|
17
|
+
|
|
13
18
|
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
14
19
|
default: vi.fn(() => <div id="Toolbar" />),
|
|
15
20
|
}));
|
|
@@ -13,7 +13,11 @@ vi.mock('../../Toolbar/Toolbar', () => ({
|
|
|
13
13
|
default: vi.fn(() => <div id="Portal" />),
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
16
|
+
vi.mock('@plone/volto/components/manage/Form', async () => {
|
|
17
|
+
return await import(
|
|
18
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
19
|
+
);
|
|
20
|
+
});
|
|
17
21
|
|
|
18
22
|
describe('EditRule', () => {
|
|
19
23
|
it('renders rules edit interface', () => {
|
|
@@ -7,7 +7,11 @@ import UndoControlpanel from './UndoControlpanel';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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
|
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
12
16
|
default: vi.fn(() => <div id="Portal" />),
|
|
13
17
|
}));
|
|
@@ -12,7 +12,12 @@ vi.mock('../Toolbar/Toolbar', () => ({
|
|
|
12
12
|
default: vi.fn(() => <div id="Portal" />),
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
|
-
vi.mock('@plone/volto/helpers/Loadable/Loadable')
|
|
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
|
+
|
|
16
21
|
beforeAll(async () => {
|
|
17
22
|
const { __setLoadables } = await import(
|
|
18
23
|
'@plone/volto/helpers/Loadable/Loadable'
|
|
@@ -4,7 +4,12 @@ import { Provider } from 'react-intl-redux';
|
|
|
4
4
|
import { waitFor, render, screen } from '@testing-library/react';
|
|
5
5
|
import DiffField from './DiffField';
|
|
6
6
|
|
|
7
|
-
vi.mock('@plone/volto/helpers/Loadable/Loadable')
|
|
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
|
+
|
|
8
13
|
beforeAll(async () => {
|
|
9
14
|
const { __setLoadables } = await import(
|
|
10
15
|
'@plone/volto/helpers/Loadable/Loadable'
|
|
@@ -8,8 +8,17 @@ import Display from './Display';
|
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
11
|
-
vi.mock('@plone/volto/components/manage/Widgets')
|
|
12
|
-
|
|
11
|
+
vi.mock('@plone/volto/components/manage/Widgets', async () => {
|
|
12
|
+
return await import(
|
|
13
|
+
'@plone/volto/components/manage/Widgets/__mocks__/index.vitest.tsx'
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable', async () => {
|
|
17
|
+
return await import(
|
|
18
|
+
'@plone/volto/helpers/Loadable/__mocks__/Loadable.vitest.jsx'
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
|
|
13
22
|
beforeAll(async () => {
|
|
14
23
|
const { __setLoadables } = await import(
|
|
15
24
|
'@plone/volto/helpers/Loadable/Loadable'
|
|
@@ -8,7 +8,11 @@ import { __test__ as Edit } from './Edit';
|
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
11
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
11
|
+
vi.mock('@plone/volto/components/manage/Form', async () => {
|
|
12
|
+
return await import(
|
|
13
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
14
|
+
);
|
|
15
|
+
});
|
|
12
16
|
vi.mock('../Toolbar/Toolbar', () => ({
|
|
13
17
|
default: vi.fn(() => <div id="Portal" />),
|
|
14
18
|
}));
|
|
@@ -5,7 +5,11 @@ import configureStore from 'redux-mock-store';
|
|
|
5
5
|
import config from '@plone/volto/registry';
|
|
6
6
|
import { Provider } from 'react-intl-redux';
|
|
7
7
|
|
|
8
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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
|
|
|
@@ -9,7 +9,11 @@ const mockStore = configureStore();
|
|
|
9
9
|
const errorMessage =
|
|
10
10
|
"[{'message': 'The specified email is not valid.', 'field': 'contact_email', 'error': 'ValidationError'}";
|
|
11
11
|
|
|
12
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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
|
describe('Form', () => {
|
|
15
19
|
it('renders a form component', () => {
|
|
@@ -6,7 +6,11 @@ import config from '@plone/volto/registry';
|
|
|
6
6
|
|
|
7
7
|
import InlineForm from './InlineForm';
|
|
8
8
|
|
|
9
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
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,7 +8,11 @@ import ModalForm from './ModalForm';
|
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
11
|
-
vi.mock('@plone/volto/components/manage/Form')
|
|
11
|
+
vi.mock('@plone/volto/components/manage/Form', async () => {
|
|
12
|
+
return await import(
|
|
13
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
14
|
+
);
|
|
15
|
+
});
|
|
12
16
|
|
|
13
17
|
describe('ModalForm', () => {
|
|
14
18
|
it('renders a modal form component', () => {
|
|
@@ -1,7 +1,25 @@
|
|
|
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/Form', async () => {
|
|
5
|
+
return await import(
|
|
6
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
7
|
+
);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
with the following:
|
|
12
|
+
|
|
13
|
+
vi.mock('@plone/volto/components/manage/Form');
|
|
14
|
+
|
|
15
|
+
Finally, remove this comment.
|
|
16
|
+
*/
|
|
17
|
+
|
|
1
18
|
import type { JSONSchema } from '@plone/types';
|
|
2
19
|
import type { Ref } from 'react';
|
|
3
|
-
|
|
20
|
+
const { forwardRef } = jest.requireActual('react');
|
|
4
21
|
|
|
22
|
+
// Field descriptions can contain react elements and those are not JSON stringifiable
|
|
5
23
|
const cleanupSchema = (schema: JSONSchema | null): JSONSchema | null => {
|
|
6
24
|
if (!schema || !schema.properties) return schema;
|
|
7
25
|
return {
|
|
@@ -22,38 +40,38 @@ const cleanupSchema = (schema: JSONSchema | null): JSONSchema | null => {
|
|
|
22
40
|
};
|
|
23
41
|
};
|
|
24
42
|
|
|
25
|
-
export const Field =
|
|
43
|
+
export const Field = jest.fn((props) => (
|
|
26
44
|
<div className="Field" id={props.id}>
|
|
27
45
|
{props.title}
|
|
28
46
|
</div>
|
|
29
47
|
));
|
|
30
48
|
|
|
31
|
-
export const InlineForm =
|
|
49
|
+
export const InlineForm = jest.fn((props) => (
|
|
32
50
|
<div
|
|
33
51
|
id="InlineForm"
|
|
34
52
|
data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
|
|
35
53
|
/>
|
|
36
54
|
));
|
|
37
55
|
|
|
38
|
-
export const ModalForm =
|
|
56
|
+
export const ModalForm = jest.fn((props) => (
|
|
39
57
|
<div
|
|
40
58
|
id="ModalForm"
|
|
41
59
|
data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
|
|
42
60
|
/>
|
|
43
61
|
));
|
|
44
62
|
|
|
45
|
-
export const UndoToolbar =
|
|
63
|
+
export const UndoToolbar = jest.fn(() => <div id="UndoToolbar" />);
|
|
46
64
|
|
|
47
|
-
export const BlocksToolbar =
|
|
65
|
+
export const BlocksToolbar = jest.fn(() => <div id="BlocksToolbar" />);
|
|
48
66
|
|
|
49
|
-
export const BlockDataForm =
|
|
67
|
+
export const BlockDataForm = jest.fn((props) => (
|
|
50
68
|
<div
|
|
51
69
|
id="BlockDataForm"
|
|
52
70
|
data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
|
|
53
71
|
/>
|
|
54
72
|
));
|
|
55
73
|
|
|
56
|
-
export const BlocksForm =
|
|
74
|
+
export const BlocksForm = jest.fn((props) => (
|
|
57
75
|
<div
|
|
58
76
|
id="BlocksForm"
|
|
59
77
|
data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
|
|
@@ -70,4 +88,4 @@ const MockForm = forwardRef(
|
|
|
70
88
|
),
|
|
71
89
|
);
|
|
72
90
|
|
|
73
|
-
export const Form =
|
|
91
|
+
export const Form = jest.fn((props) => <MockForm {...props} />);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { JSONSchema } from '@plone/types';
|
|
2
|
+
import type { Ref } from 'react';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
|
|
5
|
+
const cleanupSchema = (schema: JSONSchema | null): JSONSchema | null => {
|
|
6
|
+
if (!schema || !schema.properties) return schema;
|
|
7
|
+
return {
|
|
8
|
+
...schema,
|
|
9
|
+
properties: Object.entries(schema.properties).reduce<Record<string, any>>(
|
|
10
|
+
(acc, [key, value]) => {
|
|
11
|
+
acc[key] = {
|
|
12
|
+
...value,
|
|
13
|
+
description:
|
|
14
|
+
typeof value.description === 'string'
|
|
15
|
+
? value.description
|
|
16
|
+
: undefined,
|
|
17
|
+
};
|
|
18
|
+
return acc;
|
|
19
|
+
},
|
|
20
|
+
{},
|
|
21
|
+
),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Field = vi.fn((props) => (
|
|
26
|
+
<div className="Field" id={props.id}>
|
|
27
|
+
{props.title}
|
|
28
|
+
</div>
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
export const InlineForm = vi.fn((props) => (
|
|
32
|
+
<div
|
|
33
|
+
id="InlineForm"
|
|
34
|
+
data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
|
|
35
|
+
/>
|
|
36
|
+
));
|
|
37
|
+
|
|
38
|
+
export const ModalForm = vi.fn((props) => (
|
|
39
|
+
<div
|
|
40
|
+
id="ModalForm"
|
|
41
|
+
data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
|
|
42
|
+
/>
|
|
43
|
+
));
|
|
44
|
+
|
|
45
|
+
export const UndoToolbar = vi.fn(() => <div id="UndoToolbar" />);
|
|
46
|
+
|
|
47
|
+
export const BlocksToolbar = vi.fn(() => <div id="BlocksToolbar" />);
|
|
48
|
+
|
|
49
|
+
export const BlockDataForm = vi.fn((props) => (
|
|
50
|
+
<div
|
|
51
|
+
id="BlockDataForm"
|
|
52
|
+
data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
|
|
53
|
+
/>
|
|
54
|
+
));
|
|
55
|
+
|
|
56
|
+
export const BlocksForm = vi.fn((props) => (
|
|
57
|
+
<div
|
|
58
|
+
id="BlocksForm"
|
|
59
|
+
data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
|
|
60
|
+
/>
|
|
61
|
+
));
|
|
62
|
+
|
|
63
|
+
const MockForm = forwardRef(
|
|
64
|
+
(props: { schema: JSONSchema | null }, ref: Ref<any>) => (
|
|
65
|
+
<div
|
|
66
|
+
id="Form"
|
|
67
|
+
data-schema={JSON.stringify(cleanupSchema(props.schema), null, 2)}
|
|
68
|
+
ref={ref}
|
|
69
|
+
/>
|
|
70
|
+
),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
export const Form = vi.fn((props) => <MockForm {...props} />);
|