@ukhomeoffice/cop-react-form-renderer 6.0.5-peter → 6.5.1-peter
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/dist/components/CheckYourAnswers/CheckYourAnswers.scss +2 -2
- package/dist/components/CollectionPage/CollectionPage.js +8 -2
- package/dist/components/CollectionSummary/BannerStrip.js +3 -2
- package/dist/components/CollectionSummary/BannerStrip.scss +2 -2
- package/dist/components/CollectionSummary/BannerStrip.test.js +39 -4
- package/dist/components/CollectionSummary/CollectionSummary.js +82 -63
- package/dist/components/CollectionSummary/CollectionSummary.scss +1 -1
- package/dist/components/CollectionSummary/CollectionSummary.test.js +40 -80
- package/dist/components/CollectionSummary/Confirmation.scss +1 -1
- package/dist/components/CollectionSummary/RenderListView.js +24 -20
- package/dist/components/CollectionSummary/RenderListView.scss +10 -1
- package/dist/components/CollectionSummary/RenderListView.test.js +14 -4
- package/dist/components/CollectionSummary/SummaryCard.js +59 -38
- package/dist/components/CollectionSummary/SummaryCard.scss +2 -1
- package/dist/components/CollectionSummary/SummaryCard.test.js +193 -150
- package/dist/components/CollectionSummary/SummaryCardDetails.js +70 -13
- package/dist/components/CollectionSummary/SummaryCardDetails.scss +43 -6
- package/dist/components/CollectionSummary/SummaryCardDetails.test.js +174 -26
- package/dist/components/CollectionSummary/SummaryCardValidationContext.js +15 -5
- package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +5 -4
- package/dist/components/FormComponent/Collection.js +24 -17
- package/dist/components/FormComponent/Collection.test.js +138 -0
- package/dist/components/FormComponent/FormComponent.js +12 -0
- package/dist/components/FormPage/FormPage.scss +1 -1
- package/dist/components/FormRenderer/FormRenderer.js +7 -4
- package/dist/components/FormRenderer/FormRenderer.scss +1 -1
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-after.json +429 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-before.json +449 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-airpax-form.json +15219 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-after.json +516 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab-2-data-before.json +593 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-eab2-form.json +15219 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-after.json +84 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-data-before.json +98 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/cop-mandec-form.json +9158 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/test.json +1605 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/test2.json +205 -0
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +114 -61
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +30 -0
- package/dist/components/FormRenderer/helpers/deleteNodeByPath.js +8 -2
- package/dist/components/FormRenderer/onPageAction.js +6 -1
- package/dist/components/FormRenderer/onPageAction.test.js +18 -4
- package/dist/components/SummaryList/SummaryList.scss +2 -2
- package/dist/components/TaskList/TaskList.scss +1 -1
- package/dist/context/ValidationContext/ValidationContext.js +49 -5
- package/dist/context/ValidationContext/ValidationContext.test.js +16 -7
- package/dist/hooks/useRefData.js +1 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +1 -2
- package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +5 -0
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +1 -2
- package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +4 -24
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +13 -1
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +17 -2
- package/dist/utils/CollectionPage/getErrorsForCollection.js +55 -0
- package/dist/utils/CollectionPage/getErrorsForCollection.test.js +155 -0
- package/dist/utils/CollectionPage/getQuickEditPage.js +7 -1
- package/dist/utils/CollectionPage/index.js +2 -0
- package/dist/utils/CollectionPage/setCollectionPageData.js +9 -4
- package/dist/utils/CollectionPage/setCollectionPageData.test.js +18 -0
- package/dist/utils/Component/isEditable.js +1 -1
- package/dist/utils/Condition/meetsAllConditions.js +5 -1
- package/dist/utils/Condition/meetsAllConditions.test.js +13 -0
- package/dist/utils/Condition/meetsCondition.js +18 -0
- package/dist/utils/Condition/meetsCondition.test.js +100 -0
- package/dist/utils/Data/getOptions.js +10 -0
- package/dist/utils/Data/getOptions.test.js +73 -0
- package/dist/utils/Data/nestInRefdataOptions.js +49 -0
- package/dist/utils/Data/nestInRefdataOptions.test.js +236 -0
- package/dist/utils/Validate/validateContainer.js +3 -1
- package/dist/utils/Validate/validateContainer.test.js +33 -0
- package/dist/utils/Validate/validateEmail.js +1 -1
- package/dist/utils/Validate/validatePage.js +10 -1
- package/dist/utils/Validate/validatePage.test.js +69 -0
- package/package.json +4 -4
|
@@ -239,7 +239,6 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
239
239
|
expect(headerDetails.textContent).toEqual("".concat(ENTRY.detailsText, " that are interpolated"));
|
|
240
240
|
});
|
|
241
241
|
describe('Change action button', function () {
|
|
242
|
-
var inErrorValue = true;
|
|
243
242
|
var onChangeArgs = [];
|
|
244
243
|
var onChangeCalls = 0;
|
|
245
244
|
var ON_CHANGE = function ON_CHANGE(page, id) {
|
|
@@ -248,7 +247,6 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
248
247
|
id: id
|
|
249
248
|
});
|
|
250
249
|
onChangeCalls += 1;
|
|
251
|
-
inErrorValue = false;
|
|
252
250
|
};
|
|
253
251
|
beforeEach(function () {
|
|
254
252
|
onChangeArgs = [];
|
|
@@ -258,14 +256,17 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
258
256
|
var CONFIG = {
|
|
259
257
|
changeAction: {
|
|
260
258
|
label: 'Change label',
|
|
261
|
-
page: 'testPage'
|
|
259
|
+
page: 'testPage',
|
|
260
|
+
aria_label: [{
|
|
261
|
+
text: 'testText'
|
|
262
|
+
}]
|
|
262
263
|
}
|
|
263
264
|
};
|
|
264
265
|
var _renderWithValidation7 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
265
266
|
id: ID,
|
|
266
267
|
entryData: ENTRY,
|
|
267
268
|
config: CONFIG,
|
|
268
|
-
|
|
269
|
+
onFullEdit: ON_CHANGE,
|
|
269
270
|
parentCollectionName: "parent",
|
|
270
271
|
formData: {},
|
|
271
272
|
masterPage: {
|
|
@@ -277,8 +278,10 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
277
278
|
headerActionDiv = _checkSetup7.headerActionDiv;
|
|
278
279
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
279
280
|
var changeButton = headerActionDiv.children[0];
|
|
281
|
+
expect(changeButton.name).toEqual('Change');
|
|
280
282
|
expect(changeButton.tagName).toEqual('BUTTON');
|
|
281
283
|
expect(changeButton.textContent).toEqual(CONFIG.changeAction.label);
|
|
284
|
+
expect(changeButton.getAttribute('aria-label')).toEqual(CONFIG.changeAction.aria_label[0].text);
|
|
282
285
|
_react.fireEvent.click(changeButton, {});
|
|
283
286
|
expect(onChangeCalls).toEqual(1);
|
|
284
287
|
expect(onChangeArgs[0]).toMatchObject({
|
|
@@ -286,10 +289,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
286
289
|
id: ENTRY.id
|
|
287
290
|
});
|
|
288
291
|
});
|
|
289
|
-
it('should
|
|
292
|
+
it('should use the default label when one is not provided', function () {
|
|
290
293
|
var CONFIG = {
|
|
291
294
|
changeAction: {
|
|
292
|
-
label: 'Change label',
|
|
293
295
|
page: 'testPage'
|
|
294
296
|
}
|
|
295
297
|
};
|
|
@@ -297,13 +299,12 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
297
299
|
id: ID,
|
|
298
300
|
entryData: ENTRY,
|
|
299
301
|
config: CONFIG,
|
|
300
|
-
|
|
302
|
+
onFullEdit: ON_CHANGE,
|
|
301
303
|
parentCollectionName: "parent",
|
|
302
304
|
formData: {},
|
|
303
305
|
masterPage: {
|
|
304
306
|
childPages: []
|
|
305
|
-
}
|
|
306
|
-
inError: inErrorValue
|
|
307
|
+
}
|
|
307
308
|
})),
|
|
308
309
|
container = _renderWithValidation8.container;
|
|
309
310
|
var _checkSetup8 = checkSetup(container),
|
|
@@ -311,27 +312,13 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
311
312
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
312
313
|
var changeButton = headerActionDiv.children[0];
|
|
313
314
|
expect(changeButton.tagName).toEqual('BUTTON');
|
|
314
|
-
expect(changeButton.textContent).toEqual(
|
|
315
|
-
_react.fireEvent.click(changeButton, {});
|
|
316
|
-
expect(onChangeCalls).toEqual(1);
|
|
317
|
-
expect(onChangeArgs[0]).toMatchObject({
|
|
318
|
-
page: CONFIG.changeAction.page,
|
|
319
|
-
id: ENTRY.id
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
// Check that the inError prop is now false
|
|
323
|
-
expect(inErrorValue).toBe(false);
|
|
315
|
+
expect(changeButton.textContent).toEqual(_SummaryCard.DEFAULT_CHANGE_BUTTON_LABEL);
|
|
324
316
|
});
|
|
325
|
-
it('should
|
|
326
|
-
var CONFIG = {
|
|
327
|
-
changeAction: {
|
|
328
|
-
page: 'testPage'
|
|
329
|
-
}
|
|
330
|
-
};
|
|
317
|
+
it('should not render when no config is provided for it', function () {
|
|
331
318
|
var _renderWithValidation9 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
332
319
|
id: ID,
|
|
333
320
|
entryData: ENTRY,
|
|
334
|
-
config:
|
|
321
|
+
config: {},
|
|
335
322
|
onChange: ON_CHANGE,
|
|
336
323
|
parentCollectionName: "parent",
|
|
337
324
|
formData: {},
|
|
@@ -342,26 +329,6 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
342
329
|
container = _renderWithValidation9.container;
|
|
343
330
|
var _checkSetup9 = checkSetup(container),
|
|
344
331
|
headerActionDiv = _checkSetup9.headerActionDiv;
|
|
345
|
-
expect(headerActionDiv.children.length).toEqual(1);
|
|
346
|
-
var changeButton = headerActionDiv.children[0];
|
|
347
|
-
expect(changeButton.tagName).toEqual('BUTTON');
|
|
348
|
-
expect(changeButton.textContent).toEqual(_SummaryCard.DEFAULT_CHANGE_BUTTON_LABEL);
|
|
349
|
-
});
|
|
350
|
-
it('should not render when no config is provided for it', function () {
|
|
351
|
-
var _renderWithValidation10 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
352
|
-
id: ID,
|
|
353
|
-
entryData: ENTRY,
|
|
354
|
-
config: {},
|
|
355
|
-
onChange: ON_CHANGE,
|
|
356
|
-
parentCollectionName: "parent",
|
|
357
|
-
formData: {},
|
|
358
|
-
masterPage: {
|
|
359
|
-
childPages: []
|
|
360
|
-
}
|
|
361
|
-
})),
|
|
362
|
-
container = _renderWithValidation10.container;
|
|
363
|
-
var _checkSetup10 = checkSetup(container),
|
|
364
|
-
headerActionDiv = _checkSetup10.headerActionDiv;
|
|
365
332
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
366
333
|
});
|
|
367
334
|
it('should not render when onChange is not supplied', function () {
|
|
@@ -371,7 +338,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
371
338
|
page: 'testPage'
|
|
372
339
|
}
|
|
373
340
|
};
|
|
374
|
-
var
|
|
341
|
+
var _renderWithValidation10 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
375
342
|
id: ID,
|
|
376
343
|
entryData: ENTRY,
|
|
377
344
|
config: CONFIG,
|
|
@@ -381,9 +348,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
381
348
|
childPages: []
|
|
382
349
|
}
|
|
383
350
|
})),
|
|
384
|
-
container =
|
|
385
|
-
var
|
|
386
|
-
headerActionDiv =
|
|
351
|
+
container = _renderWithValidation10.container;
|
|
352
|
+
var _checkSetup10 = checkSetup(container),
|
|
353
|
+
headerActionDiv = _checkSetup10.headerActionDiv;
|
|
387
354
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
388
355
|
});
|
|
389
356
|
});
|
|
@@ -401,10 +368,13 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
401
368
|
it('should render correctly', function () {
|
|
402
369
|
var CONFIG = {
|
|
403
370
|
deleteAction: {
|
|
404
|
-
label: 'Delete label'
|
|
371
|
+
label: 'Delete label',
|
|
372
|
+
aria_label: [{
|
|
373
|
+
text: 'testText'
|
|
374
|
+
}]
|
|
405
375
|
}
|
|
406
376
|
};
|
|
407
|
-
var
|
|
377
|
+
var _renderWithValidation11 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
408
378
|
id: ID,
|
|
409
379
|
entryData: ENTRY,
|
|
410
380
|
config: CONFIG,
|
|
@@ -415,13 +385,15 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
415
385
|
childPages: []
|
|
416
386
|
}
|
|
417
387
|
})),
|
|
418
|
-
container =
|
|
419
|
-
var
|
|
420
|
-
headerActionDiv =
|
|
388
|
+
container = _renderWithValidation11.container;
|
|
389
|
+
var _checkSetup11 = checkSetup(container),
|
|
390
|
+
headerActionDiv = _checkSetup11.headerActionDiv;
|
|
421
391
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
422
392
|
var deleteButton = headerActionDiv.children[0];
|
|
393
|
+
expect(deleteButton.name).toEqual('Delete');
|
|
423
394
|
expect(deleteButton.tagName).toEqual('BUTTON');
|
|
424
395
|
expect(deleteButton.textContent).toEqual(CONFIG.deleteAction.label);
|
|
396
|
+
expect(deleteButton.getAttribute('aria-label')).toEqual(CONFIG.deleteAction.aria_label[0].text);
|
|
425
397
|
_react.fireEvent.click(deleteButton, {});
|
|
426
398
|
expect(onDeleteCalls).toEqual(1);
|
|
427
399
|
expect(onDeleteArgs[0]).toMatchObject(ENTRY);
|
|
@@ -430,7 +402,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
430
402
|
var CONFIG = {
|
|
431
403
|
deleteAction: {}
|
|
432
404
|
};
|
|
433
|
-
var
|
|
405
|
+
var _renderWithValidation12 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
434
406
|
id: ID,
|
|
435
407
|
entryData: ENTRY,
|
|
436
408
|
config: CONFIG,
|
|
@@ -441,16 +413,16 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
441
413
|
childPages: []
|
|
442
414
|
}
|
|
443
415
|
})),
|
|
444
|
-
container =
|
|
445
|
-
var
|
|
446
|
-
headerActionDiv =
|
|
416
|
+
container = _renderWithValidation12.container;
|
|
417
|
+
var _checkSetup12 = checkSetup(container),
|
|
418
|
+
headerActionDiv = _checkSetup12.headerActionDiv;
|
|
447
419
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
448
420
|
var deleteButton = headerActionDiv.children[0];
|
|
449
421
|
expect(deleteButton.tagName).toEqual('BUTTON');
|
|
450
422
|
expect(deleteButton.textContent).toEqual(_SummaryCard.DEFAULT_DELETE_BUTTON_LABEL);
|
|
451
423
|
});
|
|
452
424
|
it('should not render when no config is provided for it', function () {
|
|
453
|
-
var
|
|
425
|
+
var _renderWithValidation13 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
454
426
|
id: ID,
|
|
455
427
|
entryData: ENTRY,
|
|
456
428
|
config: {},
|
|
@@ -461,9 +433,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
461
433
|
childPages: []
|
|
462
434
|
}
|
|
463
435
|
})),
|
|
464
|
-
container =
|
|
465
|
-
var
|
|
466
|
-
headerActionDiv =
|
|
436
|
+
container = _renderWithValidation13.container;
|
|
437
|
+
var _checkSetup13 = checkSetup(container),
|
|
438
|
+
headerActionDiv = _checkSetup13.headerActionDiv;
|
|
467
439
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
468
440
|
});
|
|
469
441
|
it('should not render when onDelete is not supplied', function () {
|
|
@@ -472,7 +444,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
472
444
|
label: 'Delete label'
|
|
473
445
|
}
|
|
474
446
|
};
|
|
475
|
-
var
|
|
447
|
+
var _renderWithValidation14 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
476
448
|
id: ID,
|
|
477
449
|
entryData: ENTRY,
|
|
478
450
|
config: CONFIG,
|
|
@@ -482,9 +454,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
482
454
|
childPages: []
|
|
483
455
|
}
|
|
484
456
|
})),
|
|
485
|
-
container =
|
|
486
|
-
var
|
|
487
|
-
headerActionDiv =
|
|
457
|
+
container = _renderWithValidation14.container;
|
|
458
|
+
var _checkSetup14 = checkSetup(container),
|
|
459
|
+
headerActionDiv = _checkSetup14.headerActionDiv;
|
|
488
460
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
489
461
|
});
|
|
490
462
|
it('should correctly render the Details section with entry data', function () {
|
|
@@ -493,7 +465,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
493
465
|
label: 'Delete label'
|
|
494
466
|
}
|
|
495
467
|
};
|
|
496
|
-
var
|
|
468
|
+
var _renderWithValidation15 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
497
469
|
id: ID,
|
|
498
470
|
entryData: ENTRY,
|
|
499
471
|
config: CONFIG,
|
|
@@ -503,7 +475,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
503
475
|
childPages: []
|
|
504
476
|
}
|
|
505
477
|
})),
|
|
506
|
-
container =
|
|
478
|
+
container = _renderWithValidation15.container;
|
|
507
479
|
var detailsSection = container.querySelector('.details');
|
|
508
480
|
expect(detailsSection).not.toBeNull();
|
|
509
481
|
expect(detailsSection.textContent).toContain(ENTRY.summaryText);
|
|
@@ -526,7 +498,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
526
498
|
label: 'Duplicate label'
|
|
527
499
|
}
|
|
528
500
|
};
|
|
529
|
-
var
|
|
501
|
+
var _renderWithValidation16 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
530
502
|
id: ID,
|
|
531
503
|
entryData: ENTRY,
|
|
532
504
|
config: CONFIG,
|
|
@@ -537,11 +509,12 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
537
509
|
childPages: []
|
|
538
510
|
}
|
|
539
511
|
})),
|
|
540
|
-
container =
|
|
541
|
-
var
|
|
542
|
-
headerActionDiv =
|
|
512
|
+
container = _renderWithValidation16.container;
|
|
513
|
+
var _checkSetup15 = checkSetup(container),
|
|
514
|
+
headerActionDiv = _checkSetup15.headerActionDiv;
|
|
543
515
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
544
516
|
var duplicateButton = headerActionDiv.children[0];
|
|
517
|
+
expect(duplicateButton.name).toEqual('Duplicate');
|
|
545
518
|
expect(duplicateButton.tagName).toEqual('BUTTON');
|
|
546
519
|
expect(duplicateButton.textContent).toEqual(CONFIG.duplicateAction.label);
|
|
547
520
|
_react.fireEvent.click(duplicateButton, {});
|
|
@@ -552,7 +525,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
552
525
|
var CONFIG = {
|
|
553
526
|
duplicateAction: {}
|
|
554
527
|
};
|
|
555
|
-
var
|
|
528
|
+
var _renderWithValidation17 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
556
529
|
id: ID,
|
|
557
530
|
entryData: ENTRY,
|
|
558
531
|
config: CONFIG,
|
|
@@ -563,16 +536,16 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
563
536
|
childPages: []
|
|
564
537
|
}
|
|
565
538
|
})),
|
|
566
|
-
container =
|
|
567
|
-
var
|
|
568
|
-
headerActionDiv =
|
|
539
|
+
container = _renderWithValidation17.container;
|
|
540
|
+
var _checkSetup16 = checkSetup(container),
|
|
541
|
+
headerActionDiv = _checkSetup16.headerActionDiv;
|
|
569
542
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
570
543
|
var duplicateButton = headerActionDiv.children[0];
|
|
571
544
|
expect(duplicateButton.tagName).toEqual('BUTTON');
|
|
572
545
|
expect(duplicateButton.textContent).toEqual(_SummaryCard.DEFAULT_DUPLICATE_BUTTON_LABEL);
|
|
573
546
|
});
|
|
574
547
|
it('should not render when no config is provided for it', function () {
|
|
575
|
-
var
|
|
548
|
+
var _renderWithValidation18 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
576
549
|
id: ID,
|
|
577
550
|
entryData: ENTRY,
|
|
578
551
|
config: {},
|
|
@@ -583,9 +556,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
583
556
|
childPages: []
|
|
584
557
|
}
|
|
585
558
|
})),
|
|
586
|
-
container =
|
|
587
|
-
var
|
|
588
|
-
headerActionDiv =
|
|
559
|
+
container = _renderWithValidation18.container;
|
|
560
|
+
var _checkSetup17 = checkSetup(container),
|
|
561
|
+
headerActionDiv = _checkSetup17.headerActionDiv;
|
|
589
562
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
590
563
|
});
|
|
591
564
|
it('should not render when onDuplicate is not supplied', function () {
|
|
@@ -594,7 +567,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
594
567
|
label: 'Duplicate label'
|
|
595
568
|
}
|
|
596
569
|
};
|
|
597
|
-
var
|
|
570
|
+
var _renderWithValidation19 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
598
571
|
id: ID,
|
|
599
572
|
entryData: ENTRY,
|
|
600
573
|
config: CONFIG,
|
|
@@ -604,9 +577,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
604
577
|
childPages: []
|
|
605
578
|
}
|
|
606
579
|
})),
|
|
607
|
-
container =
|
|
608
|
-
var
|
|
609
|
-
headerActionDiv =
|
|
580
|
+
container = _renderWithValidation19.container;
|
|
581
|
+
var _checkSetup18 = checkSetup(container),
|
|
582
|
+
headerActionDiv = _checkSetup18.headerActionDiv;
|
|
610
583
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
611
584
|
});
|
|
612
585
|
});
|
|
@@ -638,7 +611,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
638
611
|
}
|
|
639
612
|
}];
|
|
640
613
|
it('should render correctly', function () {
|
|
641
|
-
var
|
|
614
|
+
var _renderWithValidation20 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
642
615
|
id: ID,
|
|
643
616
|
entryData: ENTRY,
|
|
644
617
|
config: CONFIG,
|
|
@@ -646,16 +619,16 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
646
619
|
formData: {},
|
|
647
620
|
masterPage: {
|
|
648
621
|
childPages: PAGES
|
|
649
|
-
}
|
|
650
|
-
inError: true
|
|
622
|
+
}
|
|
651
623
|
})),
|
|
652
|
-
container =
|
|
653
|
-
var
|
|
654
|
-
headerActionDiv =
|
|
624
|
+
container = _renderWithValidation20.container;
|
|
625
|
+
var _checkSetup19 = checkSetup(container),
|
|
626
|
+
headerActionDiv = _checkSetup19.headerActionDiv;
|
|
655
627
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
656
628
|
|
|
657
629
|
// Shows edit button but no quick edit
|
|
658
630
|
var editButton = headerActionDiv.children[0];
|
|
631
|
+
expect(editButton.name).toEqual('QuickEdit');
|
|
659
632
|
expect(editButton.tagName).toEqual('BUTTON');
|
|
660
633
|
expect(editButton.textContent).toEqual('Quick Edit');
|
|
661
634
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // Quick edit hidden
|
|
@@ -679,7 +652,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
679
652
|
});
|
|
680
653
|
|
|
681
654
|
it('should not render when no config is provided for it', function () {
|
|
682
|
-
var
|
|
655
|
+
var _renderWithValidation21 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
683
656
|
id: ID,
|
|
684
657
|
entryData: ENTRY,
|
|
685
658
|
config: {},
|
|
@@ -687,12 +660,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
687
660
|
formData: {},
|
|
688
661
|
masterPage: {
|
|
689
662
|
childPages: PAGES
|
|
690
|
-
}
|
|
691
|
-
inError: true
|
|
663
|
+
}
|
|
692
664
|
})),
|
|
693
|
-
container =
|
|
694
|
-
var
|
|
695
|
-
headerActionDiv =
|
|
665
|
+
container = _renderWithValidation21.container;
|
|
666
|
+
var _checkSetup20 = checkSetup(container),
|
|
667
|
+
headerActionDiv = _checkSetup20.headerActionDiv;
|
|
696
668
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
697
669
|
});
|
|
698
670
|
});
|
|
@@ -735,7 +707,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
735
707
|
entryId: '123',
|
|
736
708
|
error: 'top-level error message'
|
|
737
709
|
}];
|
|
738
|
-
var
|
|
710
|
+
var _renderWithValidation22 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
739
711
|
entryId: CUSTOM_ENTRY.id,
|
|
740
712
|
topLevelErrors: TOP_LEVEL_ERRORS
|
|
741
713
|
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
@@ -746,12 +718,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
746
718
|
formData: {},
|
|
747
719
|
masterPage: {
|
|
748
720
|
childPages: PAGES
|
|
749
|
-
}
|
|
750
|
-
inError: true
|
|
721
|
+
}
|
|
751
722
|
}))),
|
|
752
|
-
container =
|
|
753
|
-
var
|
|
754
|
-
headerActionDiv =
|
|
723
|
+
container = _renderWithValidation22.container;
|
|
724
|
+
var _checkSetup21 = checkSetup(container),
|
|
725
|
+
headerActionDiv = _checkSetup21.headerActionDiv;
|
|
755
726
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
756
727
|
|
|
757
728
|
// Shows edit button but no quick edit
|
|
@@ -771,7 +742,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
771
742
|
expect(errorSummary.textContent).toContain(TOP_LEVEL_ERRORS[0].error);
|
|
772
743
|
});
|
|
773
744
|
it('should only show errors from validation when it happens, ignoring top-level errors', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
774
|
-
var TOP_LEVEL_ERRORS,
|
|
745
|
+
var TOP_LEVEL_ERRORS, _renderWithValidation23, container, _checkSetup22, headerActionDiv, editButton, quickEdit, errorSummary, component, componentInput, quickEditButtons, saveButton;
|
|
775
746
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
776
747
|
while (1) switch (_context3.prev = _context3.next) {
|
|
777
748
|
case 0:
|
|
@@ -780,7 +751,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
780
751
|
entryId: '123',
|
|
781
752
|
error: 'top-level error message'
|
|
782
753
|
}];
|
|
783
|
-
|
|
754
|
+
_renderWithValidation23 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
784
755
|
entryId: CUSTOM_ENTRY.id,
|
|
785
756
|
topLevelErrors: TOP_LEVEL_ERRORS
|
|
786
757
|
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
@@ -792,10 +763,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
792
763
|
masterPage: {
|
|
793
764
|
childPages: PAGES
|
|
794
765
|
},
|
|
795
|
-
onQuickEdit: function onQuickEdit() {}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
_checkSetup23 = checkSetup(container), headerActionDiv = _checkSetup23.headerActionDiv;
|
|
766
|
+
onQuickEdit: function onQuickEdit() {}
|
|
767
|
+
}))), container = _renderWithValidation23.container;
|
|
768
|
+
_checkSetup22 = checkSetup(container), headerActionDiv = _checkSetup22.headerActionDiv;
|
|
799
769
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
800
770
|
|
|
801
771
|
// Shows edit button but no quick edit
|
|
@@ -894,7 +864,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
894
864
|
}
|
|
895
865
|
}];
|
|
896
866
|
it('should render correctly', function () {
|
|
897
|
-
var
|
|
867
|
+
var _renderWithValidation24 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
898
868
|
id: ID,
|
|
899
869
|
entryData: ENTRY,
|
|
900
870
|
config: CONFIG,
|
|
@@ -902,12 +872,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
902
872
|
formData: {},
|
|
903
873
|
masterPage: {
|
|
904
874
|
childPages: PAGES
|
|
905
|
-
}
|
|
906
|
-
inError: true
|
|
875
|
+
}
|
|
907
876
|
})),
|
|
908
|
-
container =
|
|
909
|
-
var
|
|
910
|
-
headerActionDiv =
|
|
877
|
+
container = _renderWithValidation24.container;
|
|
878
|
+
var _checkSetup23 = checkSetup(container),
|
|
879
|
+
headerActionDiv = _checkSetup23.headerActionDiv;
|
|
911
880
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
912
881
|
|
|
913
882
|
// Shows edit button but no quick edit
|
|
@@ -941,7 +910,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
941
910
|
return ON_SUBMIT_CALLS.push(patch);
|
|
942
911
|
}
|
|
943
912
|
};
|
|
944
|
-
var
|
|
913
|
+
var _renderWithValidation25 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
945
914
|
id: ID,
|
|
946
915
|
entryData: ENTRY,
|
|
947
916
|
config: CONFIG,
|
|
@@ -949,14 +918,13 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
949
918
|
formData: {},
|
|
950
919
|
masterPage: {
|
|
951
920
|
childPages: PAGES
|
|
952
|
-
}
|
|
953
|
-
inError: true
|
|
921
|
+
}
|
|
954
922
|
}), {
|
|
955
923
|
hooks: hooks
|
|
956
924
|
}),
|
|
957
|
-
container =
|
|
958
|
-
var
|
|
959
|
-
headerActionDiv =
|
|
925
|
+
container = _renderWithValidation25.container;
|
|
926
|
+
var _checkSetup24 = checkSetup(container),
|
|
927
|
+
headerActionDiv = _checkSetup24.headerActionDiv;
|
|
960
928
|
|
|
961
929
|
// Shows edit button but no quick edit
|
|
962
930
|
var editButton = headerActionDiv.children[0];
|
|
@@ -970,7 +938,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
970
938
|
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
971
939
|
});
|
|
972
940
|
it('should return after local validation if errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
973
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
941
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation26, container, _checkSetup25, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
974
942
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
975
943
|
while (1) switch (_context6.prev = _context6.next) {
|
|
976
944
|
case 0:
|
|
@@ -985,7 +953,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
985
953
|
var target = _ref5.target;
|
|
986
954
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
987
955
|
};
|
|
988
|
-
|
|
956
|
+
_renderWithValidation26 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
989
957
|
id: ID,
|
|
990
958
|
entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
991
959
|
index: 0
|
|
@@ -1000,12 +968,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1000
968
|
},
|
|
1001
969
|
masterPage: {
|
|
1002
970
|
childPages: PAGES
|
|
1003
|
-
}
|
|
1004
|
-
inError: true
|
|
971
|
+
}
|
|
1005
972
|
}), {
|
|
1006
973
|
hooks: hooks
|
|
1007
|
-
}), container =
|
|
1008
|
-
|
|
974
|
+
}), container = _renderWithValidation26.container;
|
|
975
|
+
_checkSetup25 = checkSetup(container), headerActionDiv = _checkSetup25.headerActionDiv;
|
|
1009
976
|
editButton = headerActionDiv.children[0];
|
|
1010
977
|
_react.fireEvent.click(editButton, {});
|
|
1011
978
|
quickEdit = container.childNodes[0].childNodes[1];
|
|
@@ -1051,8 +1018,8 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1051
1018
|
}
|
|
1052
1019
|
}, _callee6);
|
|
1053
1020
|
})));
|
|
1054
|
-
it('should run hook validation when
|
|
1055
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
1021
|
+
it('should run hook validation when local validation is passed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1022
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation27, container, _checkSetup26, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
1056
1023
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1057
1024
|
while (1) switch (_context8.prev = _context8.next) {
|
|
1058
1025
|
case 0:
|
|
@@ -1071,7 +1038,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1071
1038
|
var target = _ref9.target;
|
|
1072
1039
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
1073
1040
|
};
|
|
1074
|
-
|
|
1041
|
+
_renderWithValidation27 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1075
1042
|
id: ID,
|
|
1076
1043
|
entryData: ENTRY,
|
|
1077
1044
|
config: CONFIG,
|
|
@@ -1084,12 +1051,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1084
1051
|
},
|
|
1085
1052
|
masterPage: {
|
|
1086
1053
|
childPages: PAGES
|
|
1087
|
-
}
|
|
1088
|
-
inError: true
|
|
1054
|
+
}
|
|
1089
1055
|
}), {
|
|
1090
1056
|
hooks: hooks
|
|
1091
|
-
}), container =
|
|
1092
|
-
|
|
1057
|
+
}), container = _renderWithValidation27.container;
|
|
1058
|
+
_checkSetup26 = checkSetup(container), headerActionDiv = _checkSetup26.headerActionDiv;
|
|
1093
1059
|
editButton = headerActionDiv.children[0];
|
|
1094
1060
|
_react.fireEvent.click(editButton, {});
|
|
1095
1061
|
quickEdit = container.childNodes[0].childNodes[1]; // Make a change
|
|
@@ -1115,7 +1081,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1115
1081
|
}, _callee7);
|
|
1116
1082
|
})));
|
|
1117
1083
|
case 16:
|
|
1118
|
-
expect(ON_SUBMIT_CALLS[0]).
|
|
1084
|
+
expect(ON_SUBMIT_CALLS[0]).toMatchObject({
|
|
1119
1085
|
testText: 'new value'
|
|
1120
1086
|
});
|
|
1121
1087
|
expect(ON_QUICK_EDIT_CALLS.length).toEqual(0);
|
|
@@ -1126,11 +1092,10 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1126
1092
|
}, _callee8);
|
|
1127
1093
|
})));
|
|
1128
1094
|
it('should apply changes if no errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
1129
|
-
var
|
|
1095
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation28, container, _checkSetup27, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
1130
1096
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1131
1097
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1132
1098
|
case 0:
|
|
1133
|
-
inErrorValue = true;
|
|
1134
1099
|
ON_SUBMIT_CALLS = [];
|
|
1135
1100
|
hooks = {
|
|
1136
1101
|
onSubmit: function onSubmit(type, patch) {
|
|
@@ -1141,9 +1106,12 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1141
1106
|
ON_QUICK_EDIT = function ON_QUICK_EDIT(_ref12) {
|
|
1142
1107
|
var target = _ref12.target;
|
|
1143
1108
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
1144
|
-
inErrorValue = false;
|
|
1145
1109
|
};
|
|
1146
|
-
|
|
1110
|
+
_renderWithValidation28 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
1111
|
+
entryId: "id",
|
|
1112
|
+
topLevelErrors: [],
|
|
1113
|
+
clearTopLevelErrorsForCard: function clearTopLevelErrorsForCard() {}
|
|
1114
|
+
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1147
1115
|
id: ID,
|
|
1148
1116
|
entryData: {
|
|
1149
1117
|
index: 0,
|
|
@@ -1159,12 +1127,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1159
1127
|
},
|
|
1160
1128
|
masterPage: {
|
|
1161
1129
|
childPages: PAGES
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
}), {
|
|
1130
|
+
}
|
|
1131
|
+
})), {
|
|
1165
1132
|
hooks: hooks
|
|
1166
|
-
}), container =
|
|
1167
|
-
|
|
1133
|
+
}), container = _renderWithValidation28.container;
|
|
1134
|
+
_checkSetup27 = checkSetup(container), headerActionDiv = _checkSetup27.headerActionDiv;
|
|
1168
1135
|
editButton = headerActionDiv.children[0];
|
|
1169
1136
|
_react.fireEvent.click(editButton, {});
|
|
1170
1137
|
quickEdit = container.childNodes[0].childNodes[1]; // Make a change that will be accepted
|
|
@@ -1177,7 +1144,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1177
1144
|
});
|
|
1178
1145
|
quickEditButtons = quickEdit.childNodes[2];
|
|
1179
1146
|
saveButton = quickEditButtons.childNodes[0];
|
|
1180
|
-
_context10.next =
|
|
1147
|
+
_context10.next = 16;
|
|
1181
1148
|
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
1182
1149
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1183
1150
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -1189,21 +1156,97 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1189
1156
|
}
|
|
1190
1157
|
}, _callee9);
|
|
1191
1158
|
})));
|
|
1192
|
-
case
|
|
1159
|
+
case 16:
|
|
1193
1160
|
expect(ON_QUICK_EDIT_CALLS.length).toEqual(1);
|
|
1194
1161
|
expect(ON_QUICK_EDIT_CALLS[0].value[0]).toEqual({
|
|
1195
1162
|
alreadyProvidedField: 'hello',
|
|
1196
1163
|
testText: 'new value'
|
|
1197
1164
|
});
|
|
1198
|
-
|
|
1199
|
-
// Check that the inError prop is now false
|
|
1200
|
-
expect(inErrorValue).toBe(false);
|
|
1201
|
-
case 20:
|
|
1165
|
+
case 18:
|
|
1202
1166
|
case "end":
|
|
1203
1167
|
return _context10.stop();
|
|
1204
1168
|
}
|
|
1205
1169
|
}, _callee10);
|
|
1206
1170
|
})));
|
|
1171
|
+
it('should remove the isDuplicate flag on a sucessful quick edit', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1172
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation29, container, _checkSetup28, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
1173
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1174
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1175
|
+
case 0:
|
|
1176
|
+
ON_SUBMIT_CALLS = [];
|
|
1177
|
+
hooks = {
|
|
1178
|
+
onSubmit: function onSubmit(type, patch) {
|
|
1179
|
+
return ON_SUBMIT_CALLS.push(patch);
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
ON_QUICK_EDIT_CALLS = [];
|
|
1183
|
+
ON_QUICK_EDIT = function ON_QUICK_EDIT(_ref15) {
|
|
1184
|
+
var target = _ref15.target;
|
|
1185
|
+
ON_QUICK_EDIT_CALLS.push(target);
|
|
1186
|
+
};
|
|
1187
|
+
_renderWithValidation29 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
1188
|
+
entryId: "id",
|
|
1189
|
+
topLevelErrors: [],
|
|
1190
|
+
clearTopLevelErrorsForCard: function clearTopLevelErrorsForCard() {}
|
|
1191
|
+
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1192
|
+
id: ID,
|
|
1193
|
+
entryData: {
|
|
1194
|
+
index: 0,
|
|
1195
|
+
id: '0',
|
|
1196
|
+
isDuplicate: true
|
|
1197
|
+
},
|
|
1198
|
+
config: CONFIG,
|
|
1199
|
+
parentCollectionName: "parents",
|
|
1200
|
+
onQuickEdit: ON_QUICK_EDIT,
|
|
1201
|
+
formData: {
|
|
1202
|
+
parents: [{
|
|
1203
|
+
alreadyProvidedField: 'hello'
|
|
1204
|
+
}]
|
|
1205
|
+
},
|
|
1206
|
+
masterPage: {
|
|
1207
|
+
childPages: PAGES
|
|
1208
|
+
}
|
|
1209
|
+
})), {
|
|
1210
|
+
hooks: hooks
|
|
1211
|
+
}), container = _renderWithValidation29.container;
|
|
1212
|
+
_checkSetup28 = checkSetup(container), headerActionDiv = _checkSetup28.headerActionDiv;
|
|
1213
|
+
editButton = headerActionDiv.children[0];
|
|
1214
|
+
_react.fireEvent.click(editButton, {});
|
|
1215
|
+
quickEdit = container.childNodes[0].childNodes[1]; // Make a change that will be accepted
|
|
1216
|
+
component = quickEdit.childNodes[1];
|
|
1217
|
+
componentInput = component.childNodes[2];
|
|
1218
|
+
_react.fireEvent.change(componentInput, {
|
|
1219
|
+
target: {
|
|
1220
|
+
value: 'new value'
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1223
|
+
quickEditButtons = quickEdit.childNodes[2];
|
|
1224
|
+
saveButton = quickEditButtons.childNodes[0];
|
|
1225
|
+
_context12.next = 16;
|
|
1226
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
1227
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1228
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1229
|
+
case 0:
|
|
1230
|
+
_react.fireEvent.click(saveButton, {});
|
|
1231
|
+
case 1:
|
|
1232
|
+
case "end":
|
|
1233
|
+
return _context11.stop();
|
|
1234
|
+
}
|
|
1235
|
+
}, _callee11);
|
|
1236
|
+
})));
|
|
1237
|
+
case 16:
|
|
1238
|
+
expect(ON_QUICK_EDIT_CALLS.length).toEqual(1);
|
|
1239
|
+
// isDuplicate flag should not be present.
|
|
1240
|
+
expect(ON_QUICK_EDIT_CALLS[0].value[0]).toEqual({
|
|
1241
|
+
alreadyProvidedField: 'hello',
|
|
1242
|
+
testText: 'new value'
|
|
1243
|
+
});
|
|
1244
|
+
case 18:
|
|
1245
|
+
case "end":
|
|
1246
|
+
return _context12.stop();
|
|
1247
|
+
}
|
|
1248
|
+
}, _callee12);
|
|
1249
|
+
})));
|
|
1207
1250
|
});
|
|
1208
1251
|
describe('Details prop behavior', function () {
|
|
1209
1252
|
it('should render the provided details', function () {
|