@ukhomeoffice/cop-react-form-renderer 5.19.0 → 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.
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +3 -1
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +52 -0
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +1 -2
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +0 -20
- package/package.json +1 -1
|
@@ -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.
|
|
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
|
});
|
|
@@ -9,7 +9,6 @@ var _getNextPageId = _interopRequireDefault(require("./getNextPageId"));
|
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentPageId, action, formData, currentTask, isCompleted, sections) {
|
|
11
11
|
if (formType === _models.FormTypes.TASK || formType === _models.FormTypes.FORM_WITH_TASK) {
|
|
12
|
-
var _currentTask$pages;
|
|
13
12
|
var formStatus = formData.formStatus || {};
|
|
14
13
|
formStatus.tasks = formStatus.tasks || {};
|
|
15
14
|
formStatus.tasks[currentTask.name] = formStatus.tasks[currentTask.name] || {};
|
|
@@ -43,7 +42,7 @@ var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentP
|
|
|
43
42
|
complete: false,
|
|
44
43
|
currentPage: (0, _getNextPageId.default)(formType, pages, currentPageId, action, formData)
|
|
45
44
|
};
|
|
46
|
-
} else
|
|
45
|
+
} else {
|
|
47
46
|
formStatus.tasks[currentTask.name] = {
|
|
48
47
|
complete: !!(action !== null && action !== void 0 && action.complete),
|
|
49
48
|
currentPage: currentPageId
|
|
@@ -275,26 +275,6 @@ describe('components', function () {
|
|
|
275
275
|
})
|
|
276
276
|
});
|
|
277
277
|
});
|
|
278
|
-
it('should not update the current task state if the current page does not belong in the task', function () {
|
|
279
|
-
var CUSTOM_FORM_TYPE = _models.FormTypes.FORM_WITH_TASK;
|
|
280
|
-
var ACTION = _models.PageAction.DEFAULTS.saveAndContinue;
|
|
281
|
-
var CURRENT_TASK = {
|
|
282
|
-
name: 'test-task',
|
|
283
|
-
pages: ['page-a']
|
|
284
|
-
};
|
|
285
|
-
var CURRENT_PAGE_ID = 'page-b';
|
|
286
|
-
var CUSTOM_FORM_DATA = {
|
|
287
|
-
formStatus: {
|
|
288
|
-
tasks: {
|
|
289
|
-
'test-task': {
|
|
290
|
-
complete: false,
|
|
291
|
-
currentPage: 'page-a'
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
expect((0, _getSubmissionStatus.default)(CUSTOM_FORM_TYPE, PAGES, CURRENT_PAGE_ID, ACTION, CUSTOM_FORM_DATA, CURRENT_TASK, true, [])).toMatchObject(CUSTOM_FORM_DATA.formStatus);
|
|
297
|
-
});
|
|
298
278
|
});
|
|
299
279
|
});
|
|
300
280
|
});
|