@ukhomeoffice/cop-react-form-renderer 5.62.1 → 5.65.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.
Files changed (22) hide show
  1. package/dist/components/CollectionSummary/BannerStrip.js +3 -2
  2. package/dist/components/CollectionSummary/BannerStrip.test.js +39 -4
  3. package/dist/components/CollectionSummary/CollectionSummary.js +71 -33
  4. package/dist/components/CollectionSummary/CollectionSummary.test.js +40 -80
  5. package/dist/components/CollectionSummary/RenderListView.js +9 -7
  6. package/dist/components/CollectionSummary/RenderListView.scss +4 -0
  7. package/dist/components/CollectionSummary/RenderListView.test.js +13 -4
  8. package/dist/components/CollectionSummary/SummaryCard.js +26 -17
  9. package/dist/components/CollectionSummary/SummaryCard.test.js +177 -146
  10. package/dist/components/CollectionSummary/SummaryCardDetails.js +16 -0
  11. package/dist/components/CollectionSummary/SummaryCardDetails.test.js +77 -8
  12. package/dist/components/CollectionSummary/SummaryCardValidationContext.js +15 -5
  13. package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +5 -4
  14. package/dist/components/FormRenderer/onPageAction.js +6 -1
  15. package/dist/components/FormRenderer/onPageAction.test.js +18 -4
  16. package/dist/context/ValidationContext/ValidationContext.js +51 -5
  17. package/dist/context/ValidationContext/ValidationContext.test.js +16 -7
  18. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +13 -1
  19. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +17 -2
  20. package/dist/utils/Validate/validatePage.js +6 -1
  21. package/dist/utils/Validate/validatePage.test.js +44 -0
  22. package/package.json +1 -1
@@ -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 = [];
@@ -265,7 +263,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
265
263
  id: ID,
266
264
  entryData: ENTRY,
267
265
  config: CONFIG,
268
- onChange: ON_CHANGE,
266
+ onFullEdit: ON_CHANGE,
269
267
  parentCollectionName: "parent",
270
268
  formData: {},
271
269
  masterPage: {
@@ -286,10 +284,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
286
284
  id: ENTRY.id
287
285
  });
288
286
  });
289
- it('should render correctly when inError is true', function () {
287
+ it('should use the default label when one is not provided', function () {
290
288
  var CONFIG = {
291
289
  changeAction: {
292
- label: 'Change label',
293
290
  page: 'testPage'
294
291
  }
295
292
  };
@@ -297,13 +294,12 @@ describe('components.CollectionSummary.SummaryCard', function () {
297
294
  id: ID,
298
295
  entryData: ENTRY,
299
296
  config: CONFIG,
300
- onChange: ON_CHANGE,
297
+ onFullEdit: ON_CHANGE,
301
298
  parentCollectionName: "parent",
302
299
  formData: {},
303
300
  masterPage: {
304
301
  childPages: []
305
- },
306
- inError: inErrorValue
302
+ }
307
303
  })),
308
304
  container = _renderWithValidation8.container;
309
305
  var _checkSetup8 = checkSetup(container),
@@ -311,27 +307,13 @@ describe('components.CollectionSummary.SummaryCard', function () {
311
307
  expect(headerActionDiv.children.length).toEqual(1);
312
308
  var changeButton = headerActionDiv.children[0];
313
309
  expect(changeButton.tagName).toEqual('BUTTON');
314
- expect(changeButton.textContent).toEqual(CONFIG.changeAction.label);
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);
310
+ expect(changeButton.textContent).toEqual(_SummaryCard.DEFAULT_CHANGE_BUTTON_LABEL);
324
311
  });
325
- it('should use the default label when one is not provided', function () {
326
- var CONFIG = {
327
- changeAction: {
328
- page: 'testPage'
329
- }
330
- };
312
+ it('should not render when no config is provided for it', function () {
331
313
  var _renderWithValidation9 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
332
314
  id: ID,
333
315
  entryData: ENTRY,
334
- config: CONFIG,
316
+ config: {},
335
317
  onChange: ON_CHANGE,
336
318
  parentCollectionName: "parent",
337
319
  formData: {},
@@ -342,26 +324,6 @@ describe('components.CollectionSummary.SummaryCard', function () {
342
324
  container = _renderWithValidation9.container;
343
325
  var _checkSetup9 = checkSetup(container),
344
326
  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
327
  expect(headerActionDiv.children.length).toEqual(0);
366
328
  });
367
329
  it('should not render when onChange is not supplied', function () {
@@ -371,7 +333,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
371
333
  page: 'testPage'
372
334
  }
373
335
  };
374
- var _renderWithValidation11 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
336
+ var _renderWithValidation10 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
375
337
  id: ID,
376
338
  entryData: ENTRY,
377
339
  config: CONFIG,
@@ -381,9 +343,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
381
343
  childPages: []
382
344
  }
383
345
  })),
384
- container = _renderWithValidation11.container;
385
- var _checkSetup11 = checkSetup(container),
386
- headerActionDiv = _checkSetup11.headerActionDiv;
346
+ container = _renderWithValidation10.container;
347
+ var _checkSetup10 = checkSetup(container),
348
+ headerActionDiv = _checkSetup10.headerActionDiv;
387
349
  expect(headerActionDiv.children.length).toEqual(0);
388
350
  });
