@ukhomeoffice/cop-react-form-renderer 4.56.0 → 4.56.1
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.
|
@@ -70,16 +70,18 @@ var TaskList = function TaskList(_ref) {
|
|
|
70
70
|
var classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className); //TODO state will be retrieved from a document in S3 rather than given in the component definition, covered under COP-9885
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
var _sections$
|
|
73
|
+
var _sections$filter$redu = sections.filter(function (section) {
|
|
74
|
+
return !section.skipped;
|
|
75
|
+
}).reduce(function (acc, current) {
|
|
74
76
|
var _current$tasks$filter, _current$tasks, _current$tasks$length, _current$tasks2;
|
|
75
77
|
|
|
76
78
|
return [acc[0] + ((_current$tasks$filter = (_current$tasks = current.tasks) === null || _current$tasks === void 0 ? void 0 : _current$tasks.filter(function (t) {
|
|
77
79
|
return t.state === _models.TaskStates.TYPES.COMPLETE;
|
|
78
80
|
}).length) !== null && _current$tasks$filter !== void 0 ? _current$tasks$filter : 0), acc[1] + ((_current$tasks$length = (_current$tasks2 = current.tasks) === null || _current$tasks2 === void 0 ? void 0 : _current$tasks2.length) !== null && _current$tasks$length !== void 0 ? _current$tasks$length : 0)];
|
|
79
81
|
}, [0, 0]),
|
|
80
|
-
_sections$
|
|
81
|
-
completeSections = _sections$
|
|
82
|
-
totalSections = _sections$
|
|
82
|
+
_sections$filter$redu2 = _slicedToArray(_sections$filter$redu, 2),
|
|
83
|
+
completeSections = _sections$filter$redu2[0],
|
|
84
|
+
totalSections = _sections$filter$redu2[1];
|
|
83
85
|
|
|
84
86
|
var notesId = "".concat(attrs.id, "Notes");
|
|
85
87
|
|
|
@@ -309,6 +309,56 @@ describe('components', function () {
|
|
|
309
309
|
var incompleteForm = childNodes[0].childNodes[0];
|
|
310
310
|
expect(incompleteForm.textContent).toEqual(INCOMPLETE_TITLE);
|
|
311
311
|
});
|
|
312
|
+
it('should not show skipped sections', function () {
|
|
313
|
+
var INCOMPLETE_TITLE = 'Alpha Bravo';
|
|
314
|
+
var COP_REF = '123';
|
|
315
|
+
var sections = [{
|
|
316
|
+
name: 'These are your tasks',
|
|
317
|
+
skipped: true,
|
|
318
|
+
tasks: [{
|
|
319
|
+
name: 'Nice task',
|
|
320
|
+
state: 'complete',
|
|
321
|
+
pages: ['pageOne']
|
|
322
|
+
}, {
|
|
323
|
+
name: 'Ok task',
|
|
324
|
+
state: 'inProgress',
|
|
325
|
+
pages: ['pageTwo']
|
|
326
|
+
}, {
|
|
327
|
+
name: 'Terrible task',
|
|
328
|
+
state: 'notStarted',
|
|
329
|
+
pages: ['pageThree']
|
|
330
|
+
}]
|
|
331
|
+
}, {
|
|
332
|
+
name: 'These are your extra bonus tasks',
|
|
333
|
+
tasks: [{
|
|
334
|
+
name: 'Nice task',
|
|
335
|
+
state: 'complete',
|
|
336
|
+
pages: ['pageFour']
|
|
337
|
+
}, {
|
|
338
|
+
name: 'Ok task',
|
|
339
|
+
state: 'cannotStartYet',
|
|
340
|
+
pages: ['pageFive']
|
|
341
|
+
}, {
|
|
342
|
+
name: 'Terrible task',
|
|
343
|
+
state: 'cannotStartYet',
|
|
344
|
+
pages: ['pageSix']
|
|
345
|
+
}]
|
|
346
|
+
}];
|
|
347
|
+
|
|
348
|
+
var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
349
|
+
refNumber: COP_REF,
|
|
350
|
+
sections: sections,
|
|
351
|
+
incompleteTitle: INCOMPLETE_TITLE
|
|
352
|
+
})),
|
|
353
|
+
container = _render6.container;
|
|
354
|
+
|
|
355
|
+
var childNodes = container.childNodes;
|
|
356
|
+
expect(childNodes.length).toEqual(1);
|
|
357
|
+
expect(childNodes[0].childNodes.length).toEqual(4);
|
|
358
|
+
expect(childNodes[0].childNodes[0].textContent).toEqual(INCOMPLETE_TITLE);
|
|
359
|
+
expect(childNodes[0].childNodes[1].textContent).toEqual('You have completed 1 of 3 sections');
|
|
360
|
+
expect(childNodes[0].childNodes[2].textContent).toEqual("1. ".concat(sections[1].name));
|
|
361
|
+
});
|
|
312
362
|
});
|
|
313
363
|
it('should pass the selected task to the given onTaskAction function', function () {
|
|
314
364
|
var COP_REF = '123';
|
|
@@ -336,13 +386,13 @@ describe('components', function () {
|
|
|
336
386
|
}]
|
|
337
387
|
}];
|
|
338
388
|
|
|
339
|
-
var
|
|
389
|
+
var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
|
|
340
390
|
refNumber: COP_REF,
|
|
341
391
|
refTitle: REF_TITLE,
|
|
342
392
|
sections: sections,
|
|
343
393
|
onTaskAction: ON_CLICK
|
|
344
394
|
})),
|
|
345
|
-
container =
|
|
395
|
+
container = _render7.container;
|
|
346
396
|
|
|
347
397
|
var taskList = container.childNodes[0].childNodes[5].childNodes;
|
|
348
398
|
var firstTask = taskList[1].childNodes[0].childNodes[0];
|