@eeacms/volto-group-block 6.4.0 → 7.0.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/.eslintrc.js ADDED
@@ -0,0 +1,65 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const projectRootPath = fs.realpathSync(__dirname + '/../../../');
4
+
5
+ let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
6
+ let configFile;
7
+ if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
8
+ configFile = `${projectRootPath}/tsconfig.json`;
9
+ else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
10
+ configFile = `${projectRootPath}/jsconfig.json`;
11
+
12
+ if (configFile) {
13
+ const jsConfig = require(configFile).compilerOptions;
14
+ const pathsConfig = jsConfig.paths;
15
+ if (pathsConfig['@plone/volto'])
16
+ voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
17
+ }
18
+
19
+ const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
20
+ const reg = new AddonConfigurationRegistry(projectRootPath);
21
+
22
+ // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
23
+ const addonAliases = Object.keys(reg.packages).map((o) => [
24
+ o,
25
+ reg.packages[o].modulePath,
26
+ ]);
27
+
28
+ const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
29
+
30
+ const defaultConfig = {
31
+ extends: `${voltoPath}/.eslintrc`,
32
+ settings: {
33
+ 'import/resolver': {
34
+ alias: {
35
+ map: [
36
+ ['@plone/volto', '@plone/volto/src'],
37
+ ['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
38
+ ...addonAliases,
39
+ ['@package', `${__dirname}/src`],
40
+ ['@root', `${__dirname}/src`],
41
+ ['~', `${__dirname}/src`],
42
+ ],
43
+ extensions: ['.js', '.jsx', '.json'],
44
+ },
45
+ 'babel-plugin-root-import': {
46
+ rootPathSuffix: 'src',
47
+ },
48
+ },
49
+ },
50
+ rules: {
51
+ 'react/jsx-no-target-blank': [
52
+ 'error',
53
+ {
54
+ allowReferrer: true,
55
+ },
56
+ ],
57
+ }
58
+ };
59
+
60
+ const config = addonExtenders.reduce(
61
+ (acc, extender) => extender.modify(acc),
62
+ defaultConfig,
63
+ );
64
+
65
+ module.exports = config;
package/CHANGELOG.md CHANGED
@@ -4,15 +4,21 @@ 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.4.0](https://github.com/eea/volto-group-block/compare/6.3.5...6.4.0) - 17 January 2024
7
+ ### [7.0.0](https://github.com/eea/volto-group-block/compare/6.4.0...7.0.0) - 22 April 2024
8
8
 
9
9
  #### :rocket: New Features
10
10
 
11
- - feat: wrap section with id and classname if defined in data [Razvan - [`1a08457`](https://github.com/eea/volto-group-block/commit/1a08457db3a5a17bc10d1a2887cd85f9c92faf9a)]
11
+ - feat: Release 7.0.0 - Volto 17 support [alin - [`a490088`](https://github.com/eea/volto-group-block/commit/a490088c35a61537939da0050f52cf7720ab91c2)]
12
+ - feat: Volto 17 support - refs #264527 [EEA Jenkins - [`9526f06`](https://github.com/eea/volto-group-block/commit/9526f063779a64ecd8af189494a1dde4d7d506b1)]
12
13
 
13
14
  #### :hammer_and_wrench: Others
14
15
 
15
- - Release 6.4.0 [Alin Voinea - [`2ebb40f`](https://github.com/eea/volto-group-block/commit/2ebb40f20fb99806602772d44bfb1fd3f90115c4)]
16
+ ### [6.4.0](https://github.com/eea/volto-group-block/compare/6.3.5...6.4.0) - 17 January 2024
17
+
18
+ #### :rocket: New Features
19
+
20
+ - feat: wrap section with id and classname if defined in data [Razvan - [`1a08457`](https://github.com/eea/volto-group-block/commit/1a08457db3a5a17bc10d1a2887cd85f9c92faf9a)]
21
+
16
22
  ### [6.3.5](https://github.com/eea/volto-group-block/compare/6.3.4...6.3.5) - 24 November 2023
17
23
 
18
24
  #### :bug: Bug Fixes
@@ -1,3 +1,5 @@
1
+ require('dotenv').config({ path: __dirname + '/.env' })
2
+
1
3
  module.exports = {
2
4
  testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
3
5
  collectCoverageFrom: [
@@ -9,18 +11,26 @@ module.exports = {
9
11
  '@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
10
12
  '@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
11
13
  '@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
12
- '@package/(.*)$': '<rootDir>/src/$1',
13
- '@root/(.*)$': '<rootDir>/src/$1',
14
+ '@package/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
15
+ '@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
14
16
  '@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
17
+ '@eeacms/search/(.*)$': '<rootDir>/src/addons/volto-searchlib/searchlib/$1',
18
+ '@eeacms/search': '<rootDir>/src/addons/volto-searchlib/searchlib',
15
19
  '@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
16
- '@plone/volto-slate':
20
+ '@plone/volto-slate$':
17
21
  '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
22
+ '@plone/volto-slate/(.*)$':
23
+ '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
18
24
  '~/(.*)$': '<rootDir>/src/$1',
19
25
  'load-volto-addons':
20
26
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
21
27
  },
28
+ transformIgnorePatterns: [
29
+ '/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
30
+ ],
22
31
  transform: {
23
32
  '^.+\\.js(x)?$': 'babel-jest',
33
+ '^.+\\.ts(x)?$': 'babel-jest',
24
34
  '^.+\\.(png)$': 'jest-file',
25
35
  '^.+\\.(jpg)$': 'jest-file',
26
36
  '^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
@@ -33,4 +43,9 @@ module.exports = {
33
43
  statements: 5,
34
44
  },
35
45
  },
36
- };
46
+ ...(process.env.JEST_USE_SETUP === 'ON' && {
47
+ setupFilesAfterEnv: [
48
+ '<rootDir>/node_modules/@eeacms/volto-group-block/jest.setup.js',
49
+ ],
50
+ }),
51
+ }
package/jest.setup.js ADDED
@@ -0,0 +1,65 @@
1
+ import { jest } from '@jest/globals';
2
+ import configureStore from 'redux-mock-store';
3
+ import thunk from 'redux-thunk';
4
+ import { blocksConfig } from '@plone/volto/config/Blocks';
5
+ import installSlate from '@plone/volto-slate/index';
6
+
7
+ var mockSemanticComponents = jest.requireActual('semantic-ui-react');
8
+ var mockComponents = jest.requireActual('@plone/volto/components');
9
+ var config = jest.requireActual('@plone/volto/registry').default;
10
+
11
+ config.blocks.blocksConfig = {
12
+ ...blocksConfig,
13
+ ...config.blocks.blocksConfig,
14
+ };
15
+
16
+ jest.doMock('semantic-ui-react', () => ({
17
+ __esModule: true,
18
+ ...mockSemanticComponents,
19
+ Popup: ({ content, trigger }) => {
20
+ return (
21
+ <div className="popup">
22
+ <div className="trigger">{trigger}</div>
23
+ <div className="content">{content}</div>
24
+ </div>
25
+ );
26
+ },
27
+ }));
28
+
29
+ jest.doMock('@plone/volto/components', () => {
30
+ return {
31
+ __esModule: true,
32
+ ...mockComponents,
33
+ SidebarPortal: ({ children }) => <div id="sidebar">{children}</div>,
34
+ };
35
+ });
36
+
37
+ jest.doMock('@plone/volto/registry', () =>
38
+ [installSlate].reduce((acc, apply) => apply(acc), config),
39
+ );
40
+
41
+ const mockStore = configureStore([thunk]);
42
+
43
+ global.fetch = jest.fn(() =>
44
+ Promise.resolve({
45
+ json: () => Promise.resolve({}),
46
+ }),
47
+ );
48
+
49
+ global.store = mockStore({
50
+ intl: {
51
+ locale: 'en',
52
+ messages: {},
53
+ formatMessage: jest.fn(),
54
+ },
55
+ content: {
56
+ create: {},
57
+ subrequests: [],
58
+ },
59
+ connected_data_parameters: {},
60
+ screen: {
61
+ page: {
62
+ width: 768,
63
+ },
64
+ },
65
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-group-block",
3
- "version": "6.4.0",
3
+ "version": "7.0.0",
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",
@@ -22,6 +22,7 @@
22
22
  "@cypress/code-coverage": "^3.10.0",
23
23
  "@plone/scripts": "*",
24
24
  "babel-plugin-transform-class-properties": "^6.24.1",
25
+ "dotenv": "^16.3.2",
25
26
  "husky": "^8.0.3",
26
27
  "lint-staged": "^14.0.1",
27
28
  "md5": "^2.3.0"
@@ -9,23 +9,22 @@ import delightedSVG from '@plone/volto/icons/delighted.svg';
9
9
  import dissatisfiedSVG from '@plone/volto/icons/dissatisfied.svg';
10
10
  import { countCharsWithoutSpaces, countCharsWithSpaces } from './utils';
11
11
 
12
- const countTextInEachBlock = (countTextIn, ignoreSpaces, groupCharCount) => ([
13
- id,
14
- blockData,
15
- ]) => {
16
- const foundText =
17
- blockData && countTextIn?.includes(blockData?.['@type'])
18
- ? isString(blockData?.plaintext)
19
- ? blockData?.plaintext
20
- : isArray(blockData?.value) && blockData?.value !== null
21
- ? serializeNodesToText(blockData?.value)
22
- : ''
23
- : '';
12
+ const countTextInEachBlock =
13
+ (countTextIn, ignoreSpaces, groupCharCount) =>
14
+ ([id, blockData]) => {
15
+ const foundText =
16
+ blockData && countTextIn?.includes(blockData?.['@type'])
17
+ ? isString(blockData?.plaintext)
18
+ ? blockData?.plaintext
19
+ : isArray(blockData?.value) && blockData?.value !== null
20
+ ? serializeNodesToText(blockData?.value)
21
+ : ''
22
+ : '';
24
23
 
25
- groupCharCount.value += ignoreSpaces
26
- ? countCharsWithoutSpaces(foundText)
27
- : countCharsWithSpaces(foundText);
28
- };
24
+ groupCharCount.value += ignoreSpaces
25
+ ? countCharsWithoutSpaces(foundText)
26
+ : countCharsWithSpaces(foundText);
27
+ };
29
28
 
30
29
  const countTextInBlocks = (blocksObject, ignoreSpaces, maxChars) => {
31
30
  const { countTextIn } = config.blocks?.blocksConfig?.group || [];
@@ -3,8 +3,7 @@ import { default as Edit } from './Edit';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { Provider } from 'react-intl-redux';
5
5
  import thunk from 'redux-thunk';
6
- import renderer from 'react-test-renderer';
7
- import { render, fireEvent } from '@testing-library/react';
6
+ import { render, screen, fireEvent } from '@testing-library/react';
8
7
  import '@testing-library/jest-dom/extend-expect';
9
8
 
10
9
  const mockStore = configureStore([thunk]);
@@ -69,14 +68,17 @@ describe('Edit', () => {
69
68
  };
70
69
 
71
70
  it('should render without crashing', () => {
72
- const component = renderer.create(
71
+ const { container, getByRole } = render(
73
72
  <Provider store={store}>
74
73
  <Edit {...props} />
75
74
  </Provider>,
76
75
  );
77
76
 
78
- const json = component.toJSON();
79
- expect(json).toMatchSnapshot();
77
+ expect(getByRole('presentation')).toBeInTheDocument();
78
+ expect(container.querySelector('legend')).toBeInTheDocument();
79
+ expect(container.querySelector('div.blocks-form')).toBeInTheDocument();
80
+ expect(screen.getByText('BlocksToolbar')).toBeInTheDocument();
81
+ expect(screen.getByText('SidebarPortal')).toBeInTheDocument();
80
82
  });
81
83
 
82
84
  it('renders without crashing', () => {
@@ -61,14 +61,8 @@ class EditBlockWrapper extends React.Component {
61
61
  blockNode = React.createRef();
62
62
 
63
63
  render() {
64
- const {
65
- intl,
66
- blockProps,
67
- draginfo,
68
- extraControls,
69
- disabled,
70
- children,
71
- } = this.props;
64
+ const { intl, blockProps, draginfo, extraControls, disabled, children } =
65
+ this.props;
72
66
 
73
67
  const {
74
68
  allowedBlocks,
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import View from './View';
3
- import renderer from 'react-test-renderer';
4
- import { render } from '@testing-library/react';
3
+ import { render, screen } from '@testing-library/react';
5
4
  import { RenderBlocks } from '@plone/volto/components';
6
5
  import '@testing-library/jest-dom/extend-expect';
7
6
 
@@ -31,10 +30,8 @@ describe('View', () => {
31
30
  properties: {},
32
31
  variation: {},
33
32
  };
34
- const component = renderer.create(<View {...props} />);
35
-
36
- const json = component.toJSON();
37
- expect(json).toMatchSnapshot();
33
+ render(<View {...props} />);
34
+ expect(screen.getByText('RenderBlocks')).toBeInTheDocument();
38
35
  });
39
36
 
40
37
  it('renders with default tag and without crashing', () => {
@@ -1,48 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const projectRootPath = fs.existsSync('./project')
5
- ? fs.realpathSync('./project')
6
- : fs.realpathSync('./../../../');
7
- const packageJson = require(path.join(projectRootPath, 'package.json'));
8
- const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions;
9
-
10
- const pathsConfig = jsConfig.paths;
11
-
12
- let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
13
-
14
- Object.keys(pathsConfig).forEach(pkg => {
15
- if (pkg === '@plone/volto') {
16
- voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
17
- }
18
- });
19
- const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
20
- const reg = new AddonConfigurationRegistry(projectRootPath);
21
-
22
- // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
23
- const addonAliases = Object.keys(reg.packages).map(o => [
24
- o,
25
- reg.packages[o].modulePath,
26
- ]);
27
-
28
-
29
- module.exports = {
30
- extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
31
- settings: {
32
- 'import/resolver': {
33
- alias: {
34
- map: [
35
- ['@plone/volto', '@plone/volto/src'],
36
- ...addonAliases,
37
- ['@package', `${__dirname}/src`],
38
- ['~', `${__dirname}/src`],
39
- ],
40
- extensions: ['.js', '.jsx', '.json'],
41
- },
42
- 'babel-plugin-root-import': {
43
- rootPathSuffix: 'src',
44
- },
45
- },
46
- },
47
- };
48
-