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

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.
@@ -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, {
@@ -147,11 +167,12 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
147
167
  });
148
168
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
149
169
  key: taskIndex
150
- }, /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, filterPages.length > 0 && task.name), filterPages.map(function (page, pageIndex) {
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
- }, !hide_page_titles && page.title && !isGroup(page.id) && /*#__PURE__*/_react.default.createElement(_copReactComponents.SmallHeading, null, _utils.default.interpolateString(page.title, page.formData)), /*#__PURE__*/_react.default.createElement(_SummaryList.default, {
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
- }, !hide_page_titles && page.title && !isGroup(page.id) && /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, _utils.default.interpolateString(page.title, page.formData)), isGroup(page.id) && /*#__PURE__*/_react.default.createElement("div", {
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 no title if is set to hidden', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
264
- var cya, _cya$childNodes4, cyaChildNode, names, _names$childNodes2, firstName, surname;
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
- _context12.next = 2;
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 _context11.stop();
403
+ return _context15.stop();
282
404
  }
283
- }, _callee11);
405
+ }, _callee15);
284
406
  })));
285
407
  case 2:
286
408
  cya = checkCYA(container);
287
- _cya$childNodes4 = _slicedToArray(cya.childNodes, 1), cyaChildNode = _cya$childNodes4[0];
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 _context12.stop();
418
+ return _context16.stop();
297
419
  }
298
- }, _callee12);
420
+ }, _callee16);
299
421
  })));
300
- it('should show task list in CYA style', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
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 _callee14$(_context14) {
303
- while (1) switch (_context14.prev = _context14.next) {
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
- _context14.next = 3;
318
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
319
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
320
- while (1) switch (_context13.prev = _context13.next) {
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 _context13.stop();
454
+ return _context17.stop();
333
455
  }
334
- }, _callee13);
456
+ }, _callee17);
335
457
  })));
336
458
  case 3:
337
459
  taskHeading1 = container.childNodes[0].childNodes[0];
@@ -352,21 +474,70 @@ describe('components', function () {
352
474
  expect(gradePageHeading.classList).toContain("govuk-heading-s");
353
475
  case 19:
354
476
  case "end":
355
- return _context14.stop();
477
+ return _context18.stop();
356
478
  }
357
- }, _callee14);
479
+ }, _callee18);
358
480
  })));
359
- it('Show answers from multiple address fields into in one DL', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
481
+ it('should show task list in CYA style and priotitise displayName over name for a task', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
482
+ var sections, taskHeading1, taskHeading2;
483
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
484
+ while (1) switch (_context20.prev = _context20.next) {
485
+ case 0:
486
+ sections = [{
487
+ name: 'These are your tasks',
488
+ tasks: [{
489
+ name: 'Task 1',
490
+ displayName: 'Blue',
491
+ state: 'complete',
492
+ pages: ['names']
493
+ }, {
494
+ name: 'Task 2',
495
+ displayName: 'Red',
496
+ state: 'complete',
497
+ pages: ['grade']
498
+ }]
499
+ }];
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) {
504
+ case 0:
505
+ (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
506
+ pages: PAGES,
507
+ onRowAction: ON_ROW_ACTION,
508
+ onAction: ON_ACTION,
509
+ hide_title: true,
510
+ sections: sections,
511
+ type: "task-list-cya"
512
+ }), container);
513
+ case 1:
514
+ case "end":
515
+ return _context19.stop();
516
+ }
517
+ }, _callee19);
518
+ })));
519
+ case 3:
520
+ taskHeading1 = container.childNodes[0].childNodes[0];
521
+ expect(taskHeading1.textContent).toEqual('Blue');
522
+ taskHeading2 = container.childNodes[0].childNodes[2];
523
+ expect(taskHeading2.textContent).toEqual('Red');
524
+ case 7:
525
+ case "end":
526
+ return _context20.stop();
527
+ }
528
+ }, _callee20);
529
+ })));
530
+ it('Show answers from multiple address fields into in one DL', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
360
531
  var ADDRESS_DATA, GROUP_PAGES, cya, groupedComponent, keyGroup, valueGroup, changeButtonDiv, changeButton;
361
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
362
- while (1) switch (_context16.prev = _context16.next) {
532
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
533
+ while (1) switch (_context22.prev = _context22.next) {
363
534
  case 0:
364
535
  ADDRESS_DATA = _utils.default.Data.setupForm(_group.default.pages, _group.default.components, _groupData.default);
365
536
  GROUP_PAGES = _utils.default.FormPage.getAll(_group.default.pages, _group.default.components, _objectSpread({}, ADDRESS_DATA));
366
- _context16.next = 4;
367
- return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
368
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
369
- while (1) switch (_context15.prev = _context15.next) {
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) {
370
541
  case 0:
371
542
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
372
543
  pages: GROUP_PAGES,
@@ -376,9 +547,9 @@ describe('components', function () {
376
547
  }), container);
377
548
  case 1:
378
549
  case "end":
379
- return _context15.stop();
550
+ return _context21.stop();
380
551
  }
381
- }, _callee15);
552
+ }, _callee21);
382
553
  })));
