@ukhomeoffice/cop-react-form-renderer 4.32.0 → 4.32.3

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.
@@ -5,7 +5,8 @@
5
5
  margin-bottom: 0.75rem;
6
6
  }
7
7
  &__item {
8
- margin-top: 0;
8
+ margin-top: 15px;
9
+ margin-bottom: 15px;
9
10
  position: relative;
10
11
  }
11
12
  &__item-title {
@@ -584,7 +584,7 @@ describe('components', function () {
584
584
  }, _callee18);
585
585
  })));
586
586
  it('should handle navigating between task list pages', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20() {
587
- var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, taskList, firstTaskStatus, secondTaskStatus, firstTask, newPage, continueButton, cyaPageChange, modeChangeLink, changePage, cyaPage, finalSubmit;
587
+ var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, taskList, firstTaskStatus, secondTaskStatus, firstTask, newPage, continueButton, seaButton, cyaPageChange, modeChangeLink, changePage, airButton, cyaPage, finalSubmit;
588
588
  return regeneratorRuntime.wrap(function _callee20$(_context20) {
589
589
  while (1) {
590
590
  switch (_context20.prev = _context20.next) {
@@ -662,8 +662,10 @@ describe('components', function () {
662
662
 
663
663
  newPage = container.childNodes[0].childNodes[0];
664
664
  expect(newPage.childNodes[0].textContent).toEqual('Event Mode');
665
+ seaButton = newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0];
666
+ expect(seaButton.textContent).toEqual('Sea');
665
667
 
666
- _react.fireEvent.click(newPage.childNodes[1].childNodes[0].childNodes[1], {});
668
+ _react.fireEvent.click(seaButton.childNodes[0], {});
667
669
 
668
670
  continueButton = newPage.childNodes[2].childNodes[0];
669
671
 
@@ -671,17 +673,23 @@ describe('components', function () {
671
673
 
672
674
 
673
675
  cyaPageChange = container.childNodes[0].childNodes[0];
674
- modeChangeLink = cyaPageChange.childNodes[0].childNodes[1].childNodes[0].childNodes[0];
676
+ expect(cyaPageChange.childNodes[0].textContent).toEqual('Check your answers');
677
+ modeChangeLink = cyaPageChange.childNodes[4].childNodes[0].childNodes[0].childNodes[2].childNodes[0];
678
+ expect(modeChangeLink.textContent).toEqual('Change Event Mode');
675
679
 
676
680
  _react.fireEvent.click(modeChangeLink, {});
677
681
 
678
682
  changePage = container.childNodes[0].childNodes[0];
679
- expect(changePage.childNodes[1].textContent).toEqual('Event Mode'); // Click on radio for 'Air'
683
+ expect(changePage.childNodes[0].textContent).toEqual('Event Mode'); // Click on radio for 'Air'
680
684
 
681
- _react.fireEvent.click(changePage.childNodes[2].childNodes[0].childNodes[3].childNodes[1].childNodes[0]); // Continue again to CYA page
685
+ airButton = changePage.childNodes[1].childNodes[0].childNodes[2].childNodes[1];
686
+ expect(airButton.textContent).toEqual('Air');
682
687
 
688
+ _react.fireEvent.click(airButton.childNodes[0]); // Continue again to CYA page
683
689
 
684
- continueButton = changePage.childNodes[3].childNodes[0];
690
+
691
+ expect(changePage.childNodes[2].childNodes[0].textContent).toEqual('Save and continue');
692
+ continueButton = changePage.childNodes[2].childNodes[0];
685
693
 
686
694
  _react.fireEvent.click(continueButton, {}); //Continue on from CYA page
687
695
 
@@ -706,7 +714,7 @@ describe('components', function () {
706
714
  expect(finalSubmit.mode).toEqual('air');
707
715
  expect(finalSubmit.formStatus.tasks['Date, location and mode details'].complete).toEqual(true);
708
716
 
709
- case 47:
717
+ case 54:
710
718
  case "end":
711
719
  return _context20.stop();
712
720
  }
@@ -174,26 +174,26 @@ describe('utils.CollectionPage.mergeCollectionPages', function () {
174
174
  },
175
175
  components: [{
176
176
  type: 'text',
177
- show_when: [{
177
+ show_when: {
178
178
  field: 'field',
179
179
  op: '=',
180
180
  value: 'value'
181
- }]
181
+ }
182
182
  }, {
183
183
  type: 'container',
184
184
  components: [{
185
185
  type: 'date',
186
- show_when: [{
186
+ show_when: {
187
187
  field: 'field',
188
188
  op: '=',
189
189
  value: 'otherValue'
190
- }]
190
+ }
191
191
  }],
192
- show_when: [{
192
+ show_when: {
193
193
  field: 'field',
194
194
  op: '=',
195
195
  value: 'otherValue'
196
- }]
196
+ }
197
197
  }],
198
198
  formData: {}
199
199
  });
@@ -36,7 +36,7 @@ var addShowWhen = function addShowWhen(component, condition) {
36
36
  if (result.show_when) {
37
37
  result.show_when = Array.isArray(result.show_when) ? [].concat(result.show_when, [_objectSpread({}, condition)]) : [result.show_when, _objectSpread({}, condition)];
38
38
  } else {
39
- result.show_when = [_objectSpread({}, condition)];
39
+ result.show_when = condition;
40
40
  }
41
41
 
42
42
  return result;
@@ -44,7 +44,27 @@ describe('utils.Component.addShowWhen', function () {
44
44
  var result = (0, _addShowWhen.default)(COMPONENT, NEW_SHOW_WHEN);
45
45
  expect(result).toEqual({
46
46
  alpha: 'bravo',
47
- show_when: [NEW_SHOW_WHEN]
47
+ show_when: NEW_SHOW_WHEN
48
+ });
49
+ });
50
+ it('should add the array type show_when to a component with no existing show_whens', function () {
51
+ var NEW_ARRAY_SHOW_WHEN = [{
52
+ field: 'abc',
53
+ op: '=',
54
+ value: 'bcd'
55
+ }, {
56
+ field: 'cde',
57
+ op: '=',
58
+ value: 'efg'
59
+ }];
60
+ var COMPONENT = {
61
+ alpha: 'bravo'
62
+ };
63
+ var result = (0, _addShowWhen.default)(COMPONENT, NEW_ARRAY_SHOW_WHEN);
64
+ console.log(result);
65
+ expect(result).toEqual({
66
+ alpha: 'bravo',
67
+ show_when: NEW_ARRAY_SHOW_WHEN
48
68
  });
49
69
  });
50
70
  it('should add the show_when to a component with a single show_when', function () {
@@ -93,4 +113,26 @@ describe('utils.Component.addShowWhen', function () {
93
113
  }, NEW_SHOW_WHEN]
94
114
  });
95
115
  });
116
+ it('should add the or type show_when to a component with no existing show_whens in an object not an array', function () {
117
+ var COMPONENT = {
118
+ alpha: 'bravo'
119
+ };
120
+ var SHOW_WHEN_OR = {
121
+ type: 'or',
122
+ condition: [{
123
+ field: 'field1',
124
+ op: '=',
125
+ values: 1
126
+ }, {
127
+ field: 'field2',
128
+ op: '=',
129
+ value: 2
130
+ }]
131
+ };
132
+ var result = (0, _addShowWhen.default)(COMPONENT, SHOW_WHEN_OR);
133
+ expect(result).toEqual({
134
+ alpha: 'bravo',
135
+ show_when: SHOW_WHEN_OR
136
+ });
137
+ });
96
138
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "4.32.0",
3
+ "version": "4.32.3",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",