389
351
  });
@@ -404,7 +366,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
404
366
  label: 'Delete label'
405
367
  }
406
368
  };
407
- var _renderWithValidation12 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
369
+ var _renderWithValidation11 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
408
370
  id: ID,
409
371
  entryData: ENTRY,
410
372
  config: CONFIG,
@@ -415,9 +377,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
415
377
  childPages: []
416
378
  }
417
379
  })),
418
- container = _renderWithValidation12.container;
419
- var _checkSetup12 = checkSetup(container),
420
- headerActionDiv = _checkSetup12.headerActionDiv;
380
+ container = _renderWithValidation11.container;
381
+ var _checkSetup11 = checkSetup(container),
382
+ headerActionDiv = _checkSetup11.headerActionDiv;
421
383
  expect(headerActionDiv.children.length).toEqual(1);
422
384
  var deleteButton = headerActionDiv.children[0];
423
385
  expect(deleteButton.tagName).toEqual('BUTTON');
@@ -430,7 +392,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
430
392
  var CONFIG = {
431
393
  deleteAction: {}
432
394
  };
433
- var _renderWithValidation13 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
395
+ var _renderWithValidation12 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
434
396
  id: ID,
435
397
  entryData: ENTRY,
436
398
  config: CONFIG,
@@ -441,16 +403,16 @@ describe('components.CollectionSummary.SummaryCard', function () {
441
403
  childPages: []
442
404
  }
443
405
  })),
444
- container = _renderWithValidation13.container;
445
- var _checkSetup13 = checkSetup(container),
446
- headerActionDiv = _checkSetup13.headerActionDiv;
406
+ container = _renderWithValidation12.container;
407
+ var _checkSetup12 = checkSetup(container),
408
+ headerActionDiv = _checkSetup12.headerActionDiv;
447
409
  expect(headerActionDiv.children.length).toEqual(1);
448
410
  var deleteButton = headerActionDiv.children[0];
449
411
  expect(deleteButton.tagName).toEqual('BUTTON');
450
412
  expect(deleteButton.textContent).toEqual(_SummaryCard.DEFAULT_DELETE_BUTTON_LABEL);
451
413
  });
452
414
  it('should not render when no config is provided for it', function () {
453
- var _renderWithValidation14 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
415
+ var _renderWithValidation13 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
454
416
  id: ID,
455
417
  entryData: ENTRY,
456
418
  config: {},
@@ -461,9 +423,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
461
423
  childPages: []
462
424
  }
463
425
  })),
464
- container = _renderWithValidation14.container;
465
- var _checkSetup14 = checkSetup(container),
466
- headerActionDiv = _checkSetup14.headerActionDiv;
426
+ container = _renderWithValidation13.container;
427
+ var _checkSetup13 = checkSetup(container),
428
+ headerActionDiv = _checkSetup13.headerActionDiv;
467
429
  expect(headerActionDiv.children.length).toEqual(0);
468
430
  });
469
431
  it('should not render when onDelete is not supplied', function () {
@@ -472,7 +434,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
472
434
  label: 'Delete label'
473
435
  }
474
436
  };
475
- var _renderWithValidation15 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
437
+ var _renderWithValidation14 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
476
438
  id: ID,
477
439
  entryData: ENTRY,
478
440
  config: CONFIG,
@@ -482,9 +444,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
482
444
  childPages: []
483
445
  }
484
446
  })),
