@eeacms/volto-eea-website-policy 1.7.0 → 1.7.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 +16 -2
- package/package.json +1 -1
- package/src/components/Blocks/ContextNavigation/ContextNavigationEdit.test.jsx +64 -0
- package/src/components/Blocks/ContextNavigation/ContextNavigationView.test.jsx +50 -0
- package/src/components/Widgets/DataProvenance.jsx +6 -0
- package/src/components/Widgets/FrequencyOfDissemination.jsx +15 -0
- package/src/components/Widgets/InstitutionalMandate.jsx +6 -0
- package/src/helpers.test.js +86 -0
- package/src/index.js +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,20 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
-
### [1.7.
|
|
7
|
+
### [1.7.1](https://github.com/eea/volto-eea-website-policy/compare/1.7.0...1.7.1) - 24 July 2023
|
|
8
8
|
|
|
9
9
|
#### :rocket: New Features
|
|
10
10
|
|
|
11
|
-
- feat:
|
|
11
|
+
- feat: Add IMSv4 custom widgets - refs #145772 [Alin Voinea - [`367f0b6`](https://github.com/eea/volto-eea-website-policy/commit/367f0b611d6f69f217b1b0aaa25783968b8911ba)]
|
|
12
|
+
|
|
13
|
+
#### :house: Internal changes
|
|
14
|
+
|
|
15
|
+
- chore: Disable InstitutionalMandate DataProvenance widgets for now as there are issues - refs #160747 [Alin Voinea - [`bbdc3fb`](https://github.com/eea/volto-eea-website-policy/commit/bbdc3fb85a6ebd04205d763a75a1288f00efa634)]
|
|
16
|
+
|
|
17
|
+
#### :hammer_and_wrench: Others
|
|
18
|
+
|
|
19
|
+
- test: add unit tests - refs #254313 [ana-oprea - [`b51c1a9`](https://github.com/eea/volto-eea-website-policy/commit/b51c1a95f6a0624e75d168627d80009762ac4803)]
|
|
20
|
+
### [1.7.0](https://github.com/eea/volto-eea-website-policy/compare/1.6.3...1.7.0) - 16 June 2023
|
|
12
21
|
|
|
13
22
|
#### :house: Internal changes
|
|
14
23
|
|
|
@@ -62,6 +71,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
62
71
|
|
|
63
72
|
- Release 1.5.0 [Alin Voinea - [`a3dea8e`](https://github.com/eea/volto-eea-website-policy/commit/a3dea8ea15cb8d2a876dc10da926ece3a5707ea9)]
|
|
64
73
|
- test(Jenkinsfile): Use latest stable volto for testing [Alin Voinea - [`a8f7123`](https://github.com/eea/volto-eea-website-policy/commit/a8f712364187f9638886667c249fa102cb49b5c0)]
|
|
74
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`124a8f8`](https://github.com/eea/volto-eea-website-policy/commit/124a8f8ad4ced507aeec27012d725f2e2b977e08)]
|
|
65
75
|
### [1.4.0](https://github.com/eea/volto-eea-website-policy/compare/1.3.4...1.4.0) - 21 February 2023
|
|
66
76
|
|
|
67
77
|
#### :rocket: New Features
|
|
@@ -141,6 +151,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
141
151
|
#### :hammer_and_wrench: Others
|
|
142
152
|
|
|
143
153
|
- Release 1.1.0 [Alin Voinea - [`0291b3b`](https://github.com/eea/volto-eea-website-policy/commit/0291b3bb7b4c6ab09ca98728885cea4051eac8e3)]
|
|
154
|
+
- yarn 3 [Alin Voinea - [`593aa58`](https://github.com/eea/volto-eea-website-policy/commit/593aa58eaa4d28aced0603b7f7dd125c857a6f54)]
|
|
144
155
|
### [1.0.4](https://github.com/eea/volto-eea-website-policy/compare/1.0.3...1.0.4) - 22 November 2022
|
|
145
156
|
|
|
146
157
|
#### :nail_care: Enhancements
|
|
@@ -186,6 +197,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
186
197
|
|
|
187
198
|
#### :hammer_and_wrench: Others
|
|
188
199
|
|
|
200
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`d153f54`](https://github.com/eea/volto-eea-website-policy/commit/d153f54e55e918fa4746e05488c734624eaf14a9)]
|
|
189
201
|
### [0.4.0](https://github.com/eea/volto-eea-website-policy/compare/0.3.3...0.4.0) - 19 September 2022
|
|
190
202
|
|
|
191
203
|
#### :hammer_and_wrench: Others
|
|
@@ -261,6 +273,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
261
273
|
- format index.js [Andrei Grigore - [`db4481a`](https://github.com/eea/volto-eea-website-policy/commit/db4481aeeba59a769272659f33278c902fc69bec)]
|
|
262
274
|
- Update index.js [Alexandru Ghica - [`dc09886`](https://github.com/eea/volto-eea-website-policy/commit/dc0988640a76a9914381b120f58bb61a9ab1eb39)]
|
|
263
275
|
- Added externalRoutes [Alexandru Ghica - [`b68135b`](https://github.com/eea/volto-eea-website-policy/commit/b68135b013fafa93a41ea602ea2fad30879abe0f)]
|
|
276
|
+
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`575cca6`](https://github.com/eea/volto-eea-website-policy/commit/575cca674602ca2e1c2a41300c47ba594ff49aa0)]
|
|
264
277
|
### [0.1.1](https://github.com/eea/volto-eea-website-policy/compare/0.1.0...0.1.1) - 4 March 2022
|
|
265
278
|
|
|
266
279
|
#### :hammer_and_wrench: Others
|
|
@@ -273,4 +286,5 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
273
286
|
|
|
274
287
|
#### :hammer_and_wrench: Others
|
|
275
288
|
|
|
289
|
+
- yarn bootstrap [Alin Voinea - [`9b4d197`](https://github.com/eea/volto-eea-website-policy/commit/9b4d197cbc7992566cb36524d190078d5ad21a44)]
|
|
276
290
|
- Initial commit [Alin Voinea - [`3800692`](https://github.com/eea/volto-eea-website-policy/commit/3800692f7a4de6460815bd6061facacb986cbef0)]
|
package/package.json
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import ContextNavigationEdit from './ContextNavigationEdit';
|
|
4
|
+
import { Router } from 'react-router-dom';
|
|
5
|
+
import { createMemoryHistory } from 'history';
|
|
6
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
+
|
|
8
|
+
jest.mock('@plone/volto/components', () => ({
|
|
9
|
+
InlineForm: ({ onChangeField }) => (
|
|
10
|
+
<div>
|
|
11
|
+
<p>InlineForm</p>
|
|
12
|
+
<input id="test" onChange={onChangeField} />
|
|
13
|
+
</div>
|
|
14
|
+
),
|
|
15
|
+
SidebarPortal: ({ children }) => (
|
|
16
|
+
<div>
|
|
17
|
+
<div>SidebarPortal</div>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
jest.mock('@plone/volto/components/theme/Navigation/ContextNavigation', () => {
|
|
24
|
+
return {
|
|
25
|
+
__esModule: true,
|
|
26
|
+
default: ({ params }) => {
|
|
27
|
+
return <div>ConnectedContextNavigation {params.root_path}</div>;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('ContextNavigationEdit', () => {
|
|
33
|
+
it('renders corectly', () => {
|
|
34
|
+
const history = createMemoryHistory();
|
|
35
|
+
const { getByText, queryByText } = render(
|
|
36
|
+
<Router history={history}>
|
|
37
|
+
<ContextNavigationEdit />
|
|
38
|
+
</Router>,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
expect(getByText('Context navigation')).toBeInTheDocument();
|
|
42
|
+
expect(getByText('ConnectedContextNavigation')).toBeInTheDocument();
|
|
43
|
+
expect(queryByText('InlineForm')).toBeNull();
|
|
44
|
+
expect(getByText('SidebarPortal')).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('renders corectly', () => {
|
|
48
|
+
const history = createMemoryHistory();
|
|
49
|
+
const { container, getByText } = render(
|
|
50
|
+
<Router history={history}>
|
|
51
|
+
<ContextNavigationEdit selected={true} onChangeBlock={() => {}} />
|
|
52
|
+
</Router>,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
expect(getByText('Context navigation')).toBeInTheDocument();
|
|
56
|
+
expect(getByText('ConnectedContextNavigation')).toBeInTheDocument();
|
|
57
|
+
expect(getByText('InlineForm')).toBeInTheDocument();
|
|
58
|
+
expect(getByText('SidebarPortal')).toBeInTheDocument();
|
|
59
|
+
|
|
60
|
+
fireEvent.change(container.querySelector('#test'), {
|
|
61
|
+
target: { value: 'test' },
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import ContextNavigationView from './ContextNavigationView';
|
|
4
|
+
import { Router } from 'react-router-dom';
|
|
5
|
+
import { createMemoryHistory } from 'history';
|
|
6
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
+
|
|
8
|
+
jest.mock('@plone/volto/components/theme/Navigation/ContextNavigation', () => {
|
|
9
|
+
return {
|
|
10
|
+
__esModule: true,
|
|
11
|
+
default: ({ params }) => {
|
|
12
|
+
return <div>ConnectedContextNavigation {params.root_path}</div>;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('ContextNavigationView', () => {
|
|
18
|
+
let history;
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
history = createMemoryHistory();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders corectly', () => {
|
|
24
|
+
const { container } = render(
|
|
25
|
+
<Router history={history}>
|
|
26
|
+
<ContextNavigationView />
|
|
27
|
+
</Router>,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
expect(container.firstChild).toHaveTextContent(
|
|
31
|
+
'ConnectedContextNavigation',
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renders corectly', () => {
|
|
36
|
+
const { container } = render(
|
|
37
|
+
<Router history={history}>
|
|
38
|
+
<ContextNavigationView
|
|
39
|
+
data={{
|
|
40
|
+
navProps: { root_path: 'https://localhost:3000/test' },
|
|
41
|
+
root_node: [{ '@id': 'root_node' }],
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
44
|
+
</Router>,
|
|
45
|
+
);
|
|
46
|
+
expect(container.firstChild).toHaveTextContent(
|
|
47
|
+
'ConnectedContextNavigation root_node',
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
|
|
4
|
+
export const FrequencyOfDissemination = ({ value, children, className }) => {
|
|
5
|
+
if (!value) {
|
|
6
|
+
return '';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const text = value > 1 ? `Every ${value} years` : 'Once a year';
|
|
10
|
+
return (
|
|
11
|
+
<span className={cx(className, 'text', 'widget')}>
|
|
12
|
+
{children ? children(text) : text}
|
|
13
|
+
</span>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as helpers from './helpers';
|
|
2
|
+
import config from '@plone/volto/registry';
|
|
3
|
+
import { serializeNodes } from '@plone/volto-slate/editor/render';
|
|
4
|
+
import { isArray } from 'lodash';
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
6
|
+
|
|
7
|
+
jest.mock('@plone/volto/registry', () => ({
|
|
8
|
+
settings: {
|
|
9
|
+
slate: {
|
|
10
|
+
defaultValue: jest.fn(),
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
blocks: {
|
|
14
|
+
groupBlocksOrder: [
|
|
15
|
+
{ id: 'group1', title: 'Group1' },
|
|
16
|
+
{ id: 'group2', title: 'Group2' },
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock('@plone/volto-slate/editor/render', () => ({
|
|
22
|
+
serializeNodes: jest.fn(),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
describe('createSlateParagraph', () => {
|
|
26
|
+
it('should return default value when input is not an array', () => {
|
|
27
|
+
const input = 'test';
|
|
28
|
+
helpers.createSlateParagraph(input);
|
|
29
|
+
expect(config.settings.slate.defaultValue).toHaveBeenCalledTimes(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should return input when input is an array', () => {
|
|
33
|
+
const input = ['test'];
|
|
34
|
+
const result = helpers.createSlateParagraph(input);
|
|
35
|
+
expect(result).toBe(input);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('serializeText', () => {
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
jest.resetAllMocks();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should return the text when it is not an array', () => {
|
|
45
|
+
const text = 'Hello, World!';
|
|
46
|
+
|
|
47
|
+
expect(helpers.serializeText(text)).toEqual(text);
|
|
48
|
+
expect(isArray(text)).toBe(false);
|
|
49
|
+
expect(serializeNodes).not.toHaveBeenCalled();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should call serializeNodes when text is an array', () => {
|
|
53
|
+
const text = ['Hello', 'World!'];
|
|
54
|
+
|
|
55
|
+
helpers.serializeText(text);
|
|
56
|
+
expect(isArray(text)).toBe(true);
|
|
57
|
+
expect(serializeNodes).toHaveBeenCalledWith(text);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('appendGroup', () => {
|
|
62
|
+
beforeEach(() => {
|
|
63
|
+
jest.resetAllMocks();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should return the text when it is not an array', () => {
|
|
67
|
+
const id = 'group2';
|
|
68
|
+
const title = 'Group2';
|
|
69
|
+
const result = helpers.appendGroup(config, id, title);
|
|
70
|
+
expect(result).toEqual([
|
|
71
|
+
{ id: 'group1', title: 'Group1' },
|
|
72
|
+
{ id: 'group2', title: 'Group2' },
|
|
73
|
+
]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should return the text when it is not an array', () => {
|
|
77
|
+
const id = 'group3';
|
|
78
|
+
const title = 'Group3';
|
|
79
|
+
const result = helpers.appendGroup(config, id, title);
|
|
80
|
+
expect(result).toEqual([
|
|
81
|
+
{ id: 'group1', title: 'Group1' },
|
|
82
|
+
{ id: 'group2', title: 'Group2' },
|
|
83
|
+
{ id, title },
|
|
84
|
+
]);
|
|
85
|
+
});
|
|
86
|
+
});
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { runtimeConfig } from '@plone/volto/runtime_config';
|
|
2
2
|
import installContextNavigationBlock from '@eeacms/volto-eea-website-policy/components/Blocks/ContextNavigation';
|
|
3
3
|
import { appendGroup } from './helpers';
|
|
4
|
+
import { FrequencyOfDissemination } from '@eeacms/volto-eea-website-policy/components/Widgets/FrequencyOfDissemination';
|
|
5
|
+
import { DataProvenance } from '@eeacms/volto-eea-website-policy/components/Widgets/DataProvenance';
|
|
6
|
+
import { InstitutionalMandate } from '@eeacms/volto-eea-website-policy/components/Widgets/InstitutionalMandate';
|
|
4
7
|
|
|
5
8
|
const restrictedBlocks = [
|
|
6
9
|
'imagecards',
|
|
@@ -116,6 +119,12 @@ const applyConfig = (config) => {
|
|
|
116
119
|
}
|
|
117
120
|
});
|
|
118
121
|
|
|
122
|
+
// Custom widgets
|
|
123
|
+
config.widgets.id.data_provenance = DataProvenance;
|
|
124
|
+
config.widgets.id.institutional_mandate = InstitutionalMandate;
|
|
125
|
+
config.widgets.views.id.frequency_of_dissemination = FrequencyOfDissemination;
|
|
126
|
+
|
|
127
|
+
// Subsite
|
|
119
128
|
config.settings.apiExpanders = [
|
|
120
129
|
...config.settings.apiExpanders,
|
|
121
130
|
{
|