@ukhomeoffice/cop-react-form-renderer 5.25.1 → 5.25.3

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.
@@ -147,7 +147,7 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
147
147
  });
148
148
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
149
149
  key: taskIndex
150
- }, /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, filterPages.length > 0 && task.name), filterPages.map(function (page, pageIndex) {
150
+ }, /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, filterPages.length > 0 && task.displayName || task.name), filterPages.map(function (page, pageIndex) {
151
151
  var hideActionButtons = isGroup(page.id) || noChangeAction;
152
152
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
153
153
  key: pageIndex
@@ -356,23 +356,37 @@ describe('components', function () {
356
356
  }
357
357
  }, _callee14);
358
358
  })));
359
- it('Show answers from multiple address fields into in one DL', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
360
- var ADDRESS_DATA, GROUP_PAGES, cya, groupedComponent, keyGroup, valueGroup, changeButtonDiv, changeButton;
359
+ it('should show task list in CYA style and priotitise displayName over name for a task', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
360
+ var sections, taskHeading1, taskHeading2;
361
361
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
362
362
  while (1) switch (_context16.prev = _context16.next) {
363
363
  case 0:
364
- ADDRESS_DATA = _utils.default.Data.setupForm(_group.default.pages, _group.default.components, _groupData.default);
365
- GROUP_PAGES = _utils.default.FormPage.getAll(_group.default.pages, _group.default.components, _objectSpread({}, ADDRESS_DATA));
366
- _context16.next = 4;
364
+ sections = [{
365
+ name: 'These are your tasks',
366
+ tasks: [{
367
+ name: 'Task 1',
368
+ displayName: 'Blue',
369
+ state: 'complete',
370
+ pages: ['names']
371
+ }, {
372
+ name: 'Task 2',
373
+ displayName: 'Red',
374
+ state: 'complete',
375
+ pages: ['grade']
376
+ }]
377
+ }];
378
+ _context16.next = 3;
367
379
  return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
368
380
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
369
381
  while (1) switch (_context15.prev = _context15.next) {
370
382
  case 0:
371
383
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
372
- pages: GROUP_PAGES,
384
+ pages: PAGES,
373
385
  onRowAction: ON_ROW_ACTION,
374
386
  onAction: ON_ACTION,
375
- hide_title: true
387
+ hide_title: true,
388
+ sections: sections,
389
+ type: "task-list-cya"
376
390
  }), container);
377
391
  case 1:
378
392
  case "end":
@@ -380,6 +394,41 @@ describe('components', function () {
380
394
  }
381
395
  }, _callee15);
382
396
  })));
397
+ case 3:
398
+ taskHeading1 = container.childNodes[0].childNodes[0];
399
+ expect(taskHeading1.textContent).toEqual('Blue');
400
+ taskHeading2 = container.childNodes[0].childNodes[2];
401
+ expect(taskHeading2.textContent).toEqual('Red');
402
+ case 7:
403
+ case "end":
404
+ return _context16.stop();
405
+ }
406
+ }, _callee16);
407
+ })));
408
+ it('Show answers from multiple address fields into in one DL', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
409
+ var ADDRESS_DATA, GROUP_PAGES, cya, groupedComponent, keyGroup, valueGroup, changeButtonDiv, changeButton;
410
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
411
+ while (1) switch (_context18.prev = _context18.next) {
412
+ case 0:
413
+ ADDRESS_DATA = _utils.default.Data.setupForm(_group.default.pages, _group.default.components, _groupData.default);
414
+ GROUP_PAGES = _utils.default.FormPage.getAll(_group.default.pages, _group.default.components, _objectSpread({}, ADDRESS_DATA));
415
+ _context18.next = 4;
416
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
417
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
418
+ while (1) switch (_context17.prev = _context17.next) {
419
+ case 0:
420
+ (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
421
+ pages: GROUP_PAGES,
422
+ onRowAction: ON_ROW_ACTION,
423
+ onAction: ON_ACTION,
424
+ hide_title: true
425
+ }), container);
426
+ case 1:
427
+ case "end":
428
+ return _context17.stop();
429
+ }
430
+ }, _callee17);
431
+ })));
383
432
  case 4:
