@eeacms/volto-group-block 6.1.1 → 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,11 +4,18 @@ 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.
|
|
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
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`ad30e83`](https://github.com/eea/volto-group-block/commit/ad30e832bb869b67dc4e64ed99590b51cb80ab75)]
|
|
10
12
|
|
|
11
|
-
|
|
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
|
|
12
19
|
|
|
13
20
|
### [6.1.0](https://github.com/eea/volto-group-block/compare/6.0.0...6.1.0) - 4 April 2023
|
|
14
21
|
|
package/jest-addon.config.js
CHANGED
|
@@ -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>/
|
|
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
|
@@ -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
|
+
});
|