@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
|
@@ -5,7 +5,12 @@ import { Provider } from 'react-intl-redux';
|
|
|
5
5
|
|
|
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
|
|
|
@@ -16,6 +21,7 @@ test('renders a Lead Image block Sidebar component', () => {
|
|
|
16
21
|
messages: {},
|
|
17
22
|
},
|
|
18
23
|
});
|
|
24
|
+
|
|
19
25
|
const component = renderer.create(
|
|
20
26
|
<Provider store={store}>
|
|
21
27
|
<LeadImageSidebar
|
|
@@ -45,6 +51,7 @@ test('renders a Lead Image block Sidebar component', () => {
|
|
|
45
51
|
/>
|
|
46
52
|
</Provider>,
|
|
47
53
|
);
|
|
54
|
+
|
|
48
55
|
const json = component.toJSON();
|
|
49
56
|
expect(json).toMatchSnapshot();
|
|
50
57
|
});
|
|
@@ -2,7 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import renderer from 'react-test-renderer';
|
|
3
3
|
import View from './View';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
vi.mock('./ListingBody', () => ({
|
|
6
|
+
default: () => <div className="theblock" />,
|
|
7
|
+
}));
|
|
6
8
|
|
|
7
9
|
test('renders a view image component for the listing block', () => {
|
|
8
10
|
const component = renderer.create(
|
|
@@ -5,7 +5,11 @@ import { Provider } from 'react-intl-redux';
|
|
|
5
5
|
|
|
6
6
|
import MapsSidebar from './MapsSidebar';
|
|
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
|
|
|
@@ -2,18 +2,24 @@ 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 DateRangeFacet from './DateRangeFacet';
|
|
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
|
-
describe('
|
|
22
|
+
describe('DateRangeFacet', () => {
|
|
17
23
|
it('renders a facet component with a date range widget', async () => {
|
|
18
24
|
const store = mockStore({
|
|
19
25
|
userSession: { token: null },
|
|
@@ -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 SelectFacet from './SelectFacet';
|
|
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
|
describe('SelectFacet', () => {
|
|
17
23
|
it('renders a facet component with select dropdown', async () => {
|
|
@@ -8,6 +8,12 @@ const mockStore = configureStore();
|
|
|
8
8
|
|
|
9
9
|
const data = { '@type': 'toc', variation: 'default' };
|
|
10
10
|
|
|
11
|
+
const properties = {
|
|
12
|
+
title: 'Table of Contents',
|
|
13
|
+
hide_title: false,
|
|
14
|
+
ordered: true,
|
|
15
|
+
};
|
|
16
|
+
|
|
11
17
|
const tocEntries = [
|
|
12
18
|
{
|
|
13
19
|
level: 2,
|
|
@@ -35,7 +41,11 @@ test('renders a default toc renderer component', () => {
|
|
|
35
41
|
const component = renderer.create(
|
|
36
42
|
<Provider store={store}>
|
|
37
43
|
<MemoryRouter>
|
|
38
|
-
<DefaultTocRenderer
|
|
44
|
+
<DefaultTocRenderer
|
|
45
|
+
properties={properties}
|
|
46
|
+
data={data}
|
|
47
|
+
tocEntries={tocEntries}
|
|
48
|
+
/>
|
|
39
49
|
</MemoryRouter>
|
|
40
50
|
</Provider>,
|
|
41
51
|
);
|
|
@@ -5,7 +5,11 @@ import { Provider } from 'react-intl-redux';
|
|
|
5
5
|
|
|
6
6
|
import VideoSidebar from './VideoSidebar';
|
|
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
|
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
import { Provider } from 'react-intl-redux';
|
|
5
|
+
import configureStore from 'redux-mock-store';
|
|
6
|
+
import '@testing-library/jest-dom';
|
|
7
|
+
|
|
8
|
+
import ConditionalLink from './ConditionalLink';
|
|
9
|
+
|
|
10
|
+
const mockStore = configureStore();
|
|
11
|
+
const store = mockStore({
|
|
12
|
+
userSession: {
|
|
13
|
+
token: null,
|
|
14
|
+
},
|
|
15
|
+
intl: {
|
|
16
|
+
locale: 'en',
|
|
17
|
+
messages: {},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('ConditionalLink', () => {
|
|
22
|
+
it('renders a link when condition is true', () => {
|
|
23
|
+
render(
|
|
24
|
+
<Provider store={store}>
|
|
25
|
+
<MemoryRouter>
|
|
26
|
+
<ConditionalLink to="/test" condition={true}>
|
|
27
|
+
Link Text
|
|
28
|
+
</ConditionalLink>
|
|
29
|
+
</MemoryRouter>
|
|
30
|
+
</Provider>,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const link = screen.getByText('Link Text');
|
|
34
|
+
expect(link.tagName).toBe('A');
|
|
35
|
+
expect(link).toHaveAttribute('href', '/test');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('renders a link when condition is true', () => {
|
|
39
|
+
render(
|
|
40
|
+
<Provider store={store}>
|
|
41
|
+
<MemoryRouter>
|
|
42
|
+
<ConditionalLink href="/test" condition={true}>
|
|
43
|
+
Link Text
|
|
44
|
+
</ConditionalLink>
|
|
45
|
+
</MemoryRouter>
|
|
46
|
+
</Provider>,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const link = screen.getByText('Link Text');
|
|
50
|
+
expect(link.tagName).toBe('A');
|
|
51
|
+
expect(link).toHaveAttribute('href', '/test');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('renders a span when condition is false', () => {
|
|
55
|
+
render(
|
|
56
|
+
<Provider store={store}>
|
|
57
|
+
<MemoryRouter>
|
|
58
|
+
<ConditionalLink to="/test" condition={false}>
|
|
59
|
+
Link Text
|
|
60
|
+
</ConditionalLink>
|
|
61
|
+
</MemoryRouter>
|
|
62
|
+
</Provider>,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const span = screen.getByText('Link Text');
|
|
66
|
+
expect(span.tagName).toBe('DIV');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('passes additional props when rendering a link', () => {
|
|
70
|
+
render(
|
|
71
|
+
<Provider store={store}>
|
|
72
|
+
<MemoryRouter>
|
|
73
|
+
<ConditionalLink
|
|
74
|
+
to="/test"
|
|
75
|
+
condition={true}
|
|
76
|
+
className="custom-class"
|
|
77
|
+
data-test="test-id"
|
|
78
|
+
>
|
|
79
|
+
Link Text
|
|
80
|
+
</ConditionalLink>
|
|
81
|
+
</MemoryRouter>
|
|
82
|
+
</Provider>,
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const link = screen.getByText('Link Text');
|
|
86
|
+
expect(link).toHaveClass('custom-class');
|
|
87
|
+
expect(link).toHaveAttribute('data-test', 'test-id');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('renders a component if no external (href) link is passed', () => {
|
|
91
|
+
render(
|
|
92
|
+
<Provider store={store}>
|
|
93
|
+
<MemoryRouter>
|
|
94
|
+
<ConditionalLink
|
|
95
|
+
condition={true}
|
|
96
|
+
item={{
|
|
97
|
+
'@id': 'http://localhost:3000/en/welcome-to-volto',
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
<h1>Title</h1>
|
|
101
|
+
</ConditionalLink>
|
|
102
|
+
</MemoryRouter>
|
|
103
|
+
</Provider>,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const title = screen.getByText('Title');
|
|
107
|
+
expect(title.tagName).toBe('H1');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink';
|
|
3
|
+
import type { UniversalLinkProps } from '@plone/volto/components/manage/UniversalLink/UniversalLink';
|
|
4
|
+
|
|
5
|
+
type ConditionalLinkProps = {
|
|
6
|
+
condition?: boolean;
|
|
7
|
+
to?: string; // Alias for href
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
} & Omit<UniversalLinkProps, 'href' | 'item'> & {
|
|
10
|
+
href?: string;
|
|
11
|
+
item?: UniversalLinkProps['item'];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const ConditionalLink = React.forwardRef<
|
|
15
|
+
HTMLAnchorElement | HTMLDivElement,
|
|
16
|
+
ConditionalLinkProps
|
|
17
|
+
>(function ConditionalLink(
|
|
18
|
+
{ condition = true, to, href, item, children, ...rest },
|
|
19
|
+
ref,
|
|
20
|
+
) {
|
|
21
|
+
if (!condition) {
|
|
22
|
+
return <>{children}</>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Normalize: prefer explicit href over "to"
|
|
26
|
+
const finalHref = href ?? to;
|
|
27
|
+
|
|
28
|
+
// Rebuild props safely to satisfy UniversalLinkProps union
|
|
29
|
+
const universalLinkProps: UniversalLinkProps = finalHref
|
|
30
|
+
? { ...rest, href: finalHref, children }
|
|
31
|
+
: { ...rest, item: item!, children }; // assume item is defined if href isn't
|
|
32
|
+
|
|
33
|
+
return <UniversalLink ref={ref} {...universalLinkProps} />;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export default React.memo(ConditionalLink);
|
|
@@ -8,20 +8,29 @@ import { __test__ as Contents } from './Contents';
|
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
);
|
|
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
|
+
|
|
17
|
+
beforeAll(async () => {
|
|
18
|
+
const { __setLoadables } = await import(
|
|
19
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
20
|
+
);
|
|
21
|
+
await __setLoadables();
|
|
22
|
+
});
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
vi.mock('../Toolbar/Toolbar', () => ({
|
|
25
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
26
|
+
}));
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
);
|
|
28
|
+
vi.mock('../../theme/Pagination/Pagination', () => ({
|
|
29
|
+
default: vi.fn(() => <div className="Pagination" />),
|
|
30
|
+
}));
|
|
31
|
+
vi.mock('./ContentsUploadModal', () => ({
|
|
32
|
+
default: vi.fn(() => <div className="UploadModal" />),
|
|
33
|
+
}));
|
|
25
34
|
|
|
26
35
|
describe('Contents', () => {
|
|
27
36
|
it('renders a folder contents view component', () => {
|
|
@@ -87,7 +96,14 @@ describe('Contents', () => {
|
|
|
87
96
|
},
|
|
88
97
|
intl: {
|
|
89
98
|
locale: 'en',
|
|
90
|
-
messages: {
|
|
99
|
+
messages: {
|
|
100
|
+
ID: 'ID',
|
|
101
|
+
Title: 'Title',
|
|
102
|
+
'Publication date': 'Publication date',
|
|
103
|
+
'Created on': 'Created on',
|
|
104
|
+
'Last modified': 'Last modified',
|
|
105
|
+
Type: 'Type',
|
|
106
|
+
},
|
|
91
107
|
},
|
|
92
108
|
});
|
|
93
109
|
const { container } = render(
|
|
@@ -7,7 +7,11 @@ import ContentsPropertiesModal from './ContentsPropertiesModal';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
vi.mock('@plone/volto/components/manage/Form', async () => {
|
|
11
|
+
return await import(
|
|
12
|
+
'@plone/volto/components/manage/Form/__mocks__/index.vitest.tsx'
|
|
13
|
+
);
|
|
14
|
+
});
|
|
11
15
|
|
|
12
16
|
describe('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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,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/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
|
+
|
|
1
17
|
export const Contents = jest.fn(() => <div className="Contents" />);
|
|
2
18
|
|
|
3
19
|
export const ContentsRenameModal = jest.fn(() => (
|
|
@@ -7,7 +7,9 @@ import AddonsControlpanel from './AddonsControlpanel';
|
|
|
7
7
|
|
|
8
8
|
const mockStore = configureStore();
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
11
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
12
|
+
}));
|
|
11
13
|
|
|
12
14
|
describe('AddonsControlpanel', () => {
|
|
13
15
|
it('renders an addon control component', () => {
|
|
@@ -54,11 +56,34 @@ describe('AddonsControlpanel', () => {
|
|
|
54
56
|
locale: 'en',
|
|
55
57
|
messages: {},
|
|
56
58
|
},
|
|
59
|
+
actions: {
|
|
60
|
+
actions: {},
|
|
61
|
+
},
|
|
62
|
+
userSession: {
|
|
63
|
+
token: null,
|
|
64
|
+
},
|
|
65
|
+
content: {
|
|
66
|
+
data: {},
|
|
67
|
+
get: {
|
|
68
|
+
loading: false,
|
|
69
|
+
loaded: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
types: {
|
|
73
|
+
types: [],
|
|
74
|
+
get: {
|
|
75
|
+
loading: false,
|
|
76
|
+
loaded: true,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
57
79
|
});
|
|
80
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
58
81
|
const { container } = render(
|
|
59
82
|
<Provider store={store}>
|
|
60
|
-
<
|
|
61
|
-
|
|
83
|
+
<div>
|
|
84
|
+
<AddonsControlpanel location={{ pathname: '/blog' }} />
|
|
85
|
+
<div id="toolbar"></div>
|
|
86
|
+
</div>
|
|
62
87
|
</Provider>,
|
|
63
88
|
);
|
|
64
89
|
|
|
@@ -10,8 +10,15 @@ import { MemoryRouter } from 'react-router';
|
|
|
10
10
|
const middlewares = [thunk];
|
|
11
11
|
const mockStore = configureMockStore(middlewares);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
|
|
19
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
20
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
21
|
+
}));
|
|
15
22
|
|
|
16
23
|
describe('Aliases', () => {
|
|
17
24
|
it('renders an aliases control component', () => {
|
|
@@ -55,7 +62,11 @@ describe('Aliases', () => {
|
|
|
55
62
|
},
|
|
56
63
|
intl: {
|
|
57
64
|
locale: 'en',
|
|
58
|
-
messages: {
|
|
65
|
+
messages: {
|
|
66
|
+
Both: 'Both',
|
|
67
|
+
Automatically: 'Automatically',
|
|
68
|
+
Manually: 'Manually',
|
|
69
|
+
},
|
|
59
70
|
},
|
|
60
71
|
site: {
|
|
61
72
|
data: {
|
|
@@ -64,7 +75,28 @@ describe('Aliases', () => {
|
|
|
64
75
|
},
|
|
65
76
|
},
|
|
66
77
|
},
|
|
78
|
+
actions: {
|
|
79
|
+
actions: {},
|
|
80
|
+
},
|
|
81
|
+
userSession: {
|
|
82
|
+
token: null,
|
|
83
|
+
},
|
|
84
|
+
content: {
|
|
85
|
+
data: {},
|
|
86
|
+
get: {
|
|
87
|
+
loading: false,
|
|
88
|
+
loaded: true,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
types: {
|
|
92
|
+
types: [],
|
|
93
|
+
get: {
|
|
94
|
+
loading: false,
|
|
95
|
+
loaded: true,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
67
98
|
});
|
|
99
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
68
100
|
const { container } = render(
|
|
69
101
|
<Provider store={store}>
|
|
70
102
|
<MemoryRouter>
|
|
@@ -8,8 +8,14 @@ import ContentType from './ContentType';
|
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
});
|
|
16
|
+
vi.mock('../../Toolbar/Toolbar', () => ({
|
|
17
|
+
default: vi.fn(() => <div id="Portal" />),
|
|
18
|
+
}));
|
|
13
19
|
|
|
14
20
|
describe('ContentType', () => {
|
|
15
21
|
it('renders dexterity content-type component', () => {
|
|
@@ -32,8 +38,28 @@ describe('ContentType', () => {
|
|
|
32
38
|
locale: 'en',
|
|
33
39
|
messages: {},
|
|
34
40
|
},
|
|
41
|
+
actions: {
|
|
42
|
+
actions: {},
|
|
43
|
+
},
|
|
44
|
+
userSession: {
|
|
45
|
+
token: null,
|
|
46
|
+
},
|
|
47
|
+
content: {
|
|
48
|
+
data: {},
|
|
49
|
+
get: {
|
|
50
|
+
loading: false,
|
|
51
|
+
loaded: true,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
types: {
|
|
55
|
+
types: [],
|
|
56
|
+
get: {
|
|
57
|
+
loading: false,
|
|
58
|
+
loaded: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
35
61
|
});
|
|
36
|
-
|
|
62
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
37
63
|
const { container } = render(
|
|
38
64
|
<Provider store={store}>
|
|
39
65
|
<MemoryRouter
|
|
@@ -8,9 +8,11 @@ import ContentTypeLayout from './ContentTypeLayout';
|
|
|
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
|
-
|
|
15
|
+
vi.mock('../Form/Form', () => ({ default: vi.fn(() => <div id="form" />) }));
|
|
14
16
|
|
|
15
17
|
describe('ContentTypeLayout', () => {
|
|
16
18
|
it('renders dexterity content-type layout component', () => {
|
|
@@ -8,9 +8,11 @@ import ContentTypes from './ContentTypes';
|
|
|
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
|
-
|
|
15
|
+
vi.mock('../Form/Form', () => ({ default: vi.fn(() => <div id="form" />) }));
|
|
14
16
|
|
|
15
17
|
describe('ContentTypes', () => {
|
|
16
18
|
it('renders dexterity content-types controlpanel component', () => {
|
|
@@ -58,7 +60,28 @@ describe('ContentTypes', () => {
|
|
|
58
60
|
locale: 'en',
|
|
59
61
|
messages: {},
|
|
60
62
|
},
|
|
63
|
+
actions: {
|
|
64
|
+
actions: {},
|
|
65
|
+
},
|
|
66
|
+
userSession: {
|
|
67
|
+
token: null,
|
|
68
|
+
},
|
|
69
|
+
content: {
|
|
70
|
+
data: {},
|
|
71
|
+
get: {
|
|
72
|
+
loading: false,
|
|
73
|
+
loaded: true,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
types: {
|
|
77
|
+
types: [],
|
|
78
|
+
get: {
|
|
79
|
+
loading: false,
|
|
80
|
+
loaded: true,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
61
83
|
});
|
|
84
|
+
store.dispatch = vi.fn(() => Promise.resolve());
|
|
62
85
|
const { container } = render(
|
|
63
86
|
<Provider store={store}>
|
|
64
87
|
<MemoryRouter initialEntries={['/controlpanel/dexterity-types']}>
|