383
554
  case 4:
384
555
  cya = checkCYA(container);
@@ -400,20 +571,20 @@ describe('components', function () {
400
571
  expect(changeButton.textContent).toEqual('Change address details');
401
572
  case 21:
402
573
  case "end":
403
- return _context16.stop();
574
+ return _context22.stop();
404
575
  }
405
- }, _callee16);
576
+ }, _callee22);
406
577
  })));
407
- it('should render a group with one action button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
578
+ it('should render a group with one action button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
408
579
  var GROUP_PAGES, cya, namesGroup, firstNameRow, surname, changeButtonDiv, changeButton;
409
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
410
- while (1) switch (_context18.prev = _context18.next) {
580
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
581
+ while (1) switch (_context24.prev = _context24.next) {
411
582
  case 0:
412
583
  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) {
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) {
417
588
  case 0:
418
589
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
419
590
  pages: GROUP_PAGES,
@@ -423,9 +594,9 @@ describe('components', function () {
423
594
  }), container);
424
595
  case 1:
425
596
  case "end":
426
- return _context17.stop();
597
+ return _context23.stop();
427
598
  }
428
- }, _callee17);
599
+ }, _callee23);
429
600
  })));
430
601
  case 3:
431
602
  cya = checkCYA(container);
@@ -449,14 +620,14 @@ describe('components', function () {
449
620
  expect(changeButton.textContent).toEqual('Change names');
450
621
  case 22:
451
622
  case "end":
452
- return _context18.stop();
623
+ return _context24.stop();
453
624
  }
454
- }, _callee18);
625
+ }, _callee24);
455
626
  })));
456
- it('should show page components corrently with interpolated title and cya_label, if label is missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
457
- 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) {
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) {
460
631
  case 0:
461
632
  _PAGES = [].concat(_userProfile.default.pages); // eslint-disable-next-line no-template-curly-in-string
462
633
  _PAGES[0] = _objectSpread(_objectSpread({}, _PAGES[0]), {}, {
@@ -470,10 +641,10 @@ describe('components', function () {
470
641
  cya_label: "Text ${currentUser.familyName}"
471
642
  });
472
643
  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) {
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) {
477
648
  case 0:
478
649
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
479
650
  pages: T_PAGES,
@@ -482,13 +653,13 @@ describe('components', function () {
482
653
  }), container);
483
654
  case 1:
484
655
  case "end":
485
- return _context19.stop();
656
+ return _context25.stop();
486
657
  }
487
- }, _callee19);
658
+ }, _callee25);
488
659
  })));
489
660
  case 7:
490
661
  cya = checkCYA(container);
491
- _cya$childNodes5 = _slicedToArray(cya.childNodes, 3), cyaTitle = _cya$childNodes5[1], cyaChildNode = _cya$childNodes5[2];
662
+ _cya$childNodes7 = _slicedToArray(cya.childNodes, 3), cyaTitle = _cya$childNodes7[1], cyaChildNode = _cya$childNodes7[2];
492
663
  expect(cyaTitle.textContent).toEqual('Alpha ID: 123456789');
