@ukhomeoffice/cop-react-form-renderer 2.7.1 → 2.8.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.
@@ -22,6 +22,10 @@ var _userProfileData = _interopRequireDefault(require("../../json/userProfile.da
22
22
 
23
23
  var _userProfile = _interopRequireDefault(require("../../json/userProfile.json"));
24
24
 
25
+ var _groupData = _interopRequireDefault(require("../../json/group.data.json"));
26
+
27
+ var _group = _interopRequireDefault(require("../../json/group.json"));
28
+
25
29
  var _groupOfRow = _interopRequireDefault(require("../../json/groupOfRow.json"));
26
30
 
27
31
  var _utils = _interopRequireDefault(require("../../utils"));
@@ -378,14 +382,15 @@ describe('components', function () {
378
382
  }
379
383
  }, _callee12);
380
384
  })));
381
- it('should render a group with one action button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() {
382
- var GROUP_PAGES, cya, namesGroup, firstNameRow, surname, changeButtonDiv, changeButton;
385
+ it('Show answers from multiple address fields into in one DL', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() {
386
+ var DATA, GROUP_PAGES, cya, groupedComponent, keyGroup, valueGroup, changeButtonDiv, changeButton;
383
387
  return regeneratorRuntime.wrap(function _callee14$(_context14) {
384
388
  while (1) {
385
389
  switch (_context14.prev = _context14.next) {
386
390
  case 0:
387
- GROUP_PAGES = _utils.default.FormPage.getAll(_groupOfRow.default.pages, _groupOfRow.default.components, _objectSpread({}, DATA));
388
- _context14.next = 3;
391
+ DATA = _utils.default.Data.setupForm(_group.default.pages, _group.default.components, _groupData.default);
392
+ GROUP_PAGES = _utils.default.FormPage.getAll(_group.default.pages, _group.default.components, _objectSpread({}, DATA));
393
+ _context14.next = 4;
389
394
  return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {
390
395
  return regeneratorRuntime.wrap(function _callee13$(_context13) {
391
396
  while (1) {
@@ -395,7 +400,7 @@ describe('components', function () {
395
400
  pages: GROUP_PAGES,
396
401
  onRowAction: ON_ROW_ACTION,
397
402
  onAction: ON_ACTION,
398
- groups: _groupOfRow.default.cya.groups
403
+ hide_title: true
399
404
  }), container);
400
405
 
401
406
  case 1:
@@ -406,6 +411,60 @@ describe('components', function () {
406
411
  }, _callee13);
407
412
  })));
408
413
 
414
+ case 4:
415
+ cya = checkCYA(container);
416
+ groupedComponent = cya.childNodes[10];
417
+ keyGroup = groupedComponent.childNodes[0].childNodes[0].childNodes[0];
418
+ expect(keyGroup.tagName).toEqual('DT');
419
+ expect(keyGroup.textContent).toEqual('Address details (optional)');
420
+ valueGroup = groupedComponent.childNodes[0].childNodes[0].childNodes[1];
421
+ expect(valueGroup.childNodes.length).toEqual(4);
422
+ expect(valueGroup.tagName).toEqual('DD');
423
+ expect(valueGroup.childNodes[0].textContent).toContain('10 Downing Street');
424
+ expect(valueGroup.childNodes[1].textContent).toContain('City of Westminster');
425
+ expect(valueGroup.childNodes[2].textContent).toContain('London');
426
+ expect(valueGroup.childNodes[3].textContent).toContain('SW1A 2AA');
427
+ changeButtonDiv = groupedComponent.childNodes[0].childNodes[0].childNodes[2];
428
+ expect(changeButtonDiv.classList).toContain('govuk-summary-list__actions');
429
+ changeButton = changeButtonDiv.childNodes[0];
430
+ expect(changeButton.tagName).toEqual('A');
431
+ expect(changeButton.textContent).toEqual('Change address details');
432
+
433
+ case 21:
434
+ case "end":
435
+ return _context14.stop();
436
+ }
437
+ }
438
+ }, _callee14);
439
+ })));
440
+ it('should render a group with one action button', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() {
441
+ var GROUP_PAGES, cya, namesGroup, firstNameRow, surname, changeButtonDiv, changeButton;
442
+ return regeneratorRuntime.wrap(function _callee16$(_context16) {
443
+ while (1) {
444
+ switch (_context16.prev = _context16.next) {
445
+ case 0:
446
+ GROUP_PAGES = _utils.default.FormPage.getAll(_groupOfRow.default.pages, _groupOfRow.default.components, _objectSpread({}, DATA));
447
+ _context16.next = 3;
448
+ return (0, _testUtils.act)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15() {
449
+ return regeneratorRuntime.wrap(function _callee15$(_context15) {
450
+ while (1) {
451
+ switch (_context15.prev = _context15.next) {
452
+ case 0:
453
+ (0, _reactDom.render)( /*#__PURE__*/_react.default.createElement(_CheckYourAnswers.default, {
454
+ pages: GROUP_PAGES,
455
+ onRowAction: ON_ROW_ACTION,
456
+ onAction: ON_ACTION,
457
+ groups: _groupOfRow.default.cya.groups
458
+ }), container);
459
+
460
+ case 1:
461
+ case "end":
462
+ return _context15.stop();
463
+ }
464
+ }
465
+ }, _callee15);
466
+ })));
467
+
409
468
  case 3:
410
469
  cya = checkCYA(container);
411
470
  namesGroup = cya.childNodes[2];
@@ -429,10 +488,10 @@ describe('components', function () {
429
488
 
430
489
  case 22:
431
490
  case "end":
432
- return _context14.stop();
491
+ return _context16.stop();
433
492
  }
434
493
  }
435
- }, _callee14);
494
+ }, _callee16);
436
495
  })));