485
- container = _renderWithValidation15.container;
486
- var _checkSetup15 = checkSetup(container),
487
- headerActionDiv = _checkSetup15.headerActionDiv;
447
+ container = _renderWithValidation14.container;
448
+ var _checkSetup14 = checkSetup(container),
449
+ headerActionDiv = _checkSetup14.headerActionDiv;
488
450
  expect(headerActionDiv.children.length).toEqual(0);
489
451
  });
490
452
  it('should correctly render the Details section with entry data', function () {
@@ -493,7 +455,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
493
455
  label: 'Delete label'
494
456
  }
495
457
  };
496
- var _renderWithValidation16 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
458
+ var _renderWithValidation15 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
497
459
  id: ID,
498
460
  entryData: ENTRY,
499
461
  config: CONFIG,
@@ -503,7 +465,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
503
465
  childPages: []
504
466
  }
505
467
  })),
506
- container = _renderWithValidation16.container;
468
+ container = _renderWithValidation15.container;
507
469
  var detailsSection = container.querySelector('.details');
508
470
  expect(detailsSection).not.toBeNull();
509
471
  expect(detailsSection.textContent).toContain(ENTRY.summaryText);
@@ -526,7 +488,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
526
488
  label: 'Duplicate label'
527
489
  }
528
490
  };
529
- var _renderWithValidation17 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
491
+ var _renderWithValidation16 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
530
492
  id: ID,
531
493
  entryData: ENTRY,
532
494
  config: CONFIG,
@@ -537,9 +499,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
537
499
  childPages: []
538
500
  }
539
501
  })),
540
- container = _renderWithValidation17.container;
541
- var _checkSetup16 = checkSetup(container),
542
- headerActionDiv = _checkSetup16.headerActionDiv;
502
+ container = _renderWithValidation16.container;
503
+ var _checkSetup15 = checkSetup(container),
504
+ headerActionDiv = _checkSetup15.headerActionDiv;
543
505
  expect(headerActionDiv.children.length).toEqual(1);
544
506
  var duplicateButton = headerActionDiv.children[0];
545
507
  expect(duplicateButton.tagName).toEqual('BUTTON');
@@ -552,7 +514,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
552
514
  var CONFIG = {
553
515
  duplicateAction: {}
554
516
  };
555
- var _renderWithValidation18 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
517
+ var _renderWithValidation17 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
556
518
  id: ID,
557
519
  entryData: ENTRY,
558
520
  config: CONFIG,
@@ -563,16 +525,16 @@ describe('components.CollectionSummary.SummaryCard', function () {
563
525
  childPages: []
564
526
  }
565
527
  })),
566
- container = _renderWithValidation18.container;
567
- var _checkSetup17 = checkSetup(container),
568
- headerActionDiv = _checkSetup17.headerActionDiv;
528
+ container = _renderWithValidation17.container;
529
+ var _checkSetup16 = checkSetup(container),
530
+ headerActionDiv = _checkSetup16.headerActionDiv;
569
531
  expect(headerActionDiv.children.length).toEqual(1);
570
532
  var duplicateButton = headerActionDiv.children[0];
571
533
  expect(duplicateButton.tagName).toEqual('BUTTON');
572
534
  expect(duplicateButton.textContent).toEqual(_SummaryCard.DEFAULT_DUPLICATE_BUTTON_LABEL);
573
535
  });
574
536
  it('should not render when no config is provided for it', function () {
575
- var _renderWithValidation19 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
537
+ var _renderWithValidation18 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
576
538
  id: ID,
577
539
  entryData: ENTRY,
578
540
  config: {},
@@ -583,9 +545,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
583
545
  childPages: []
584
546
  }
585
547
  })),
586
- container = _renderWithValidation19.container;
587
- var _checkSetup18 = checkSetup(container),
588
- headerActionDiv = _checkSetup18.headerActionDiv;
548
+ container = _renderWithValidation18.container;
549
+ var _checkSetup17 = checkSetup(container),
550
+ headerActionDiv = _checkSetup17.headerActionDiv;
589
551
  expect(headerActionDiv.children.length).toEqual(0);
590
552
  });
591
553
  it('should not render when onDuplicate is not supplied', function () {
@@ -594,7 +556,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
594
556
  label: 'Duplicate label'
595
557
  }
596
558
  };
597
- var _renderWithValidation20 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
559
+ var _renderWithValidation19 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
598
560
  id: ID,