384
433
  cya = checkCYA(container);
385
434
  groupedComponent = cya.childNodes[10];
@@ -400,20 +449,20 @@ describe('components', function () {
400
449
  expect(changeButton.textContent).toEqual('Change address details');
401
450
  case 21:
402
451
  case "end":
403
- return _context16.stop();
452
+ return _context18.stop();
404
453
  }
405
- }, _callee16);
454
+ }, _callee18);
406
455
  })));
407
- it('should render a group with one action button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
456
+ it('should render a group with one action button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
408
457
  var GROUP_PAGES, cya, namesGroup, firstNameRow, surname, changeButtonDiv, changeButton;
409
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
410
- while (1) switch (_context18.prev = _context18.next) {
458
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
459
+ while (1) switch (_context20.prev = _context20.next) {
411
460
  case 0:
412
461
  GROUP_PAGES = _utils.default.FormPage.getAll(_groupOfRow.default.pages, _groupOfRow.default.components, _objectSpread({}, DATA));
413
- _context18.next = 3;
414
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
415
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
416
- while (1) switch (_context17.prev = _context17.next) {
462
+ _context20.next = 3;
463
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
464
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
465
+ while (1) switch (_context19.prev = _context19.next) {
417
466
  case 0:
418
467
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
419
468
  pages: GROUP_PAGES,
@@ -423,9 +472,9 @@ describe('components', function () {
423
472
  }), container);
424
473
  case 1:
425
474
  case "end":
426
- return _context17.stop();
475
+ return _context19.stop();
427
476
  }
428
- }, _callee17);
477
+ }, _callee19);
429
478
  })));
430
479
  case 3:
431
480
  cya = checkCYA(container);
@@ -449,14 +498,14 @@ describe('components', function () {
449
498
  expect(changeButton.textContent).toEqual('Change names');
450
499
  case 22:
451
500
  case "end":
452
- return _context18.stop();
501
+ return _context20.stop();
453
502
  }
454
- }, _callee18);
503
+ }, _callee20);
455
504
  })));
456
- it('should show page components corrently with interpolated title and cya_label, if label is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
505
+ it('should show page components corrently with interpolated title and cya_label, if label is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
457
506
  var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$childNodes5, cyaTitle, cyaChildNode, names, _names$childNodes3, firstName, surname, _firstName$childNodes, label;
458
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
459
- while (1) switch (_context20.prev = _context20.next) {
507
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
508
+ while (1) switch (_context22.prev = _context22.next) {
460
509
  case 0:
461
510
  _PAGES = [].concat(_userProfile.default.pages); // eslint-disable-next-line no-template-curly-in-string
462
511
  _PAGES[0] = _objectSpread(_objectSpread({}, _PAGES[0]), {}, {
@@ -470,10 +519,10 @@ describe('components', function () {
470
519
  cya_label: "Text ${currentUser.familyName}"
471
520
  });
472
521
  T_PAGES = _utils.default.FormPage.getAll(_PAGES, _COMPONENTS, DATA);
473
- _context20.next = 7;
474
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
475
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
476
- while (1) switch (_context19.prev = _context19.next) {
522
+ _context22.next = 7;
523
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
524
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
525
+ while (1) switch (_context21.prev = _context21.next) {
477
526
  case 0:
478
527
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
479
528
  pages: T_PAGES,
@@ -482,9 +531,9 @@ describe('components', function () {
482
531
  }), container);
483
532
  case 1:
484
533
  case "end":
485
- return _context19.stop();
534
+ return _context21.stop();
486
535
  }
487
- }, _callee19);
536
+ }, _callee21);
488
537
  })));
489
538
  case 7:
490
539
  cya = checkCYA(container);
@@ -499,14 +548,14 @@ describe('components', function () {
499
548
  checkRow(surname, 'Last name', 'Smith', false);
500
549
  case 17:
501
550
  case "end":
502
- return _context20.stop();
551
+ return _context22.stop();
503
552
  }
504
- }, _callee20);
553
+ }, _callee22);
505
554
  })));