437
496
  });
438
497
  });
@@ -581,12 +581,12 @@ describe('components', function () {
581
581
  case 5:
582
582
  taskList = container.childNodes[0].childNodes[1]; //Check status's are correct
583
583
 
584
- firstTaskStatus = taskList.childNodes[4].childNodes[0].childNodes[1];
584
+ firstTaskStatus = taskList.childNodes[3].childNodes[0].childNodes[1];
585
585
  expect(firstTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.NOT_STARTED].label);
586
- secondTaskStatus = taskList.childNodes[4].childNodes[1].childNodes[1];
586
+ secondTaskStatus = taskList.childNodes[3].childNodes[1].childNodes[1];
587
587
  expect(secondTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.CANNOT_START_YET].label); //Launch first task
588
588
 
589
- firstTask = taskList.childNodes[4].childNodes[0].childNodes[0].childNodes[0];
589
+ firstTask = taskList.childNodes[3].childNodes[0].childNodes[0].childNodes[0];
590
590
  expect(firstTask.textContent).toEqual('Date, location and mode details');
591
591
 
592
592
  _react.fireEvent.click(firstTask, {}); //Fill first page and navigate
@@ -638,11 +638,11 @@ describe('components', function () {
638
638
  _react.fireEvent.click(cyaPage.childNodes[5].childNodes[0], {}); //Should be back at task list
639
639
 
640
640
 
641
- expect(container.childNodes[0].childNodes[0].textContent).toEqual('Event at the border'); //Check status's are correct
641
+ expect(container.childNodes[0].childNodes[0].textContent).toEqual('Task List Form'); //Check status's are correct
642
642
 
643
- firstTaskStatus = container.childNodes[0].childNodes[1].childNodes[4].childNodes[0].childNodes[1];
643
+ firstTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[0].childNodes[1];
644
644
  expect(firstTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.COMPLETE].label);
645
- secondTaskStatus = container.childNodes[0].childNodes[1].childNodes[4].childNodes[1].childNodes[1];
645
+ secondTaskStatus = container.childNodes[0].childNodes[1].childNodes[3].childNodes[1].childNodes[1];
646
646
  expect(secondTaskStatus.textContent).toEqual(_models.TaskStates.DETAILS[_models.TaskStates.TYPES.NOT_STARTED].label); //Check final data submitted to backend is as expected
647
647
 
648
648
  finalSubmit = ON_SUBMIT_CALLS[ON_SUBMIT_CALLS.length - 1];
@@ -691,7 +691,7 @@ describe('components', function () {
691
691
  case 4:
692
692
  taskList = container.childNodes[0].childNodes[1]; //Launch first task
693
693
 
694
- _react.fireEvent.click(taskList.childNodes[4].childNodes[0].childNodes[0].childNodes[0], {}); //Fill first page and navigate
694
+ _react.fireEvent.click(taskList.childNodes[3].childNodes[0].childNodes[0].childNodes[0], {}); //Fill first page and navigate
695
695
 
696
696
 
697
697
  newPage = container.childNodes[0].childNodes[0];
@@ -730,7 +730,7 @@ describe('components', function () {
730
730
  _react.fireEvent.click(container.childNodes[0].childNodes[0].childNodes[5].childNodes[0], {}); //Launch same task again
731
731
 
732
732
 
733
- _react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[4].childNodes[0].childNodes[0].childNodes[0], {}); //Should be at CYA page
733
+ _react.fireEvent.click(container.childNodes[0].childNodes[1].childNodes[3].childNodes[0].childNodes[0].childNodes[0], {}); //Should be at CYA page
734
734
 
735
735
 
736
736
  expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Check your answers');
@@ -32,6 +32,7 @@ var ActionButton = function ActionButton(_ref) {
32
32
  attrs = _objectWithoutProperties(_ref, _excluded);
33
33
 
34
34
  var action = typeof _action === 'string' ? _models.PageAction.DEFAULTS[_action] : _action;
35
+ var actionLabel = _models.PageAction.DEFAULTS[_action.type];
35
36
 
36
37
  if (!action) {
37
38
  return null;
@@ -44,7 +45,7 @@ var ActionButton = function ActionButton(_ref) {
44
45
  onClick: function onClick() {
45
46
  return onAction(action);
46
47
  }
47
- }), action.label || DEFAULT_LABEL);
48
+ }), action.label || (actionLabel === null || actionLabel === void 0 ? void 0 : actionLabel.label) || DEFAULT_LABEL);
48
49
  };
