@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
|
@@ -2,19 +2,21 @@ import { render, waitFor, screen } from '@testing-library/react';
|
|
|
2
2
|
import configureStore from 'redux-mock-store';
|
|
3
3
|
import { Provider } from 'react-intl-redux';
|
|
4
4
|
import { MemoryRouter, Route } from 'react-router-dom';
|
|
5
|
-
|
|
6
5
|
import Controlpanel from './Controlpanel';
|
|
7
6
|
|
|
8
7
|
const mockStore = configureStore();
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
vi.mock('../Form/Form', () => ({
|
|
10
|
+
default: vi.fn(({ requestError }) => (
|
|
12
11
|
<div id="form">
|
|
13
|
-
{requestError ? `requestError
|
|
12
|
+
{requestError ? `requestError: ${requestError}` : 'Form rendered'}
|
|
14
13
|
</div>
|
|
15
14
|
)),
|
|
16
|
-
);
|
|
17
|
-
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
18
|
+
default: vi.fn(() => <div id="Portal">Toolbar Component</div>),
|
|
19
|
+
}));
|
|
18
20
|
|
|
19
21
|
const store = mockStore({
|
|
20
22
|
controlpanels: {
|
|
@@ -37,10 +39,35 @@ const store = mockStore({
|
|
|
37
39
|
locale: 'en',
|
|
38
40
|
messages: {},
|
|
39
41
|
},
|
|
42
|
+
actions: {
|
|
43
|
+
actions: {},
|
|
44
|
+
},
|
|
45
|
+
userSession: {
|
|
46
|
+
token: null,
|
|
47
|
+
},
|
|
48
|
+
content: {
|
|
49
|
+
data: {},
|
|
50
|
+
unlock: {
|
|
51
|
+
loading: false,
|
|
52
|
+
loaded: true,
|
|
53
|
+
},
|
|
54
|
+
get: {
|
|
55
|
+
loading: false,
|
|
56
|
+
loaded: true,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
types: {
|
|
60
|
+
types: [],
|
|
61
|
+
get: {
|
|
62
|
+
loading: false,
|
|
63
|
+
loaded: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
40
66
|
});
|
|
41
67
|
|
|
42
68
|
describe('Controlpanel', () => {
|
|
43
69
|
it('renders a controlpanel component', () => {
|
|
70
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
44
71
|
const { container } = render(
|
|
45
72
|
<Provider store={store}>
|
|
46
73
|
<MemoryRouter initialEntries={['/controlpanel/date-and-time']}>
|
|
@@ -52,6 +79,7 @@ describe('Controlpanel', () => {
|
|
|
52
79
|
|
|
53
80
|
expect(container).toMatchSnapshot();
|
|
54
81
|
});
|
|
82
|
+
|
|
55
83
|
it('renders a controlpanel component with error', async () => {
|
|
56
84
|
const { container, rerender } = render(
|
|
57
85
|
<Provider store={store}>
|
|
@@ -61,9 +89,11 @@ describe('Controlpanel', () => {
|
|
|
61
89
|
</MemoryRouter>
|
|
62
90
|
</Provider>,
|
|
63
91
|
);
|
|
92
|
+
|
|
64
93
|
store.getState().controlpanels.update.loading = true;
|
|
65
94
|
store.getState().controlpanels.update.error.response.body.message =
|
|
66
95
|
"[{'message': 'Twitter username should not include the \"@\" prefix character.', 'field': 'twitter_username', 'error': 'ValidationError'}]";
|
|
96
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
67
97
|
|
|
68
98
|
rerender(
|
|
69
99
|
<Provider store={store}>
|
|
@@ -73,6 +103,7 @@ describe('Controlpanel', () => {
|
|
|
73
103
|
</MemoryRouter>
|
|
74
104
|
</Provider>,
|
|
75
105
|
);
|
|
106
|
+
|
|
76
107
|
await waitFor(() => screen.findByText(/Twitter/i));
|
|
77
108
|
expect(container).toMatchSnapshot();
|
|
78
109
|
});
|
|
@@ -9,10 +9,12 @@ import Controlpanels from './Controlpanels';
|
|
|
9
9
|
|
|
10
10
|
const mockStore = configureStore();
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
13
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
14
|
+
}));
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
VersionOverview:
|
|
16
|
+
vi.mock('@plone/volto/components/manage/Controlpanels', () => ({
|
|
17
|
+
VersionOverview: vi.fn(() => <div className="VersionOverview" />),
|
|
16
18
|
}));
|
|
17
19
|
|
|
18
20
|
describe('Controlpanels', () => {
|
|
@@ -72,7 +74,28 @@ describe('Controlpanels', () => {
|
|
|
72
74
|
locale: 'en',
|
|
73
75
|
messages: {},
|
|
74
76
|
},
|
|
77
|
+
actions: {
|
|
78
|
+
actions: {},
|
|
79
|
+
},
|
|
80
|
+
userSession: {
|
|
81
|
+
token: null,
|
|
82
|
+
},
|
|
83
|
+
content: {
|
|
84
|
+
data: {},
|
|
85
|
+
get: {
|
|
86
|
+
loading: false,
|
|
87
|
+
loaded: true,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
types: {
|
|
91
|
+
types: [],
|
|
92
|
+
get: {
|
|
93
|
+
loading: false,
|
|
94
|
+
loaded: true,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
75
97
|
});
|
|
98
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
76
99
|
const { container } = render(
|
|
77
100
|
<Provider store={store}>
|
|
78
101
|
<MemoryRouter>
|
|
@@ -111,6 +134,26 @@ describe('Controlpanels', () => {
|
|
|
111
134
|
locale: 'en',
|
|
112
135
|
messages: {},
|
|
113
136
|
},
|
|
137
|
+
actions: {
|
|
138
|
+
actions: {},
|
|
139
|
+
},
|
|
140
|
+
userSession: {
|
|
141
|
+
token: null,
|
|
142
|
+
},
|
|
143
|
+
content: {
|
|
144
|
+
data: {},
|
|
145
|
+
get: {
|
|
146
|
+
loading: false,
|
|
147
|
+
loaded: true,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
types: {
|
|
151
|
+
types: [],
|
|
152
|
+
get: {
|
|
153
|
+
loading: false,
|
|
154
|
+
loaded: true,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
114
157
|
});
|
|
115
158
|
|
|
116
159
|
const FooComponent = () => {
|
|
@@ -130,6 +173,7 @@ describe('Controlpanels', () => {
|
|
|
130
173
|
component: FooComponent,
|
|
131
174
|
},
|
|
132
175
|
];
|
|
176
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
133
177
|
const { container } = render(
|
|
134
178
|
<Provider store={store}>
|
|
135
179
|
<MemoryRouter>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { render, act } from '@testing-library/react';
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
5
|
import jwt from 'jsonwebtoken';
|
|
@@ -7,10 +7,12 @@ import jwt from 'jsonwebtoken';
|
|
|
7
7
|
import GroupsControlpanel from './GroupsControlpanel';
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
|
-
|
|
10
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
11
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
12
|
+
}));
|
|
11
13
|
|
|
12
14
|
describe('UsersControlpanel', () => {
|
|
13
|
-
it('renders a user control component', () => {
|
|
15
|
+
it('renders a user control component', async () => {
|
|
14
16
|
const store = mockStore({
|
|
15
17
|
userSession: {
|
|
16
18
|
token: jwt.sign({ sub: 'john' }, 'secret'),
|
|
@@ -36,12 +38,16 @@ describe('UsersControlpanel', () => {
|
|
|
36
38
|
messages: {},
|
|
37
39
|
},
|
|
38
40
|
});
|
|
39
|
-
const { container } =
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const { container } = await act(async () => {
|
|
42
|
+
return render(
|
|
43
|
+
<Provider store={store}>
|
|
44
|
+
<>
|
|
45
|
+
<GroupsControlpanel location={{ pathname: '/blog' }} />
|
|
46
|
+
<div id="toolbar"></div>
|
|
47
|
+
</>
|
|
48
|
+
</Provider>,
|
|
49
|
+
);
|
|
50
|
+
});
|
|
45
51
|
|
|
46
52
|
expect(container).toMatchSnapshot();
|
|
47
53
|
});
|
|
@@ -2,13 +2,14 @@ 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 ModerateComments from './ModerateComments';
|
|
7
6
|
|
|
8
7
|
const mockStore = configureStore();
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
vi.mock('@plone/volto/components/theme/Comments');
|
|
10
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
11
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
12
|
+
}));
|
|
12
13
|
|
|
13
14
|
describe('ModerateComments', () => {
|
|
14
15
|
it('renders a moderate comments component', () => {
|
|
@@ -26,11 +27,36 @@ describe('ModerateComments', () => {
|
|
|
26
27
|
locale: 'en',
|
|
27
28
|
messages: {},
|
|
28
29
|
},
|
|
30
|
+
actions: {
|
|
31
|
+
actions: {},
|
|
32
|
+
},
|
|
33
|
+
userSession: {
|
|
34
|
+
token: null,
|
|
35
|
+
},
|
|
36
|
+
content: {
|
|
37
|
+
data: {},
|
|
38
|
+
get: {
|
|
39
|
+
loading: false,
|
|
40
|
+
loaded: true,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
types: {
|
|
44
|
+
types: [],
|
|
45
|
+
get: {
|
|
46
|
+
loading: false,
|
|
47
|
+
loaded: true,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
29
50
|
});
|
|
51
|
+
|
|
52
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
53
|
+
|
|
30
54
|
const { container } = render(
|
|
31
55
|
<Provider store={store}>
|
|
32
|
-
<
|
|
33
|
-
|
|
56
|
+
<div>
|
|
57
|
+
<ModerateComments location={{ pathname: '/blog' }} />
|
|
58
|
+
<div id="toolbar"></div>
|
|
59
|
+
</div>
|
|
34
60
|
</Provider>,
|
|
35
61
|
);
|
|
36
62
|
|
|
@@ -9,8 +9,15 @@ import AddRule from './AddRule';
|
|
|
9
9
|
const middlewares = [thunk];
|
|
10
10
|
const mockStore = configureMockStore(middlewares);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
|
|
18
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
19
|
+
default: vi.fn(() => <div id="Toolbar" />),
|
|
20
|
+
}));
|
|
14
21
|
|
|
15
22
|
describe('AddRule', () => {
|
|
16
23
|
it('renders rules add interface', () => {
|
|
@@ -22,8 +29,10 @@ describe('AddRule', () => {
|
|
|
22
29
|
});
|
|
23
30
|
const { container } = render(
|
|
24
31
|
<Provider store={store}>
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
<>
|
|
33
|
+
<AddRule location={{ pathname: '/controlpanel/rules/add' }} />
|
|
34
|
+
<div id="toolbar"></div>
|
|
35
|
+
</>
|
|
27
36
|
</Provider>,
|
|
28
37
|
);
|
|
29
38
|
|
|
@@ -9,7 +9,9 @@ import ConfigureRule from './ConfigureRule';
|
|
|
9
9
|
const middlewares = [thunk];
|
|
10
10
|
const mockStore = configureMockStore(middlewares);
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
13
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
14
|
+
}));
|
|
13
15
|
|
|
14
16
|
describe('ConfigureRule', () => {
|
|
15
17
|
it('renders rules configure interface', () => {
|
|
@@ -21,10 +23,12 @@ describe('ConfigureRule', () => {
|
|
|
21
23
|
});
|
|
22
24
|
const { container } = render(
|
|
23
25
|
<Provider store={store}>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
<>
|
|
27
|
+
<ConfigureRule
|
|
28
|
+
location={{ pathname: '/controlpanel/rules/:id/configure' }}
|
|
29
|
+
/>
|
|
30
|
+
<div id="toolbar"></div>
|
|
31
|
+
</>
|
|
28
32
|
</Provider>,
|
|
29
33
|
);
|
|
30
34
|
|
|
@@ -9,9 +9,15 @@ import EditRule from './EditRule';
|
|
|
9
9
|
const middlewares = [thunk];
|
|
10
10
|
const mockStore = configureMockStore(middlewares);
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
13
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
14
|
+
}));
|
|
13
15
|
|
|
14
|
-
|
|
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
|
+
});
|
|
15
21
|
|
|
16
22
|
describe('EditRule', () => {
|
|
17
23
|
it('renders rules edit interface', () => {
|
|
@@ -23,8 +29,10 @@ describe('EditRule', () => {
|
|
|
23
29
|
});
|
|
24
30
|
const { container } = render(
|
|
25
31
|
<Provider store={store}>
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
<>
|
|
33
|
+
<EditRule location={{ pathname: '/controlpanel/rules/:id/edit' }} />
|
|
34
|
+
<div id="toolbar"></div>
|
|
35
|
+
</>
|
|
28
36
|
</Provider>,
|
|
29
37
|
);
|
|
30
38
|
|
|
@@ -9,7 +9,9 @@ import Rules from './Rules';
|
|
|
9
9
|
const middlewares = [thunk];
|
|
10
10
|
const mockStore = configureMockStore(middlewares);
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
13
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
14
|
+
}));
|
|
13
15
|
|
|
14
16
|
describe('Rules', () => {
|
|
15
17
|
it('renders rules control panel control', () => {
|
|
@@ -64,8 +66,10 @@ describe('Rules', () => {
|
|
|
64
66
|
});
|
|
65
67
|
const { container } = render(
|
|
66
68
|
<Provider store={store}>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
<>
|
|
70
|
+
<Rules location={{ pathname: '/controlpanel/rules' }} />
|
|
71
|
+
<div id="toolbar"></div>
|
|
72
|
+
</>
|
|
69
73
|
</Provider>,
|
|
70
74
|
);
|
|
71
75
|
|
|
@@ -7,8 +7,14 @@ import UndoControlpanel from './UndoControlpanel';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
});
|
|
15
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
16
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
17
|
+
}));
|
|
12
18
|
|
|
13
19
|
describe('UndoControlpanel', () => {
|
|
14
20
|
it('renders undo controlpanel component', () => {
|
|
@@ -81,11 +87,34 @@ describe('UndoControlpanel', () => {
|
|
|
81
87
|
locale: 'en',
|
|
82
88
|
messages: {},
|
|
83
89
|
},
|
|
90
|
+
actions: {
|
|
91
|
+
actions: {},
|
|
92
|
+
},
|
|
93
|
+
userSession: {
|
|
94
|
+
token: null,
|
|
95
|
+
},
|
|
96
|
+
content: {
|
|
97
|
+
data: {},
|
|
98
|
+
get: {
|
|
99
|
+
loading: false,
|
|
100
|
+
loaded: true,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
types: {
|
|
104
|
+
types: [],
|
|
105
|
+
get: {
|
|
106
|
+
loading: false,
|
|
107
|
+
loaded: true,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
84
110
|
});
|
|
111
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
85
112
|
const { container } = render(
|
|
86
113
|
<Provider store={store}>
|
|
87
|
-
<
|
|
88
|
-
|
|
114
|
+
<div>
|
|
115
|
+
<UndoControlpanel location={{ pathname: '/blog' }} />
|
|
116
|
+
<div id="toolbar"></div>
|
|
117
|
+
</div>
|
|
89
118
|
</Provider>,
|
|
90
119
|
);
|
|
91
120
|
|
|
@@ -7,7 +7,9 @@ import { MemoryRouter } from 'react-router-dom';
|
|
|
7
7
|
import UserGroupMembershipControlPanel from './UserGroupMembershipControlPanel';
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
|
-
|
|
10
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
11
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
12
|
+
}));
|
|
11
13
|
|
|
12
14
|
describe('UserGroupMembershipControlPanel', () => {
|
|
13
15
|
it('renders a user group membership control component', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { render, act } from '@testing-library/react';
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
5
|
import jwt from 'jsonwebtoken';
|
|
@@ -7,10 +7,12 @@ import jwt from 'jsonwebtoken';
|
|
|
7
7
|
import UsersControlpanel from './UsersControlpanel';
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
|
-
|
|
10
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
11
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
12
|
+
}));
|
|
11
13
|
|
|
12
14
|
describe('UsersControlpanel', () => {
|
|
13
|
-
it('renders a user control component', () => {
|
|
15
|
+
it('renders a user control component', async () => {
|
|
14
16
|
const store = mockStore({
|
|
15
17
|
userSession: {
|
|
16
18
|
token: jwt.sign({ sub: 'john' }, 'secret'),
|
|
@@ -36,12 +38,16 @@ describe('UsersControlpanel', () => {
|
|
|
36
38
|
messages: {},
|
|
37
39
|
},
|
|
38
40
|
});
|
|
39
|
-
const { container } =
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const { container } = await act(async () => {
|
|
42
|
+
return render(
|
|
43
|
+
<Provider store={store}>
|
|
44
|
+
<>
|
|
45
|
+
<UsersControlpanel location={{ pathname: '/blog' }} />
|
|
46
|
+
<div id="toolbar"></div>
|
|
47
|
+
</>
|
|
48
|
+
</Provider>,
|
|
49
|
+
);
|
|
50
|
+
});
|
|
45
51
|
|
|
46
52
|
expect(container).toMatchSnapshot();
|
|
47
53
|
});
|
|
@@ -3,12 +3,13 @@ import { render } from '@testing-library/react';
|
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
5
|
import { MemoryRouter } from 'react-router-dom';
|
|
6
|
-
|
|
7
6
|
import Delete from './Delete';
|
|
8
7
|
|
|
9
8
|
const mockStore = configureStore();
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
11
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
12
|
+
}));
|
|
12
13
|
|
|
13
14
|
describe('Delete', () => {
|
|
14
15
|
it('renders an empty delete component', () => {
|
|
@@ -19,16 +20,36 @@ describe('Delete', () => {
|
|
|
19
20
|
loading: false,
|
|
20
21
|
loaded: true,
|
|
21
22
|
},
|
|
23
|
+
get: {
|
|
24
|
+
loading: false,
|
|
25
|
+
loaded: true,
|
|
26
|
+
},
|
|
22
27
|
},
|
|
23
28
|
intl: {
|
|
24
29
|
locale: 'en',
|
|
25
30
|
messages: {},
|
|
26
31
|
},
|
|
32
|
+
actions: {
|
|
33
|
+
actions: {},
|
|
34
|
+
},
|
|
35
|
+
userSession: {
|
|
36
|
+
token: null,
|
|
37
|
+
},
|
|
38
|
+
types: {
|
|
39
|
+
types: [],
|
|
40
|
+
get: {
|
|
41
|
+
loading: false,
|
|
42
|
+
loaded: true,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
27
45
|
});
|
|
46
|
+
|
|
47
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
48
|
+
|
|
28
49
|
const { container } = render(
|
|
29
50
|
<Provider store={store}>
|
|
30
51
|
<MemoryRouter>
|
|
31
|
-
<Delete location={{ pathname: '/blog', search:
|
|
52
|
+
<Delete location={{ pathname: '/blog', search: '' }} />
|
|
32
53
|
<div id="toolbar"></div>
|
|
33
54
|
</MemoryRouter>
|
|
34
55
|
</Provider>,
|
|
@@ -47,16 +68,36 @@ describe('Delete', () => {
|
|
|
47
68
|
loading: false,
|
|
48
69
|
loaded: true,
|
|
49
70
|
},
|
|
71
|
+
get: {
|
|
72
|
+
loading: false,
|
|
73
|
+
loaded: true,
|
|
74
|
+
},
|
|
50
75
|
},
|
|
51
76
|
intl: {
|
|
52
77
|
locale: 'en',
|
|
53
78
|
messages: {},
|
|
54
79
|
},
|
|
80
|
+
actions: {
|
|
81
|
+
actions: {},
|
|
82
|
+
},
|
|
83
|
+
userSession: {
|
|
84
|
+
token: null,
|
|
85
|
+
},
|
|
86
|
+
types: {
|
|
87
|
+
types: [],
|
|
88
|
+
get: {
|
|
89
|
+
loading: false,
|
|
90
|
+
loaded: true,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
55
93
|
});
|
|
94
|
+
|
|
95
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
96
|
+
|
|
56
97
|
const { container } = render(
|
|
57
98
|
<Provider store={store}>
|
|
58
99
|
<MemoryRouter>
|
|
59
|
-
<Delete location={{ pathname: '/blog', search:
|
|
100
|
+
<Delete location={{ pathname: '/blog', search: '' }} />
|
|
60
101
|
<div id="toolbar"></div>
|
|
61
102
|
</MemoryRouter>
|
|
62
103
|
</Provider>,
|
|
@@ -8,13 +8,22 @@ import Diff from './Diff';
|
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
vi.mock('../Toolbar/Toolbar', () => ({
|
|
12
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
13
|
+
}));
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
);
|
|
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
|
+
});
|
|
18
27
|
|
|
19
28
|
describe('Diff', () => {
|
|
20
29
|
it('renders a diff component', async () => {
|
|
@@ -2,14 +2,20 @@ 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 DiffField from './DiffField';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
);
|
|
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
|
+
|
|
13
|
+
beforeAll(async () => {
|
|
14
|
+
const { __setLoadables } = await import(
|
|
15
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
16
|
+
);
|
|
17
|
+
await __setLoadables();
|
|
18
|
+
});
|
|
13
19
|
|
|
14
20
|
const mockStore = configureStore();
|
|
15
21
|
|