599
561
  entryData: ENTRY,
600
562
  config: CONFIG,
@@ -604,9 +566,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
604
566
  childPages: []
605
567
  }
606
568
  })),
607
- container = _renderWithValidation20.container;
608
- var _checkSetup19 = checkSetup(container),
609
- headerActionDiv = _checkSetup19.headerActionDiv;
569
+ container = _renderWithValidation19.container;
570
+ var _checkSetup18 = checkSetup(container),
571
+ headerActionDiv = _checkSetup18.headerActionDiv;
610
572
  expect(headerActionDiv.children.length).toEqual(0);
611
573
  });
612
574
  });
@@ -638,7 +600,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
638
600
  }
639
601
  }];
640
602
  it('should render correctly', function () {
641
- var _renderWithValidation21 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
603
+ var _renderWithValidation20 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
642
604
  id: ID,
643
605
  entryData: ENTRY,
644
606
  config: CONFIG,
@@ -646,12 +608,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
646
608
  formData: {},
647
609
  masterPage: {
648
610
  childPages: PAGES
649
- },
650
- inError: true
611
+ }
651
612
  })),
652
- container = _renderWithValidation21.container;
653
- var _checkSetup20 = checkSetup(container),
654
- headerActionDiv = _checkSetup20.headerActionDiv;
613
+ container = _renderWithValidation20.container;
614
+ var _checkSetup19 = checkSetup(container),
615
+ headerActionDiv = _checkSetup19.headerActionDiv;
655
616
  expect(headerActionDiv.children.length).toEqual(1);
656
617
 
657
618
  // Shows edit button but no quick edit
@@ -679,7 +640,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
679
640
  });
680
641
 
681
642
  it('should not render when no config is provided for it', function () {
682
- var _renderWithValidation22 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
643
+ var _renderWithValidation21 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
683
644
  id: ID,
684
645
  entryData: ENTRY,
685
646
  config: {},
@@ -687,12 +648,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
687
648
  formData: {},
688
649
  masterPage: {
689
650
  childPages: PAGES
690
- },
691
- inError: true
651
+ }
692
652
  })),
693
- container = _renderWithValidation22.container;
694
- var _checkSetup21 = checkSetup(container),
695
- headerActionDiv = _checkSetup21.headerActionDiv;
653
+ container = _renderWithValidation21.container;
654
+ var _checkSetup20 = checkSetup(container),
655
+ headerActionDiv = _checkSetup20.headerActionDiv;
696
656
  expect(headerActionDiv.children.length).toEqual(0);
697
657
  });
698
658
  });
@@ -735,7 +695,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
735
695
  entryId: '123',
736
696
  error: 'top-level error message'
737
697
  }];
738
- var _renderWithValidation23 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
698
+ var _renderWithValidation22 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
739
699
  entryId: CUSTOM_ENTRY.id,
740
700
  topLevelErrors: TOP_LEVEL_ERRORS
741
701
  }, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
@@ -746,12 +706,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
746
706
  formData: {},
747
707
  masterPage: {
748
708
  childPages: PAGES
749
- },
750
- inError: true
709
+ }
751
710
  }))),
752
- container = _renderWithValidation23.container;
753
- var _checkSetup22 = checkSetup(container),
754
- headerActionDiv = _checkSetup22.headerActionDiv;
711
+ container = _renderWithValidation22.container;
712
+ var _checkSetup21 = checkSetup(container),
713
+ headerActionDiv = _checkSetup21.headerActionDiv;
755
714
  expect(headerActionDiv.children.length).toEqual(1);
756
715
 
757
716
  // Shows edit button but no quick edit
@@ -771,7 +730,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
771
730
  expect(errorSummary.textContent).toContain(TOP_LEVEL_ERRORS[0].error);
772
731
  });
773
732
  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, _renderWithValidation24, container, _checkSetup23, headerActionDiv, editButton, quickEdit, errorSummary, component, componentInput, quickEditButtons, saveButton;
733
+ var TOP_LEVEL_ERRORS, _renderWithValidation23, container, _checkSetup22, headerActionDiv, editButton, quickEdit, errorSummary, component, componentInput, quickEditButtons, saveButton;
775
734
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
776
735
  while (1) switch (_context3.prev = _context3.next) {
777
736
  case 0:
@@ -780,7 +739,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
780
739
  entryId: '123',
781
740
  error: 'top-level error message'
782
741
  }];
