@eeacms/volto-eea-website-theme 3.5.4 → 3.6.0
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 +19 -21
- package/package.json +1 -1
- package/src/components/manage/Blocks/Title/variations/WebReport.test.jsx +134 -0
- package/src/components/theme/Widgets/ContributorsViewWidget.jsx +23 -0
- package/src/components/theme/Widgets/ContributorsViewWidget.test.jsx +60 -0
- package/src/components/theme/Widgets/CreatorsViewWidget.jsx +23 -0
- package/src/components/theme/Widgets/CreatorsViewWidget.test.jsx +60 -0
- package/src/components/theme/Widgets/ImageViewWidget.jsx +3 -0
- package/src/components/theme/Widgets/UserSelectWidget.jsx +331 -0
- package/src/components/theme/Widgets/UserSelectWidget.test.jsx +255 -0
- package/src/customizations/volto/actions/vocabularies/vocabularies.js +89 -0
- package/src/customizations/volto/actions/vocabularies/vocabularies.js.diff +32 -0
- package/src/customizations/volto/actions/vocabularies/vocabularies.js.md +4 -0
- package/src/customizations/volto/actions/vocabularies/vocabularies.test.js +57 -0
- package/src/customizations/volto/actions/vocabularies/vocabularies.test.js.diff +45 -0
- package/src/customizations/volto/components/manage/Diff/DiffField.diff +150 -0
- package/src/customizations/volto/components/manage/Diff/DiffField.jsx +387 -0
- package/src/customizations/volto/components/manage/Diff/DiffField.txt +1 -0
- package/src/hocs/withRootNavigation.test.jsx +70 -0
- package/src/index.js +14 -3
@@ -0,0 +1,70 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Provider } from 'react-redux';
|
3
|
+
import configureStore from 'redux-mock-store';
|
4
|
+
import thunk from 'redux-thunk'; // ✅ Add redux-thunk middleware
|
5
|
+
import { render } from '@testing-library/react';
|
6
|
+
import withRootNavigation from './withRootNavigation';
|
7
|
+
import { getNavigation } from '@plone/volto/actions';
|
8
|
+
import { getBaseUrl, hasApiExpander } from '@plone/volto/helpers';
|
9
|
+
import config from '@plone/volto/registry';
|
10
|
+
|
11
|
+
// Mock dependencies
|
12
|
+
jest.mock('@plone/volto/actions', () => ({
|
13
|
+
getNavigation: jest.fn(() => ({ type: 'GET_NAVIGATION' })), // ✅ Ensure it returns a plain object
|
14
|
+
}));
|
15
|
+
jest.mock('@plone/volto/helpers', () => ({
|
16
|
+
getBaseUrl: jest.fn(() => '/en'),
|
17
|
+
hasApiExpander: jest.fn(() => false),
|
18
|
+
}));
|
19
|
+
jest.mock('@plone/volto/registry', () => ({
|
20
|
+
settings: { navDepth: 2 },
|
21
|
+
}));
|
22
|
+
|
23
|
+
// ✅ Use redux-thunk middleware
|
24
|
+
const mockStore = configureStore([thunk]); // Add thunk to support async actions
|
25
|
+
|
26
|
+
const initialState = {
|
27
|
+
navigation: { items: [{ title: 'Home', url: '/' }] },
|
28
|
+
intl: { locale: 'en' },
|
29
|
+
};
|
30
|
+
|
31
|
+
const store = mockStore(initialState);
|
32
|
+
|
33
|
+
// Mock Wrapped Component
|
34
|
+
const MockComponent = (props) => {
|
35
|
+
return (
|
36
|
+
<div data-testid="wrapped-component">{JSON.stringify(props.items)}</div>
|
37
|
+
);
|
38
|
+
};
|
39
|
+
|
40
|
+
const WrappedComponent = withRootNavigation(MockComponent);
|
41
|
+
|
42
|
+
describe('withRootNavigation HOC', () => {
|
43
|
+
beforeEach(() => {
|
44
|
+
jest.clearAllMocks();
|
45
|
+
});
|
46
|
+
|
47
|
+
test('calls getNavigation when API expander is not set', () => {
|
48
|
+
render(
|
49
|
+
<Provider store={store}>
|
50
|
+
<WrappedComponent />
|
51
|
+
</Provider>,
|
52
|
+
);
|
53
|
+
|
54
|
+
expect(getBaseUrl).toHaveBeenCalledWith('/en'); // Check base URL calculation
|
55
|
+
expect(hasApiExpander).toHaveBeenCalledWith('navigation', '/en'); // Ensure API expander is checked
|
56
|
+
expect(getNavigation).toHaveBeenCalledWith('/en', config.settings.navDepth); // Ensure getNavigation is dispatched
|
57
|
+
});
|
58
|
+
|
59
|
+
test('does not call getNavigation if API expander is already set', () => {
|
60
|
+
hasApiExpander.mockReturnValue(true); // Simulate that API expander is already set
|
61
|
+
|
62
|
+
render(
|
63
|
+
<Provider store={store}>
|
64
|
+
<WrappedComponent />
|
65
|
+
</Provider>,
|
66
|
+
);
|
67
|
+
|
68
|
+
expect(getNavigation).not.toHaveBeenCalled(); // Ensure getNavigation is NOT called
|
69
|
+
});
|
70
|
+
});
|
package/src/index.js
CHANGED
@@ -2,7 +2,6 @@ import React from 'react';
|
|
2
2
|
import { v4 as uuid } from 'uuid';
|
3
3
|
import { Icon } from '@plone/volto/components';
|
4
4
|
import { default as TokenWidgetEdit } from '@plone/volto/components/manage/Widgets/TokenWidget';
|
5
|
-
import SelectAutoCompleteWidget from '@plone/volto/components/manage/Widgets/SelectAutoComplete';
|
6
5
|
import { serializeNodesToText } from '@plone/volto-slate/editor/render';
|
7
6
|
import TableBlockEdit from '@plone/volto-slate/blocks/Table/TableBlockEdit';
|
8
7
|
import TableBlockView from '@plone/volto-slate/blocks/Table/TableBlockView';
|
@@ -20,6 +19,10 @@ import { TopicsWidget } from '@eeacms/volto-eea-website-theme/components/theme/W
|
|
20
19
|
import { DateWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/DateWidget';
|
21
20
|
import { DatetimeWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/DatetimeWidget';
|
22
21
|
import CreatableSelectWidget from '@eeacms/volto-eea-website-theme/components/theme/Widgets/CreatableSelectWidget';
|
22
|
+
import UserSelectWidget from '@eeacms/volto-eea-website-theme/components/theme/Widgets/UserSelectWidget';
|
23
|
+
import ImageViewWidget from '@eeacms/volto-eea-website-theme/components/theme/Widgets/ImageViewWidget';
|
24
|
+
import CreatorsViewWidget from '@eeacms/volto-eea-website-theme/components/theme/Widgets/CreatorsViewWidget';
|
25
|
+
import ContributorsViewWidget from '@eeacms/volto-eea-website-theme/components/theme/Widgets/ContributorsViewWidget';
|
23
26
|
|
24
27
|
import Tag from '@eeacms/volto-eea-design-system/ui/Tag/Tag';
|
25
28
|
|
@@ -370,9 +373,17 @@ const applyConfig = (config) => {
|
|
370
373
|
config.widgets.views.id.topics = TopicsWidget;
|
371
374
|
config.widgets.views.id.subjects = TokenWidget;
|
372
375
|
config.widgets.views.widget.tags = TokenWidget;
|
376
|
+
config.widgets.views.id.creators = CreatorsViewWidget;
|
377
|
+
config.widgets.views.id.contributors = ContributorsViewWidget;
|
378
|
+
config.widgets.views.widget.contributors = ContributorsViewWidget;
|
379
|
+
config.widgets.views.widget.creators = CreatorsViewWidget;
|
373
380
|
config.widgets.widget.creatable_select = CreatableSelectWidget;
|
374
|
-
config.widgets.vocabulary['plone.app.vocabularies.Users'] =
|
375
|
-
|
381
|
+
config.widgets.vocabulary['plone.app.vocabularies.Users'] = UserSelectWidget;
|
382
|
+
|
383
|
+
config.widgets.views.factory = {
|
384
|
+
...(config.widgets.views.factory || {}),
|
385
|
+
Image: ImageViewWidget,
|
386
|
+
};
|
376
387
|
|
377
388
|
// /voltoCustom.css express-middleware
|
378
389
|
// /ok express-middleware - see also: https://github.com/plone/volto/pull/4432
|