49
50
 
50
51
  ActionButton.propTypes = {
@@ -67,9 +67,11 @@ var TaskList = function TaskList(_ref) {
67
67
 
68
68
  return /*#__PURE__*/_react.default.createElement("div", _extends({}, attrs, {
69
69
  className: classes()
70
- }), /*#__PURE__*/_react.default.createElement("h2", {
71
- className: "govuk-heading-s govuk-!-margin-bottom-2"
72
- }, "".concat(refTitle, " ").concat(refNumber)), numberOfSections !== numberOfCompleteSections && /*#__PURE__*/_react.default.createElement("h2", {
70
+ }), refNumber && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("h2", {
71
+ className: "hods-task-reference-description govuk-heading-s govuk-!-margin-bottom-2 govuk-!-padding-right-1"
72
+ }, "".concat(refTitle)), /*#__PURE__*/_react.default.createElement("h2", {
73
+ className: "govuk-heading-s govuk-!-font-weight-regular"
74
+ }, "".concat(refNumber))), numberOfSections !== numberOfCompleteSections && /*#__PURE__*/_react.default.createElement("h2", {
73
75
  className: "govuk-heading-s govuk-!-margin-bottom-2"
74
76
  }, "Incomplete form"), /*#__PURE__*/_react.default.createElement("p", {
75
77
  className: "govuk-body govuk-!-margin-bottom-7"
@@ -15,9 +15,7 @@
15
15
  @include govuk-responsive-margin(9, 'bottom');
16
16
  list-style: none;
17
17
  padding-left: 0;
18
- @include govuk-media-query($from: tablet) {
19
- padding-left: govuk-spacing(6);
20
- }
18
+ padding-left: govuk-spacing(4);
21
19
  }
22
20
  }
23
21
 
@@ -54,6 +52,13 @@
54
52
  }
55
53
  }
56
54
 
55
+ .hods-task-reference-description{
56
+ @include govuk-media-query($from: 450px) {
57
+ float: left;
58
+ }
59
+ }
60
+
61
+
57
62
  // The `hods-task-list__task-completed` class was previously used on the task
58
63
  // list for the completed tag (changed in 86c90ec) – it's still included here to
59
64
  // avoid breaking task lists in existing prototypes.
@@ -57,23 +57,26 @@ describe('components', function () {
57
57
  expect(container.childNodes.length).toEqual(1);
58
58
  var referenceHeading = container.childNodes[0].childNodes[0];
59
59
  expect(referenceHeading.tagName).toEqual('H2');
60
- expect(referenceHeading.textContent).toEqual('COP reference number 123');
61
- var incompleteForm = container.childNodes[0].childNodes[1];
60
+ expect(referenceHeading.textContent).toEqual('COP reference number');
61
+ var referenceNumber = container.childNodes[0].childNodes[1];
62
+ expect(referenceNumber.tagName).toEqual('H2');
63
+ expect(referenceNumber.textContent).toEqual('123');
64
+ var incompleteForm = container.childNodes[0].childNodes[2];
62
65
  expect(incompleteForm.tagName).toEqual('H2');
63
66
  expect(incompleteForm.textContent).toEqual('Incomplete form');
64
- var numComplete = container.childNodes[0].childNodes[2];
67
+ var numComplete = container.childNodes[0].childNodes[3];
65
68
  expect(numComplete.tagName).toEqual('P');
66
69
  expect(numComplete.textContent).toEqual('You have completed 2 of 6 sections');
67
- expect(container.childNodes[0].childNodes.length).toEqual(7);
68
- var subSectionOneHeading = container.childNodes[0].childNodes[3];
70
+ expect(container.childNodes[0].childNodes.length).toEqual(8);
71
+ var subSectionOneHeading = container.childNodes[0].childNodes[4];
69
72
  expect(subSectionOneHeading.tagName).toEqual('H2');
70
73
  expect(subSectionOneHeading.textContent).toEqual('1. These are your tasks');
71
- var subSectionOneList = container.childNodes[0].childNodes[4];
74
+ var subSectionOneList = container.childNodes[0].childNodes[5];
72
75
  expect(subSectionOneList.childNodes.length).toEqual(3);
73
- var subSectionTwoHeading = container.childNodes[0].childNodes[5];
76
+ var subSectionTwoHeading = container.childNodes[0].childNodes[6];
74
77
  expect(subSectionTwoHeading.tagName).toEqual('H2');
75
78
  expect(subSectionTwoHeading.textContent).toEqual('2. These are your extra bonus tasks');
76
- var subSectionTwoList = container.childNodes[0].childNodes[6];
79
+ var subSectionTwoList = container.childNodes[0].childNodes[7];
77
80
  expect(subSectionTwoList.childNodes.length).toEqual(3);
78
81
  });
