@eeacms/volto-group-block 6.3.4 → 6.4.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 +28 -26
- 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.jsx +3 -1
- 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,37 @@ 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.
|
|
7
|
+
### [6.4.0](https://github.com/eea/volto-group-block/compare/6.3.5...6.4.0) - 17 January 2024
|
|
8
|
+
|
|
9
|
+
#### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
- feat: wrap section with id and classname if defined in data [Razvan - [`1a08457`](https://github.com/eea/volto-group-block/commit/1a08457db3a5a17bc10d1a2887cd85f9c92faf9a)]
|
|
8
12
|
|
|
9
13
|
#### :hammer_and_wrench: Others
|
|
10
14
|
|
|
11
|
-
-
|
|
15
|
+
- Release 6.4.0 [Alin Voinea - [`2ebb40f`](https://github.com/eea/volto-group-block/commit/2ebb40f20fb99806602772d44bfb1fd3f90115c4)]
|
|
16
|
+
### [6.3.5](https://github.com/eea/volto-group-block/compare/6.3.4...6.3.5) - 24 November 2023
|
|
17
|
+
|
|
18
|
+
#### :bug: Bug Fixes
|
|
19
|
+
|
|
20
|
+
- fix: Pass location to RenderBlocks [kreafox - [`87ae0df`](https://github.com/eea/volto-group-block/commit/87ae0dff17cb508466b17f959e99d62c6ab69a60)]
|
|
21
|
+
|
|
22
|
+
#### :house: Internal changes
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
#### :hammer_and_wrench: Others
|
|
26
|
+
|
|
27
|
+
- test: update cypress test [kreafox - [`f84a866`](https://github.com/eea/volto-group-block/commit/f84a866a313f30f94fd1c0a41737face83dac3e0)]
|
|
28
|
+
- more tests [kreafox - [`7f93774`](https://github.com/eea/volto-group-block/commit/7f93774774119fe1fa5e8266e8ec700cd2bc9427)]
|
|
29
|
+
- test: fix bug reported by sonarqube, add more tests [kreafox - [`3599b0f`](https://github.com/eea/volto-group-block/commit/3599b0f7edf22037729c52e35f29d8919e466e5f)]
|
|
30
|
+
- test: add more tests [kreafox - [`0c5fc63`](https://github.com/eea/volto-group-block/commit/0c5fc63866d6590e64051483ee8ec97e548d0b14)]
|
|
31
|
+
- test: update jest tests [kreafox - [`88d9945`](https://github.com/eea/volto-group-block/commit/88d9945c6f338992247232325a25ea9795c2fe42)]
|
|
32
|
+
- test: increase coverage [kreafox - [`081a2d0`](https://github.com/eea/volto-group-block/commit/081a2d0bb001c980d2023bcce81830d71d23aeca)]
|
|
33
|
+
- Prettier [kreafox - [`0c5d2d1`](https://github.com/eea/volto-group-block/commit/0c5d2d1a494489663cc97c5dc0f4ad13c4b67c8d)]
|
|
34
|
+
- test: mock useLocation [kreafox - [`746887f`](https://github.com/eea/volto-group-block/commit/746887fa0e778f2d4cbe86661fc8c38c8a4bafb5)]
|
|
35
|
+
- test: mock useLocation [kreafox - [`a360401`](https://github.com/eea/volto-group-block/commit/a360401b8ee05e9cb54b253b0e605d0a040c8f78)]
|
|
36
|
+
### [6.3.4](https://github.com/eea/volto-group-block/compare/6.3.3...6.3.4) - 22 October 2023
|
|
37
|
+
|
|
12
38
|
### [6.3.3](https://github.com/eea/volto-group-block/compare/6.3.2...6.3.3) - 17 October 2023
|
|
13
39
|
|
|
14
40
|
#### :house: Internal changes
|
|
@@ -54,7 +80,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
54
80
|
|
|
55
81
|
- Release #39 from eea/develop [ichim-david - [`283e1e8`](https://github.com/eea/volto-group-block/commit/283e1e8dd1047415bae054cfd502d1691deaeb59)]
|
|
56
82
|
- Release 6.3.0 [Alin Voinea - [`3d74bb5`](https://github.com/eea/volto-group-block/commit/3d74bb5342e3882e0ddee1aa8edab7e90949def6)]
|
|
57
|
-
- test: Fix eslint and yarn i18n [Alin Voinea - [`763f764`](https://github.com/eea/volto-group-block/commit/763f76448625e05b53a2bde86ca48dda0cb263cb)]
|
|
58
83
|
- i18n: Add en [Alin Voinea - [`f3385cd`](https://github.com/eea/volto-group-block/commit/f3385cd33bfbe3efe514fd82fd140d17e33051e1)]
|
|
59
84
|
- test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`3aa996b`](https://github.com/eea/volto-group-block/commit/3aa996b4c115da6f37ca771f07f10d58fbfa33e8)]
|
|
60
85
|
- fix eslint warnings [nileshgulia1 - [`cfdf2e9`](https://github.com/eea/volto-group-block/commit/cfdf2e900bcc456fa5a24ce7b03859170ad024ba)]
|
|
@@ -85,7 +110,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
85
110
|
|
|
86
111
|
#### :house: Internal changes
|
|
87
112
|
|
|
88
|
-
- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`ad30e83`](https://github.com/eea/volto-group-block/commit/ad30e832bb869b67dc4e64ed99590b51cb80ab75)]
|
|
89
113
|
|
|
90
114
|
#### :hammer_and_wrench: Others
|
|
91
115
|
|
|
@@ -102,19 +126,12 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
102
126
|
|
|
103
127
|
#### :hammer_and_wrench: Others
|
|
104
128
|
|
|
105
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`37ffae5`](https://github.com/eea/volto-group-block/commit/37ffae512967b36af22cbed208a3ec9e1ddc392b)]
|
|
106
129
|
## [6.0.0](https://github.com/eea/volto-group-block/compare/5.0.1...6.0.0) - 24 March 2023
|
|
107
130
|
|
|
108
131
|
#### :hammer_and_wrench: Others
|
|
109
132
|
|
|
110
133
|
- (feat): Possibility to copy/cut/paste blocks within section group block - refs #157469 [dobri1408 - [`e9fc098`](https://github.com/eea/volto-group-block/commit/e9fc09825ba2ae258feb77864491d97d94c585b4)]
|
|
111
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`db4b09a`](https://github.com/eea/volto-group-block/commit/db4b09a6c14a8b271dec0c766886ffbcc3fe205e)]
|
|
112
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`b8c2bf4`](https://github.com/eea/volto-group-block/commit/b8c2bf471868bb0394b2dbbf75ccb7917a9ef0bf)]
|
|
113
|
-
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`b343119`](https://github.com/eea/volto-group-block/commit/b3431196931fd568476fa8bf6fbc508e086229ae)]
|
|
114
134
|
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`2f42e7c`](https://github.com/eea/volto-group-block/commit/2f42e7c19a1da5a9c6a883cb4f101e8fa224ff94)]
|
|
115
|
-
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`73afcc2`](https://github.com/eea/volto-group-block/commit/73afcc2f417797cedaa78cceefb007001d6c2406)]
|
|
116
|
-
- yarn 3 [Alin Voinea - [`3c00ccc`](https://github.com/eea/volto-group-block/commit/3c00ccc7110bbf12a4d268182313418fb46b1a5d)]
|
|
117
|
-
- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`9b9662b`](https://github.com/eea/volto-group-block/commit/9b9662bda1da70ba0c3a7b4b05cebf130ed89e9e)]
|
|
118
135
|
### [5.0.1](https://github.com/eea/volto-group-block/compare/5.0.0...5.0.1) - 16 November 2022
|
|
119
136
|
|
|
120
137
|
#### :nail_care: Enhancements
|
|
@@ -131,8 +148,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
131
148
|
|
|
132
149
|
- Prepare 5.0.0 release [Miu Razvan - [`88c0ddd`](https://github.com/eea/volto-group-block/commit/88c0ddd569aeda7ee34d1eadea6a087f4e7dc257)]
|
|
133
150
|
- Update dependencies [Alin Voinea - [`c8405af`](https://github.com/eea/volto-group-block/commit/c8405afb830cdf62e7877bf30b619933519e1d71)]
|
|
134
|
-
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`18e26c6`](https://github.com/eea/volto-group-block/commit/18e26c6939706d572ab8574e9b1826b9abc76314)]
|
|
135
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`8ed6d21`](https://github.com/eea/volto-group-block/commit/8ed6d21d8489911cc4cb471e3f8823c35f4adc50)]
|
|
136
151
|
### [4.3.8](https://github.com/eea/volto-group-block/compare/4.3.7...4.3.8) - 26 August 2022
|
|
137
152
|
|
|
138
153
|
### [4.3.7](https://github.com/eea/volto-group-block/compare/4.3.6...4.3.7) - 22 August 2022
|
|
@@ -145,9 +160,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
145
160
|
|
|
146
161
|
#### :hammer_and_wrench: Others
|
|
147
162
|
|
|
148
|
-
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`4e73f8b`](https://github.com/eea/volto-group-block/commit/4e73f8be3c73559557efadc410cb56abc055d82d)]
|
|
149
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`3040335`](https://github.com/eea/volto-group-block/commit/3040335002c63b50208c95918413bc958150e7a9)]
|
|
150
|
-
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`386f730`](https://github.com/eea/volto-group-block/commit/386f730ed65f73fe1468b9b77351c97fb70edcc5)]
|
|
151
163
|
### [4.3.5](https://github.com/eea/volto-group-block/compare/4.3.4...4.3.5) - 4 January 2022
|
|
152
164
|
|
|
153
165
|
### [4.3.4](https://github.com/eea/volto-group-block/compare/4.3.3...4.3.4) - 3 January 2022
|
|
@@ -156,23 +168,15 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
156
168
|
|
|
157
169
|
#### :hammer_and_wrench: Others
|
|
158
170
|
|
|
159
|
-
- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`3e62d79`](https://github.com/eea/volto-group-block/commit/3e62d79a7ed37d10d623bc845d43e1144f8080f7)]
|
|
160
171
|
### [4.3.2](https://github.com/eea/volto-group-block/compare/4.3.1...4.3.2) - 10 December 2021
|
|
161
172
|
|
|
162
173
|
#### :hammer_and_wrench: Others
|
|
163
174
|
|
|
164
175
|
- Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`bc36cf5`](https://github.com/eea/volto-group-block/commit/bc36cf58c39e2b43c2fbf5189df6ddefc1260857)]
|
|
165
|
-
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`8038e78`](https://github.com/eea/volto-group-block/commit/8038e783c1e8ddd71e21f72070fdfa8e7e098993)]
|
|
166
|
-
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`daccdbc`](https://github.com/eea/volto-group-block/commit/daccdbc733e47be7d6536eb67f8f2eea038dc94b)]
|
|
167
176
|
### [4.3.1](https://github.com/eea/volto-group-block/compare/4.3.0...4.3.1) - 11 October 2021
|
|
168
177
|
|
|
169
178
|
#### :hammer_and_wrench: Others
|
|
170
179
|
|
|
171
|
-
- Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`b0092e4`](https://github.com/eea/volto-group-block/commit/b0092e4f78a1a0184e22e32bb9806cd57417dfb2)]
|
|
172
|
-
- Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`ff8889c`](https://github.com/eea/volto-group-block/commit/ff8889cb7b0761b1df43b201984ce40b14e1561b)]
|
|
173
|
-
- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`0375c28`](https://github.com/eea/volto-group-block/commit/0375c28ed1ffe9186a4790b454795c0ca8039f72)]
|
|
174
|
-
- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`c392190`](https://github.com/eea/volto-group-block/commit/c392190f044f5d9397bd2fb8c3d6a357f84960d0)]
|
|
175
|
-
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`9694501`](https://github.com/eea/volto-group-block/commit/9694501141e6780eba89464d36406e3c93629fd8)]
|
|
176
180
|
### [4.3.0](https://github.com/eea/volto-group-block/compare/4.2.3...4.3.0) - 24 June 2021
|
|
177
181
|
|
|
178
182
|
#### :hammer_and_wrench: Others
|
|
@@ -288,7 +292,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
288
292
|
- Release 1.0.0 [Alin Voinea - [`b6ef873`](https://github.com/eea/volto-group-block/commit/b6ef873cb6f61e17db66fdd4de1d9d4902a66fc6)]
|
|
289
293
|
- Update package meta info [Alin Voinea - [`143b7d4`](https://github.com/eea/volto-group-block/commit/143b7d44438d7afa5e346a9d21a85352df4e925f)]
|
|
290
294
|
- Add Jenkinkins pipeline [Alin Voinea - [`866a4e1`](https://github.com/eea/volto-group-block/commit/866a4e14ea1eb8f5adb01222e576e5ab6dc73a70)]
|
|
291
|
-
- yarn prettier [Alin Voinea - [`e3fe0a3`](https://github.com/eea/volto-group-block/commit/e3fe0a36b89878769341b45198d6c9e2f2584d15)]
|
|
292
295
|
### [0.1.3](https://github.com/eea/volto-group-block/compare/0.1.2...0.1.3) - 9 November 2020
|
|
293
296
|
|
|
294
297
|
#### :hammer_and_wrench: Others
|
|
@@ -328,5 +331,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
328
331
|
- Render meta block [Alin Voinea - [`0d44560`](https://github.com/eea/volto-group-block/commit/0d4456011ca56454068a54c610250b02df4ccb3b)]
|
|
329
332
|
- Implement meta block allowedBlocks settings [Alin Voinea - [`f24feb1`](https://github.com/eea/volto-group-block/commit/f24feb1a1751f04841c21c7cd52a517fb02074ba)]
|
|
330
333
|
- Edit meta block [Alin Voinea - [`236d291`](https://github.com/eea/volto-group-block/commit/236d29156fa835a7aa54eecdb4f120de0d64b271)]
|
|
331
|
-
- yarn bootstrap [Alin Voinea - [`e009dfb`](https://github.com/eea/volto-group-block/commit/e009dfb6b9b74d101a6722f0982a5359fc522b6b)]
|
|
332
334
|
- Initial commit [Alin Voinea - [`6a7b0de`](https://github.com/eea/volto-group-block/commit/6a7b0deb8f873d1462fd6a9c61edfc1562b3aace)]
|
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
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useState, useCallback } from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
2
3
|
import { isEmpty, without } from 'lodash';
|
|
3
4
|
import {
|
|
4
5
|
emptyBlocksForm,
|
|
@@ -139,7 +140,8 @@ const Edit = (props) => {
|
|
|
139
140
|
return (
|
|
140
141
|
<fieldset
|
|
141
142
|
role="presentation"
|
|
142
|
-
|
|
143
|
+
id={props.data.id}
|
|
144
|
+
className={cx('section-block', props.data.className)}
|
|
143
145
|
onKeyDown={(e) => {
|
|
144
146
|
handleKeyDown(e, props.index, props.block, props.blockNode.current);
|
|
145
147
|
}}
|
|
@@ -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
|
+
});
|