506
- it('should show page components corrently with no label, if label and cya_label are missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
555
+ it('should show page components corrently with no label, if label and cya_label are missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
507
556
  var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$childNodes6, cyaChildNode, names, _names$childNodes4, firstName, surname, _firstName$childNodes2, label;
508
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
509
- while (1) switch (_context22.prev = _context22.next) {
557
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
558
+ while (1) switch (_context24.prev = _context24.next) {
510
559
  case 0:
511
560
  _PAGES = [].concat(_userProfile.default.pages);
512
561
  _COMPONENTS = [].concat(_userProfile.default.components);
@@ -516,10 +565,10 @@ describe('components', function () {
516
565
  cya_label: undefined
517
566
  });
518
567
  T_PAGES = _utils.default.FormPage.getAll(_PAGES, _COMPONENTS, _objectSpread({}, DATA));
519
- _context22.next = 6;
520
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
521
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
522
- while (1) switch (_context21.prev = _context21.next) {
568
+ _context24.next = 6;
569
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
570
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
571
+ while (1) switch (_context23.prev = _context23.next) {
523
572
  case 0:
524
573
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
525
574
  pages: T_PAGES,
@@ -528,9 +577,9 @@ describe('components', function () {
528
577
  }), container);
529
578
  case 1:
530
579
  case "end":
531
- return _context21.stop();
580
+ return _context23.stop();
532
581
  }
533
- }, _callee21);
582
+ }, _callee23);
534
583
  })));
535
584
  case 6:
536
585
  cya = checkCYA(container);
@@ -544,14 +593,14 @@ describe('components', function () {
544
593
  checkRow(surname, 'Last name', 'Smith', false);
545
594
  case 15:
546
595
  case "end":
547
- return _context22.stop();
596
+ return _context24.stop();
548
597
  }
549
- }, _callee22);
598
+ }, _callee24);
550
599
  })));
551
- it('should show task list in CYA style and hide pages from skipped tasks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
600
+ it('should show task list in CYA style and hide pages from skipped tasks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
552
601
  var sections, taskHeading1, namesPageHeading;
553
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
554
- while (1) switch (_context24.prev = _context24.next) {
602
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
603
+ while (1) switch (_context26.prev = _context26.next) {
555
604
  case 0:
556
605
  sections = [{
557
606
  name: 'These are your tasks',
@@ -565,10 +614,10 @@ describe('components', function () {
565
614
  pages: ['grade']
566
615
  }]
567
616
  }];
568
- _context24.next = 3;
569
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
570
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
571
- while (1) switch (_context23.prev = _context23.next) {
617
+ _context26.next = 3;
618
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
619
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
620
+ while (1) switch (_context25.prev = _context25.next) {
572
621
  case 0:
573
622
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
574
623
  pages: PAGES,
@@ -580,9 +629,9 @@ describe('components', function () {
580
629
  }), container);
581
630
  case 1:
582
631
  case "end":
583
- return _context23.stop();
632
+ return _context25.stop();
584
633
  }
585
- }, _callee23);
634
+ }, _callee25);
586
635
  })));
587
636
  case 3:
588
637
  taskHeading1 = container.childNodes[0].childNodes[0];
@@ -596,9 +645,9 @@ describe('components', function () {
596
645
  expect(container.childNodes[0].childNodes.length).toEqual(2); // second task skipped so not shown
597
646
  case 12:
598
647
  case "end":
599
- return _context24.stop();
648
+ return _context26.stop();
600
649
  }
601
- }, _callee24);
650
+ }, _callee26);
602
651
  })));
603
652
  });
604
653
  });
@@ -156,7 +156,7 @@ var getCYARowsForChildPages = function getCYARowsForChildPages(childPages, item,
156
156
  rows = rows.concat(headingRow);
157
157
  }
158
158
  var container = getContainerForPage(childPage, item, labelCount, fullPath);
159
- var rowChangeAction = getChangeActionForPage(childPage, item, onAction, activeIds);
159
+ var rowChangeAction = getChangeActionForPage(childPage, onAction, activeIds);
160
160
  var containerRows = (0, _getCYARowsForContainer.default)(childPage, container, item, rowChangeAction, fnOverride);
161
161
  rows = rows.concat(containerRows);
162
162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "5.25.1",
3
+ "version": "5.25.3",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",