79
82
  it('should not show incomplete form if form is complete', function () {
@@ -118,11 +121,14 @@ describe('components', function () {
118
121
  })),
119
122
  container = _render2.container;
120
123
 
121
- expect(container.childNodes[0].childNodes.length).toEqual(6);
124
+ expect(container.childNodes[0].childNodes.length).toEqual(7);
122
125
  var referenceHeading = container.childNodes[0].childNodes[0];
123
126
  expect(referenceHeading.tagName).toEqual('H2');
124
- expect(referenceHeading.textContent).toEqual('COP reference number 123');
125
- var numComplete = container.childNodes[0].childNodes[1];
127
+ expect(referenceHeading.textContent).toEqual('COP reference number');
128
+ var referenceNumber = container.childNodes[0].childNodes[1];
129
+ expect(referenceNumber.tagName).toEqual('H2');
130
+ expect(referenceNumber.textContent).toEqual('123');
131
+ var numComplete = container.childNodes[0].childNodes[2];
126
132
  expect(numComplete.tagName).toEqual('P');
127
133
  expect(numComplete.textContent).toEqual('You have completed 6 of 6 sections');
128
134
  });
@@ -153,7 +159,7 @@ describe('components', function () {
153
159
  })),
154
160
  container = _render3.container;
155
161
 
156
- var subSectionOne = container.childNodes[0].childNodes[3];
162
+ var subSectionOne = container.childNodes[0].childNodes[4];
157
163
  expect(subSectionOne.childNodes[0].textContent).toEqual('');
158
164
  expect(subSectionOne.childNodes[1].textContent).toEqual('These are your tasks');
159
165
  });
@@ -192,9 +198,9 @@ describe('components', function () {
192
198
  })),
193
199
  container = _render4.container;
194
200
 
195
- var firstTask = container.childNodes[0].childNodes[4].childNodes[0].childNodes[0].childNodes[0];
196
- var secondTask = container.childNodes[0].childNodes[4].childNodes[1].childNodes[0].childNodes[0];
197
- var thirdTask = container.childNodes[0].childNodes[4].childNodes[2].childNodes[0].childNodes[0];
201
+ var firstTask = container.childNodes[0].childNodes[5].childNodes[0].childNodes[0].childNodes[0];
202
+ var secondTask = container.childNodes[0].childNodes[5].childNodes[1].childNodes[0].childNodes[0];
203
+ var thirdTask = container.childNodes[0].childNodes[5].childNodes[2].childNodes[0].childNodes[0];
198
204
 
199
205
  _react.fireEvent.click(firstTask.childNodes[0]);
200
206
 
@@ -0,0 +1,21 @@
1
+ {
2
+ "urls": {
3
+ "refData": "/ref-data"
4
+ },
5
+ "currentUser": {
6
+ "givenName": "John",
7
+ "familyName": "Smith"
8
+ },
9
+ "areYouACivilServant": "yes",
10
+ "userDetails": {
11
+ "linemanagerEmail": "line.manager@digital.homeoffice.gov.uk",
12
+ "delegateEmails": "del.egate@digital.homeoffice.gov.uk"
13
+ },
14
+ "addressDetails": {
15
+ "firstLineOfTheAddress": "10 Downing Street",
16
+ "city": "London",
17
+ "town": "City of Westminster",
18
+ "postCode": "SW1A 2AA"
19
+ },
20
+ "businessKey": "123456789"
21
+ }