@eeacms/volto-group-block 6.3.4 → 6.3.5
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 +25 -2
- package/cypress.config.js +3 -3
- package/package.json +1 -1
- package/src/components/manage/Blocks/Group/CounterComponent.jsx +2 -10
- package/src/components/manage/Blocks/Group/DefaultBody.jsx +7 -1
- package/src/components/manage/Blocks/Group/DefaultBody.test.jsx +75 -0
- package/src/components/manage/Blocks/Group/Edit.test.jsx +9 -0
- package/src/components/manage/Blocks/Group/View.test.jsx +15 -0
- package/src/components/manage/Blocks/Group/utils.js +8 -0
- package/src/components/manage/Blocks/Group/utils.test.js +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,34 @@ 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
|
-
### [6.3.
|
|
7
|
+
### [6.3.5](https://github.com/eea/volto-group-block/compare/6.3.4...6.3.5) - 24 November 2023
|
|
8
|
+
|
|
9
|
+
#### :bug: Bug Fixes
|
|
10
|
+
|
|
11
|
+
- fix: Pass location to RenderBlocks [kreafox - [`87ae0df`](https://github.com/eea/volto-group-block/commit/87ae0dff17cb508466b17f959e99d62c6ab69a60)]
|
|
12
|
+
|
|
13
|
+
#### :house: Internal changes
|
|
14
|
+
|
|
15
|
+
- chore: [JENKINS] Refactor automated testing [valentinab25 - [`616f6eb`](https://github.com/eea/volto-group-block/commit/616f6ebe0385d82a827c6679eabdcf4e92a18c11)]
|
|
8
16
|
|
|
9
17
|
#### :hammer_and_wrench: Others
|
|
10
18
|
|
|
11
|
-
-
|
|
19
|
+
- test: update cypress test [kreafox - [`f84a866`](https://github.com/eea/volto-group-block/commit/f84a866a313f30f94fd1c0a41737face83dac3e0)]
|
|
20
|
+
- more tests [kreafox - [`7f93774`](https://github.com/eea/volto-group-block/commit/7f93774774119fe1fa5e8266e8ec700cd2bc9427)]
|
|
21
|
+
- test: fix bug reported by sonarqube, add more tests [kreafox - [`3599b0f`](https://github.com/eea/volto-group-block/commit/3599b0f7edf22037729c52e35f29d8919e466e5f)]
|
|
22
|
+
- test: add more tests [kreafox - [`0c5fc63`](https://github.com/eea/volto-group-block/commit/0c5fc63866d6590e64051483ee8ec97e548d0b14)]
|
|
23
|
+
- test: update jest tests [kreafox - [`88d9945`](https://github.com/eea/volto-group-block/commit/88d9945c6f338992247232325a25ea9795c2fe42)]
|
|
24
|
+
- test: increase coverage [kreafox - [`081a2d0`](https://github.com/eea/volto-group-block/commit/081a2d0bb001c980d2023bcce81830d71d23aeca)]
|
|
25
|
+
- Prettier [kreafox - [`0c5d2d1`](https://github.com/eea/volto-group-block/commit/0c5d2d1a494489663cc97c5dc0f4ad13c4b67c8d)]
|
|
26
|
+
- test: mock useLocation [kreafox - [`746887f`](https://github.com/eea/volto-group-block/commit/746887fa0e778f2d4cbe86661fc8c38c8a4bafb5)]
|
|
27
|
+
- test: mock useLocation [kreafox - [`a360401`](https://github.com/eea/volto-group-block/commit/a360401b8ee05e9cb54b253b0e605d0a040c8f78)]
|
|
28
|
+
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`25030fb`](https://github.com/eea/volto-group-block/commit/25030fbd69108f90df02130e5010e56398941ad2)]
|
|
29
|
+
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`1517dbb`](https://github.com/eea/volto-group-block/commit/1517dbb81cf9128752d835ae59dc22b251f4b035)]
|
|
30
|
+
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`b0ba5f9`](https://github.com/eea/volto-group-block/commit/b0ba5f9c6d37526411a7a984595ac624401f8ac5)]
|
|
31
|
+
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`8dbdfeb`](https://github.com/eea/volto-group-block/commit/8dbdfeb89fe53c6dc2f476b183a53c9266ab2bdf)]
|
|
32
|
+
- test: [JENKINS] Improve cypress time [valentinab25 - [`d0324f4`](https://github.com/eea/volto-group-block/commit/d0324f4aad6d94233ca8ce3645ca5162f39d9834)]
|
|
33
|
+
### [6.3.4](https://github.com/eea/volto-group-block/compare/6.3.3...6.3.4) - 22 October 2023
|
|
34
|
+
|
|
12
35
|
### [6.3.3](https://github.com/eea/volto-group-block/compare/6.3.2...6.3.3) - 17 October 2023
|
|
13
36
|
|
|
14
37
|
#### :house: Internal changes
|
package/cypress.config.js
CHANGED
|
@@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');
|
|
|
2
2
|
|
|
3
3
|
module.exports = defineConfig({
|
|
4
4
|
viewportWidth: 1280,
|
|
5
|
-
defaultCommandTimeout:
|
|
5
|
+
defaultCommandTimeout: 8888,
|
|
6
6
|
chromeWebSecurity: false,
|
|
7
7
|
reporter: 'junit',
|
|
8
|
-
video:
|
|
8
|
+
video: false,
|
|
9
9
|
retries: {
|
|
10
|
-
runMode:
|
|
10
|
+
runMode: 2,
|
|
11
11
|
openMode: 0,
|
|
12
12
|
},
|
|
13
13
|
reporterOptions: {
|
package/package.json
CHANGED
|
@@ -7,15 +7,7 @@ import { visitBlocks } from '@plone/volto/helpers/Blocks/Blocks';
|
|
|
7
7
|
import { serializeNodesToText } from '@plone/volto-slate/editor/render';
|
|
8
8
|
import delightedSVG from '@plone/volto/icons/delighted.svg';
|
|
9
9
|
import dissatisfiedSVG from '@plone/volto/icons/dissatisfied.svg';
|
|
10
|
-
|
|
11
|
-
const countCharsWithoutSpaces = (paragraph) => {
|
|
12
|
-
const regex = /[^\s\\]/g;
|
|
13
|
-
return (paragraph.match(regex) || []).length;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const countCharsWithSpaces = (paragraph) => {
|
|
17
|
-
return paragraph?.length || 0;
|
|
18
|
-
};
|
|
10
|
+
import { countCharsWithoutSpaces, countCharsWithSpaces } from './utils';
|
|
19
11
|
|
|
20
12
|
const countTextInEachBlock = (countTextIn, ignoreSpaces, groupCharCount) => ([
|
|
21
13
|
id,
|
|
@@ -36,7 +28,7 @@ const countTextInEachBlock = (countTextIn, ignoreSpaces, groupCharCount) => ([
|
|
|
36
28
|
};
|
|
37
29
|
|
|
38
30
|
const countTextInBlocks = (blocksObject, ignoreSpaces, maxChars) => {
|
|
39
|
-
const { countTextIn } = config.blocks?.blocksConfig?.group;
|
|
31
|
+
const { countTextIn } = config.blocks?.blocksConfig?.group || [];
|
|
40
32
|
// use obj ref to update value - if you send number it will not be updated
|
|
41
33
|
const groupCharCount = { value: 0 };
|
|
42
34
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Button } from 'semantic-ui-react';
|
|
2
2
|
import { BlocksForm, Icon, RenderBlocks } from '@plone/volto/components';
|
|
3
3
|
import EditBlockWrapper from './EditBlockWrapper';
|
|
4
|
+
import { useLocation } from 'react-router-dom';
|
|
4
5
|
|
|
5
6
|
import helpSVG from '@plone/volto/icons/help.svg';
|
|
6
7
|
|
|
7
8
|
const GroupBlockDefaultBody = (props) => {
|
|
9
|
+
const location = useLocation();
|
|
8
10
|
const {
|
|
9
11
|
block,
|
|
10
12
|
data,
|
|
@@ -98,7 +100,11 @@ const GroupBlockDefaultBody = (props) => {
|
|
|
98
100
|
)}
|
|
99
101
|
</BlocksForm>
|
|
100
102
|
) : (
|
|
101
|
-
<RenderBlocks
|
|
103
|
+
<RenderBlocks
|
|
104
|
+
location={location}
|
|
105
|
+
metadata={metadata}
|
|
106
|
+
content={data?.data || {}}
|
|
107
|
+
/>
|
|
102
108
|
);
|
|
103
109
|
};
|
|
104
110
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { Provider } from 'react-intl-redux';
|
|
4
|
+
import DefaultBody from './DefaultBody';
|
|
5
|
+
import configureStore from 'redux-mock-store';
|
|
6
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
+
|
|
8
|
+
jest.mock('react-router-dom', () => ({
|
|
9
|
+
...jest.requireActual('react-router-dom'),
|
|
10
|
+
useLocation: () => ({
|
|
11
|
+
pathname: '/',
|
|
12
|
+
hash: '',
|
|
13
|
+
search: '',
|
|
14
|
+
}),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
jest.mock('@plone/volto/components', () => ({
|
|
18
|
+
BlocksForm: jest.fn(() => <div className="blocks-form">RenderBlocks</div>),
|
|
19
|
+
RenderBlocks: jest.fn(() => <div>RenderBlocks</div>),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const mockStore = configureStore();
|
|
23
|
+
const store = mockStore({
|
|
24
|
+
intl: {
|
|
25
|
+
locale: 'en',
|
|
26
|
+
messages: {},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('DefaultBody', () => {
|
|
31
|
+
it('renders children', () => {
|
|
32
|
+
const props = {
|
|
33
|
+
data: {
|
|
34
|
+
variation: {},
|
|
35
|
+
},
|
|
36
|
+
metadata: {},
|
|
37
|
+
properties: {},
|
|
38
|
+
variation: {},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const { getByText } = render(
|
|
42
|
+
<Provider store={store}>
|
|
43
|
+
<DefaultBody {...props} />
|
|
44
|
+
</Provider>,
|
|
45
|
+
);
|
|
46
|
+
expect(getByText('RenderBlocks')).toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('DefaultBody Edit', () => {
|
|
51
|
+
it('renders children', () => {
|
|
52
|
+
const props = {
|
|
53
|
+
isEditMode: true,
|
|
54
|
+
data: {
|
|
55
|
+
variation: {},
|
|
56
|
+
allowedBlocks: ['listing'],
|
|
57
|
+
},
|
|
58
|
+
metadata: {},
|
|
59
|
+
properties: {},
|
|
60
|
+
variation: {},
|
|
61
|
+
onSelectBlock: jest.fn(),
|
|
62
|
+
onDeleteBlock: jest.fn(),
|
|
63
|
+
onMutateBlock: jest.fn(),
|
|
64
|
+
onInsertBlock: jest.fn(),
|
|
65
|
+
selected: true,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const { getByText } = render(
|
|
69
|
+
<Provider store={store}>
|
|
70
|
+
<DefaultBody {...props} />
|
|
71
|
+
</Provider>,
|
|
72
|
+
);
|
|
73
|
+
expect(getByText('RenderBlocks')).toBeInTheDocument();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -30,6 +30,15 @@ jest.mock('@plone/volto/helpers', () => ({
|
|
|
30
30
|
getBlocksLayoutFieldname: jest.fn(),
|
|
31
31
|
}));
|
|
32
32
|
|
|
33
|
+
jest.mock('react-router-dom', () => ({
|
|
34
|
+
...jest.requireActual('react-router-dom'),
|
|
35
|
+
useLocation: () => ({
|
|
36
|
+
pathname: '/',
|
|
37
|
+
hash: '',
|
|
38
|
+
search: '',
|
|
39
|
+
}),
|
|
40
|
+
}));
|
|
41
|
+
|
|
33
42
|
describe('Edit', () => {
|
|
34
43
|
const onChangeBlock = jest.fn();
|
|
35
44
|
const onChangeField = jest.fn();
|
|
@@ -14,6 +14,15 @@ jest.mock('@plone/volto/helpers', () => ({
|
|
|
14
14
|
withBlockExtensions: jest.fn((Component) => Component),
|
|
15
15
|
}));
|
|
16
16
|
|
|
17
|
+
jest.mock('react-router-dom', () => ({
|
|
18
|
+
...jest.requireActual('react-router-dom'),
|
|
19
|
+
useLocation: () => ({
|
|
20
|
+
pathname: '/',
|
|
21
|
+
hash: '',
|
|
22
|
+
search: '',
|
|
23
|
+
}),
|
|
24
|
+
}));
|
|
25
|
+
|
|
17
26
|
describe('View', () => {
|
|
18
27
|
it('should render without crashing', () => {
|
|
19
28
|
const props = {
|
|
@@ -66,12 +75,18 @@ describe('View', () => {
|
|
|
66
75
|
metadata: { meta: 'data' },
|
|
67
76
|
properties: { prop: 'erty' },
|
|
68
77
|
variation: {},
|
|
78
|
+
location: {
|
|
79
|
+
pathname: '/',
|
|
80
|
+
search: '',
|
|
81
|
+
hash: '',
|
|
82
|
+
},
|
|
69
83
|
};
|
|
70
84
|
render(<View {...props} />);
|
|
71
85
|
expect(RenderBlocks).toHaveBeenCalledWith(
|
|
72
86
|
expect.objectContaining({
|
|
73
87
|
metadata: props.metadata,
|
|
74
88
|
content: props.data.data,
|
|
89
|
+
location: props.location,
|
|
75
90
|
}),
|
|
76
91
|
{},
|
|
77
92
|
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { countCharsWithoutSpaces, countCharsWithSpaces } from './utils';
|
|
2
|
+
|
|
3
|
+
describe('countCharsWithoutSpaces', () => {
|
|
4
|
+
it('should return number of charts without spaces', () => {
|
|
5
|
+
const paragraph = 'Lorem ipsum dolor sit';
|
|
6
|
+
expect(countCharsWithoutSpaces(paragraph)).toBe(18);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe('countCharsWithSpaces', () => {
|
|
11
|
+
it('should return number of charts with spaces', () => {
|
|
12
|
+
const paragraph = 'Lorem ipsum dolor sit';
|
|
13
|
+
expect(countCharsWithSpaces(paragraph)).toBe(21);
|
|
14
|
+
});
|
|
15
|
+
});
|