@ukhomeoffice/cop-react-form-renderer 5.19.1 → 5.19.2

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.
@@ -137,7 +137,9 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
137
137
  }, title), errors && errors.length > 0 && /*#__PURE__*/_react.default.createElement(_copReactComponents.ErrorSummary, {
138
138
  errors: errors
139
139
  }), type === _models.FormTypes.TASK_CYA && pages.length > 0 && sections && sections.map(function (section) {
140
- return section.tasks.map(function (task, taskIndex) {
140
+ return section.tasks.filter(function (task) {
141
+ return task.state !== _models.TaskStates.TYPES.SKIPPED;
142
+ }).map(function (task, taskIndex) {
141
143
  var filterPages = pages.filter(function (page) {
142
144
  return task.pages.some(function (p) {
143
145
  return p === page.name;
@@ -548,5 +548,57 @@ describe('components', function () {
548
548
  }
549
549
  }, _callee22);
550
550
  })));
551
+ it('should show task list in CYA style and hide pages from skipped tasks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
552
+ var sections, taskHeading1, namesPageHeading;
553
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
554
+ while (1) switch (_context24.prev = _context24.next) {
555
+ case 0:
556
+ sections = [{
557
+ name: 'These are your tasks',
558
+ tasks: [{
559
+ name: 'Task 1',
560
+ state: 'complete',
561
+ pages: ['names']
562
+ }, {
563
+ name: 'Task 2',
564
+ state: 'skipped',
565
+ pages: ['grade']
566
+ }]
567
+ }];
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) {
572
+ case 0:
573
+ (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
574
+ pages: PAGES,
575
+ onRowAction: ON_ROW_ACTION,
576
+ onAction: ON_ACTION,
577
+ hide_title: true,
578
+ sections: sections,
579
+ type: "task-list-cya"
580
+ }), container);
581
+ case 1:
582
+ case "end":
583
+ return _context23.stop();
584
+ }
585
+ }, _callee23);
586
+ })));
587
+ case 3:
588
+ taskHeading1 = container.childNodes[0].childNodes[0];
589
+ expect(taskHeading1.tagName).toEqual('H2');
590
+ expect(taskHeading1.textContent).toEqual('Task 1');
591
+ expect(taskHeading1.classList).toContain("govuk-heading-m");
592
+ namesPageHeading = container.childNodes[0].childNodes[1];
593
+ expect(namesPageHeading.tagName).toEqual('DIV');
594
+ expect(namesPageHeading.textContent).toContain('John');
595
+ expect(namesPageHeading.classList).toContain("group-of-rows");
596
+ expect(container.childNodes[0].childNodes.length).toEqual(2); // second task skipped so not shown
597
+ case 12:
598
+ case "end":
599
+ return _context24.stop();
600
+ }
601
+ }, _callee24);
602
+ })));
551
603
  });
552
604
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "5.19.1",
3
+ "version": "5.19.2",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",