783
- _renderWithValidation24 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
742
+ _renderWithValidation23 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
784
743
  entryId: CUSTOM_ENTRY.id,
785
744
  topLevelErrors: TOP_LEVEL_ERRORS
786
745
  }, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
@@ -792,10 +751,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
792
751
  masterPage: {
793
752
  childPages: PAGES
794
753
  },
795
- onQuickEdit: function onQuickEdit() {},
796
- inError: true
797
- }))), container = _renderWithValidation24.container;
798
- _checkSetup23 = checkSetup(container), headerActionDiv = _checkSetup23.headerActionDiv;
754
+ onQuickEdit: function onQuickEdit() {}
755
+ }))), container = _renderWithValidation23.container;
756
+ _checkSetup22 = checkSetup(container), headerActionDiv = _checkSetup22.headerActionDiv;
799
757
  expect(headerActionDiv.children.length).toEqual(1);
800
758
 
801
759
  // Shows edit button but no quick edit
@@ -894,7 +852,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
894
852
  }
895
853
  }];
896
854
  it('should render correctly', function () {
897
- var _renderWithValidation25 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
855
+ var _renderWithValidation24 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
898
856
  id: ID,
899
857
  entryData: ENTRY,
900
858
  config: CONFIG,
@@ -902,12 +860,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
902
860
  formData: {},
903
861
  masterPage: {
904
862
  childPages: PAGES
905
- },
906
- inError: true
863
+ }
907
864
  })),
908
- container = _renderWithValidation25.container;
909
- var _checkSetup24 = checkSetup(container),
910
- headerActionDiv = _checkSetup24.headerActionDiv;
865
+ container = _renderWithValidation24.container;
866
+ var _checkSetup23 = checkSetup(container),
867
+ headerActionDiv = _checkSetup23.headerActionDiv;
911
868
  expect(headerActionDiv.children.length).toEqual(1);
912
869
 
913
870
  // Shows edit button but no quick edit
@@ -941,7 +898,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
941
898
  return ON_SUBMIT_CALLS.push(patch);
942
899
  }
943
900
  };
944
- var _renderWithValidation26 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
901
+ var _renderWithValidation25 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
945
902
  id: ID,
946
903
  entryData: ENTRY,
947
904
  config: CONFIG,
@@ -949,14 +906,13 @@ describe('components.CollectionSummary.SummaryCard', function () {
949
906
  formData: {},
950
907
  masterPage: {
951
908
  childPages: PAGES
952
- },
953
- inError: true
909
+ }
954
910
  }), {
955
911
  hooks: hooks
956
912
  }),
957
- container = _renderWithValidation26.container;
958
- var _checkSetup25 = checkSetup(container),
959
- headerActionDiv = _checkSetup25.headerActionDiv;
913
+ container = _renderWithValidation25.container;
914
+ var _checkSetup24 = checkSetup(container),
915
+ headerActionDiv = _checkSetup24.headerActionDiv;
960
916
 
961
917
  // Shows edit button but no quick edit
962
918
  var editButton = headerActionDiv.children[0];
@@ -970,7 +926,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
970
926
  expect(ON_SUBMIT_CALLS.length).toEqual(0);
971
927
  });
972
928
  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, _renderWithValidation27, container, _checkSetup26, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
929
+ var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation26, container, _checkSetup25, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
974
930
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
975
931
  while (1) switch (_context6.prev = _context6.next) {
976
932
  case 0:
@@ -985,7 +941,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
985
941
  var target = _ref5.target;
986
942
  ON_QUICK_EDIT_CALLS.push(target);
987
943
  };
988
- _renderWithValidation27 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
944
+ _renderWithValidation26 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
989
945
  id: ID,
990
946
  entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
991
947
  index: 0
@@ -1000,12 +956,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
1000
956
  },
1001
957
  masterPage: {
1002
958
  childPages: PAGES
1003
- },
1004
- inError: true
959
+ }
1005
960
  }), {
1006
961
  hooks: hooks
1007
- }), container = _renderWithValidation27.container;
1008
- _checkSetup26 = checkSetup(container), headerActionDiv = _checkSetup26.headerActionDiv;
962
+ }), container = _renderWithValidation26.container;
963
+ _checkSetup25 = checkSetup(container), headerActionDiv = _checkSetup25.headerActionDiv;
1009
964
  editButton = headerActionDiv.children[0];
