@eeacms/volto-group-block 6.1.0 → 6.1.2

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 CHANGED
@@ -4,6 +4,19 @@ 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.1.2](https://github.com/eea/volto-group-block/compare/6.1.1...6.1.2) - 12 June 2023
8
+
9
+ #### :house: Internal changes
10
+
11
+ - chore: [JENKINS] Deprecate circularity website [valentinab25 - [`ad30e83`](https://github.com/eea/volto-group-block/commit/ad30e832bb869b67dc4e64ed99590b51cb80ab75)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`4352c3a`](https://github.com/eea/volto-group-block/commit/4352c3afb80d6f1cbfca06b27abd11e156f1c216)]
16
+ - test: Add unit tests for View, Edit, EditBlockWrapper - refs #253277 [ana-oprea - [`2f7e7ac`](https://github.com/eea/volto-group-block/commit/2f7e7ac2c9cf7654f5a0b6b123e7589364ba13c2)]
17
+ - test: Fix test config, coverage Refs #253277 [valentinab25 - [`fa46d74`](https://github.com/eea/volto-group-block/commit/fa46d741f4ac393eb7123b09a38b774192550f95)]
18
+ ### [6.1.1](https://github.com/eea/volto-group-block/compare/6.1.0...6.1.1) - 22 May 2023
19
+
7
20
  ### [6.1.0](https://github.com/eea/volto-group-block/compare/6.0.0...6.1.0) - 4 April 2023
8
21
 
9
22
  #### :house: Internal changes
@@ -12,12 +25,19 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
12
25
 
13
26
  #### :hammer_and_wrench: Others
14
27
 
28
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`37ffae5`](https://github.com/eea/volto-group-block/commit/37ffae512967b36af22cbed208a3ec9e1ddc392b)]
15
29
  ## [6.0.0](https://github.com/eea/volto-group-block/compare/5.0.1...6.0.0) - 24 March 2023
16
30
 
17
31
  #### :hammer_and_wrench: Others
18
32
 
19
33
  - (feat): Possibility to copy/cut/paste blocks within section group block - refs #157469 [dobri1408 - [`e9fc098`](https://github.com/eea/volto-group-block/commit/e9fc09825ba2ae258feb77864491d97d94c585b4)]
34
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`db4b09a`](https://github.com/eea/volto-group-block/commit/db4b09a6c14a8b271dec0c766886ffbcc3fe205e)]
35
+ - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`b8c2bf4`](https://github.com/eea/volto-group-block/commit/b8c2bf471868bb0394b2dbbf75ccb7917a9ef0bf)]
36
+ - Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`b343119`](https://github.com/eea/volto-group-block/commit/b3431196931fd568476fa8bf6fbc508e086229ae)]
20
37
  - test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`2f42e7c`](https://github.com/eea/volto-group-block/commit/2f42e7c19a1da5a9c6a883cb4f101e8fa224ff94)]
38
+ - Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`73afcc2`](https://github.com/eea/volto-group-block/commit/73afcc2f417797cedaa78cceefb007001d6c2406)]
39
+ - yarn 3 [Alin Voinea - [`3c00ccc`](https://github.com/eea/volto-group-block/commit/3c00ccc7110bbf12a4d268182313418fb46b1a5d)]
40
+ - Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`9b9662b`](https://github.com/eea/volto-group-block/commit/9b9662bda1da70ba0c3a7b4b05cebf130ed89e9e)]
21
41
  ### [5.0.1](https://github.com/eea/volto-group-block/compare/5.0.0...5.0.1) - 16 November 2022
22
42
 
23
43
  #### :nail_care: Enhancements
@@ -34,6 +54,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
34
54
 
35
55
  - Prepare 5.0.0 release [Miu Razvan - [`88c0ddd`](https://github.com/eea/volto-group-block/commit/88c0ddd569aeda7ee34d1eadea6a087f4e7dc257)]
36
56
  - Update dependencies [Alin Voinea - [`c8405af`](https://github.com/eea/volto-group-block/commit/c8405afb830cdf62e7877bf30b619933519e1d71)]
57
+ - Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`18e26c6`](https://github.com/eea/volto-group-block/commit/18e26c6939706d572ab8574e9b1826b9abc76314)]
58
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`8ed6d21`](https://github.com/eea/volto-group-block/commit/8ed6d21d8489911cc4cb471e3f8823c35f4adc50)]
37
59
  ### [4.3.8](https://github.com/eea/volto-group-block/compare/4.3.7...4.3.8) - 26 August 2022
38
60
 
39
61
  ### [4.3.7](https://github.com/eea/volto-group-block/compare/4.3.6...4.3.7) - 22 August 2022
@@ -46,6 +68,9 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
46
68
 
47
69
  #### :hammer_and_wrench: Others
48
70
 
71
+ - Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`4e73f8b`](https://github.com/eea/volto-group-block/commit/4e73f8be3c73559557efadc410cb56abc055d82d)]
72
+ - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`3040335`](https://github.com/eea/volto-group-block/commit/3040335002c63b50208c95918413bc958150e7a9)]
73
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`386f730`](https://github.com/eea/volto-group-block/commit/386f730ed65f73fe1468b9b77351c97fb70edcc5)]
49
74
  ### [4.3.5](https://github.com/eea/volto-group-block/compare/4.3.4...4.3.5) - 4 January 2022
50
75
 
51
76
  ### [4.3.4](https://github.com/eea/volto-group-block/compare/4.3.3...4.3.4) - 3 January 2022
@@ -54,15 +79,23 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
54
79
 
55
80
  #### :hammer_and_wrench: Others
56
81
 
82
+ - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`3e62d79`](https://github.com/eea/volto-group-block/commit/3e62d79a7ed37d10d623bc845d43e1144f8080f7)]
57
83
  ### [4.3.2](https://github.com/eea/volto-group-block/compare/4.3.1...4.3.2) - 10 December 2021
58
84
 
59
85
  #### :hammer_and_wrench: Others
60
86
 
61
87
  - Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`bc36cf5`](https://github.com/eea/volto-group-block/commit/bc36cf58c39e2b43c2fbf5189df6ddefc1260857)]
88
+ - Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`8038e78`](https://github.com/eea/volto-group-block/commit/8038e783c1e8ddd71e21f72070fdfa8e7e098993)]
89
+ - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`daccdbc`](https://github.com/eea/volto-group-block/commit/daccdbc733e47be7d6536eb67f8f2eea038dc94b)]
62
90
  ### [4.3.1](https://github.com/eea/volto-group-block/compare/4.3.0...4.3.1) - 11 October 2021
63
91
 
64
92
  #### :hammer_and_wrench: Others
65
93
 
94
+ - Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`b0092e4`](https://github.com/eea/volto-group-block/commit/b0092e4f78a1a0184e22e32bb9806cd57417dfb2)]
95
+ - Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`ff8889c`](https://github.com/eea/volto-group-block/commit/ff8889cb7b0761b1df43b201984ce40b14e1561b)]
96
+ - Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`0375c28`](https://github.com/eea/volto-group-block/commit/0375c28ed1ffe9186a4790b454795c0ca8039f72)]
97
+ - Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`c392190`](https://github.com/eea/volto-group-block/commit/c392190f044f5d9397bd2fb8c3d6a357f84960d0)]
98
+ - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`9694501`](https://github.com/eea/volto-group-block/commit/9694501141e6780eba89464d36406e3c93629fd8)]
66
99
  ### [4.3.0](https://github.com/eea/volto-group-block/compare/4.2.3...4.3.0) - 24 June 2021
67
100
 
68
101
  #### :hammer_and_wrench: Others
@@ -178,6 +211,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
178
211
  - Release 1.0.0 [Alin Voinea - [`b6ef873`](https://github.com/eea/volto-group-block/commit/b6ef873cb6f61e17db66fdd4de1d9d4902a66fc6)]
179
212
  - Update package meta info [Alin Voinea - [`143b7d4`](https://github.com/eea/volto-group-block/commit/143b7d44438d7afa5e346a9d21a85352df4e925f)]
180
213
  - Add Jenkinkins pipeline [Alin Voinea - [`866a4e1`](https://github.com/eea/volto-group-block/commit/866a4e14ea1eb8f5adb01222e576e5ab6dc73a70)]
214
+ - yarn prettier [Alin Voinea - [`e3fe0a3`](https://github.com/eea/volto-group-block/commit/e3fe0a36b89878769341b45198d6c9e2f2584d15)]
181
215
  ### [0.1.3](https://github.com/eea/volto-group-block/compare/0.1.2...0.1.3) - 9 November 2020
182
216
 
183
217
  #### :hammer_and_wrench: Others
@@ -217,4 +251,5 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
217
251
  - Render meta block [Alin Voinea - [`0d44560`](https://github.com/eea/volto-group-block/commit/0d4456011ca56454068a54c610250b02df4ccb3b)]
218
252
  - Implement meta block allowedBlocks settings [Alin Voinea - [`f24feb1`](https://github.com/eea/volto-group-block/commit/f24feb1a1751f04841c21c7cd52a517fb02074ba)]
219
253
  - Edit meta block [Alin Voinea - [`236d291`](https://github.com/eea/volto-group-block/commit/236d29156fa835a7aa54eecdb4f120de0d64b271)]
254
+ - yarn bootstrap [Alin Voinea - [`e009dfb`](https://github.com/eea/volto-group-block/commit/e009dfb6b9b74d101a6722f0982a5359fc522b6b)]
220
255
  - Initial commit [Alin Voinea - [`6a7b0de`](https://github.com/eea/volto-group-block/commit/6a7b0deb8f873d1462fd6a9c61edfc1562b3aace)]
@@ -5,19 +5,19 @@ module.exports = {
5
5
  '!src/**/*.d.ts',
6
6
  ],
7
7
  moduleNameMapper: {
8
+ '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
8
9
  '@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
9
10
  '@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
10
11
  '@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
11
12
  '@package/(.*)$': '<rootDir>/src/$1',
12
13
  '@root/(.*)$': '<rootDir>/src/$1',
13
14
  '@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
14
- '@eeacms/(.*?)/(.*)$': '<rootDir>/src/addons/$1/src/$2',
15
+ '@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
15
16
  '@plone/volto-slate':
16
17
  '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
17
18
  '~/(.*)$': '<rootDir>/src/$1',
18
19
  'load-volto-addons':
19
20
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
20
- '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
21
21
  },
22
22
  transform: {
23
23
  '^.+\\.js(x)?$': 'babel-jest',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-group-block",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
4
4
  "description": "volto-group-block: Volto block to be used to group other blocks",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -0,0 +1,79 @@
1
+ import React from 'react';
2
+ import Edit from './Edit';
3
+ import configureStore from 'redux-mock-store';
4
+ import { Provider } from 'react-intl-redux';
5
+ import thunk from 'redux-thunk';
6
+ import renderer from 'react-test-renderer';
7
+ import { render, fireEvent } from '@testing-library/react';
8
+ import '@testing-library/jest-dom/extend-expect';
9
+
10
+ const mockStore = configureStore([thunk]);
11
+ const store = mockStore({
12
+ intl: {
13
+ locale: 'en',
14
+ messages: {},
15
+ },
16
+ });
17
+
18
+ describe('Edit', () => {
19
+ const onChangeBlock = jest.fn();
20
+ const onChangeField = jest.fn();
21
+ const mockBlockNode = { current: {} };
22
+ const props = {
23
+ block: 'testBlock',
24
+ data: {
25
+ data: {
26
+ blocks: {
27
+ block1: {
28
+ type: 'test',
29
+ data: {
30
+ value: 'Test',
31
+ },
32
+ },
33
+ },
34
+ blocks_layout: {
35
+ items: ['block1'],
36
+ },
37
+ },
38
+ },
39
+ onChangeBlock,
40
+ onChangeField,
41
+ pathname: '/',
42
+ selected: true,
43
+ manage: true,
44
+ };
45
+
46
+ it('should render without crashing', () => {
47
+ const component = renderer.create(
48
+ <Provider store={store}>
49
+ <Edit {...props} />
50
+ </Provider>,
51
+ );
52
+
53
+ const json = component.toJSON();
54
+ expect(json).toMatchSnapshot();
55
+ });
56
+
57
+ it('renders without crashing', () => {
58
+ const { getByRole } = render(
59
+ <Provider store={store}>
60
+ <Edit {...props} />
61
+ </Provider>,
62
+ );
63
+ expect(getByRole('presentation')).toBeInTheDocument();
64
+ });
65
+
66
+ it('should call ArrowUp keydown', () => {
67
+ const mockOnFocusPreviousBlock = jest.fn();
68
+ const { getByRole } = render(
69
+ <Provider store={store}>
70
+ <Edit
71
+ {...props}
72
+ onFocusPreviousBlock={mockOnFocusPreviousBlock}
73
+ blockNode={mockBlockNode}
74
+ />
75
+ </Provider>,
76
+ );
77
+ fireEvent.keyDown(getByRole('presentation'), { key: 'ArrowUp', code: 38 });
78
+ });
79
+ });
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import { fireEvent, render } from '@testing-library/react';
3
+ import { Provider } from 'react-intl-redux';
4
+ import EditBlockWrapper from './EditBlockWrapper';
5
+ import configureStore from 'redux-mock-store';
6
+ import '@testing-library/jest-dom/extend-expect';
7
+
8
+ const mockDragInfo = {
9
+ innerRef: {
10
+ current: {
11
+ childMethod: jest.fn(),
12
+ },
13
+ },
14
+ draggableProps: {},
15
+ dragHandleProps: {},
16
+ };
17
+
18
+ const mockStore = configureStore();
19
+ const store = mockStore({
20
+ intl: {
21
+ locale: 'en',
22
+ messages: {},
23
+ },
24
+ });
25
+
26
+ describe('EditBlockWrapper', () => {
27
+ const mockBlockProps = {
28
+ allowedBlocks: [],
29
+ block: 'mockBlock',
30
+ data: {},
31
+ onSelectBlock: jest.fn(),
32
+ onDeleteBlock: jest.fn(),
33
+ onMutateBlock: jest.fn(),
34
+ onInsertBlock: jest.fn(),
35
+ selected: true,
36
+ };
37
+
38
+ it('renders children', () => {
39
+ const { getByText } = render(
40
+ <Provider store={store}>
41
+ <EditBlockWrapper blockProps={mockBlockProps} draginfo={mockDragInfo}>
42
+ <div>Test child</div>
43
+ </EditBlockWrapper>
44
+ </Provider>,
45
+ );
46
+ expect(getByText('Test child')).toBeInTheDocument();
47
+ });
48
+
49
+ it('calls onDeleteBlock when delete button is clicked', () => {
50
+ const { getByTitle } = render(
51
+ <Provider store={store}>
52
+ <EditBlockWrapper blockProps={mockBlockProps} draginfo={mockDragInfo} />
53
+ </Provider>,
54
+ );
55
+ fireEvent.click(getByTitle('Remove block'));
56
+ expect(mockBlockProps.onDeleteBlock).toHaveBeenCalledWith('mockBlock');
57
+ });
58
+ });
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import View from './View';
3
+ import renderer from 'react-test-renderer';
4
+ import { render } from '@testing-library/react';
5
+ import { RenderBlocks } from '@plone/volto/components';
6
+ import '@testing-library/jest-dom/extend-expect';
7
+
8
+ jest.mock('@plone/volto/components', () => ({
9
+ RenderBlocks: jest.fn(() => <div>RenderBlocks</div>),
10
+ }));
11
+
12
+ describe('View', () => {
13
+ it('should render without crashing', () => {
14
+ const props = {
15
+ data: {},
16
+ metadata: {},
17
+ properties: {},
18
+ };
19
+ const component = renderer.create(<View {...props} />);
20
+
21
+ const json = component.toJSON();
22
+ expect(json).toMatchSnapshot();
23
+ });
24
+
25
+ it('renders with default tag and without crashing', () => {
26
+ const props = {
27
+ data: {},
28
+ metadata: {},
29
+ properties: {},
30
+ };
31
+ const { container } = render(<View {...props} />);
32
+ expect(container.querySelector('div')).toBeInTheDocument();
33
+ });
34
+
35
+ it('renders with a custom tag and custom id', () => {
36
+ const props = {
37
+ data: {
38
+ as: 'section',
39
+ title: 'Test Title',
40
+ data: { key: 'value' },
41
+ },
42
+ properties: {},
43
+ };
44
+ const { container } = render(<View {...props} />);
45
+ expect(container.querySelector('section')).toBeInTheDocument();
46
+ expect(container.querySelector('#test-title')).toBeInTheDocument();
47
+ });
48
+
49
+ it('renders RenderBlocks with correct props', () => {
50
+ const props = {
51
+ data: {
52
+ as: 'section',
53
+ title: 'Test Title',
54
+ data: { key: 'value' },
55
+ },
56
+ metadata: { meta: 'data' },
57
+ properties: { prop: 'erty' },
58
+ };
59
+ render(<View {...props} />);
60
+ expect(RenderBlocks).toHaveBeenCalledWith(
61
+ expect.objectContaining({
62
+ metadata: props.metadata,
63
+ content: props.data.data,
64
+ }),
65
+ {},
66
+ );
67
+ });
68
+ });
package/src/index.js CHANGED
@@ -1,6 +1,8 @@
1
- import codeSVG from '@plone/volto/icons/row.svg';
1
+ import { getBlocks } from '@plone/volto/helpers';
2
2
  import { GroupBlockEdit, GroupBlockView, GroupBlockLayout } from './components';
3
3
 
4
+ import codeSVG from '@plone/volto/icons/row.svg';
5
+
4
6
  const applyConfig = (config) => {
5
7
  const choices = Object.keys(config.blocks.blocksConfig)
6
8
  .map((key) => {
@@ -43,6 +45,20 @@ const applyConfig = (config) => {
43
45
  addPermission: [],
44
46
  view: [],
45
47
  },
48
+ tocEntries: (block = {}, tocData) => {
49
+ // integration with volto-block-toc
50
+ const headlines = tocData.levels || ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
51
+ let entries = [];
52
+ const blocks = getBlocks(block?.data || {});
53
+ blocks.forEach((block) => {
54
+ const { value, plaintext } = block[1];
55
+ const type = value?.[0]?.type;
56
+ if (headlines.includes(type)) {
57
+ entries.push([parseInt(type.slice(1)), plaintext, block[0]]);
58
+ }
59
+ });
60
+ return entries;
61
+ },
46
62
  };
47
63
 
48
64
  return config;