@ukhomeoffice/cop-react-form-renderer 5.25.3 → 5.26.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.
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +24 -2
- package/dist/components/CheckYourAnswers/CheckYourAnswers.scss +31 -0
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +211 -89
- package/dist/utils/CheckYourAnswers/getCYARow.js +2 -1
- package/dist/utils/CheckYourAnswers/getCYARow.test.js +30 -0
- package/dist/utils/Component/getDefaultValue.js +1 -1
- package/dist/utils/Component/getDefaultValue.test.js +0 -5
- package/package.json +1 -1
|
@@ -8,8 +8,10 @@ exports.default = exports.DEFAULT_TITLE = exports.DEFAULT_MARGIN_BOTTOM = export
|
|
|
8
8
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _getCYAAction = _interopRequireDefault(require("../../utils/CheckYourAnswers/getCYAAction"));
|
|
11
12
|
var _hooks = require("../../hooks");
|
|
12
13
|
var _models = require("../../models");
|
|
14
|
+
var _RowAction = _interopRequireDefault(require("../SummaryList/RowAction"));
|
|
13
15
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
14
16
|
var _PageActions = _interopRequireDefault(require("../PageActions"));
|
|
15
17
|
var _SummaryList = _interopRequireDefault(require("../SummaryList"));
|
|
@@ -130,6 +132,24 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
130
132
|
return group.pageId === pageId;
|
|
131
133
|
});
|
|
132
134
|
};
|
|
135
|
+
var getPageHeading = function getPageHeading(page, size) {
|
|
136
|
+
var _page$cya_link;
|
|
137
|
+
if (!((_page$cya_link = page.cya_link) !== null && _page$cya_link !== void 0 && _page$cya_link.singleChangeLink) || noChangeAction) {
|
|
138
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, size === 's' && /*#__PURE__*/_react.default.createElement(_copReactComponents.SmallHeading, null, _utils.default.interpolateString(page.title, page.formData)), size === 'm' && /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, _utils.default.interpolateString(page.title, page.formData)));
|
|
139
|
+
}
|
|
140
|
+
var headingAction = (0, _getCYAAction.default)(false, page, onRowAction);
|
|
141
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
142
|
+
className: "heading-with-action"
|
|
143
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
144
|
+
className: "heading-text"
|
|
145
|
+
}, size === 's' && /*#__PURE__*/_react.default.createElement(_copReactComponents.SmallHeading, null, _utils.default.interpolateString(page.title, page.formData)), size === 'm' && /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, _utils.default.interpolateString(page.title, page.formData))), /*#__PURE__*/_react.default.createElement("div", {
|
|
146
|
+
className: "heading-action"
|
|
147
|
+
}, /*#__PURE__*/_react.default.createElement(_RowAction.default, {
|
|
148
|
+
row: {
|
|
149
|
+
action: headingAction
|
|
150
|
+
}
|
|
151
|
+
})));
|
|
152
|
+
};
|
|
133
153
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
134
154
|
className: DEFAULT_CLASS
|
|
135
155
|
}, title && !hide_title && /*#__PURE__*/_react.default.createElement(_copReactComponents.LargeHeading, {
|
|
@@ -149,9 +169,10 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
149
169
|
key: taskIndex
|
|
150
170
|
}, /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, filterPages.length > 0 && task.displayName || task.name), filterPages.map(function (page, pageIndex) {
|
|
151
171
|
var hideActionButtons = isGroup(page.id) || noChangeAction;
|
|
172
|
+
var showHeading = !hide_page_titles && page.title && !isGroup(page.id);
|
|
152
173
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
153
174
|
key: pageIndex
|
|
154
|
-
},
|
|
175
|
+
}, showHeading && getPageHeading(page, 's'), /*#__PURE__*/_react.default.createElement(_SummaryList.default, {
|
|
155
176
|
rows: page.rows,
|
|
156
177
|
classModifiers: summaryListClassModifiers,
|
|
157
178
|
noChangeAction: hideActionButtons,
|
|
@@ -165,9 +186,10 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
165
186
|
var currentGroup = isGroup(page.id) ? getGroupForPage(page.id) : undefined;
|
|
166
187
|
var className = "govuk-!-margin-bottom-".concat(pageMarginBottom);
|
|
167
188
|
var hideActionButtons = isGroup(page.id) || noChangeAction;
|
|
189
|
+
var showHeading = !hide_page_titles && page.title && !isGroup(page.id);
|
|
168
190
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
169
191
|
key: pageIndex
|
|
170
|
-
},
|
|
192
|
+
}, showHeading && getPageHeading(page, 'm'), isGroup(page.id) && /*#__PURE__*/_react.default.createElement("div", {
|
|
171
193
|
className: "group-title"
|
|
172
194
|
}, /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, currentGroup.title || page.title)), /*#__PURE__*/_react.default.createElement(_SummaryList.default, {
|
|
173
195
|
className: className,
|
|
@@ -10,3 +10,34 @@
|
|
|
10
10
|
.group-title{
|
|
11
11
|
padding-right: 75px;
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
.heading-with-action {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: row;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.heading-text {
|
|
20
|
+
width: 80%
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.heading-action {
|
|
24
|
+
width: 20%;
|
|
25
|
+
text-align: right;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@media screen and (max-width: 640px) {
|
|
29
|
+
.heading-with-action {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.heading-text {
|
|
35
|
+
width: 100%
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.heading-action {
|
|
39
|
+
margin-bottom: govuk-spacing(3);
|
|
40
|
+
width: 20%;
|
|
41
|
+
text-align: left;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -13,6 +13,7 @@ var _userProfile = _interopRequireDefault(require("../../json/userProfile.json")
|
|
|
13
13
|
var _groupData = _interopRequireDefault(require("../../json/group.data.json"));
|
|
14
14
|
var _group = _interopRequireDefault(require("../../json/group.json"));
|
|
15
15
|
var _groupOfRow = _interopRequireDefault(require("../../json/groupOfRow.json"));
|
|
16
|
+
var _models = require("../../models");
|
|
16
17
|
var _setupTests = require("../../setupTests");
|
|
17
18
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
18
19
|
var _CheckYourAnswers = _interopRequireWildcard(require("./CheckYourAnswers"));
|
|
@@ -260,15 +261,136 @@ describe('components', function () {
|
|
|
260
261
|
}
|
|
261
262
|
}, _callee10);
|
|
262
263
|
})));
|
|
263
|
-
it('should show
|
|
264
|
-
var cya, _cya$childNodes4, cyaChildNode,
|
|
264
|
+
it('should only show change link next to the heading when the page is configured to only have a single change link', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
265
|
+
var CUSTOM_PAGES, cya, _cya$childNodes4, title, cyaChildNode, titleText, titleAction, civilServant, _civilServant$childNo3, status;
|
|
265
266
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
266
267
|
while (1) switch (_context12.prev = _context12.next) {
|
|
267
268
|
case 0:
|
|
268
|
-
|
|
269
|
+
CUSTOM_PAGES = PAGES.map(function (page) {
|
|
270
|
+
return _objectSpread(_objectSpread({}, page), {}, {
|
|
271
|
+
cya_link: {
|
|
272
|
+
page: page.id,
|
|
273
|
+
aria_suffix: 'page details',
|
|
274
|
+
singleChangeLink: true
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
_context12.next = 3;
|
|
269
279
|
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
270
280
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
271
281
|
while (1) switch (_context11.prev = _context11.next) {
|
|
282
|
+
case 0:
|
|
283
|
+
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
284
|
+
pages: CUSTOM_PAGES,
|
|
285
|
+
onRowAction: ON_ROW_ACTION,
|
|
286
|
+
onAction: ON_ACTION
|
|
287
|
+
}), container);
|
|
288
|
+
case 1:
|
|
289
|
+
case "end":
|
|
290
|
+
return _context11.stop();
|
|
291
|
+
}
|
|
292
|
+
}, _callee11);
|
|
293
|
+
})));
|
|
294
|
+
case 3:
|
|
295
|
+
cya = checkCYA(container);
|
|
296
|
+
_cya$childNodes4 = _slicedToArray(cya.childNodes, 4), title = _cya$childNodes4[2], cyaChildNode = _cya$childNodes4[3];
|
|
297
|
+
expect(title.tagName).toEqual('DIV');
|
|
298
|
+
expect(title.classList).toContain('heading-with-action');
|
|
299
|
+
titleText = title.children[0];
|
|
300
|
+
expect(titleText.tagName).toEqual('DIV');
|
|
301
|
+
expect(titleText.classList).toContain('heading-text');
|
|
302
|
+
expect(titleText.textContent).toEqual('Are you a civil servant?');
|
|
303
|
+
titleAction = title.children[1];
|
|
304
|
+
expect(titleAction.tagName).toEqual('DIV');
|
|
305
|
+
expect(titleAction.classList).toContain('heading-action');
|
|
306
|
+
expect(titleAction.textContent).toEqual("Change page details");
|
|
307
|
+
civilServant = cyaChildNode.childNodes[0];
|
|
308
|
+
expect(civilServant.tagName).toEqual('DL');
|
|
309
|
+
_civilServant$childNo3 = _slicedToArray(civilServant.childNodes, 1), status = _civilServant$childNo3[0];
|
|
310
|
+
checkRow(status, 'Are you a civil servant?', 'Yes', false);
|
|
311
|
+
case 19:
|
|
312
|
+
case "end":
|
|
313
|
+
return _context12.stop();
|
|
314
|
+
}
|
|
315
|
+
}, _callee12);
|
|
316
|
+
})));
|
|
317
|
+
it('should only show change link next to the heading when the page is configured to have a single change link and form is a task list', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
318
|
+
var CUSTOM_PAGES, SECTIONS, taskHeading1, cya, _cya$childNodes5, title, cyaChildNode, titleText, titleAction, civilServant, _civilServant$childNo4, status;
|
|
319
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
320
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
321
|
+
case 0:
|
|
322
|
+
CUSTOM_PAGES = PAGES.map(function (page) {
|
|
323
|
+
return _objectSpread(_objectSpread({}, page), {}, {
|
|
324
|
+
cya_link: {
|
|
325
|
+
page: page.id,
|
|
326
|
+
aria_suffix: 'page details',
|
|
327
|
+
singleChangeLink: true
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
SECTIONS = [{
|
|
332
|
+
name: 'These are your tasks',
|
|
333
|
+
tasks: [{
|
|
334
|
+
name: 'Task 1',
|
|
335
|
+
state: 'complete',
|
|
336
|
+
pages: ['civil-servant-status']
|
|
337
|
+
}]
|
|
338
|
+
}];
|
|
339
|
+
_context14.next = 4;
|
|
340
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
341
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
342
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
343
|
+
case 0:
|
|
344
|
+
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
345
|
+
pages: CUSTOM_PAGES,
|
|
346
|
+
onRowAction: ON_ROW_ACTION,
|
|
347
|
+
onAction: ON_ACTION,
|
|
348
|
+
hide_title: true,
|
|
349
|
+
sections: SECTIONS,
|
|
350
|
+
type: _models.FormTypes.TASK_CYA
|
|
351
|
+
}), container);
|
|
352
|
+
case 1:
|
|
353
|
+
case "end":
|
|
354
|
+
return _context13.stop();
|
|
355
|
+
}
|
|
356
|
+
}, _callee13);
|
|
357
|
+
})));
|
|
358
|
+
case 4:
|
|
359
|
+
taskHeading1 = container.childNodes[0].childNodes[0];
|
|
360
|
+
expect(taskHeading1.tagName).toEqual('H2');
|
|
361
|
+
expect(taskHeading1.textContent).toEqual('Task 1');
|
|
362
|
+
expect(taskHeading1.classList).toContain("govuk-heading-m");
|
|
363
|
+
cya = checkCYA(container);
|
|
364
|
+
_cya$childNodes5 = _slicedToArray(cya.childNodes, 3), title = _cya$childNodes5[1], cyaChildNode = _cya$childNodes5[2];
|
|
365
|
+
expect(title.tagName).toEqual('DIV');
|
|
366
|
+
expect(title.classList).toContain('heading-with-action');
|
|
367
|
+
titleText = title.children[0];
|
|
368
|
+
expect(titleText.tagName).toEqual('DIV');
|
|
369
|
+
expect(titleText.classList).toContain('heading-text');
|
|
370
|
+
expect(titleText.textContent).toEqual('Are you a civil servant?');
|
|
371
|
+
titleAction = title.children[1];
|
|
372
|
+
expect(titleAction.tagName).toEqual('DIV');
|
|
373
|
+
expect(titleAction.classList).toContain('heading-action');
|
|
374
|
+
expect(titleAction.textContent).toEqual("Change page details");
|
|
375
|
+
civilServant = cyaChildNode.childNodes[0];
|
|
376
|
+
expect(civilServant.tagName).toEqual('DL');
|
|
377
|
+
_civilServant$childNo4 = _slicedToArray(civilServant.childNodes, 1), status = _civilServant$childNo4[0];
|
|
378
|
+
checkRow(status, 'Are you a civil servant?', 'Yes', false);
|
|
379
|
+
case 24:
|
|
380
|
+
case "end":
|
|
381
|
+
return _context14.stop();
|
|
382
|
+
}
|
|
383
|
+
}, _callee14);
|
|
384
|
+
})));
|
|
385
|
+
it('should show no title if is set to hidden', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
386
|
+
var cya, _cya$childNodes6, cyaChildNode, names, _names$childNodes2, firstName, surname;
|
|
387
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
388
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
389
|
+
case 0:
|
|
390
|
+
_context16.next = 2;
|
|
391
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
392
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
393
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
272
394
|
case 0:
|
|
273
395
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
274
396
|
pages: PAGES,
|
|
@@ -278,13 +400,13 @@ describe('components', function () {
|
|
|
278
400
|
}), container);
|
|
279
401
|
case 1:
|
|
280
402
|
case "end":
|
|
281
|
-
return
|
|
403
|
+
return _context15.stop();
|
|
282
404
|
}
|
|
283
|
-
},
|
|
405
|
+
}, _callee15);
|
|
284
406
|
})));
|
|
285
407
|
case 2:
|
|
286
408
|
cya = checkCYA(container);
|
|
287
|
-
_cya$
|
|
409
|
+
_cya$childNodes6 = _slicedToArray(cya.childNodes, 1), cyaChildNode = _cya$childNodes6[0];
|
|
288
410
|
names = cyaChildNode.childNodes[0];
|
|
289
411
|
expect(names.tagName).toEqual('DL');
|
|
290
412
|
expect(names.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
|
|
@@ -293,14 +415,14 @@ describe('components', function () {
|
|
|
293
415
|
checkRow(surname, 'Last name', 'Smith', false);
|
|
294
416
|
case 10:
|
|
295
417
|
case "end":
|
|
296
|
-
return
|
|
418
|
+
return _context16.stop();
|
|
297
419
|
}
|
|
298
|
-
},
|
|
420
|
+
}, _callee16);
|
|
299
421
|
})));
|
|
300
|
-
it('should show task list in CYA style', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
422
|
+
it('should show task list in CYA style', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
301
423
|
var sections, taskHeading1, namesPageHeading, taskHeading2, gradePageHeading;
|
|
302
|
-
return _regeneratorRuntime().wrap(function
|
|
303
|
-
while (1) switch (
|
|
424
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
425
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
304
426
|
case 0:
|
|
305
427
|
sections = [{
|
|
306
428
|
name: 'These are your tasks',
|
|
@@ -314,10 +436,10 @@ describe('components', function () {
|
|
|
314
436
|
pages: ['grade']
|
|
315
437
|
}]
|
|
316
438
|
}];
|
|
317
|
-
|
|
318
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
319
|
-
return _regeneratorRuntime().wrap(function
|
|
320
|
-
while (1) switch (
|
|
439
|
+
_context18.next = 3;
|
|
440
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
441
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
442
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
321
443
|
case 0:
|
|
322
444
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
323
445
|
pages: PAGES,
|
|
@@ -329,9 +451,9 @@ describe('components', function () {
|
|
|
329
451
|
}), container);
|
|
330
452
|
case 1:
|
|
331
453
|
case "end":
|
|
332
|
-
return
|
|
454
|
+
return _context17.stop();
|
|
333
455
|
}
|
|
334
|
-
},
|
|
456
|
+
}, _callee17);
|
|
335
457
|
})));
|
|
336
458
|
case 3:
|
|
337
459
|
taskHeading1 = container.childNodes[0].childNodes[0];
|
|
@@ -352,14 +474,14 @@ describe('components', function () {
|
|
|
352
474
|
expect(gradePageHeading.classList).toContain("govuk-heading-s");
|
|
353
475
|
case 19:
|
|
354
476
|
case "end":
|
|
355
|
-
return
|
|
477
|
+
return _context18.stop();
|
|
356
478
|
}
|
|
357
|
-
},
|
|
479
|
+
}, _callee18);
|
|
358
480
|
})));
|
|
359
|
-
it('should show task list in CYA style and priotitise displayName over name for a task', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
481
|
+
it('should show task list in CYA style and priotitise displayName over name for a task', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
360
482
|
var sections, taskHeading1, taskHeading2;
|
|
361
|
-
return _regeneratorRuntime().wrap(function
|
|
362
|
-
while (1) switch (
|
|
483
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
484
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
363
485
|
case 0:
|
|
364
486
|
sections = [{
|
|
365
487
|
name: 'These are your tasks',
|
|
@@ -375,10 +497,10 @@ describe('components', function () {
|
|
|
375
497
|
pages: ['grade']
|
|
376
498
|
}]
|
|
377
499
|
}];
|
|
378
|
-
|
|
379
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
380
|
-
return _regeneratorRuntime().wrap(function
|
|
381
|
-
while (1) switch (
|
|
500
|
+
_context20.next = 3;
|
|
501
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
502
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
503
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
382
504
|
case 0:
|
|
383
505
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
384
506
|
pages: PAGES,
|
|
@@ -390,9 +512,9 @@ describe('components', function () {
|
|
|
390
512
|
}), container);
|
|
391
513
|
case 1:
|
|
392
514
|
case "end":
|
|
393
|
-
return
|
|
515
|
+
return _context19.stop();
|
|
394
516
|
}
|
|
395
|
-
},
|
|
517
|
+
}, _callee19);
|
|
396
518
|
})));
|
|
397
519
|
case 3:
|
|
398
520
|
taskHeading1 = container.childNodes[0].childNodes[0];
|
|
@@ -401,21 +523,21 @@ describe('components', function () {
|
|
|
401
523
|
expect(taskHeading2.textContent).toEqual('Red');
|
|
402
524
|
case 7:
|
|
403
525
|
case "end":
|
|
404
|
-
return
|
|
526
|
+
return _context20.stop();
|
|
405
527
|
}
|
|
406
|
-
},
|
|
528
|
+
}, _callee20);
|
|
407
529
|
})));
|
|
408
|
-
it('Show answers from multiple address fields into in one DL', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
530
|
+
it('Show answers from multiple address fields into in one DL', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
409
531
|
var ADDRESS_DATA, GROUP_PAGES, cya, groupedComponent, keyGroup, valueGroup, changeButtonDiv, changeButton;
|
|
410
|
-
return _regeneratorRuntime().wrap(function
|
|
411
|
-
while (1) switch (
|
|
532
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
533
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
412
534
|
case 0:
|
|
413
535
|
ADDRESS_DATA = _utils.default.Data.setupForm(_group.default.pages, _group.default.components, _groupData.default);
|
|
414
536
|
GROUP_PAGES = _utils.default.FormPage.getAll(_group.default.pages, _group.default.components, _objectSpread({}, ADDRESS_DATA));
|
|
415
|
-
|
|
416
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
417
|
-
return _regeneratorRuntime().wrap(function
|
|
418
|
-
while (1) switch (
|
|
537
|
+
_context22.next = 4;
|
|
538
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
539
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
540
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
419
541
|
case 0:
|
|
420
542
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
421
543
|
pages: GROUP_PAGES,
|
|
@@ -425,9 +547,9 @@ describe('components', function () {
|
|
|
425
547
|
}), container);
|
|
426
548
|
case 1:
|
|
427
549
|
case "end":
|
|
428
|
-
return
|
|
550
|
+
return _context21.stop();
|
|
429
551
|
}
|
|
430
|
-
},
|
|
552
|
+
}, _callee21);
|
|
431
553
|
})));
|
|
432
554
|
case 4:
|
|
433
555
|
cya = checkCYA(container);
|
|
@@ -449,20 +571,20 @@ describe('components', function () {
|
|
|
449
571
|
expect(changeButton.textContent).toEqual('Change address details');
|
|
450
572
|
case 21:
|
|
451
573
|
case "end":
|
|
452
|
-
return
|
|
574
|
+
return _context22.stop();
|
|
453
575
|
}
|
|
454
|
-
},
|
|
576
|
+
}, _callee22);
|
|
455
577
|
})));
|
|
456
|
-
it('should render a group with one action button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
578
|
+
it('should render a group with one action button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
457
579
|
var GROUP_PAGES, cya, namesGroup, firstNameRow, surname, changeButtonDiv, changeButton;
|
|
458
|
-
return _regeneratorRuntime().wrap(function
|
|
459
|
-
while (1) switch (
|
|
580
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
581
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
460
582
|
case 0:
|
|
461
583
|
GROUP_PAGES = _utils.default.FormPage.getAll(_groupOfRow.default.pages, _groupOfRow.default.components, _objectSpread({}, DATA));
|
|
462
|
-
|
|
463
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
464
|
-
return _regeneratorRuntime().wrap(function
|
|
465
|
-
while (1) switch (
|
|
584
|
+
_context24.next = 3;
|
|
585
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
586
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
587
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
466
588
|
case 0:
|
|
467
589
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
468
590
|
pages: GROUP_PAGES,
|
|
@@ -472,9 +594,9 @@ describe('components', function () {
|
|
|
472
594
|
}), container);
|
|
473
595
|
case 1:
|
|
474
596
|
case "end":
|
|
475
|
-
return
|
|
597
|
+
return _context23.stop();
|
|
476
598
|
}
|
|
477
|
-
},
|
|
599
|
+
}, _callee23);
|
|
478
600
|
})));
|
|
479
601
|
case 3:
|
|
480
602
|
cya = checkCYA(container);
|
|
@@ -498,14 +620,14 @@ describe('components', function () {
|
|
|
498
620
|
expect(changeButton.textContent).toEqual('Change names');
|
|
499
621
|
case 22:
|
|
500
622
|
case "end":
|
|
501
|
-
return
|
|
623
|
+
return _context24.stop();
|
|
502
624
|
}
|
|
503
|
-
},
|
|
625
|
+
}, _callee24);
|
|
504
626
|
})));
|
|
505
|
-
it('should show page components corrently with interpolated title and cya_label, if label is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
506
|
-
var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$
|
|
507
|
-
return _regeneratorRuntime().wrap(function
|
|
508
|
-
while (1) switch (
|
|
627
|
+
it('should show page components corrently with interpolated title and cya_label, if label is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
628
|
+
var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$childNodes7, cyaTitle, cyaChildNode, names, _names$childNodes3, firstName, surname, _firstName$childNodes, label;
|
|
629
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
630
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
509
631
|
case 0:
|
|
510
632
|
_PAGES = [].concat(_userProfile.default.pages); // eslint-disable-next-line no-template-curly-in-string
|
|
511
633
|
_PAGES[0] = _objectSpread(_objectSpread({}, _PAGES[0]), {}, {
|
|
@@ -519,10 +641,10 @@ describe('components', function () {
|
|
|
519
641
|
cya_label: "Text ${currentUser.familyName}"
|
|
520
642
|
});
|
|
521
643
|
T_PAGES = _utils.default.FormPage.getAll(_PAGES, _COMPONENTS, DATA);
|
|
522
|
-
|
|
523
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
524
|
-
return _regeneratorRuntime().wrap(function
|
|
525
|
-
while (1) switch (
|
|
644
|
+
_context26.next = 7;
|
|
645
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
646
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
647
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
526
648
|
case 0:
|
|
527
649
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
528
650
|
pages: T_PAGES,
|
|
@@ -531,13 +653,13 @@ describe('components', function () {
|
|
|
531
653
|
}), container);
|
|
532
654
|
case 1:
|
|
533
655
|
case "end":
|
|
534
|
-
return
|
|
656
|
+
return _context25.stop();
|
|
535
657
|
}
|
|
536
|
-
},
|
|
658
|
+
}, _callee25);
|
|
537
659
|
})));
|
|
538
660
|
case 7:
|
|
539
661
|
cya = checkCYA(container);
|
|
540
|
-
_cya$
|
|
662
|
+
_cya$childNodes7 = _slicedToArray(cya.childNodes, 3), cyaTitle = _cya$childNodes7[1], cyaChildNode = _cya$childNodes7[2];
|
|
541
663
|
expect(cyaTitle.textContent).toEqual('Alpha ID: 123456789');
|
|
542
664
|
names = cyaChildNode.childNodes[0];
|
|
543
665
|
expect(names.tagName).toEqual('DL');
|
|
@@ -548,14 +670,14 @@ describe('components', function () {
|
|
|
548
670
|
checkRow(surname, 'Last name', 'Smith', false);
|
|
549
671
|
case 17:
|
|
550
672
|
case "end":
|
|
551
|
-
return
|
|
673
|
+
return _context26.stop();
|
|
552
674
|
}
|
|
553
|
-
},
|
|
675
|
+
}, _callee26);
|
|
554
676
|
})));
|
|
555
|
-
it('should show page components corrently with no label, if label and cya_label are missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
556
|
-
var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$
|
|
557
|
-
return _regeneratorRuntime().wrap(function
|
|
558
|
-
while (1) switch (
|
|
677
|
+
it('should show page components corrently with no label, if label and cya_label are missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
678
|
+
var _PAGES, _COMPONENTS, T_PAGES, cya, _cya$childNodes8, cyaChildNode, names, _names$childNodes4, firstName, surname, _firstName$childNodes2, label;
|
|
679
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
680
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
559
681
|
case 0:
|
|
560
682
|
_PAGES = [].concat(_userProfile.default.pages);
|
|
561
683
|
_COMPONENTS = [].concat(_userProfile.default.components);
|
|
@@ -565,10 +687,10 @@ describe('components', function () {
|
|
|
565
687
|
cya_label: undefined
|
|
566
688
|
});
|
|
567
689
|
T_PAGES = _utils.default.FormPage.getAll(_PAGES, _COMPONENTS, _objectSpread({}, DATA));
|
|
568
|
-
|
|
569
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
570
|
-
return _regeneratorRuntime().wrap(function
|
|
571
|
-
while (1) switch (
|
|
690
|
+
_context28.next = 6;
|
|
691
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
692
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
693
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
572
694
|
case 0:
|
|
573
695
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
574
696
|
pages: T_PAGES,
|
|
@@ -577,13 +699,13 @@ describe('components', function () {
|
|
|
577
699
|
}), container);
|
|
578
700
|
case 1:
|
|
579
701
|
case "end":
|
|
580
|
-
return
|
|
702
|
+
return _context27.stop();
|
|
581
703
|
}
|
|
582
|
-
},
|
|
704
|
+
}, _callee27);
|
|
583
705
|
})));
|
|
584
706
|
case 6:
|
|
585
707
|
cya = checkCYA(container);
|
|
586
|
-
_cya$
|
|
708
|
+
_cya$childNodes8 = _slicedToArray(cya.childNodes, 2), cyaChildNode = _cya$childNodes8[1];
|
|
587
709
|
names = cyaChildNode.childNodes[0];
|
|
588
710
|
expect(names.tagName).toEqual('DL');
|
|
589
711
|
expect(names.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
|
|
@@ -593,14 +715,14 @@ describe('components', function () {
|
|
|
593
715
|
checkRow(surname, 'Last name', 'Smith', false);
|
|
594
716
|
case 15:
|
|
595
717
|
case "end":
|
|
596
|
-
return
|
|
718
|
+
return _context28.stop();
|
|
597
719
|
}
|
|
598
|
-
},
|
|
720
|
+
}, _callee28);
|
|
599
721
|
})));
|
|
600
|
-
it('should show task list in CYA style and hide pages from skipped tasks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
722
|
+
it('should show task list in CYA style and hide pages from skipped tasks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
601
723
|
var sections, taskHeading1, namesPageHeading;
|
|
602
|
-
return _regeneratorRuntime().wrap(function
|
|
603
|
-
while (1) switch (
|
|
724
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
725
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
604
726
|
case 0:
|
|
605
727
|
sections = [{
|
|
606
728
|
name: 'These are your tasks',
|
|
@@ -614,10 +736,10 @@ describe('components', function () {
|
|
|
614
736
|
pages: ['grade']
|
|
615
737
|
}]
|
|
616
738
|
}];
|
|
617
|
-
|
|
618
|
-
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
619
|
-
return _regeneratorRuntime().wrap(function
|
|
620
|
-
while (1) switch (
|
|
739
|
+
_context30.next = 3;
|
|
740
|
+
return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
741
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
742
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
621
743
|
case 0:
|
|
622
744
|
(0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
|
|
623
745
|
pages: PAGES,
|
|
@@ -629,9 +751,9 @@ describe('components', function () {
|
|
|
629
751
|
}), container);
|
|
630
752
|
case 1:
|
|
631
753
|
case "end":
|
|
632
|
-
return
|
|
754
|
+
return _context29.stop();
|
|
633
755
|
}
|
|
634
|
-
},
|
|
756
|
+
}, _callee29);
|
|
635
757
|
})));
|
|
636
758
|
case 3:
|
|
637
759
|
taskHeading1 = container.childNodes[0].childNodes[0];
|
|
@@ -645,9 +767,9 @@ describe('components', function () {
|
|
|
645
767
|
expect(container.childNodes[0].childNodes.length).toEqual(2); // second task skipped so not shown
|
|
646
768
|
case 12:
|
|
647
769
|
case "end":
|
|
648
|
-
return
|
|
770
|
+
return _context30.stop();
|
|
649
771
|
}
|
|
650
|
-
},
|
|
772
|
+
}, _callee30);
|
|
651
773
|
})));
|
|
652
774
|
});
|
|
653
775
|
});
|
|
@@ -36,6 +36,7 @@ var setNestedValue = function setNestedValue(component, page) {
|
|
|
36
36
|
* @returns A configuration object for a Check your answers row.
|
|
37
37
|
*/
|
|
38
38
|
var getCYARow = function getCYARow(page, component, onAction) {
|
|
39
|
+
var _page$cya_link;
|
|
39
40
|
var value = '';
|
|
40
41
|
if (page.formData && component.fieldId) {
|
|
41
42
|
value = page.formData[component.fieldId];
|
|
@@ -50,7 +51,7 @@ var getCYARow = function getCYARow(page, component, onAction) {
|
|
|
50
51
|
required: component.required,
|
|
51
52
|
component: _Component.default.editable(component) ? component : undefined,
|
|
52
53
|
value: value || '',
|
|
53
|
-
action: (0, _getCYAAction.default)(component.readonly, page, onAction)
|
|
54
|
+
action: (_page$cya_link = page.cya_link) !== null && _page$cya_link !== void 0 && _page$cya_link.singleChangeLink ? null : (0, _getCYAAction.default)(component.readonly, page, onAction)
|
|
54
55
|
};
|
|
55
56
|
};
|
|
56
57
|
var _default = getCYARow;
|
|
@@ -337,6 +337,36 @@ describe('utils', function () {
|
|
|
337
337
|
value: 'Bravo'
|
|
338
338
|
});
|
|
339
339
|
});
|
|
340
|
+
it('should not produce an action when the page is configured to have a single change link', function () {
|
|
341
|
+
var PAGE = {
|
|
342
|
+
id: 'page',
|
|
343
|
+
formData: {
|
|
344
|
+
a: 'Bravo'
|
|
345
|
+
},
|
|
346
|
+
cya_link: {
|
|
347
|
+
page: 'page',
|
|
348
|
+
aria_suffix: 'page details',
|
|
349
|
+
singleChangeLink: true
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
var COMPONENT = {
|
|
353
|
+
type: 'text',
|
|
354
|
+
readonly: true,
|
|
355
|
+
id: 'a',
|
|
356
|
+
fieldId: 'a',
|
|
357
|
+
label: 'Alpha'
|
|
358
|
+
};
|
|
359
|
+
var ON_ACTION = function ON_ACTION() {};
|
|
360
|
+
var ROW = (0, _getCYARow.default)(PAGE, COMPONENT, ON_ACTION);
|
|
361
|
+
(0, _setupTests.expectObjectLike)(ROW, {
|
|
362
|
+
pageId: PAGE.id,
|
|
363
|
+
fieldId: COMPONENT.fieldId,
|
|
364
|
+
key: COMPONENT.label,
|
|
365
|
+
action: null,
|
|
366
|
+
component: COMPONENT,
|
|
367
|
+
value: 'Bravo'
|
|
368
|
+
});
|
|
369
|
+
});
|
|
340
370
|
});
|
|
341
371
|
});
|
|
342
372
|
});
|
|
@@ -12,7 +12,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
12
12
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
13
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
14
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
-
var DEFAULT_VALUES = (_DEFAULT_VALUES = {}, _defineProperty(_DEFAULT_VALUES, _models.ComponentTypes.COLLECTION, []), _defineProperty(_DEFAULT_VALUES, _models.ComponentTypes.CONTAINER, {}),
|
|
15
|
+
var DEFAULT_VALUES = (_DEFAULT_VALUES = {}, _defineProperty(_DEFAULT_VALUES, _models.ComponentTypes.COLLECTION, []), _defineProperty(_DEFAULT_VALUES, _models.ComponentTypes.CONTAINER, {}), _DEFAULT_VALUES);
|
|
16
16
|
var getDefaultValue = function getDefaultValue(component, formData) {
|
|
17
17
|
if (!component) {
|
|
18
18
|
return '';
|
|
@@ -33,11 +33,6 @@ describe('utils.Component.defaultValue', function () {
|
|
|
33
33
|
type: _models.ComponentTypes.CONTAINER
|
|
34
34
|
})).toEqual({});
|
|
35
35
|
});
|
|
36
|
-
it("should return an empty object if the component type is 'file'", function () {
|
|
37
|
-
expect((0, _getDefaultValue.default)({
|
|
38
|
-
type: _models.ComponentTypes.FILE
|
|
39
|
-
})).toEqual({});
|
|
40
|
-
});
|
|
41
36
|
it('should return defaultValue if the component has defaultValue prop', function () {
|
|
42
37
|
expect((0, _getDefaultValue.default)({
|
|
43
38
|
type: _models.ComponentTypes.AUTOCOMPLETE,
|