493
664
  names = cyaChildNode.childNodes[0];
494
665
  expect(names.tagName).toEqual('DL');
@@ -499,14 +670,14 @@ describe('components', function () {
499
670
  checkRow(surname, 'Last name', 'Smith', false);
500
671
  case 17:
501
672
  case "end":
502
- return _context20.stop();
673
+ return _context26.stop();
503
674
  }
504
- }, _callee20);
675
+ }, _callee26);
505
676
  })));
506
- it('should show page components corrently with no label, if label and cya_label are missing', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
507
- 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) {
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) {
510
681
  case 0:
511
682
  _PAGES = [].concat(_userProfile.default.pages);
512
683
  _COMPONENTS = [].concat(_userProfile.default.components);
@@ -516,10 +687,10 @@ describe('components', function () {
516
687
  cya_label: undefined
517
688
  });
518
689
  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) {
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) {
523
694
  case 0:
524
695
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
525
696
  pages: T_PAGES,
@@ -528,13 +699,13 @@ describe('components', function () {
528
699
  }), container);
529
700
  case 1:
530
701
  case "end":
531
- return _context21.stop();
702
+ return _context27.stop();
532
703
  }
533
- }, _callee21);
704
+ }, _callee27);
534
705
  })));
535
706
  case 6:
536
707
  cya = checkCYA(container);
537
- _cya$childNodes6 = _slicedToArray(cya.childNodes, 2), cyaChildNode = _cya$childNodes6[1];
708
+ _cya$childNodes8 = _slicedToArray(cya.childNodes, 2), cyaChildNode = _cya$childNodes8[1];
538
709
  names = cyaChildNode.childNodes[0];
539
710
  expect(names.tagName).toEqual('DL');
540
711
  expect(names.classList).toContain("govuk-!-margin-bottom-".concat(_CheckYourAnswers.DEFAULT_MARGIN_BOTTOM));
@@ -544,14 +715,14 @@ describe('components', function () {
544
715
  checkRow(surname, 'Last name', 'Smith', false);
545
716
  case 15:
546
717
  case "end":
547
- return _context22.stop();
718
+ return _context28.stop();
548
719
  }
549
- }, _callee22);
720
+ }, _callee28);
550
721
  })));
551
- it('should show task list in CYA style and hide pages from skipped tasks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
722
+ it('should show task list in CYA style and hide pages from skipped tasks', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
552
723
  var sections, taskHeading1, namesPageHeading;
553
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
554
- while (1) switch (_context24.prev = _context24.next) {
724
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
725
+ while (1) switch (_context30.prev = _context30.next) {
555
726
  case 0:
556
727
  sections = [{
557
728
  name: 'These are your tasks',
@@ -565,10 +736,10 @@ describe('components', function () {
565
736
  pages: ['grade']
566
737
  }]
567
738
  }];
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) {
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) {
572
743
  case 0:
573
744
  (0, _setupTests.renderDomWithValidation)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
574
745
  pages: PAGES,
@@ -580,9 +751,9 @@ describe('components', function () {
580
751
  }), container);
581
752
  case 1:
582
753
  case "end":
583
- return _context23.stop();
754
+ return _context29.stop();
584
755
  }
585
- }, _callee23);
756
+ }, _callee29);
586
757
  })));
587
758
  case 3:
588
759
  taskHeading1 = container.childNodes[0].childNodes[0];
@@ -596,9 +767,9 @@ describe('components', function () {
596
767
  expect(container.childNodes[0].childNodes.length).toEqual(2); // second task skipped so not shown
597
768
  case 12:
598
769
  case "end":
599
- return _context24.stop();
770
+ return _context30.stop();
600
771
  }
601
- }, _callee24);
772
+ }, _callee30);
602
773
  })));
603
774
  });
604
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
  });
@@ -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.26.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",