1010
965
  _react.fireEvent.click(editButton, {});
1011
966
  quickEdit = container.childNodes[0].childNodes[1];
@@ -1052,7 +1007,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
1052
1007
  }, _callee6);
1053
1008
  })));
1054
1009
  it('should run hook validation when a value changes and local validation is passed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1055
- var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation28, container, _checkSetup27, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
1010
+ var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation27, container, _checkSetup26, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
1056
1011
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1057
1012
  while (1) switch (_context8.prev = _context8.next) {
1058
1013
  case 0:
@@ -1071,7 +1026,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
1071
1026
  var target = _ref9.target;
1072
1027
  ON_QUICK_EDIT_CALLS.push(target);
1073
1028
  };
1074
- _renderWithValidation28 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1029
+ _renderWithValidation27 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1075
1030
  id: ID,
1076
1031
  entryData: ENTRY,
1077
1032
  config: CONFIG,
@@ -1084,12 +1039,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
1084
1039
  },
1085
1040
  masterPage: {
1086
1041
  childPages: PAGES
1087
- },
1088
- inError: true
1042
+ }
1089
1043
  }), {
1090
1044
  hooks: hooks
1091
- }), container = _renderWithValidation28.container;
1092
- _checkSetup27 = checkSetup(container), headerActionDiv = _checkSetup27.headerActionDiv;
1045
+ }), container = _renderWithValidation27.container;
1046
+ _checkSetup26 = checkSetup(container), headerActionDiv = _checkSetup26.headerActionDiv;
1093
1047
  editButton = headerActionDiv.children[0];
1094
1048
  _react.fireEvent.click(editButton, {});
1095
1049
  quickEdit = container.childNodes[0].childNodes[1]; // Make a change
@@ -1126,11 +1080,10 @@ describe('components.CollectionSummary.SummaryCard', function () {
1126
1080
  }, _callee8);
1127
1081
  })));
1128
1082
  it('should apply changes if no errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1129
- var inErrorValue, ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation29, container, _checkSetup28, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
1083
+ var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation28, container, _checkSetup27, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
1130
1084
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1131
1085
  while (1) switch (_context10.prev = _context10.next) {
1132
1086
  case 0:
1133
- inErrorValue = true;
1134
1087
  ON_SUBMIT_CALLS = [];
1135
1088
  hooks = {
1136
1089
  onSubmit: function onSubmit(type, patch) {
@@ -1141,9 +1094,12 @@ describe('components.CollectionSummary.SummaryCard', function () {
1141
1094
  ON_QUICK_EDIT = function ON_QUICK_EDIT(_ref12) {
1142
1095
  var target = _ref12.target;
1143
1096
  ON_QUICK_EDIT_CALLS.push(target);
1144
- inErrorValue = false;
1145
1097
  };
1146
- _renderWithValidation29 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1098
+ _renderWithValidation28 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
1099
+ entryId: "id",
1100
+ topLevelErrors: [],
1101
+ clearTopLevelErrorsForCard: function clearTopLevelErrorsForCard() {}
1102
+ }, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1147
1103
  id: ID,
1148
1104
  entryData: {
1149
1105
  index: 0,
@@ -1159,12 +1115,11 @@ describe('components.CollectionSummary.SummaryCard', function () {
1159
1115
  },
1160
1116
  masterPage: {
1161
1117
  childPages: PAGES
1162
- },
1163
- inError: inErrorValue
1164
- }), {
1118
+ }
1119
+ })), {
1165
1120
  hooks: hooks
1166
- }), container = _renderWithValidation29.container;
1167
- _checkSetup28 = checkSetup(container), headerActionDiv = _checkSetup28.headerActionDiv;
1121
+ }), container = _renderWithValidation28.container;
1122
+ _checkSetup27 = checkSetup(container), headerActionDiv = _checkSetup27.headerActionDiv;
1168
1123
  editButton = headerActionDiv.children[0];
1169
1124
  _react.fireEvent.click(editButton, {});
1170
1125
  quickEdit = container.childNodes[0].childNodes[1]; // Make a change that will be accepted
@@ -1177,7 +1132,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
1177
1132
  });
1178
1133
  quickEditButtons = quickEdit.childNodes[2];
1179
1134
  saveButton = quickEditButtons.childNodes[0];
1180
- _context10.next = 17;
1135
+ _context10.next = 16;
1181
1136
  return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1182
