@eeacms/volto-eea-website-theme 1.22.1 → 1.24.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 +42 -10
- package/RELEASE.md +14 -14
- package/cypress.config.js +3 -3
- package/jest-addon.config.js +3 -0
- package/package.json +4 -3
- package/src/components/manage/Blocks/Title/schema.js +40 -1
- package/src/components/theme/Banner/View.jsx +2 -1
- package/src/config.js +27 -15
- package/src/customizations/@plone/volto-slate/editor/extensions/normalizeExternalData.js +9 -0
- package/src/customizations/volto/components/manage/Blocks/Image/Edit.jsx +9 -6
- package/src/customizations/volto/components/manage/Blocks/Image/Edit.test.jsx +312 -0
- package/src/customizations/volto/components/manage/Blocks/Image/View.jsx +9 -6
- package/src/customizations/volto/components/manage/Blocks/LeadImage/Edit.jsx +8 -4
- package/src/customizations/volto/components/manage/Blocks/LeadImage/View.jsx +8 -5
- package/src/customizations/volto/components/manage/Blocks/LeadImage/schema.js +0 -1
- package/src/customizations/volto/components/manage/Form/Form.test.jsx +1124 -0
- package/src/customizations/volto/components/manage/Widgets/ObjectBrowserWidget.test.jsx +193 -0
- package/src/customizations/volto/components/theme/Comments/Comments.test.jsx +407 -0
- package/src/customizations/volto/components/theme/Header/Header.jsx +53 -50
- package/src/customizations/volto/components/theme/Header/Header.test.jsx +326 -0
- package/src/helpers/schema-utils.js +40 -34
- package/src/index.js +122 -15
- package/src/index.test.js +343 -0
- package/src/customizations/@eeacms/volto-tabs-block/components/templates/default/schema.js +0 -109
- package/src/customizations/@eeacms/volto-tabs-block/components/templates/horizontal-responsive/schema.js +0 -109
@@ -0,0 +1,193 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
4
|
+
import { Provider } from 'react-intl-redux';
|
5
|
+
import configureStore from 'redux-mock-store';
|
6
|
+
import { Router } from 'react-router-dom';
|
7
|
+
import { createMemoryHistory } from 'history';
|
8
|
+
import ObjectBrowserWidgetComponent from './ObjectBrowserWidget';
|
9
|
+
import '@testing-library/jest-dom/extend-expect';
|
10
|
+
|
11
|
+
const mockStore = configureStore();
|
12
|
+
let store;
|
13
|
+
let history;
|
14
|
+
|
15
|
+
describe('ObjectBrowserWidgetComponent', () => {
|
16
|
+
beforeEach(() => {
|
17
|
+
store = mockStore({
|
18
|
+
search: {
|
19
|
+
subrequests: {
|
20
|
+
'testBlock-multiple': {},
|
21
|
+
'testBlock-link': {},
|
22
|
+
},
|
23
|
+
},
|
24
|
+
intl: {
|
25
|
+
locale: 'en',
|
26
|
+
messages: {},
|
27
|
+
},
|
28
|
+
});
|
29
|
+
history = createMemoryHistory();
|
30
|
+
});
|
31
|
+
|
32
|
+
it('renders without crashing', () => {
|
33
|
+
const { container } = render(
|
34
|
+
<Provider store={store}>
|
35
|
+
<Router history={history}>
|
36
|
+
<ObjectBrowserWidgetComponent
|
37
|
+
id="my-widget"
|
38
|
+
title="My widget"
|
39
|
+
onChange={() => {}}
|
40
|
+
openObjectBrowser={() => {}}
|
41
|
+
/>
|
42
|
+
</Router>
|
43
|
+
</Provider>,
|
44
|
+
);
|
45
|
+
|
46
|
+
expect(container).toBeTruthy();
|
47
|
+
});
|
48
|
+
|
49
|
+
it('renders without crashing with values, mode different than multiple, and description', () => {
|
50
|
+
const { container } = render(
|
51
|
+
<Provider store={store}>
|
52
|
+
<Router history={history}>
|
53
|
+
<ObjectBrowserWidgetComponent
|
54
|
+
id="my-widget"
|
55
|
+
title="My widget"
|
56
|
+
value={[{ '@id': 'http://locahost:3000/test' }, { title: 'test2' }]}
|
57
|
+
mode="custom"
|
58
|
+
description="My description"
|
59
|
+
onChange={() => {}}
|
60
|
+
openObjectBrowser={() => {}}
|
61
|
+
/>
|
62
|
+
</Router>
|
63
|
+
</Provider>,
|
64
|
+
);
|
65
|
+
|
66
|
+
expect(container).toBeTruthy();
|
67
|
+
});
|
68
|
+
|
69
|
+
it('renders without crashing with values, mode different than multiple and triggers the cancel function', () => {
|
70
|
+
const { container, getByPlaceholderText } = render(
|
71
|
+
<Provider store={store}>
|
72
|
+
<Router history={history}>
|
73
|
+
<ObjectBrowserWidgetComponent
|
74
|
+
id="my-widget"
|
75
|
+
title="My widget"
|
76
|
+
mode="custom"
|
77
|
+
description="My description"
|
78
|
+
onChange={() => {}}
|
79
|
+
openObjectBrowser={() => {}}
|
80
|
+
allowExternals={true}
|
81
|
+
placeholder="My placeholder"
|
82
|
+
/>
|
83
|
+
</Router>
|
84
|
+
</Provider>,
|
85
|
+
);
|
86
|
+
|
87
|
+
fireEvent.change(getByPlaceholderText('My placeholder'), {
|
88
|
+
target: { value: 'http://localhost:8080/Plone/test' },
|
89
|
+
});
|
90
|
+
|
91
|
+
expect(container.querySelector('button.cancel')).toBeInTheDocument();
|
92
|
+
fireEvent.click(container.querySelector('button.cancel'));
|
93
|
+
|
94
|
+
expect(container.querySelector('button.action')).toBeInTheDocument();
|
95
|
+
fireEvent.click(container.querySelector('button.action'));
|
96
|
+
});
|
97
|
+
|
98
|
+
it('renders without crashing with values, mode different than multiple with placeholder and triggers the cancel function', () => {
|
99
|
+
const { container, getByPlaceholderText } = render(
|
100
|
+
<Provider store={store}>
|
101
|
+
<Router history={history}>
|
102
|
+
<ObjectBrowserWidgetComponent
|
103
|
+
id="my-widget"
|
104
|
+
title="My widget"
|
105
|
+
mode="custom"
|
106
|
+
description="My description"
|
107
|
+
onChange={() => {}}
|
108
|
+
openObjectBrowser={() => {}}
|
109
|
+
allowExternals={true}
|
110
|
+
/>
|
111
|
+
</Router>
|
112
|
+
</Provider>,
|
113
|
+
);
|
114
|
+
|
115
|
+
expect(getByPlaceholderText('No items selected')).toBeInTheDocument();
|
116
|
+
fireEvent.change(getByPlaceholderText('No items selected'), {
|
117
|
+
target: { value: 'test' },
|
118
|
+
});
|
119
|
+
|
120
|
+
expect(container.querySelector('button.cancel')).toBeInTheDocument();
|
121
|
+
fireEvent.click(container.querySelector('button.cancel'));
|
122
|
+
|
123
|
+
expect(container.querySelector('button.action')).toBeInTheDocument();
|
124
|
+
|
125
|
+
expect(container).toBeTruthy();
|
126
|
+
});
|
127
|
+
|
128
|
+
it('renders without crashing with values, mode different than multiple and triggers for keydown, change and submit', () => {
|
129
|
+
const { container, getByPlaceholderText } = render(
|
130
|
+
<Provider store={store}>
|
131
|
+
<Router history={history}>
|
132
|
+
<ObjectBrowserWidgetComponent
|
133
|
+
id="my-widget"
|
134
|
+
title="My widget"
|
135
|
+
mode="custom"
|
136
|
+
description="My description"
|
137
|
+
onChange={() => {}}
|
138
|
+
openObjectBrowser={() => {}}
|
139
|
+
allowExternals={true}
|
140
|
+
/>
|
141
|
+
</Router>
|
142
|
+
</Provider>,
|
143
|
+
);
|
144
|
+
|
145
|
+
expect(getByPlaceholderText('No items selected')).toBeInTheDocument();
|
146
|
+
fireEvent.keyDown(getByPlaceholderText('No items selected'), {
|
147
|
+
key: 'Enter',
|
148
|
+
code: 'Enter',
|
149
|
+
charCode: 13,
|
150
|
+
});
|
151
|
+
fireEvent.keyDown(getByPlaceholderText('No items selected'), {
|
152
|
+
key: 'Escape',
|
153
|
+
code: 'Escape',
|
154
|
+
charCode: 27,
|
155
|
+
});
|
156
|
+
fireEvent.keyDown(getByPlaceholderText('No items selected'), {
|
157
|
+
key: 'A',
|
158
|
+
code: 'KeyA',
|
159
|
+
});
|
160
|
+
|
161
|
+
fireEvent.change(getByPlaceholderText('No items selected'), {
|
162
|
+
target: { value: 'http://localhost:3000/Plone/test' },
|
163
|
+
});
|
164
|
+
|
165
|
+
expect(container.querySelector('button.primary')).toBeInTheDocument();
|
166
|
+
fireEvent.click(container.querySelector('button.primary'));
|
167
|
+
|
168
|
+
fireEvent.click(container.querySelector('button.action'));
|
169
|
+
|
170
|
+
expect(container).toBeTruthy();
|
171
|
+
});
|
172
|
+
|
173
|
+
it('renders without crashing with values, mode different than multiple and triggers for click on the Popup', () => {
|
174
|
+
const { container } = render(
|
175
|
+
<Provider store={store}>
|
176
|
+
<Router history={history}>
|
177
|
+
<ObjectBrowserWidgetComponent
|
178
|
+
id="my-widget"
|
179
|
+
title="My widget"
|
180
|
+
value={[{ '@id': 'http://locahost:3000/test', title: 'Title 1' }]}
|
181
|
+
description="My description"
|
182
|
+
onChange={() => {}}
|
183
|
+
openObjectBrowser={() => {}}
|
184
|
+
/>
|
185
|
+
</Router>
|
186
|
+
</Provider>,
|
187
|
+
);
|
188
|
+
|
189
|
+
expect(container.querySelector('.icon.right')).toBeInTheDocument();
|
190
|
+
fireEvent.click(container.querySelector('.icon.right'));
|
191
|
+
expect(container).toBeTruthy();
|
192
|
+
});
|
193
|
+
});
|
@@ -0,0 +1,407 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Provider } from 'react-intl-redux';
|
3
|
+
import { render, fireEvent } from '@testing-library/react';
|
4
|
+
import configureStore from 'redux-mock-store';
|
5
|
+
import Comments from './Comments';
|
6
|
+
import thunk from 'redux-thunk';
|
7
|
+
import renderer from 'react-test-renderer';
|
8
|
+
import '@testing-library/jest-dom/extend-expect';
|
9
|
+
|
10
|
+
const middleware = [thunk];
|
11
|
+
const mockStore = configureStore(middleware);
|
12
|
+
|
13
|
+
jest.mock('moment', () =>
|
14
|
+
jest.fn(() => ({
|
15
|
+
format: jest.fn(() => 'Tuesday, August 1, 2023 12:09 PM'),
|
16
|
+
fromNow: jest.fn(() => 'a few seconds ago'),
|
17
|
+
})),
|
18
|
+
);
|
19
|
+
|
20
|
+
jest.mock('@plone/volto/helpers/Loadable/Loadable');
|
21
|
+
beforeAll(
|
22
|
+
async () =>
|
23
|
+
await require('@plone/volto/helpers/Loadable/Loadable').__setLoadables(),
|
24
|
+
);
|
25
|
+
|
26
|
+
describe('Comments', () => {
|
27
|
+
it('renders a comments component', () => {
|
28
|
+
const props = {
|
29
|
+
addComment: jest.fn(),
|
30
|
+
deleteComment: jest.fn(),
|
31
|
+
listComments: jest.fn(),
|
32
|
+
listMoreComments: jest.fn(),
|
33
|
+
pathname: '/comments',
|
34
|
+
items: [
|
35
|
+
{
|
36
|
+
author_name: 'test',
|
37
|
+
creation_date: '2021-01-01',
|
38
|
+
text: {
|
39
|
+
data: 'test',
|
40
|
+
'mime-type': 'text/plain',
|
41
|
+
},
|
42
|
+
is_deletable: true,
|
43
|
+
is_editable: true,
|
44
|
+
},
|
45
|
+
],
|
46
|
+
addRequest: { loading: false, loaded: false },
|
47
|
+
deleteRequest: { loading: false, loaded: false },
|
48
|
+
};
|
49
|
+
const store = mockStore({
|
50
|
+
comments: {
|
51
|
+
items: [
|
52
|
+
{
|
53
|
+
'@id': 'someurl',
|
54
|
+
comment_id: '1614094601171408',
|
55
|
+
author_name: 'admin',
|
56
|
+
creation_date: '2017-11-06T19:36:01',
|
57
|
+
text: { data: 'Some comment' },
|
58
|
+
is_deletable: true,
|
59
|
+
is_editable: true,
|
60
|
+
can_reply: true,
|
61
|
+
},
|
62
|
+
{
|
63
|
+
'@id': 'someurl',
|
64
|
+
comment_id: '1614094601171409',
|
65
|
+
author_name: undefined,
|
66
|
+
creation_date: '2017-11-06T19:36:01',
|
67
|
+
text: { data: 'Some comment', 'mime-type': 'text/html' },
|
68
|
+
is_deletable: true,
|
69
|
+
is_editable: true,
|
70
|
+
can_reply: true,
|
71
|
+
},
|
72
|
+
],
|
73
|
+
permissions: {
|
74
|
+
view_comments: true,
|
75
|
+
can_reply: true,
|
76
|
+
},
|
77
|
+
add: {
|
78
|
+
loading: false,
|
79
|
+
loaded: true,
|
80
|
+
},
|
81
|
+
delete: {
|
82
|
+
loading: false,
|
83
|
+
loaded: true,
|
84
|
+
},
|
85
|
+
update: {
|
86
|
+
loading: false,
|
87
|
+
loaded: true,
|
88
|
+
},
|
89
|
+
},
|
90
|
+
intl: {
|
91
|
+
locale: 'en',
|
92
|
+
messages: {},
|
93
|
+
},
|
94
|
+
});
|
95
|
+
const component = renderer.create(
|
96
|
+
<Provider store={store}>
|
97
|
+
<Comments {...props} />
|
98
|
+
</Provider>,
|
99
|
+
);
|
100
|
+
const json = component.toJSON();
|
101
|
+
expect(json).toMatchSnapshot();
|
102
|
+
});
|
103
|
+
|
104
|
+
it('renders a comments component withour viewing the comments', () => {
|
105
|
+
const props = {
|
106
|
+
addComment: jest.fn(),
|
107
|
+
deleteComment: jest.fn(),
|
108
|
+
listComments: jest.fn(),
|
109
|
+
listMoreComments: jest.fn(),
|
110
|
+
pathname: '/comments',
|
111
|
+
items: [
|
112
|
+
{
|
113
|
+
author_name: 'test',
|
114
|
+
creation_date: '2021-01-01',
|
115
|
+
text: {
|
116
|
+
data: 'test',
|
117
|
+
'mime-type': 'text/plain',
|
118
|
+
},
|
119
|
+
is_deletable: true,
|
120
|
+
is_editable: true,
|
121
|
+
},
|
122
|
+
],
|
123
|
+
addRequest: { loading: false, loaded: false },
|
124
|
+
deleteRequest: { loading: false, loaded: false },
|
125
|
+
};
|
126
|
+
const store = mockStore({
|
127
|
+
comments: {
|
128
|
+
items: [
|
129
|
+
{
|
130
|
+
'@id': 'someurl',
|
131
|
+
comment_id: '1614094601171408',
|
132
|
+
author_name: 'admin',
|
133
|
+
creation_date: '2017-11-06T19:36:01',
|
134
|
+
text: { data: 'Some comment' },
|
135
|
+
is_deletable: true,
|
136
|
+
is_editable: true,
|
137
|
+
can_reply: true,
|
138
|
+
},
|
139
|
+
{
|
140
|
+
'@id': 'someurl',
|
141
|
+
comment_id: '1614094601171409',
|
142
|
+
author_name: undefined,
|
143
|
+
creation_date: '2017-11-06T19:36:01',
|
144
|
+
text: { data: 'Some comment', 'mime-type': 'text/html' },
|
145
|
+
is_deletable: true,
|
146
|
+
is_editable: true,
|
147
|
+
can_reply: true,
|
148
|
+
},
|
149
|
+
],
|
150
|
+
permissions: {
|
151
|
+
view_comments: false,
|
152
|
+
can_reply: true,
|
153
|
+
},
|
154
|
+
add: {
|
155
|
+
loading: false,
|
156
|
+
loaded: true,
|
157
|
+
},
|
158
|
+
delete: {
|
159
|
+
loading: false,
|
160
|
+
loaded: true,
|
161
|
+
},
|
162
|
+
update: {
|
163
|
+
loading: false,
|
164
|
+
loaded: true,
|
165
|
+
},
|
166
|
+
},
|
167
|
+
intl: {
|
168
|
+
locale: 'en',
|
169
|
+
messages: {},
|
170
|
+
},
|
171
|
+
});
|
172
|
+
const component = renderer.create(
|
173
|
+
<Provider store={store}>
|
174
|
+
<Comments {...props} />
|
175
|
+
</Provider>,
|
176
|
+
);
|
177
|
+
const json = component.toJSON();
|
178
|
+
expect(json).toMatchSnapshot();
|
179
|
+
});
|
180
|
+
|
181
|
+
it('renders a comments component without permissions', () => {
|
182
|
+
const props = {
|
183
|
+
addComment: jest.fn(),
|
184
|
+
deleteComment: jest.fn(),
|
185
|
+
listComments: jest.fn(),
|
186
|
+
listMoreComments: jest.fn(),
|
187
|
+
pathname: '/comments',
|
188
|
+
items: [
|
189
|
+
{
|
190
|
+
author_name: 'test',
|
191
|
+
creation_date: '2021-01-01',
|
192
|
+
text: {
|
193
|
+
data: 'test',
|
194
|
+
'mime-type': 'text/plain',
|
195
|
+
},
|
196
|
+
is_deletable: true,
|
197
|
+
is_editable: true,
|
198
|
+
},
|
199
|
+
],
|
200
|
+
addRequest: { loading: false, loaded: false },
|
201
|
+
deleteRequest: { loading: false, loaded: false },
|
202
|
+
};
|
203
|
+
const store = mockStore({
|
204
|
+
comments: {
|
205
|
+
items: [
|
206
|
+
{
|
207
|
+
'@id': 'someurl',
|
208
|
+
comment_id: '1614094601171408',
|
209
|
+
author_name: 'admin',
|
210
|
+
creation_date: '2017-11-06T19:36:01',
|
211
|
+
text: { data: 'Some comment' },
|
212
|
+
is_deletable: true,
|
213
|
+
is_editable: true,
|
214
|
+
can_reply: true,
|
215
|
+
},
|
216
|
+
{
|
217
|
+
'@id': 'someurl',
|
218
|
+
comment_id: '1614094601171409',
|
219
|
+
author_name: undefined,
|
220
|
+
creation_date: '2017-11-06T19:36:01',
|
221
|
+
text: { data: 'Some comment', 'mime-type': 'text/html' },
|
222
|
+
is_deletable: true,
|
223
|
+
is_editable: true,
|
224
|
+
can_reply: true,
|
225
|
+
},
|
226
|
+
],
|
227
|
+
permissions: undefined,
|
228
|
+
add: {
|
229
|
+
loading: false,
|
230
|
+
loaded: true,
|
231
|
+
},
|
232
|
+
delete: {
|
233
|
+
loading: false,
|
234
|
+
loaded: true,
|
235
|
+
},
|
236
|
+
update: {
|
237
|
+
loading: false,
|
238
|
+
loaded: true,
|
239
|
+
},
|
240
|
+
},
|
241
|
+
intl: {
|
242
|
+
locale: 'en',
|
243
|
+
messages: {},
|
244
|
+
},
|
245
|
+
});
|
246
|
+
const component = renderer.create(
|
247
|
+
<Provider store={store}>
|
248
|
+
<Comments {...props} />
|
249
|
+
</Provider>,
|
250
|
+
);
|
251
|
+
const json = component.toJSON();
|
252
|
+
expect(json).toMatchSnapshot();
|
253
|
+
});
|
254
|
+
|
255
|
+
it('renders a comments component, fires onClick events on comment and rerenders', () => {
|
256
|
+
const props = {
|
257
|
+
addComment: jest.fn(),
|
258
|
+
deleteComment: jest.fn(),
|
259
|
+
listComments: jest.fn(),
|
260
|
+
listMoreComments: jest.fn(),
|
261
|
+
pathname: '/comments',
|
262
|
+
items: [
|
263
|
+
{
|
264
|
+
'@id': 'someurl',
|
265
|
+
comment_id: '1614094601171408',
|
266
|
+
author_name: 'admin',
|
267
|
+
creation_date: '2017-11-06T19:36:01',
|
268
|
+
text: { data: 'Some comment' },
|
269
|
+
is_deletable: true,
|
270
|
+
is_editable: true,
|
271
|
+
can_reply: true,
|
272
|
+
},
|
273
|
+
{
|
274
|
+
'@id': 'someurl',
|
275
|
+
comment_id: '1614094601171409',
|
276
|
+
author_name: undefined,
|
277
|
+
creation_date: '2017-11-06T19:36:01',
|
278
|
+
text: { data: 'Some comment', 'mime-type': 'text/html' },
|
279
|
+
is_deletable: true,
|
280
|
+
is_editable: true,
|
281
|
+
can_reply: true,
|
282
|
+
in_reply_to: '1614094601171408',
|
283
|
+
},
|
284
|
+
{
|
285
|
+
'@id': 'someurl',
|
286
|
+
comment_id: '1614094601171410',
|
287
|
+
author_name: undefined,
|
288
|
+
creation_date: '2017-11-06T19:36:01',
|
289
|
+
text: { data: 'Some comment', 'mime-type': 'text/html' },
|
290
|
+
is_deletable: true,
|
291
|
+
is_editable: true,
|
292
|
+
can_reply: true,
|
293
|
+
in_reply_to: '1614094601171408',
|
294
|
+
},
|
295
|
+
],
|
296
|
+
items_total: 4,
|
297
|
+
addRequest: { loading: true, loaded: false },
|
298
|
+
deleteRequest: { loading: true, loaded: false },
|
299
|
+
};
|
300
|
+
const store = mockStore({
|
301
|
+
comments: {
|
302
|
+
items: [
|
303
|
+
{
|
304
|
+
'@id': 'someurl',
|
305
|
+
comment_id: '1614094601171408',
|
306
|
+
author_name: 'admin',
|
307
|
+
creation_date: '2017-11-06T19:36:01',
|
308
|
+
text: { data: 'Some comment' },
|
309
|
+
is_deletable: true,
|
310
|
+
is_editable: true,
|
311
|
+
can_reply: true,
|
312
|
+
},
|
313
|
+
{
|
314
|
+
'@id': 'someurl',
|
315
|
+
comment_id: '1614094601171409',
|
316
|
+
author_name: undefined,
|
317
|
+
creation_date: '2017-11-06T19:36:01',
|
318
|
+
text: { data: 'Some comment', 'mime-type': 'text/html' },
|
319
|
+
is_deletable: true,
|
320
|
+
is_editable: true,
|
321
|
+
can_reply: true,
|
322
|
+
in_reply_to: '1614094601171408',
|
323
|
+
},
|
324
|
+
{
|
325
|
+
'@id': 'someurl',
|
326
|
+
comment_id: '1614094601171410',
|
327
|
+
author_name: undefined,
|
328
|
+
creation_date: '2017-11-06T19:36:01',
|
329
|
+
text: { data: 'Some comment', 'mime-type': 'text/html' },
|
330
|
+
is_deletable: true,
|
331
|
+
is_editable: true,
|
332
|
+
can_reply: true,
|
333
|
+
in_reply_to: '1614094601171408',
|
334
|
+
},
|
335
|
+
],
|
336
|
+
items_total: 4,
|
337
|
+
permissions: {
|
338
|
+
view_comments: true,
|
339
|
+
can_reply: true,
|
340
|
+
},
|
341
|
+
add: {
|
342
|
+
loading: true,
|
343
|
+
loaded: false,
|
344
|
+
},
|
345
|
+
delete: {
|
346
|
+
loading: true,
|
347
|
+
loaded: false,
|
348
|
+
},
|
349
|
+
update: {
|
350
|
+
loading: false,
|
351
|
+
loaded: true,
|
352
|
+
},
|
353
|
+
},
|
354
|
+
intl: {
|
355
|
+
locale: 'en',
|
356
|
+
messages: {},
|
357
|
+
},
|
358
|
+
});
|
359
|
+
const { container, rerender } = render(
|
360
|
+
<Provider store={store}>
|
361
|
+
<Comments {...props} />
|
362
|
+
</Provider>,
|
363
|
+
);
|
364
|
+
|
365
|
+
const actions = container.querySelectorAll('.actions a');
|
366
|
+
|
367
|
+
fireEvent.click(container.querySelector('a[aria-label="Reply"]'));
|
368
|
+
fireEvent.click(container.querySelector('a[aria-label="Edit"]'));
|
369
|
+
fireEvent.click(container.querySelector('a[aria-label="Delete"]'));
|
370
|
+
fireEvent.click(actions[actions.length - 1]);
|
371
|
+
fireEvent.click(
|
372
|
+
container.querySelector('#comment-add-id button[aria-label="Comment"]'),
|
373
|
+
);
|
374
|
+
fireEvent.click(container.querySelector('.ui.blue.basic.fluid.button'));
|
375
|
+
|
376
|
+
rerender(
|
377
|
+
<Provider store={store}>
|
378
|
+
<Comments
|
379
|
+
{...props}
|
380
|
+
pathname={'/new-comments'}
|
381
|
+
addRequest={{ loading: true, loaded: true }}
|
382
|
+
/>
|
383
|
+
</Provider>,
|
384
|
+
);
|
385
|
+
|
386
|
+
rerender(
|
387
|
+
<Provider store={store}>
|
388
|
+
<Comments
|
389
|
+
{...props}
|
390
|
+
pathname={'/new-comments'}
|
391
|
+
addRequest={{ loading: true, loaded: true }}
|
392
|
+
/>
|
393
|
+
</Provider>,
|
394
|
+
);
|
395
|
+
|
396
|
+
rerender(
|
397
|
+
<Provider store={store}>
|
398
|
+
<Comments
|
399
|
+
{...props}
|
400
|
+
pathname={'/new-comments'}
|
401
|
+
addRequest={{ loading: false, loaded: false }}
|
402
|
+
deleteRequest={{ loading: true, loaded: true }}
|
403
|
+
/>
|
404
|
+
</Provider>,
|
405
|
+
);
|
406
|
+
});
|
407
|
+
});
|