@eeacms/volto-eea-website-theme 1.34.0 → 2.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 +7 -2
- package/CHANGELOG.md +44 -20
- package/docker-compose.yml +1 -1
- package/jest-addon.config.js +3 -0
- package/package.json +2 -1
- package/src/components/manage/Blocks/LayoutSettings/index.js +3 -1
- package/src/components/manage/Blocks/Title/index.js +3 -1
- package/src/components/manage/Blocks/Title/schema.js +3 -1
- package/src/components/theme/Banner/View.jsx +12 -5
- package/src/components/theme/DraftBackground/DraftBackground.jsx +1 -0
- package/src/components/theme/DraftBackground/DraftBackground.test.jsx +85 -0
- package/src/config.js +2 -0
- package/src/customizations/@plone/volto-slate/blocks/Text/TextBlockView.jsx +32 -0
- package/src/customizations/@plone/volto-slate/editor/render.jsx +75 -0
- package/src/customizations/@plone/volto-slate/elementEditor/utils.js +76 -75
- package/src/customizations/volto/components/manage/Blocks/Grid/Edit.jsx +70 -0
- package/src/customizations/volto/components/manage/Blocks/Grid/View.jsx +61 -0
- package/src/customizations/volto/components/manage/Blocks/Grid/readme.md +1 -0
- package/src/customizations/volto/components/manage/Blocks/Image/Edit.jsx +82 -23
- package/src/customizations/volto/components/manage/Blocks/Image/Edit.test.jsx +10 -3
- package/src/customizations/volto/components/manage/Blocks/Image/View.jsx +110 -111
- package/src/customizations/volto/components/manage/Blocks/Image/schema.js +17 -2
- package/src/customizations/volto/components/manage/Blocks/LeadImage/Edit.jsx +35 -14
- package/src/customizations/volto/components/manage/Blocks/LeadImage/View.jsx +65 -79
- package/src/customizations/volto/components/manage/Display/Display.jsx +306 -0
- package/src/customizations/volto/components/manage/Display/Readme.md +1 -0
- package/src/customizations/volto/components/manage/Sidebar/SidebarPopup copy.jsx +82 -0
- package/src/customizations/volto/components/manage/Toolbar/More.jsx +541 -0
- package/src/customizations/volto/components/manage/UniversalLink/UniversalLink.jsx +3 -1
- package/src/customizations/volto/components/manage/Widgets/ObjectBrowserWidget.jsx +24 -14
- package/src/customizations/volto/components/manage/Widgets/README.md +1 -0
- package/src/customizations/volto/components/manage/Workflow/README.txt +1 -0
- package/src/customizations/volto/components/manage/Workflow/Workflow.jsx +324 -0
- package/src/customizations/volto/components/manage/Workflow/Workflow.test.jsx +81 -0
- package/src/customizations/volto/components/theme/Comments/Comments.jsx +1 -2
- package/src/customizations/volto/components/theme/ContactForm/ContactForm.jsx +1 -1
- package/src/customizations/volto/components/theme/EventDetails/EventDetails.jsx +1 -0
- package/src/index.js +21 -16
- package/src/middleware/ok.js +4 -2
- package/src/middleware/voltoCustom.js +4 -2
- package/src/slate.js +10 -8
- package/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/README.txt +0 -1
- package/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/StyleMenu.jsx +0 -157
- package/src/customizations/@plone/volto-slate/editor/plugins/StyleMenu/utils.js +0 -168
- package/src/customizations/volto/components/manage/Add/Add.jsx +0 -498
- package/src/customizations/volto/components/manage/Add/readme.md +0 -1
- package/src/customizations/volto/components/manage/Contents/ContentsPropertiesModal.jsx +0 -232
- package/src/customizations/volto/components/manage/Form/Form.jsx +0 -810
- package/src/customizations/volto/components/manage/Form/Form.test.jsx +0 -1124
- package/src/customizations/volto/components/manage/Form/ModalForm.jsx +0 -326
- package/src/customizations/volto/components/manage/Sharing/Sharing.jsx +0 -528
- package/src/customizations/volto/components/manage/Sharing/Sharing.test.jsx +0 -72
- package/src/customizations/volto/components/manage/Widgets/ObjectBrowserWidget.test.jsx +0 -193
- package/src/customizations/volto/components/theme/AppExtras/AppExtras.jsx +0 -27
@@ -1,1124 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render, fireEvent } from '@testing-library/react';
|
3
|
-
import { Provider } from 'react-intl-redux';
|
4
|
-
import configureMockStore from 'redux-mock-store';
|
5
|
-
import Form from './Form';
|
6
|
-
import config from '@plone/volto/registry';
|
7
|
-
import { FormValidation } from '@plone/volto/helpers';
|
8
|
-
import '@testing-library/jest-dom/extend-expect';
|
9
|
-
|
10
|
-
const mockStore = configureMockStore();
|
11
|
-
let store;
|
12
|
-
|
13
|
-
jest.mock('@plone/volto/components/manage/Form/Field', () => (props) => {
|
14
|
-
return (
|
15
|
-
<div id={`mocked-field-${props.id}`}>
|
16
|
-
{props.id}
|
17
|
-
{props.description}
|
18
|
-
<textarea
|
19
|
-
onClick={props.onClick}
|
20
|
-
onBlur={props.onBlur}
|
21
|
-
onChange={(target) => props.onChange(props.id, target?.target?.value)}
|
22
|
-
/>
|
23
|
-
</div>
|
24
|
-
);
|
25
|
-
});
|
26
|
-
|
27
|
-
jest.mock(
|
28
|
-
'@plone/volto/components/manage/Form/BlocksToolbar',
|
29
|
-
() => (props) => {
|
30
|
-
return (
|
31
|
-
<input
|
32
|
-
id={'blocks-toolbar'}
|
33
|
-
onClick={(target) => {
|
34
|
-
props.onSetSelectedBlocks(
|
35
|
-
target.target.value ? [...target.target.value.split(',')] : [],
|
36
|
-
);
|
37
|
-
}}
|
38
|
-
onChange={props.onChangeBlocks}
|
39
|
-
onSelect={(target) => {
|
40
|
-
props.onSelectBlock(
|
41
|
-
target.target.id,
|
42
|
-
target.target.isMultipleSelection,
|
43
|
-
target.target.event,
|
44
|
-
);
|
45
|
-
}}
|
46
|
-
/>
|
47
|
-
);
|
48
|
-
},
|
49
|
-
);
|
50
|
-
|
51
|
-
jest.mock('@plone/volto/components/manage/Form/UndoToolbar', () => (props) => {
|
52
|
-
return <div>UndoToolbar</div>;
|
53
|
-
});
|
54
|
-
|
55
|
-
jest.mock(
|
56
|
-
'@plone/volto/components/manage/Blocks/Block/BlocksForm',
|
57
|
-
() => (props) => {
|
58
|
-
return <input id={'blocks-form'} onChange={props.onChangeFormData} />;
|
59
|
-
},
|
60
|
-
);
|
61
|
-
|
62
|
-
describe('Form', () => {
|
63
|
-
beforeEach(() => {
|
64
|
-
store = mockStore({
|
65
|
-
intl: {
|
66
|
-
locale: 'en',
|
67
|
-
messages: {},
|
68
|
-
},
|
69
|
-
});
|
70
|
-
});
|
71
|
-
|
72
|
-
it('renders "Test title" and has the correct structure without formData without crashing', () => {
|
73
|
-
config.blocks = {
|
74
|
-
initialBlocksFocus: {
|
75
|
-
typeB: 'typeB',
|
76
|
-
},
|
77
|
-
};
|
78
|
-
config.settings = {
|
79
|
-
verticalFormTabs: false,
|
80
|
-
};
|
81
|
-
const props = {
|
82
|
-
isFormSelected: false,
|
83
|
-
schema: {
|
84
|
-
fieldsets: [{ fields: [], id: 'default', title: 'Default' }],
|
85
|
-
properties: {},
|
86
|
-
definitions: {},
|
87
|
-
required: [],
|
88
|
-
},
|
89
|
-
formData: {
|
90
|
-
blocks: undefined,
|
91
|
-
blocks_layout: undefined,
|
92
|
-
},
|
93
|
-
type: 'typeB',
|
94
|
-
title: 'Test title',
|
95
|
-
};
|
96
|
-
|
97
|
-
const { container, getByText } = render(
|
98
|
-
<Provider store={store}>
|
99
|
-
<Form {...props} />
|
100
|
-
</Provider>,
|
101
|
-
);
|
102
|
-
expect(container).toBeTruthy();
|
103
|
-
expect(
|
104
|
-
container.querySelector('.ui.form .invisible .ui.raised.segments'),
|
105
|
-
).toBeInTheDocument();
|
106
|
-
expect(getByText('Test title')).toBeInTheDocument();
|
107
|
-
});
|
108
|
-
|
109
|
-
it('renders "Test title" and has the correct structure with formData without crashing with same types', () => {
|
110
|
-
config.blocks = {
|
111
|
-
initialBlocksFocus: {
|
112
|
-
typeB: 'typeB',
|
113
|
-
},
|
114
|
-
};
|
115
|
-
config.settings = {
|
116
|
-
verticalFormTabs: false,
|
117
|
-
};
|
118
|
-
const props = {
|
119
|
-
schema: {
|
120
|
-
fieldsets: [{ fields: [], id: 'default', title: 'Default' }],
|
121
|
-
properties: {},
|
122
|
-
definitions: {},
|
123
|
-
required: [],
|
124
|
-
},
|
125
|
-
formData: {
|
126
|
-
blocks: {
|
127
|
-
id1: {
|
128
|
-
'@type': 'typeB',
|
129
|
-
plaintext: 'Block A',
|
130
|
-
override_toc: false,
|
131
|
-
},
|
132
|
-
},
|
133
|
-
blocks_layout: {
|
134
|
-
items: ['id1'],
|
135
|
-
},
|
136
|
-
},
|
137
|
-
type: 'typeB',
|
138
|
-
title: 'Test title',
|
139
|
-
};
|
140
|
-
|
141
|
-
const { container, getByText } = render(
|
142
|
-
<Provider store={store}>
|
143
|
-
<Form {...props} />
|
144
|
-
</Provider>,
|
145
|
-
);
|
146
|
-
expect(container).toBeTruthy();
|
147
|
-
expect(
|
148
|
-
container.querySelector('.ui.form .invisible .ui.raised.segments'),
|
149
|
-
).toBeInTheDocument();
|
150
|
-
expect(getByText('Test title')).toBeInTheDocument();
|
151
|
-
});
|
152
|
-
|
153
|
-
it('renders "Test title" and has the correct structure with formData without crashing with different types and isEditForm true', () => {
|
154
|
-
config.blocks = {
|
155
|
-
initialBlocksFocus: {
|
156
|
-
typeA: 'typeA',
|
157
|
-
},
|
158
|
-
};
|
159
|
-
config.settings = {
|
160
|
-
verticalFormTabs: false,
|
161
|
-
};
|
162
|
-
const props = {
|
163
|
-
schema: {
|
164
|
-
fieldsets: [{ fields: [], id: 'default', title: 'Default' }],
|
165
|
-
properties: {},
|
166
|
-
definitions: {},
|
167
|
-
required: [],
|
168
|
-
},
|
169
|
-
formData: {
|
170
|
-
blocks: {
|
171
|
-
id1: {
|
172
|
-
'@type': 'typeB',
|
173
|
-
plaintext: 'Block A',
|
174
|
-
override_toc: false,
|
175
|
-
},
|
176
|
-
},
|
177
|
-
blocks_layout: {
|
178
|
-
items: ['id1'],
|
179
|
-
},
|
180
|
-
},
|
181
|
-
type: 'typeB',
|
182
|
-
title: 'Test title',
|
183
|
-
isEditForm: true,
|
184
|
-
};
|
185
|
-
|
186
|
-
const { container, getByText } = render(
|
187
|
-
<Provider store={store}>
|
188
|
-
<Form {...props} />
|
189
|
-
</Provider>,
|
190
|
-
);
|
191
|
-
expect(container).toBeTruthy();
|
192
|
-
expect(
|
193
|
-
container.querySelector('.ui.form .invisible .ui.raised.segments'),
|
194
|
-
).toBeInTheDocument();
|
195
|
-
expect(getByText('Test title')).toBeInTheDocument();
|
196
|
-
});
|
197
|
-
|
198
|
-
it('renders "Test title" and has the correct structure with formData without crashing with no focused block', () => {
|
199
|
-
config.blocks = {
|
200
|
-
initialBlocksFocus: null,
|
201
|
-
};
|
202
|
-
config.settings = {
|
203
|
-
verticalFormTabs: false,
|
204
|
-
};
|
205
|
-
const props = {
|
206
|
-
schema: {
|
207
|
-
fieldsets: [{ fields: [], id: 'default', title: 'Default' }],
|
208
|
-
properties: {},
|
209
|
-
definitions: {},
|
210
|
-
required: [],
|
211
|
-
},
|
212
|
-
formData: {
|
213
|
-
blocks: {
|
214
|
-
id1: {
|
215
|
-
'@type': 'typeB',
|
216
|
-
plaintext: 'Block A',
|
217
|
-
override_toc: false,
|
218
|
-
},
|
219
|
-
},
|
220
|
-
blocks_layout: {
|
221
|
-
items: ['id1'],
|
222
|
-
},
|
223
|
-
},
|
224
|
-
type: 'typeB',
|
225
|
-
title: 'Test title',
|
226
|
-
};
|
227
|
-
|
228
|
-
const { container, getByText } = render(
|
229
|
-
<Provider store={store}>
|
230
|
-
<Form {...props} />
|
231
|
-
</Provider>,
|
232
|
-
);
|
233
|
-
expect(container).toBeTruthy();
|
234
|
-
expect(
|
235
|
-
container.querySelector('.ui.form .invisible .ui.raised.segments'),
|
236
|
-
).toBeInTheDocument();
|
237
|
-
expect(getByText('Test title')).toBeInTheDocument();
|
238
|
-
});
|
239
|
-
|
240
|
-
it('should display the correct fields on the currently selected fieldset', () => {
|
241
|
-
config.blocks = {
|
242
|
-
initialBlocksFocus: null,
|
243
|
-
};
|
244
|
-
config.settings = {
|
245
|
-
verticalFormTabs: false,
|
246
|
-
};
|
247
|
-
const props = {
|
248
|
-
schema: {
|
249
|
-
fieldsets: [
|
250
|
-
{
|
251
|
-
fields: ['field1', 'field2'],
|
252
|
-
id: 'fieldset1',
|
253
|
-
title: 'Fieldset 1',
|
254
|
-
description: 'Fieldset 1 description',
|
255
|
-
},
|
256
|
-
{
|
257
|
-
fields: ['field3', 'field4'],
|
258
|
-
id: 'fieldset2',
|
259
|
-
title: 'Fieldset 2',
|
260
|
-
},
|
261
|
-
],
|
262
|
-
properties: {
|
263
|
-
field1: {
|
264
|
-
title: 'Field 1',
|
265
|
-
description: 'Field 1 description',
|
266
|
-
items: ['field4'],
|
267
|
-
},
|
268
|
-
field2: { title: 'Field 2' },
|
269
|
-
field3: { title: 'Field 3' },
|
270
|
-
field4: { title: 'Field 4' },
|
271
|
-
},
|
272
|
-
definitions: {},
|
273
|
-
required: [],
|
274
|
-
},
|
275
|
-
formData: {
|
276
|
-
testBlocks: {
|
277
|
-
id1: {
|
278
|
-
'@type': 'typeB',
|
279
|
-
plaintext: 'Block A',
|
280
|
-
override_toc: false,
|
281
|
-
},
|
282
|
-
},
|
283
|
-
TestBlocks_layout: {
|
284
|
-
items: ['id1'],
|
285
|
-
},
|
286
|
-
},
|
287
|
-
type: 'typeB',
|
288
|
-
title: 'Test title',
|
289
|
-
description: 'Test description',
|
290
|
-
onChangeFormData: jest.fn(),
|
291
|
-
};
|
292
|
-
|
293
|
-
const prevProps = { requestError: null };
|
294
|
-
const prevState = { formData: {}, errors: {}, activeIndex: 0 };
|
295
|
-
const giveServerErrorsToCorrespondingFieldsMock = jest.spyOn(
|
296
|
-
FormValidation,
|
297
|
-
'giveServerErrorsToCorrespondingFields',
|
298
|
-
);
|
299
|
-
giveServerErrorsToCorrespondingFieldsMock.mockImplementation(() => [
|
300
|
-
{ message: 'Sample error message' },
|
301
|
-
{ message: 'Sample error message' },
|
302
|
-
]);
|
303
|
-
const requestError = 'Sample error message';
|
304
|
-
|
305
|
-
const { container, getByText, rerender } = render(
|
306
|
-
<Provider store={store}>
|
307
|
-
<Form
|
308
|
-
{...props}
|
309
|
-
requestError={prevProps.requestError}
|
310
|
-
formData={prevState.formData}
|
311
|
-
/>
|
312
|
-
</Provider>,
|
313
|
-
);
|
314
|
-
|
315
|
-
expect(getByText('Fieldset 1')).toBeInTheDocument();
|
316
|
-
expect(getByText('Fieldset 2')).toBeInTheDocument();
|
317
|
-
expect(getByText('Fieldset 1 description')).toBeInTheDocument();
|
318
|
-
expect(getByText('Test title')).toBeInTheDocument();
|
319
|
-
expect(container.querySelector('#mocked-field-field1')).toBeInTheDocument();
|
320
|
-
expect(container.querySelector('#mocked-field-field2')).toBeInTheDocument();
|
321
|
-
expect(
|
322
|
-
container.querySelector('#mocked-field-field3'),
|
323
|
-
).not.toBeInTheDocument();
|
324
|
-
expect(
|
325
|
-
container.querySelector('#mocked-field-field4'),
|
326
|
-
).not.toBeInTheDocument();
|
327
|
-
|
328
|
-
fireEvent.click(container.querySelector('#mocked-field-field2'));
|
329
|
-
fireEvent.click(getByText('Fieldset 2'));
|
330
|
-
|
331
|
-
expect(
|
332
|
-
container.querySelector('#mocked-field-field1'),
|
333
|
-
).not.toBeInTheDocument();
|
334
|
-
expect(
|
335
|
-
container.querySelector('#mocked-field-field2'),
|
336
|
-
).not.toBeInTheDocument();
|
337
|
-
expect(container.querySelector('#mocked-field-field3')).toBeInTheDocument();
|
338
|
-
expect(container.querySelector('#mocked-field-field4')).toBeInTheDocument();
|
339
|
-
|
340
|
-
rerender(
|
341
|
-
<Provider store={store}>
|
342
|
-
<Form
|
343
|
-
{...props}
|
344
|
-
requestError={requestError}
|
345
|
-
formData={props.formData}
|
346
|
-
errors={prevState.errors}
|
347
|
-
activeIndex={prevState.activeIndex}
|
348
|
-
/>
|
349
|
-
</Provider>,
|
350
|
-
);
|
351
|
-
|
352
|
-
expect(giveServerErrorsToCorrespondingFieldsMock).toHaveBeenCalledWith(
|
353
|
-
requestError,
|
354
|
-
);
|
355
|
-
});
|
356
|
-
|
357
|
-
it('renders without crashing and selecting Submit/Cancel button with resetAfterSubmit and errors', () => {
|
358
|
-
config.blocks = {
|
359
|
-
initialBlocksFocus: null,
|
360
|
-
};
|
361
|
-
config.settings = {
|
362
|
-
verticalFormTabs: true,
|
363
|
-
};
|
364
|
-
|
365
|
-
const props = {
|
366
|
-
schema: {
|
367
|
-
fieldsets: [
|
368
|
-
{
|
369
|
-
fields: ['field1', 'field2'],
|
370
|
-
id: 'fieldset1',
|
371
|
-
title: 'Fieldset 1',
|
372
|
-
},
|
373
|
-
{
|
374
|
-
fields: ['field3', 'field4'],
|
375
|
-
id: 'fieldset2',
|
376
|
-
title: 'Fieldset 2',
|
377
|
-
},
|
378
|
-
],
|
379
|
-
properties: {
|
380
|
-
field1: {
|
381
|
-
title: 'Field 1',
|
382
|
-
description: 'Field 1 description',
|
383
|
-
items: ['field4'],
|
384
|
-
widget: 'textarea',
|
385
|
-
},
|
386
|
-
field2: { widget: 'textarea' },
|
387
|
-
},
|
388
|
-
definitions: {},
|
389
|
-
required: [],
|
390
|
-
},
|
391
|
-
formData: {
|
392
|
-
blocks: {
|
393
|
-
id1: {
|
394
|
-
'@type': 'typeB',
|
395
|
-
plaintext: 'Block A',
|
396
|
-
override_toc: false,
|
397
|
-
},
|
398
|
-
},
|
399
|
-
blocks_layout: {
|
400
|
-
items: ['id1'],
|
401
|
-
},
|
402
|
-
},
|
403
|
-
type: 'typeB',
|
404
|
-
isClient: true,
|
405
|
-
title: 'Test title',
|
406
|
-
description: 'Test description',
|
407
|
-
error: {
|
408
|
-
message: 'Sample error message',
|
409
|
-
},
|
410
|
-
onSubmit: jest.fn(),
|
411
|
-
onCancel: jest.fn(),
|
412
|
-
resetAfterSubmit: true,
|
413
|
-
submitLabel: 'Submit',
|
414
|
-
};
|
415
|
-
|
416
|
-
const validateFieldsPerFieldsetMock = jest.spyOn(
|
417
|
-
FormValidation,
|
418
|
-
'validateFieldsPerFieldset',
|
419
|
-
);
|
420
|
-
validateFieldsPerFieldsetMock.mockImplementation(() => ({
|
421
|
-
field1: [],
|
422
|
-
field2: [],
|
423
|
-
}));
|
424
|
-
|
425
|
-
const { container, getByText } = render(
|
426
|
-
<Provider store={store}>
|
427
|
-
<Form {...props} />
|
428
|
-
</Provider>,
|
429
|
-
);
|
430
|
-
|
431
|
-
expect(getByText('Fieldset 1')).toBeInTheDocument();
|
432
|
-
expect(getByText('Fieldset 2')).toBeInTheDocument();
|
433
|
-
expect(getByText('Test title')).toBeInTheDocument();
|
434
|
-
expect(container.querySelector('#mocked-field-field1')).toBeInTheDocument();
|
435
|
-
expect(container.querySelector('#mocked-field-field2')).toBeInTheDocument();
|
436
|
-
expect(
|
437
|
-
container.querySelector('#mocked-field-field3'),
|
438
|
-
).not.toBeInTheDocument();
|
439
|
-
expect(
|
440
|
-
container.querySelector('#mocked-field-field4'),
|
441
|
-
).not.toBeInTheDocument();
|
442
|
-
|
443
|
-
fireEvent.click(container.querySelector('button[aria-label="Submit"]'));
|
444
|
-
fireEvent.click(container.querySelector('button[aria-label="Cancel"]'));
|
445
|
-
});
|
446
|
-
|
447
|
-
it('renders without crashing and selecting Submit/Cancel button with resetAfterSubmit and isaEditForm and no errors', () => {
|
448
|
-
config.blocks = {
|
449
|
-
initialBlocksFocus: null,
|
450
|
-
};
|
451
|
-
config.settings = {
|
452
|
-
verticalFormTabs: true,
|
453
|
-
};
|
454
|
-
|
455
|
-
const props = {
|
456
|
-
schema: {
|
457
|
-
fieldsets: [
|
458
|
-
{
|
459
|
-
fields: ['field1', 'field2'],
|
460
|
-
id: 'fieldset1',
|
461
|
-
title: 'Fieldset 1',
|
462
|
-
},
|
463
|
-
{
|
464
|
-
fields: ['field3', 'field4'],
|
465
|
-
id: 'fieldset2',
|
466
|
-
title: 'Fieldset 2',
|
467
|
-
},
|
468
|
-
],
|
469
|
-
properties: {
|
470
|
-
field1: {
|
471
|
-
title: 'Field 1',
|
472
|
-
description: 'Field 1 description',
|
473
|
-
items: ['field4'],
|
474
|
-
widget: 'textarea',
|
475
|
-
},
|
476
|
-
field2: { widget: 'textarea' },
|
477
|
-
},
|
478
|
-
definitions: {},
|
479
|
-
required: [],
|
480
|
-
},
|
481
|
-
formData: {
|
482
|
-
blocks: {
|
483
|
-
id1: {
|
484
|
-
'@type': 'typeB',
|
485
|
-
plaintext: 'Block A',
|
486
|
-
override_toc: false,
|
487
|
-
},
|
488
|
-
},
|
489
|
-
blocks_layout: {
|
490
|
-
items: ['id1'],
|
491
|
-
},
|
492
|
-
},
|
493
|
-
type: 'typeB',
|
494
|
-
isClient: true,
|
495
|
-
title: 'Test title',
|
496
|
-
description: 'Test description',
|
497
|
-
error: {
|
498
|
-
message: 'Sample error message',
|
499
|
-
},
|
500
|
-
onSubmit: jest.fn(),
|
501
|
-
onCancel: jest.fn(),
|
502
|
-
resetAfterSubmit: true,
|
503
|
-
isEditForm: true,
|
504
|
-
submitLabel: 'Submit',
|
505
|
-
};
|
506
|
-
|
507
|
-
const validateFieldsPerFieldsetMock = jest.spyOn(
|
508
|
-
FormValidation,
|
509
|
-
'validateFieldsPerFieldset',
|
510
|
-
);
|
511
|
-
validateFieldsPerFieldsetMock.mockImplementation(() => ({}));
|
512
|
-
|
513
|
-
const { container, getByText } = render(
|
514
|
-
<Provider store={store}>
|
515
|
-
<Form {...props} />
|
516
|
-
</Provider>,
|
517
|
-
);
|
518
|
-
|
519
|
-
expect(getByText('Fieldset 1')).toBeInTheDocument();
|
520
|
-
expect(getByText('Fieldset 2')).toBeInTheDocument();
|
521
|
-
expect(getByText('Test title')).toBeInTheDocument();
|
522
|
-
expect(container.querySelector('#mocked-field-field1')).toBeInTheDocument();
|
523
|
-
expect(container.querySelector('#mocked-field-field2')).toBeInTheDocument();
|
524
|
-
expect(
|
525
|
-
container.querySelector('#mocked-field-field3'),
|
526
|
-
).not.toBeInTheDocument();
|
527
|
-
expect(
|
528
|
-
container.querySelector('#mocked-field-field4'),
|
529
|
-
).not.toBeInTheDocument();
|
530
|
-
|
531
|
-
fireEvent.click(container.querySelector('button[aria-label="Submit"]'));
|
532
|
-
fireEvent.click(container.querySelector('button[aria-label="Cancel"]'));
|
533
|
-
});
|
534
|
-
|
535
|
-
it('renders without crashing and selecting Submit/Cancel button with no errors', () => {
|
536
|
-
config.blocks = {
|
537
|
-
initialBlocksFocus: null,
|
538
|
-
};
|
539
|
-
config.settings = {
|
540
|
-
verticalFormTabs: true,
|
541
|
-
};
|
542
|
-
|
543
|
-
const props = {
|
544
|
-
schema: {
|
545
|
-
fieldsets: [
|
546
|
-
{
|
547
|
-
fields: ['field1', 'field2'],
|
548
|
-
id: 'fieldset1',
|
549
|
-
title: 'Fieldset 1',
|
550
|
-
},
|
551
|
-
{
|
552
|
-
fields: ['field3', 'field4'],
|
553
|
-
id: 'fieldset2',
|
554
|
-
title: 'Fieldset 2',
|
555
|
-
},
|
556
|
-
],
|
557
|
-
properties: {
|
558
|
-
field1: {
|
559
|
-
title: 'Field 1',
|
560
|
-
description: 'Field 1 description',
|
561
|
-
items: ['field4'],
|
562
|
-
widget: 'textarea',
|
563
|
-
},
|
564
|
-
field2: { widget: 'textarea' },
|
565
|
-
},
|
566
|
-
definitions: {},
|
567
|
-
required: [],
|
568
|
-
},
|
569
|
-
formData: {
|
570
|
-
blocks: {
|
571
|
-
id1: {
|
572
|
-
'@type': 'typeB',
|
573
|
-
plaintext: 'Block A',
|
574
|
-
override_toc: false,
|
575
|
-
},
|
576
|
-
},
|
577
|
-
blocks_layout: {
|
578
|
-
items: ['id1'],
|
579
|
-
},
|
580
|
-
},
|
581
|
-
type: 'typeB',
|
582
|
-
isClient: true,
|
583
|
-
title: 'Test title',
|
584
|
-
description: 'Test description',
|
585
|
-
error: {
|
586
|
-
message: 'Sample error message',
|
587
|
-
},
|
588
|
-
onSubmit: jest.fn(),
|
589
|
-
onCancel: jest.fn(),
|
590
|
-
submitLabel: 'Submit',
|
591
|
-
};
|
592
|
-
|
593
|
-
const validateFieldsPerFieldsetMock = jest.spyOn(
|
594
|
-
FormValidation,
|
595
|
-
'validateFieldsPerFieldset',
|
596
|
-
);
|
597
|
-
validateFieldsPerFieldsetMock.mockImplementation(() => ({}));
|
598
|
-
|
599
|
-
const { container, getByText } = render(
|
600
|
-
<Provider store={store}>
|
601
|
-
<Form {...props} />
|
602
|
-
</Provider>,
|
603
|
-
);
|
604
|
-
|
605
|
-
expect(getByText('Fieldset 1')).toBeInTheDocument();
|
606
|
-
expect(getByText('Fieldset 2')).toBeInTheDocument();
|
607
|
-
expect(getByText('Test title')).toBeInTheDocument();
|
608
|
-
expect(container.querySelector('#mocked-field-field1')).toBeInTheDocument();
|
609
|
-
expect(container.querySelector('#mocked-field-field2')).toBeInTheDocument();
|
610
|
-
expect(
|
611
|
-
container.querySelector('#mocked-field-field3'),
|
612
|
-
).not.toBeInTheDocument();
|
613
|
-
expect(
|
614
|
-
container.querySelector('#mocked-field-field4'),
|
615
|
-
).not.toBeInTheDocument();
|
616
|
-
|
617
|
-
fireEvent.click(container.querySelector('button[aria-label="Submit"]'));
|
618
|
-
fireEvent.click(container.querySelector('button[aria-label="Cancel"]'));
|
619
|
-
});
|
620
|
-
|
621
|
-
it('renders only one fieldset and the actions to save/cancel', () => {
|
622
|
-
config.blocks = {
|
623
|
-
initialBlocksFocus: null,
|
624
|
-
};
|
625
|
-
config.settings = {
|
626
|
-
verticalFormTabs: true,
|
627
|
-
};
|
628
|
-
|
629
|
-
const props = {
|
630
|
-
schema: {
|
631
|
-
fieldsets: [
|
632
|
-
{
|
633
|
-
fields: ['field1', 'field2'],
|
634
|
-
id: 'fieldset1',
|
635
|
-
title: 'Fieldset 1',
|
636
|
-
},
|
637
|
-
],
|
638
|
-
properties: {
|
639
|
-
field1: {
|
640
|
-
title: 'Field 1',
|
641
|
-
description: 'Field 1 description',
|
642
|
-
items: ['field4'],
|
643
|
-
widget: 'textarea',
|
644
|
-
},
|
645
|
-
field2: { title: 'Field 2', widget: 'textarea' },
|
646
|
-
},
|
647
|
-
definitions: {},
|
648
|
-
required: [],
|
649
|
-
},
|
650
|
-
formData: {
|
651
|
-
blocks: {
|
652
|
-
id1: {
|
653
|
-
'@type': 'typeB',
|
654
|
-
plaintext: 'Block A',
|
655
|
-
override_toc: false,
|
656
|
-
},
|
657
|
-
},
|
658
|
-
blocks_layout: {
|
659
|
-
items: ['id1'],
|
660
|
-
},
|
661
|
-
},
|
662
|
-
type: 'typeB',
|
663
|
-
isClient: true,
|
664
|
-
title: 'Test title',
|
665
|
-
description: 'Test description',
|
666
|
-
error: {
|
667
|
-
message: 'Sample error message',
|
668
|
-
},
|
669
|
-
onSubmit: jest.fn(),
|
670
|
-
onCancel: jest.fn(),
|
671
|
-
};
|
672
|
-
|
673
|
-
const validateFieldsPerFieldsetMock = jest.spyOn(
|
674
|
-
FormValidation,
|
675
|
-
'validateFieldsPerFieldset',
|
676
|
-
);
|
677
|
-
validateFieldsPerFieldsetMock.mockImplementation(() => [
|
678
|
-
'field1',
|
679
|
-
'field2',
|
680
|
-
]);
|
681
|
-
|
682
|
-
const { container, getByText } = render(
|
683
|
-
<Provider store={store}>
|
684
|
-
<Form {...props} />
|
685
|
-
</Provider>,
|
686
|
-
);
|
687
|
-
|
688
|
-
expect(getByText('Error')).toBeInTheDocument();
|
689
|
-
expect(getByText('Sample error message')).toBeInTheDocument();
|
690
|
-
|
691
|
-
expect(container.querySelector('#mocked-field-field1')).toBeInTheDocument();
|
692
|
-
expect(container.querySelector('#mocked-field-field2')).toBeInTheDocument();
|
693
|
-
|
694
|
-
fireEvent.click(container.querySelector('#mocked-field-field2 textarea'));
|
695
|
-
fireEvent.blur(container.querySelector('#mocked-field-field2 textarea'));
|
696
|
-
fireEvent.change(container.querySelector('#mocked-field-field2 textarea'), {
|
697
|
-
target: { value: 'test change' },
|
698
|
-
});
|
699
|
-
});
|
700
|
-
|
701
|
-
it('triggers the onSubmit with the shiftKey and multiple selected blocks and multiple erorrs', () => {
|
702
|
-
config.blocks = {
|
703
|
-
initialBlocksFocus: null,
|
704
|
-
};
|
705
|
-
config.settings = {
|
706
|
-
verticalFormTabs: true,
|
707
|
-
};
|
708
|
-
|
709
|
-
const props = {
|
710
|
-
schema: {
|
711
|
-
fieldsets: [
|
712
|
-
{
|
713
|
-
fields: ['field1', 'field2'],
|
714
|
-
id: 'fieldset1',
|
715
|
-
title: 'Fieldset 1',
|
716
|
-
},
|
717
|
-
],
|
718
|
-
properties: {
|
719
|
-
field1: {
|
720
|
-
title: 'Field 1',
|
721
|
-
description: 'Field 1 description',
|
722
|
-
items: ['field4'],
|
723
|
-
widget: 'textarea',
|
724
|
-
},
|
725
|
-
field2: { title: 'Field 2', widget: 'textarea' },
|
726
|
-
},
|
727
|
-
definitions: {},
|
728
|
-
required: [],
|
729
|
-
},
|
730
|
-
formData: {
|
731
|
-
blocks: {
|
732
|
-
id1: {
|
733
|
-
'@type': 'typeB',
|
734
|
-
plaintext: 'Block A',
|
735
|
-
override_toc: false,
|
736
|
-
},
|
737
|
-
},
|
738
|
-
blocks_layout: {
|
739
|
-
items: ['id1'],
|
740
|
-
},
|
741
|
-
},
|
742
|
-
type: 'typeB',
|
743
|
-
isClient: true,
|
744
|
-
visual: true,
|
745
|
-
title: 'Test title',
|
746
|
-
description: 'Test description',
|
747
|
-
error: {
|
748
|
-
message: 'Sample error message',
|
749
|
-
},
|
750
|
-
onSubmit: jest.fn(),
|
751
|
-
onCancel: jest.fn(),
|
752
|
-
};
|
753
|
-
|
754
|
-
const validateFieldsPerFieldsetMock = jest.spyOn(
|
755
|
-
FormValidation,
|
756
|
-
'validateFieldsPerFieldset',
|
757
|
-
);
|
758
|
-
validateFieldsPerFieldsetMock.mockImplementation(() => [
|
759
|
-
'field1',
|
760
|
-
'field2',
|
761
|
-
]);
|
762
|
-
|
763
|
-
const { container } = render(
|
764
|
-
<Provider store={store}>
|
765
|
-
<Form {...props} />
|
766
|
-
</Provider>,
|
767
|
-
);
|
768
|
-
|
769
|
-
fireEvent.click(container.querySelector('#blocks-toolbar'), {
|
770
|
-
target: { value: 'id1,id2' },
|
771
|
-
});
|
772
|
-
fireEvent.change(container.querySelector('#blocks-toolbar'), {
|
773
|
-
target: { value: 'test change' },
|
774
|
-
});
|
775
|
-
fireEvent.select(container.querySelector('#blocks-toolbar'), {
|
776
|
-
target: {
|
777
|
-
id: 'id1',
|
778
|
-
isMultipleSelection: true,
|
779
|
-
event: { shiftKey: true },
|
780
|
-
},
|
781
|
-
});
|
782
|
-
|
783
|
-
fireEvent.change(container.querySelector('#blocks-form'), {
|
784
|
-
target: { value: 'test change' },
|
785
|
-
});
|
786
|
-
});
|
787
|
-
|
788
|
-
it('triggers the onSubmit with the shiftKey and multiple selected blocks when the selected blocks are in another order and multiple errors', () => {
|
789
|
-
config.blocks = {
|
790
|
-
initialBlocksFocus: null,
|
791
|
-
};
|
792
|
-
config.settings = {
|
793
|
-
verticalFormTabs: true,
|
794
|
-
};
|
795
|
-
|
796
|
-
const props = {
|
797
|
-
schema: {
|
798
|
-
fieldsets: [
|
799
|
-
{
|
800
|
-
fields: ['field1', 'field2'],
|
801
|
-
id: 'fieldset1',
|
802
|
-
title: 'Fieldset 1',
|
803
|
-
},
|
804
|
-
],
|
805
|
-
properties: {
|
806
|
-
field1: {
|
807
|
-
title: 'Field 1',
|
808
|
-
description: 'Field 1 description',
|
809
|
-
items: ['field4'],
|
810
|
-
widget: 'textarea',
|
811
|
-
},
|
812
|
-
field2: { title: 'Field 2', widget: 'textarea' },
|
813
|
-
},
|
814
|
-
definitions: {},
|
815
|
-
required: [],
|
816
|
-
},
|
817
|
-
formData: {
|
818
|
-
blocks: {
|
819
|
-
id1: {
|
820
|
-
'@type': 'typeB',
|
821
|
-
plaintext: 'Block A',
|
822
|
-
override_toc: false,
|
823
|
-
},
|
824
|
-
id2: {
|
825
|
-
'@type': 'typeB',
|
826
|
-
plaintext: 'Block A',
|
827
|
-
override_toc: false,
|
828
|
-
},
|
829
|
-
},
|
830
|
-
blocks_layout: {
|
831
|
-
items: ['id1', 'id2'],
|
832
|
-
},
|
833
|
-
},
|
834
|
-
type: 'typeB',
|
835
|
-
isClient: true,
|
836
|
-
visual: true,
|
837
|
-
title: 'Test title',
|
838
|
-
description: 'Test description',
|
839
|
-
error: {
|
840
|
-
message: 'Sample error message',
|
841
|
-
},
|
842
|
-
onSubmit: jest.fn(),
|
843
|
-
onCancel: jest.fn(),
|
844
|
-
};
|
845
|
-
|
846
|
-
const validateFieldsPerFieldsetMock = jest.spyOn(
|
847
|
-
FormValidation,
|
848
|
-
'validateFieldsPerFieldset',
|
849
|
-
);
|
850
|
-
validateFieldsPerFieldsetMock.mockImplementation(() => [
|
851
|
-
'field1',
|
852
|
-
'field2',
|
853
|
-
]);
|
854
|
-
|
855
|
-
const { container } = render(
|
856
|
-
<Provider store={store}>
|
857
|
-
<Form {...props} />
|
858
|
-
</Provider>,
|
859
|
-
);
|
860
|
-
|
861
|
-
fireEvent.click(container.querySelector('#blocks-toolbar'), {
|
862
|
-
target: { value: 'id2,id1' },
|
863
|
-
});
|
864
|
-
fireEvent.change(container.querySelector('#blocks-toolbar'), {
|
865
|
-
target: { value: 'test change' },
|
866
|
-
});
|
867
|
-
fireEvent.select(container.querySelector('#blocks-toolbar'), {
|
868
|
-
target: {
|
869
|
-
id: 'id1',
|
870
|
-
isMultipleSelection: true,
|
871
|
-
event: { shiftKey: true },
|
872
|
-
},
|
873
|
-
});
|
874
|
-
});
|
875
|
-
|
876
|
-
it('triggers the onSubmit with the shiftKey and multiple selected blocks when there are no selected blocks and multiple errors', () => {
|
877
|
-
config.blocks = {
|
878
|
-
initialBlocksFocus: null,
|
879
|
-
};
|
880
|
-
config.settings = {
|
881
|
-
verticalFormTabs: true,
|
882
|
-
};
|
883
|
-
|
884
|
-
const props = {
|
885
|
-
schema: {
|
886
|
-
fieldsets: [
|
887
|
-
{
|
888
|
-
fields: ['field1', 'field2'],
|
889
|
-
id: 'fieldset1',
|
890
|
-
title: 'Fieldset 1',
|
891
|
-
},
|
892
|
-
],
|
893
|
-
properties: {
|
894
|
-
field1: {
|
895
|
-
title: 'Field 1',
|
896
|
-
description: 'Field 1 description',
|
897
|
-
items: ['field4'],
|
898
|
-
widget: 'textarea',
|
899
|
-
},
|
900
|
-
field2: { title: 'Field 2', widget: 'textarea' },
|
901
|
-
},
|
902
|
-
definitions: {},
|
903
|
-
required: [],
|
904
|
-
},
|
905
|
-
formData: {
|
906
|
-
blocks: {
|
907
|
-
id1: {
|
908
|
-
'@type': 'typeB',
|
909
|
-
plaintext: 'Block A',
|
910
|
-
override_toc: false,
|
911
|
-
},
|
912
|
-
},
|
913
|
-
blocks_layout: {
|
914
|
-
items: ['id1'],
|
915
|
-
},
|
916
|
-
},
|
917
|
-
type: 'typeB',
|
918
|
-
isClient: true,
|
919
|
-
visual: true,
|
920
|
-
title: 'Test title',
|
921
|
-
description: 'Test description',
|
922
|
-
error: {
|
923
|
-
message: 'Sample error message',
|
924
|
-
},
|
925
|
-
onSubmit: jest.fn(),
|
926
|
-
onCancel: jest.fn(),
|
927
|
-
};
|
928
|
-
|
929
|
-
const validateFieldsPerFieldsetMock = jest.spyOn(
|
930
|
-
FormValidation,
|
931
|
-
'validateFieldsPerFieldset',
|
932
|
-
);
|
933
|
-
validateFieldsPerFieldsetMock.mockImplementation(() => [
|
934
|
-
'field1',
|
935
|
-
'field2',
|
936
|
-
]);
|
937
|
-
|
938
|
-
const { container } = render(
|
939
|
-
<Provider store={store}>
|
940
|
-
<Form {...props} />
|
941
|
-
</Provider>,
|
942
|
-
);
|
943
|
-
|
944
|
-
fireEvent.click(container.querySelector('#blocks-toolbar'), {
|
945
|
-
target: { value: undefined },
|
946
|
-
});
|
947
|
-
fireEvent.change(container.querySelector('#blocks-toolbar'), {
|
948
|
-
target: { value: 'test change' },
|
949
|
-
});
|
950
|
-
fireEvent.select(container.querySelector('#blocks-toolbar'), {
|
951
|
-
target: {
|
952
|
-
id: 'id1',
|
953
|
-
isMultipleSelection: true,
|
954
|
-
event: { shiftKey: true },
|
955
|
-
},
|
956
|
-
});
|
957
|
-
});
|
958
|
-
|
959
|
-
it('triggers the onSubmit with the ctrlKey and multiple selected blocks and multiple errors', () => {
|
960
|
-
config.blocks = {
|
961
|
-
initialBlocksFocus: null,
|
962
|
-
};
|
963
|
-
config.settings = {
|
964
|
-
verticalFormTabs: true,
|
965
|
-
};
|
966
|
-
|
967
|
-
const props = {
|
968
|
-
schema: {
|
969
|
-
fieldsets: [
|
970
|
-
{
|
971
|
-
fields: ['field1', 'field2'],
|
972
|
-
id: 'fieldset1',
|
973
|
-
title: 'Fieldset 1',
|
974
|
-
},
|
975
|
-
],
|
976
|
-
properties: {
|
977
|
-
field1: {
|
978
|
-
title: 'Field 1',
|
979
|
-
description: 'Field 1 description',
|
980
|
-
items: ['field4'],
|
981
|
-
widget: 'textarea',
|
982
|
-
},
|
983
|
-
field2: { title: 'Field 2', widget: 'textarea' },
|
984
|
-
},
|
985
|
-
definitions: {},
|
986
|
-
required: [],
|
987
|
-
},
|
988
|
-
formData: {
|
989
|
-
blocks: {
|
990
|
-
id1: {
|
991
|
-
'@type': 'typeB',
|
992
|
-
plaintext: 'Block A',
|
993
|
-
override_toc: false,
|
994
|
-
},
|
995
|
-
},
|
996
|
-
blocks_layout: {
|
997
|
-
items: ['id1'],
|
998
|
-
},
|
999
|
-
},
|
1000
|
-
type: 'typeB',
|
1001
|
-
isClient: true,
|
1002
|
-
visual: true,
|
1003
|
-
title: 'Test title',
|
1004
|
-
description: 'Test description',
|
1005
|
-
error: {
|
1006
|
-
message: 'Sample error message',
|
1007
|
-
},
|
1008
|
-
onSubmit: jest.fn(),
|
1009
|
-
onCancel: jest.fn(),
|
1010
|
-
};
|
1011
|
-
|
1012
|
-
const validateFieldsPerFieldsetMock = jest.spyOn(
|
1013
|
-
FormValidation,
|
1014
|
-
'validateFieldsPerFieldset',
|
1015
|
-
);
|
1016
|
-
validateFieldsPerFieldsetMock.mockImplementation(() => [
|
1017
|
-
'field1',
|
1018
|
-
'field2',
|
1019
|
-
]);
|
1020
|
-
|
1021
|
-
const { container } = render(
|
1022
|
-
<Provider store={store}>
|
1023
|
-
<Form {...props} />
|
1024
|
-
</Provider>,
|
1025
|
-
);
|
1026
|
-
|
1027
|
-
fireEvent.click(container.querySelector('#blocks-toolbar'), {
|
1028
|
-
target: { value: 'id1,id2' },
|
1029
|
-
});
|
1030
|
-
fireEvent.change(container.querySelector('#blocks-toolbar'), {
|
1031
|
-
target: { value: 'test change' },
|
1032
|
-
});
|
1033
|
-
fireEvent.select(container.querySelector('#blocks-toolbar'), {
|
1034
|
-
target: {
|
1035
|
-
id: 'id1',
|
1036
|
-
isMultipleSelection: true,
|
1037
|
-
event: { ctrlKey: true },
|
1038
|
-
},
|
1039
|
-
});
|
1040
|
-
});
|
1041
|
-
|
1042
|
-
it('triggers the onSubmit with the ctrlKey and multiple selected blocks and multiple errors when the selected block in not in the list of selected blocks', () => {
|
1043
|
-
config.blocks = {
|
1044
|
-
initialBlocksFocus: null,
|
1045
|
-
};
|
1046
|
-
config.settings = {
|
1047
|
-
verticalFormTabs: true,
|
1048
|
-
};
|
1049
|
-
|
1050
|
-
const props = {
|
1051
|
-
schema: {
|
1052
|
-
fieldsets: [
|
1053
|
-
{
|
1054
|
-
fields: ['field1', 'field2'],
|
1055
|
-
id: 'fieldset1',
|
1056
|
-
title: 'Fieldset 1',
|
1057
|
-
},
|
1058
|
-
],
|
1059
|
-
properties: {
|
1060
|
-
field1: {
|
1061
|
-
title: 'Field 1',
|
1062
|
-
description: 'Field 1 description',
|
1063
|
-
items: ['field4'],
|
1064
|
-
widget: 'textarea',
|
1065
|
-
},
|
1066
|
-
field2: { title: 'Field 2', widget: 'textarea' },
|
1067
|
-
},
|
1068
|
-
definitions: {},
|
1069
|
-
required: [],
|
1070
|
-
},
|
1071
|
-
formData: {
|
1072
|
-
blocks: {
|
1073
|
-
id1: {
|
1074
|
-
'@type': 'typeB',
|
1075
|
-
plaintext: 'Block A',
|
1076
|
-
override_toc: false,
|
1077
|
-
},
|
1078
|
-
},
|
1079
|
-
blocks_layout: {
|
1080
|
-
items: ['id1'],
|
1081
|
-
},
|
1082
|
-
},
|
1083
|
-
type: 'typeB',
|
1084
|
-
isClient: true,
|
1085
|
-
visual: true,
|
1086
|
-
title: 'Test title',
|
1087
|
-
description: 'Test description',
|
1088
|
-
error: {
|
1089
|
-
message: 'Sample error message',
|
1090
|
-
},
|
1091
|
-
onSubmit: jest.fn(),
|
1092
|
-
onCancel: jest.fn(),
|
1093
|
-
};
|
1094
|
-
|
1095
|
-
const validateFieldsPerFieldsetMock = jest.spyOn(
|
1096
|
-
FormValidation,
|
1097
|
-
'validateFieldsPerFieldset',
|
1098
|
-
);
|
1099
|
-
validateFieldsPerFieldsetMock.mockImplementation(() => [
|
1100
|
-
'field1',
|
1101
|
-
'field2',
|
1102
|
-
]);
|
1103
|
-
|
1104
|
-
const { container } = render(
|
1105
|
-
<Provider store={store}>
|
1106
|
-
<Form {...props} />
|
1107
|
-
</Provider>,
|
1108
|
-
);
|
1109
|
-
|
1110
|
-
fireEvent.click(container.querySelector('#blocks-toolbar'), {
|
1111
|
-
target: { value: 'id1,id2' },
|
1112
|
-
});
|
1113
|
-
fireEvent.change(container.querySelector('#blocks-toolbar'), {
|
1114
|
-
target: { value: 'test change' },
|
1115
|
-
});
|
1116
|
-
fireEvent.select(container.querySelector('#blocks-toolbar'), {
|
1117
|
-
target: {
|
1118
|
-
id: 'id3',
|
1119
|
-
isMultipleSelection: true,
|
1120
|
-
event: { ctrlKey: true },
|
1121
|
-
},
|
1122
|
-
});
|
1123
|
-
});
|
1124
|
-
});
|