1137
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1183
1138
  while (1) switch (_context9.prev = _context9.next) {
@@ -1189,21 +1144,97 @@ describe('components.CollectionSummary.SummaryCard', function () {
1189
1144
  }
1190
1145
  }, _callee9);
1191
1146
  })));
1192
- case 17:
1147
+ case 16:
1193
1148
  expect(ON_QUICK_EDIT_CALLS.length).toEqual(1);
1194
1149
  expect(ON_QUICK_EDIT_CALLS[0].value[0]).toEqual({
1195
1150
  alreadyProvidedField: 'hello',
1196
1151
  testText: 'new value'
1197
1152
  });
1198
-
1199
- // Check that the inError prop is now false
1200
- expect(inErrorValue).toBe(false);
1201
- case 20:
1153
+ case 18:
1202
1154
  case "end":
1203
1155
  return _context10.stop();
1204
1156
  }
1205
1157
  }, _callee10);
1206
1158
  })));
1159
+ it('should remove the isDuplicate flag on a sucessful quick edit', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1160
+ var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation29, container, _checkSetup28, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
1161
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1162
+ while (1) switch (_context12.prev = _context12.next) {
1163
+ case 0:
1164
+ ON_SUBMIT_CALLS = [];
1165
+ hooks = {
1166
+ onSubmit: function onSubmit(type, patch) {
1167
+ return ON_SUBMIT_CALLS.push(patch);
1168
+ }
1169
+ };
1170
+ ON_QUICK_EDIT_CALLS = [];
1171
+ ON_QUICK_EDIT = function ON_QUICK_EDIT(_ref15) {
1172
+ var target = _ref15.target;
1173
+ ON_QUICK_EDIT_CALLS.push(target);
1174
+ };
1175
+ _renderWithValidation29 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
1176
+ entryId: "id",
1177
+ topLevelErrors: [],
1178
+ clearTopLevelErrorsForCard: function clearTopLevelErrorsForCard() {}
1179
+ }, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
1180
+ id: ID,
1181
+ entryData: {
1182
+ index: 0,
1183
+ id: '0',
1184
+ isDuplicate: true
1185
+ },
1186
+ config: CONFIG,
1187
+ parentCollectionName: "parents",
1188
+ onQuickEdit: ON_QUICK_EDIT,
1189
+ formData: {
1190
+ parents: [{
1191
+ alreadyProvidedField: 'hello'
1192
+ }]
1193
+ },
1194
+ masterPage: {
1195
+ childPages: PAGES
1196
+ }
1197
+ })), {
1198
+ hooks: hooks
1199
+ }), container = _renderWithValidation29.container;
1200
+ _checkSetup28 = checkSetup(container), headerActionDiv = _checkSetup28.headerActionDiv;
1201
+ editButton = headerActionDiv.children[0];
1202
+ _react.fireEvent.click(editButton, {});
1203
+ quickEdit = container.childNodes[0].childNodes[1]; // Make a change that will be accepted
1204
+ component = quickEdit.childNodes[1];
1205
+ componentInput = component.childNodes[2];
1206
+ _react.fireEvent.change(componentInput, {
1207
+ target: {
1208
+ value: 'new value'
1209
+ }
1210
+ });
1211
+ quickEditButtons = quickEdit.childNodes[2];
1212
+ saveButton = quickEditButtons.childNodes[0];
1213
+ _context12.next = 16;
1214
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
1215
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1216
+ while (1) switch (_context11.prev = _context11.next) {
1217
+ case 0:
1218
+ _react.fireEvent.click(saveButton, {});
1219
+ case 1:
1220
+ case "end":
1221
+ return _context11.stop();
1222
+ }
1223
+ }, _callee11);
1224
+ })));
1225
+ case 16:
1226
+ expect(ON_QUICK_EDIT_CALLS.length).toEqual(1);
1227
+ // isDuplicate flag should not be present.
1228
+ expect(ON_QUICK_EDIT_CALLS[0].value[0]).toEqual({
1229
+ alreadyProvidedField: 'hello',
1230
+ testText: 'new value'
1231
+ });
1232
+ case 18:
1233
+ case "end":
1234
+ return _context12.stop();
1235
+ }
1236
+ }, _callee12);
1237
+ })));
1207
1238
  });
1208
1239
  describe('Details prop behavior', function () {
1209
1240
  it('should render the provided details', function () {