@ukhomeoffice/cop-react-form-renderer 4.29.0-alpha → 4.29.0-beta
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/CollectionPage/CollectionPage.test.js +9 -9
- package/dist/components/FormComponent/Collection.test.js +7 -7
- package/dist/components/FormComponent/Container.test.js +14 -14
- package/dist/components/FormComponent/FormComponent.test.js +6 -6
- package/dist/components/FormPage/FormPage.js +6 -1
- package/dist/components/FormPage/FormPage.test.js +8 -8
- package/dist/components/FormRenderer/FormRenderer.test.js +13 -13
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +4 -3
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +4 -3
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +7 -7
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +11 -11
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +1 -7
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +1 -1
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +4 -4
- package/dist/utils/Validate/validateComponent.js +3 -2
- package/dist/utils/Validate/validateEmail.js +9 -1
- package/dist/utils/Validate/validateEmail.test.js +8 -0
- package/package.json +2 -2
|
@@ -147,16 +147,16 @@ describe('components.CollectionPage', function () {
|
|
|
147
147
|
var checkInputField = function checkInputField(formGroup, fieldId, lbl, hnt, val) {
|
|
148
148
|
expect(formGroup.tagName).toEqual('DIV');
|
|
149
149
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
150
|
-
var label = formGroup.childNodes[0];
|
|
150
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
151
151
|
expect(label.tagName).toEqual('LABEL');
|
|
152
152
|
expect(label.classList).toContain('govuk-label');
|
|
153
153
|
expect(label.textContent).toEqual(lbl);
|
|
154
154
|
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
155
|
-
var hint = formGroup.childNodes[1];
|
|
155
|
+
var hint = formGroup.childNodes[0].childNodes[1];
|
|
156
156
|
expect(hint.tagName).toEqual('SPAN');
|
|
157
157
|
expect(hint.classList).toContain('govuk-hint');
|
|
158
158
|
expect(hint.textContent).toEqual(hnt);
|
|
159
|
-
var input = formGroup.childNodes[2];
|
|
159
|
+
var input = formGroup.childNodes[0].childNodes[2];
|
|
160
160
|
expect(input.tagName).toEqual('INPUT');
|
|
161
161
|
expect(input.classList).toContain('govuk-input');
|
|
162
162
|
expect(input.id).toEqual(fieldId);
|
|
@@ -167,16 +167,16 @@ describe('components.CollectionPage', function () {
|
|
|
167
167
|
var checkAutoCompleteField = function checkAutoCompleteField(formGroup, fieldId, lbl, hnt, val) {
|
|
168
168
|
expect(formGroup.tagName).toEqual('DIV');
|
|
169
169
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
170
|
-
var label = formGroup.childNodes[0];
|
|
170
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
171
171
|
expect(label.tagName).toEqual('LABEL');
|
|
172
172
|
expect(label.classList).toContain('govuk-label');
|
|
173
173
|
expect(label.textContent).toEqual(lbl);
|
|
174
174
|
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
175
|
-
var hint = formGroup.childNodes[1];
|
|
175
|
+
var hint = formGroup.childNodes[0].childNodes[1];
|
|
176
176
|
expect(hint.tagName).toEqual('SPAN');
|
|
177
177
|
expect(hint.classList).toContain('govuk-hint');
|
|
178
178
|
expect(hint.textContent).toEqual(hnt);
|
|
179
|
-
var outerWrapper = formGroup.childNodes[2];
|
|
179
|
+
var outerWrapper = formGroup.childNodes[0].childNodes[2];
|
|
180
180
|
expect(outerWrapper.classList).toContain('hods-autocomplete__outer-wrapper');
|
|
181
181
|
var autocomplete = outerWrapper.childNodes[0];
|
|
182
182
|
expect(autocomplete.classList).toContain('hods-autocomplete__wrapper');
|
|
@@ -293,7 +293,7 @@ describe('components.CollectionPage', function () {
|
|
|
293
293
|
page = container.childNodes[0];
|
|
294
294
|
expect(page.tagName).toEqual('DIV'); // Change the input.
|
|
295
295
|
|
|
296
|
-
input = page.childNodes[1].childNodes[2];
|
|
296
|
+
input = page.childNodes[1].childNodes[0].childNodes[2];
|
|
297
297
|
NEW_VALUE = "".concat(VALUE, ".");
|
|
298
298
|
EVENT = {
|
|
299
299
|
target: {
|
|
@@ -327,7 +327,7 @@ describe('components.CollectionPage', function () {
|
|
|
327
327
|
})), container = _renderWithValidation4.container;
|
|
328
328
|
page = container.childNodes[0]; // Change the input.
|
|
329
329
|
|
|
330
|
-
input = page.childNodes[1].childNodes[2];
|
|
330
|
+
input = page.childNodes[1].childNodes[0].childNodes[2];
|
|
331
331
|
NEW_VALUE = "".concat(VALUE, ".");
|
|
332
332
|
CHANGE_EVENT = {
|
|
333
333
|
target: {
|
|
@@ -374,7 +374,7 @@ describe('components.CollectionPage', function () {
|
|
|
374
374
|
})), container = _renderWithValidation5.container;
|
|
375
375
|
page = container.childNodes[0]; // Change the input.
|
|
376
376
|
|
|
377
|
-
input = page.childNodes[1].childNodes[2];
|
|
377
|
+
input = page.childNodes[1].childNodes[0].childNodes[2];
|
|
378
378
|
NEW_VALUE = "".concat(VALUE, ".");
|
|
379
379
|
CHANGE_EVENT = {
|
|
380
380
|
target: {
|
|
@@ -88,16 +88,16 @@ describe('components.FormComponent.Collection', function () {
|
|
|
88
88
|
formGroup = itemContainer.childNodes[0];
|
|
89
89
|
expect(formGroup.tagName).toEqual('DIV');
|
|
90
90
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
91
|
-
label = formGroup.childNodes[0];
|
|
91
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
92
92
|
expect(label.tagName).toEqual('LABEL');
|
|
93
93
|
expect(label.classList).toContain('govuk-label');
|
|
94
94
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
95
95
|
expect(label.getAttribute('for')).toEqual("".concat(ID, "[0].").concat(TEXT_ID));
|
|
96
|
-
hint = formGroup.childNodes[1];
|
|
96
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
97
97
|
expect(hint.tagName).toEqual('SPAN');
|
|
98
98
|
expect(hint.classList).toContain('govuk-hint');
|
|
99
99
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
100
|
-
input = formGroup.childNodes[2];
|
|
100
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
101
101
|
expect(input.tagName).toEqual('INPUT');
|
|
102
102
|
expect(input.classList).toContain('govuk-input');
|
|
103
103
|
expect(input.id).toEqual("".concat(ID, "[0].").concat(TEXT_ID));
|
|
@@ -144,7 +144,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
144
144
|
c = container.childNodes[0];
|
|
145
145
|
item = c.childNodes[0];
|
|
146
146
|
formGroup = item.childNodes[1].childNodes[0];
|
|
147
|
-
input = formGroup.childNodes[2];
|
|
147
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
148
148
|
NEW_TEXT_VALUE = 'bravo';
|
|
149
149
|
EVENT = {
|
|
150
150
|
target: {
|
|
@@ -354,16 +354,16 @@ describe('components.FormComponent.Collection', function () {
|
|
|
354
354
|
formGroup = itemContainer.childNodes[0];
|
|
355
355
|
expect(formGroup.tagName).toEqual('DIV');
|
|
356
356
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
357
|
-
label = formGroup.childNodes[0];
|
|
357
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
358
358
|
expect(label.tagName).toEqual('LABEL');
|
|
359
359
|
expect(label.classList).toContain('govuk-label');
|
|
360
360
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
361
361
|
expect(label.getAttribute('for')).toEqual("".concat(ID, "[0].").concat(TEXT_ID));
|
|
362
|
-
hint = formGroup.childNodes[1];
|
|
362
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
363
363
|
expect(hint.tagName).toEqual('SPAN');
|
|
364
364
|
expect(hint.classList).toContain('govuk-hint');
|
|
365
365
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
366
|
-
input = formGroup.childNodes[2];
|
|
366
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
367
367
|
expect(input.tagName).toEqual('DIV'); // Now readonly, so a DIV.
|
|
368
368
|
|
|
369
369
|
expect(input.classList).toContain('hods-readonly'); // Now readonly, so hods-readonly
|
|
@@ -76,16 +76,16 @@ describe('components.FormComponent.Container', function () {
|
|
|
76
76
|
formGroup = c.childNodes[0];
|
|
77
77
|
expect(formGroup.tagName).toEqual('DIV');
|
|
78
78
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
79
|
-
label = formGroup.childNodes[0];
|
|
79
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
80
80
|
expect(label.tagName).toEqual('LABEL');
|
|
81
81
|
expect(label.classList).toContain('govuk-label');
|
|
82
82
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
83
83
|
expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
84
|
-
hint = formGroup.childNodes[1];
|
|
84
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
85
85
|
expect(hint.tagName).toEqual('SPAN');
|
|
86
86
|
expect(hint.classList).toContain('govuk-hint');
|
|
87
87
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
88
|
-
input = formGroup.childNodes[2];
|
|
88
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
89
89
|
expect(input.tagName).toEqual('INPUT');
|
|
90
90
|
expect(input.classList).toContain('govuk-input');
|
|
91
91
|
expect(input.id).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
@@ -133,16 +133,16 @@ describe('components.FormComponent.Container', function () {
|
|
|
133
133
|
formGroup = nested.childNodes[0];
|
|
134
134
|
expect(formGroup.tagName).toEqual('DIV');
|
|
135
135
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
136
|
-
label = formGroup.childNodes[0];
|
|
136
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
137
137
|
expect(label.tagName).toEqual('LABEL');
|
|
138
138
|
expect(label.classList).toContain('govuk-label');
|
|
139
139
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
140
140
|
expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(NESTED_ID, ".").concat(TEXT_ID));
|
|
141
|
-
hint = formGroup.childNodes[1];
|
|
141
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
142
142
|
expect(hint.tagName).toEqual('SPAN');
|
|
143
143
|
expect(hint.classList).toContain('govuk-hint');
|
|
144
144
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
145
|
-
input = formGroup.childNodes[2];
|
|
145
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
146
146
|
expect(input.tagName).toEqual('INPUT');
|
|
147
147
|
expect(input.classList).toContain('govuk-input');
|
|
148
148
|
expect(input.id).toEqual("".concat(ID, ".").concat(NESTED_ID, ".").concat(TEXT_ID));
|
|
@@ -188,7 +188,7 @@ describe('components.FormComponent.Container', function () {
|
|
|
188
188
|
|
|
189
189
|
c = container.childNodes[0];
|
|
190
190
|
formGroup = c.childNodes[0];
|
|
191
|
-
input = formGroup.childNodes[2];
|
|
191
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
192
192
|
NEW_TEXT_VALUE = 'bravo';
|
|
193
193
|
EVENT = {
|
|
194
194
|
target: {
|
|
@@ -253,7 +253,7 @@ describe('components.FormComponent.Container', function () {
|
|
|
253
253
|
|
|
254
254
|
c = container.childNodes[0];
|
|
255
255
|
formGroup = c.childNodes[0];
|
|
256
|
-
input = formGroup.childNodes[2].childNodes[0];
|
|
256
|
+
input = formGroup.childNodes[0].childNodes[2].childNodes[0];
|
|
257
257
|
FILE_EXTENSION = 'json';
|
|
258
258
|
FILE_NAME = "test.".concat(FILE_EXTENSION);
|
|
259
259
|
FILE_TYPE = 'application/JSON';
|
|
@@ -314,16 +314,16 @@ describe('components.FormComponent.Container', function () {
|
|
|
314
314
|
formGroup = c.childNodes[0];
|
|
315
315
|
expect(formGroup.tagName).toEqual('DIV');
|
|
316
316
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
317
|
-
label = formGroup.childNodes[0];
|
|
317
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
318
318
|
expect(label.tagName).toEqual('LABEL');
|
|
319
319
|
expect(label.classList).toContain('govuk-label');
|
|
320
320
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
321
321
|
expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
322
|
-
hint = formGroup.childNodes[1];
|
|
322
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
323
323
|
expect(hint.tagName).toEqual('SPAN');
|
|
324
324
|
expect(hint.classList).toContain('govuk-hint');
|
|
325
325
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
326
|
-
input = formGroup.childNodes[2];
|
|
326
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
327
327
|
expect(input.tagName).toEqual('INPUT');
|
|
328
328
|
expect(input.classList).toContain('govuk-input');
|
|
329
329
|
expect(input.id).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
@@ -396,16 +396,16 @@ describe('components.FormComponent.Container', function () {
|
|
|
396
396
|
formGroup = c.childNodes[0];
|
|
397
397
|
expect(formGroup.tagName).toEqual('DIV');
|
|
398
398
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
399
|
-
label = formGroup.childNodes[0];
|
|
399
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
400
400
|
expect(label.tagName).toEqual('LABEL');
|
|
401
401
|
expect(label.classList).toContain('govuk-label');
|
|
402
402
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
403
403
|
expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
404
|
-
hint = formGroup.childNodes[1];
|
|
404
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
405
405
|
expect(hint.tagName).toEqual('SPAN');
|
|
406
406
|
expect(hint.classList).toContain('govuk-hint');
|
|
407
407
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
408
|
-
input = formGroup.childNodes[2];
|
|
408
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
409
409
|
expect(input.tagName).toEqual('DIV'); // Now readonly, so a DIV.
|
|
410
410
|
|
|
411
411
|
expect(input.classList).toContain('hods-readonly'); // Now readonly, so hods-readonly
|
|
@@ -43,16 +43,16 @@ describe('components', function () {
|
|
|
43
43
|
formGroup = container.childNodes[0];
|
|
44
44
|
expect(formGroup.tagName).toEqual('DIV');
|
|
45
45
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
46
|
-
label = formGroup.childNodes[0];
|
|
46
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
47
47
|
expect(label.tagName).toEqual('LABEL');
|
|
48
48
|
expect(label.classList).toContain('govuk-label');
|
|
49
49
|
expect(label.textContent).toEqual("".concat(COMPONENT.label, " (optional)"));
|
|
50
50
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
51
|
-
hint = formGroup.childNodes[1];
|
|
51
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
52
52
|
expect(hint.tagName).toEqual('SPAN');
|
|
53
53
|
expect(hint.classList).toContain('govuk-hint');
|
|
54
54
|
expect(hint.textContent).toEqual(COMPONENT.hint);
|
|
55
|
-
input = formGroup.childNodes[2];
|
|
55
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
56
56
|
expect(input.tagName).toEqual('INPUT');
|
|
57
57
|
expect(input.classList).toContain('govuk-input');
|
|
58
58
|
expect(input.id).toEqual(ID);
|
|
@@ -238,16 +238,16 @@ describe('components', function () {
|
|
|
238
238
|
formGroup = container.childNodes[0];
|
|
239
239
|
expect(formGroup.tagName).toEqual('DIV');
|
|
240
240
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
241
|
-
label = formGroup.childNodes[0];
|
|
241
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
242
242
|
expect(label.tagName).toEqual('LABEL');
|
|
243
243
|
expect(label.classList).toContain('govuk-label');
|
|
244
244
|
expect(label.textContent).toEqual('Interpolated Text component (optional)');
|
|
245
245
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
246
|
-
hint = formGroup.childNodes[1];
|
|
246
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
247
247
|
expect(hint.tagName).toEqual('SPAN');
|
|
248
248
|
expect(hint.classList).toContain('govuk-hint');
|
|
249
249
|
expect(hint.textContent).toEqual(COMPONENT.hint);
|
|
250
|
-
input = formGroup.childNodes[2];
|
|
250
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
251
251
|
expect(input.tagName).toEqual('INPUT');
|
|
252
252
|
expect(input.classList).toContain('govuk-input');
|
|
253
253
|
expect(input.id).toEqual(ID);
|
|
@@ -73,13 +73,14 @@ var FormPage = function FormPage(_ref) {
|
|
|
73
73
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
74
74
|
patchLabel = _useState4[0],
|
|
75
75
|
setPatchLabel = _useState4[1];
|
|
76
|
+
|
|
77
|
+
var docTitle = (0, _react.useState)(document.title);
|
|
76
78
|
/**
|
|
77
79
|
* Handle the state of the data directly within the page.
|
|
78
80
|
* This is so that the overall form data isn't affected until such
|
|
79
81
|
* time as the onAction handler is invoked.
|
|
80
82
|
*/
|
|
81
83
|
|
|
82
|
-
|
|
83
84
|
var onPageChange = function onPageChange(_ref2) {
|
|
84
85
|
var target = _ref2.target;
|
|
85
86
|
page.formData[target.name] = target.value;
|
|
@@ -91,6 +92,10 @@ var FormPage = function FormPage(_ref) {
|
|
|
91
92
|
});
|
|
92
93
|
};
|
|
93
94
|
|
|
95
|
+
(0, _react.useEffect)(function () {
|
|
96
|
+
document.title = errors.length > 0 ? 'Error: ' + docTitle : docTitle;
|
|
97
|
+
}, [errors, docTitle]);
|
|
98
|
+
|
|
94
99
|
var classes = _utils.default.classBuilder(classBlock, classModifiers, className);
|
|
95
100
|
|
|
96
101
|
page.actions = (_page$actions = page.actions) === null || _page$actions === void 0 ? void 0 : _page$actions.map(function (action) {
|
|
@@ -135,16 +135,16 @@ describe('components.FormPage', function () {
|
|
|
135
135
|
var checkInputField = function checkInputField(formGroup, fieldId, lbl, hnt, val) {
|
|
136
136
|
expect(formGroup.tagName).toEqual('DIV');
|
|
137
137
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
138
|
-
var label = formGroup.childNodes[0];
|
|
138
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
139
139
|
expect(label.tagName).toEqual('LABEL');
|
|
140
140
|
expect(label.classList).toContain('govuk-label');
|
|
141
141
|
expect(label.textContent).toEqual(lbl);
|
|
142
142
|
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
143
|
-
var hint = formGroup.childNodes[1];
|
|
143
|
+
var hint = formGroup.childNodes[0].childNodes[1];
|
|
144
144
|
expect(hint.tagName).toEqual('SPAN');
|
|
145
145
|
expect(hint.classList).toContain('govuk-hint');
|
|
146
146
|
expect(hint.textContent).toEqual(hnt);
|
|
147
|
-
var input = formGroup.childNodes[2];
|
|
147
|
+
var input = formGroup.childNodes[0].childNodes[2];
|
|
148
148
|
expect(input.tagName).toEqual('INPUT');
|
|
149
149
|
expect(input.classList).toContain('govuk-input');
|
|
150
150
|
expect(input.id).toEqual(fieldId);
|
|
@@ -155,16 +155,16 @@ describe('components.FormPage', function () {
|
|
|
155
155
|
var checkAutoCompleteField = function checkAutoCompleteField(formGroup, fieldId, lbl, hnt, val) {
|
|
156
156
|
expect(formGroup.tagName).toEqual('DIV');
|
|
157
157
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
158
|
-
var label = formGroup.childNodes[0];
|
|
158
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
159
159
|
expect(label.tagName).toEqual('LABEL');
|
|
160
160
|
expect(label.classList).toContain('govuk-label');
|
|
161
161
|
expect(label.textContent).toEqual(lbl);
|
|
162
162
|
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
163
|
-
var hint = formGroup.childNodes[1];
|
|
163
|
+
var hint = formGroup.childNodes[0].childNodes[1];
|
|
164
164
|
expect(hint.tagName).toEqual('SPAN');
|
|
165
165
|
expect(hint.classList).toContain('govuk-hint');
|
|
166
166
|
expect(hint.textContent).toEqual(hnt);
|
|
167
|
-
var outerWrapper = formGroup.childNodes[2];
|
|
167
|
+
var outerWrapper = formGroup.childNodes[0].childNodes[2];
|
|
168
168
|
expect(outerWrapper.classList).toContain('hods-autocomplete__outer-wrapper');
|
|
169
169
|
var autocomplete = outerWrapper.childNodes[0];
|
|
170
170
|
expect(autocomplete.classList).toContain('hods-autocomplete__wrapper');
|
|
@@ -278,7 +278,7 @@ describe('components.FormPage', function () {
|
|
|
278
278
|
page = container.childNodes[0];
|
|
279
279
|
expect(page.tagName).toEqual('DIV'); // Change the input.
|
|
280
280
|
|
|
281
|
-
input = page.childNodes[1].childNodes[2];
|
|
281
|
+
input = page.childNodes[1].childNodes[0].childNodes[2];
|
|
282
282
|
NEW_VALUE = "".concat(VALUE, ".");
|
|
283
283
|
EVENT = {
|
|
284
284
|
target: {
|
|
@@ -312,7 +312,7 @@ describe('components.FormPage', function () {
|
|
|
312
312
|
})), container = _renderWithValidation4.container;
|
|
313
313
|
page = container.childNodes[0]; // Change the input.
|
|
314
314
|
|
|
315
|
-
input = page.childNodes[1].childNodes[2];
|
|
315
|
+
input = page.childNodes[1].childNodes[0].childNodes[2];
|
|
316
316
|
NEW_VALUE = "".concat(VALUE, ".");
|
|
317
317
|
CHANGE_EVENT = {
|
|
318
318
|
target: {
|
|
@@ -638,21 +638,21 @@ describe('components', function () {
|
|
|
638
638
|
newPage = container.childNodes[0].childNodes[0];
|
|
639
639
|
expect(newPage.childNodes[0].textContent).toEqual('Event Date');
|
|
640
640
|
|
|
641
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[0].childNodes[1], {
|
|
641
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0].childNodes[1], {
|
|
642
642
|
target: {
|
|
643
643
|
name: 'date-day',
|
|
644
644
|
value: '7'
|
|
645
645
|
}
|
|
646
646
|
});
|
|
647
647
|
|
|
648
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[1].childNodes[1], {
|
|
648
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[1], {
|
|
649
649
|
target: {
|
|
650
650
|
name: 'date-month',
|
|
651
651
|
value: '7'
|
|
652
652
|
}
|
|
653
653
|
});
|
|
654
654
|
|
|
655
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[2].childNodes[1], {
|
|
655
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[0].childNodes[1], {
|
|
656
656
|
target: {
|
|
657
657
|
name: 'date-year',
|
|
658
658
|
value: '2022'
|
|
@@ -667,7 +667,7 @@ describe('components', function () {
|
|
|
667
667
|
newPage = container.childNodes[0].childNodes[0];
|
|
668
668
|
expect(newPage.childNodes[0].textContent).toEqual('Event Mode');
|
|
669
669
|
|
|
670
|
-
_react.fireEvent.click(newPage.childNodes[1].childNodes[2].childNodes[0].childNodes[0], {});
|
|
670
|
+
_react.fireEvent.click(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0], {});
|
|
671
671
|
|
|
672
672
|
continueButton = newPage.childNodes[2].childNodes[0];
|
|
673
673
|
|
|
@@ -682,7 +682,7 @@ describe('components', function () {
|
|
|
682
682
|
changePage = container.childNodes[0].childNodes[0];
|
|
683
683
|
expect(changePage.childNodes[0].textContent).toEqual('Event Mode'); // Click on radio for 'Air'
|
|
684
684
|
|
|
685
|
-
_react.fireEvent.click(changePage.childNodes[1].childNodes[2].childNodes[1].childNodes[0], {}); // Continue again to CYA page
|
|
685
|
+
_react.fireEvent.click(changePage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[0], {}); // Continue again to CYA page
|
|
686
686
|
|
|
687
687
|
|
|
688
688
|
continueButton = changePage.childNodes[2].childNodes[0];
|
|
@@ -756,21 +756,21 @@ describe('components', function () {
|
|
|
756
756
|
|
|
757
757
|
newPage = container.childNodes[0].childNodes[0];
|
|
758
758
|
|
|
759
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[0].childNodes[1], {
|
|
759
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0].childNodes[1], {
|
|
760
760
|
target: {
|
|
761
761
|
name: 'date-day',
|
|
762
762
|
value: '7'
|
|
763
763
|
}
|
|
764
764
|
});
|
|
765
765
|
|
|
766
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[1].childNodes[1], {
|
|
766
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[1], {
|
|
767
767
|
target: {
|
|
768
768
|
name: 'date-month',
|
|
769
769
|
value: '7'
|
|
770
770
|
}
|
|
771
771
|
});
|
|
772
772
|
|
|
773
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[2].childNodes[1], {
|
|
773
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[0].childNodes[1], {
|
|
774
774
|
target: {
|
|
775
775
|
name: 'date-year',
|
|
776
776
|
value: '2022'
|
|
@@ -782,7 +782,7 @@ describe('components', function () {
|
|
|
782
782
|
|
|
783
783
|
newPage = container.childNodes[0].childNodes[0];
|
|
784
784
|
|
|
785
|
-
_react.fireEvent.click(newPage.childNodes[1].childNodes[2].childNodes[0].childNodes[0], {});
|
|
785
|
+
_react.fireEvent.click(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0], {});
|
|
786
786
|
|
|
787
787
|
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {}); //Continue on from CYA page
|
|
788
788
|
|
|
@@ -847,21 +847,21 @@ describe('components', function () {
|
|
|
847
847
|
|
|
848
848
|
newPage = container.childNodes[0].childNodes[0];
|
|
849
849
|
|
|
850
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[0].childNodes[1], {
|
|
850
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0].childNodes[1], {
|
|
851
851
|
target: {
|
|
852
852
|
name: 'date-day',
|
|
853
853
|
value: '7'
|
|
854
854
|
}
|
|
855
855
|
});
|
|
856
856
|
|
|
857
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[1].childNodes[1], {
|
|
857
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[1], {
|
|
858
858
|
target: {
|
|
859
859
|
name: 'date-month',
|
|
860
860
|
value: '7'
|
|
861
861
|
}
|
|
862
862
|
});
|
|
863
863
|
|
|
864
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[2].childNodes[2].childNodes[1], {
|
|
864
|
+
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[0].childNodes[1], {
|
|
865
865
|
target: {
|
|
866
866
|
name: 'date-year',
|
|
867
867
|
value: '2022'
|
|
@@ -873,7 +873,7 @@ describe('components', function () {
|
|
|
873
873
|
|
|
874
874
|
newPage = container.childNodes[0].childNodes[0];
|
|
875
875
|
|
|
876
|
-
_react.fireEvent.click(newPage.childNodes[1].childNodes[2].childNodes[0].childNodes[0], {});
|
|
876
|
+
_react.fireEvent.click(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[0].childNodes[0], {});
|
|
877
877
|
|
|
878
878
|
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {}); // Launch same task again
|
|
879
879
|
|
|
@@ -37,11 +37,12 @@ describe('utils.Component.get', function () {
|
|
|
37
37
|
var autocompleteWrapper = undefined;
|
|
38
38
|
var autocomplete = undefined;
|
|
39
39
|
var autocompleteInput = undefined;
|
|
40
|
-
formGroup.childNodes
|
|
40
|
+
var fieldSet = formGroup.childNodes[0];
|
|
41
|
+
fieldSet.childNodes.forEach(function (node) {
|
|
41
42
|
// Check if it's an element.
|
|
42
43
|
if (node instanceof Element) {
|
|
43
|
-
if (node.tagName === '
|
|
44
|
-
label = node;
|
|
44
|
+
if (node.tagName === 'LEGEND') {
|
|
45
|
+
label = node.childNodes[0];
|
|
45
46
|
} else if (node.classList.contains('hods-autocomplete__outer-wrapper')) {
|
|
46
47
|
autocompleteWrapper = node;
|
|
47
48
|
var autocompleteInner = node.childNodes[0];
|
|
@@ -154,7 +154,7 @@ describe('utils.Component.get', function () {
|
|
|
154
154
|
_getAllByTestId = (0, _react.getAllByTestId)(container, ID), _getAllByTestId2 = _slicedToArray(_getAllByTestId, 2), formGroup = _getAllByTestId2[0], input = _getAllByTestId2[1];
|
|
155
155
|
expect(formGroup.tagName).toEqual('DIV');
|
|
156
156
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
157
|
-
label = formGroup.childNodes[0];
|
|
157
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
158
158
|
expect(label.tagName).toEqual('LABEL');
|
|
159
159
|
expect(label.classList).toContain('govuk-label');
|
|
160
160
|
expect(label.textContent).toContain(LABEL);
|
|
@@ -268,7 +268,7 @@ describe('utils.Component.get', function () {
|
|
|
268
268
|
|
|
269
269
|
expect(formGroup.tagName).toEqual('DIV');
|
|
270
270
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
271
|
-
var label = formGroup.childNodes[0];
|
|
271
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
272
272
|
expect(label.tagName).toEqual('LABEL');
|
|
273
273
|
expect(label.classList).toContain('govuk-label');
|
|
274
274
|
expect(label.textContent).toContain(LABEL);
|
|
@@ -60,12 +60,13 @@ describe('utils.Component.get', function () {
|
|
|
60
60
|
|
|
61
61
|
expect(formGroup.tagName).toEqual('DIV');
|
|
62
62
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
63
|
+
var fieldSet = formGroup.childNodes[0];
|
|
63
64
|
var label = undefined;
|
|
64
|
-
|
|
65
|
+
fieldSet.childNodes.forEach(function (node) {
|
|
65
66
|
// Check if it's an element.
|
|
66
67
|
if (node instanceof Element) {
|
|
67
|
-
if (node.tagName === '
|
|
68
|
-
label = node;
|
|
68
|
+
if (node.tagName === 'LEGEND') {
|
|
69
|
+
label = node.childNodes[0];
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
});
|
|
@@ -50,7 +50,7 @@ describe('utils.Component.get', function () {
|
|
|
50
50
|
|
|
51
51
|
expect(formGroup.tagName).toEqual('DIV');
|
|
52
52
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
53
|
-
var label = formGroup.childNodes[0];
|
|
53
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
54
54
|
expect(label.innerHTML).toContain(LABEL);
|
|
55
55
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
56
56
|
expect(dateinput.tagName).toEqual('DIV');
|
|
@@ -59,31 +59,31 @@ describe('utils.Component.get', function () {
|
|
|
59
59
|
var dayitem = dateinput.childNodes[0];
|
|
60
60
|
expect(dayitem.tagName).toEqual('DIV');
|
|
61
61
|
expect(dayitem.classList).toContain('govuk-date-input__item');
|
|
62
|
-
var daylabel = dayitem.childNodes[0];
|
|
62
|
+
var daylabel = dayitem.childNodes[0].childNodes[0].childNodes[0];
|
|
63
63
|
expect(daylabel.tagName).toEqual('LABEL');
|
|
64
64
|
expect(daylabel.classList).toContain('govuk-label');
|
|
65
65
|
expect(daylabel.textContent).toEqual('Day');
|
|
66
|
-
var dayinput = dayitem.childNodes[1];
|
|
66
|
+
var dayinput = dayitem.childNodes[0].childNodes[1];
|
|
67
67
|
expect(dayinput.tagName).toEqual('INPUT');
|
|
68
68
|
expect(dayinput.id).toEqual("".concat(ID, "-day"));
|
|
69
69
|
var monthitem = dateinput.childNodes[1];
|
|
70
70
|
expect(monthitem.tagName).toEqual('DIV');
|
|
71
71
|
expect(monthitem.classList).toContain('govuk-date-input__item');
|
|
72
|
-
var monthlabel = monthitem.childNodes[0];
|
|
72
|
+
var monthlabel = monthitem.childNodes[0].childNodes[0].childNodes[0];
|
|
73
73
|
expect(monthlabel.tagName).toEqual('LABEL');
|
|
74
74
|
expect(monthlabel.classList).toContain('govuk-label');
|
|
75
75
|
expect(monthlabel.textContent).toEqual('Month');
|
|
76
|
-
var monthinput = monthitem.childNodes[1];
|
|
76
|
+
var monthinput = monthitem.childNodes[0].childNodes[1];
|
|
77
77
|
expect(monthinput.tagName).toEqual('INPUT');
|
|
78
78
|
expect(monthinput.id).toEqual("".concat(ID, "-month"));
|
|
79
79
|
var yearitem = dateinput.childNodes[2];
|
|
80
80
|
expect(yearitem.tagName).toEqual('DIV');
|
|
81
81
|
expect(yearitem.classList).toContain('govuk-date-input__item');
|
|
82
|
-
var yearlabel = yearitem.childNodes[0];
|
|
82
|
+
var yearlabel = yearitem.childNodes[0].childNodes[0].childNodes[0];
|
|
83
83
|
expect(yearlabel.tagName).toEqual('LABEL');
|
|
84
84
|
expect(yearlabel.classList).toContain('govuk-label');
|
|
85
85
|
expect(yearlabel.textContent).toEqual('Year');
|
|
86
|
-
var yearinput = yearitem.childNodes[1];
|
|
86
|
+
var yearinput = yearitem.childNodes[0].childNodes[1];
|
|
87
87
|
expect(yearinput.tagName).toEqual('INPUT');
|
|
88
88
|
expect(yearinput.id).toEqual("".concat(ID, "-year")); // Add something to the day and make sure it fires.
|
|
89
89
|
|
|
@@ -51,10 +51,10 @@ describe('utils.Component.get', function () {
|
|
|
51
51
|
expect(formGroup.tagName).toEqual('DIV');
|
|
52
52
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
53
53
|
var label = undefined;
|
|
54
|
-
formGroup.childNodes.forEach(function (node) {
|
|
54
|
+
formGroup.childNodes[0].childNodes.forEach(function (node) {
|
|
55
55
|
// Check if it's an element.
|
|
56
|
-
if (node instanceof Element && node.tagName === '
|
|
57
|
-
label = node;
|
|
56
|
+
if (node instanceof Element && node.tagName === 'LEGEND') {
|
|
57
|
+
label = node.childNodes[0];
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
expect(label).toBeDefined();
|
|
@@ -53,10 +53,10 @@ describe('utils.Component.get', function () {
|
|
|
53
53
|
expect(formGroup.tagName).toEqual('DIV');
|
|
54
54
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
55
55
|
var label = undefined;
|
|
56
|
-
formGroup.childNodes.forEach(function (node) {
|
|
56
|
+
formGroup.childNodes[0].childNodes.forEach(function (node) {
|
|
57
57
|
// Check if it's an element.
|
|
58
|
-
if (node instanceof Element && node.tagName === '
|
|
59
|
-
label = node;
|
|
58
|
+
if (node instanceof Element && node.tagName === 'LEGEND') {
|
|
59
|
+
label = node.childNodes[0];
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
expect(label).toBeDefined();
|
|
@@ -47,29 +47,29 @@ describe('utils.Component.get', function () {
|
|
|
47
47
|
}];
|
|
48
48
|
_renderWithValidation = (0, _setupTests.renderWithValidation)((0, _getComponent.getChildrenJsx)(PARENT_CONFIG, NESTED_CONFIG)), container = _renderWithValidation.container;
|
|
49
49
|
child = container.childNodes[0];
|
|
50
|
-
expect(child.childNodes.length).toEqual(3);
|
|
50
|
+
expect(child.childNodes[0].childNodes.length).toEqual(3);
|
|
51
51
|
expect(child.classList).toContain('govuk-form-group');
|
|
52
52
|
label = child.childNodes[0];
|
|
53
53
|
expect(label).toBeDefined();
|
|
54
54
|
expect(label.innerHTML).toContain(LABEL);
|
|
55
|
-
input = child.childNodes[2];
|
|
55
|
+
input = child.childNodes[0].childNodes[2];
|
|
56
56
|
expect(input.tagName).toEqual('INPUT');
|
|
57
57
|
expect(input.classList).toContain('govuk-input');
|
|
58
58
|
expect(input.id).toEqual(ID);
|
|
59
59
|
expect(input.value).toEqual(VALUE);
|
|
60
60
|
child2 = container.childNodes[1];
|
|
61
|
-
expect(child2.childNodes.length).toEqual(3);
|
|
61
|
+
expect(child2.childNodes[0].childNodes.length).toEqual(3);
|
|
62
62
|
expect(child2.classList).toContain('govuk-form-group');
|
|
63
63
|
label2 = child2.childNodes[0];
|
|
64
64
|
expect(label2).toBeDefined();
|
|
65
65
|
expect(label2.innerHTML).toContain(LABEL2);
|
|
66
|
-
input2 = child2.childNodes[2];
|
|
66
|
+
input2 = child2.childNodes[0].childNodes[2];
|
|
67
67
|
expect(input2.tagName).toEqual('DIV');
|
|
68
68
|
expect(input2.classList).toContain('govuk-date-input');
|
|
69
69
|
expect(input2.id).toEqual(ID2);
|
|
70
|
-
expect(input2.childNodes[0].childNodes[1].value).toEqual('1');
|
|
71
|
-
expect(input2.childNodes[1].childNodes[1].value).toEqual('2');
|
|
72
|
-
expect(input2.childNodes[2].childNodes[1].value).toEqual('2022');
|
|
70
|
+
expect(input2.childNodes[0].childNodes[0].childNodes[1].value).toEqual('1');
|
|
71
|
+
expect(input2.childNodes[1].childNodes[0].childNodes[1].value).toEqual('2');
|
|
72
|
+
expect(input2.childNodes[2].childNodes[0].childNodes[1].value).toEqual('2022');
|
|
73
73
|
|
|
74
74
|
case 35:
|
|
75
75
|
case "end":
|
|
@@ -137,12 +137,12 @@ describe('utils.Component.get', function () {
|
|
|
137
137
|
}];
|
|
138
138
|
_renderWithValidation2 = (0, _setupTests.renderWithValidation)((0, _getComponent.getChildrenJsx)(PARENT_CONFIG, NESTED_CONFIG)), container = _renderWithValidation2.container;
|
|
139
139
|
child = container.childNodes[0];
|
|
140
|
-
expect(child.childNodes.length).toEqual(3);
|
|
140
|
+
expect(child.childNodes[0].childNodes.length).toEqual(3);
|
|
141
141
|
expect(child.classList).toContain('govuk-form-group');
|
|
142
142
|
label = child.childNodes[0];
|
|
143
143
|
expect(label).toBeDefined();
|
|
144
144
|
expect(label.innerHTML).toContain(LABEL);
|
|
145
|
-
input = child.childNodes[2];
|
|
145
|
+
input = child.childNodes[0].childNodes[2];
|
|
146
146
|
expect(input.tagName).toEqual('INPUT');
|
|
147
147
|
expect(input.classList).toContain('govuk-input');
|
|
148
148
|
expect(input.id).toEqual("".concat(CONTAINER_ID, ".").concat(FIELD_ID));
|
|
@@ -180,12 +180,12 @@ describe('utils.Component.get', function () {
|
|
|
180
180
|
}];
|
|
181
181
|
_renderWithValidation3 = (0, _setupTests.renderWithValidation)((0, _getComponent.getChildrenJsx)(PARENT_CONFIG, NESTED_CONFIG)), container = _renderWithValidation3.container;
|
|
182
182
|
child = container.childNodes[0];
|
|
183
|
-
expect(child.childNodes.length).toEqual(3);
|
|
183
|
+
expect(child.childNodes[0].childNodes.length).toEqual(3);
|
|
184
184
|
expect(child.classList).toContain('govuk-form-group');
|
|
185
185
|
label = child.childNodes[0];
|
|
186
186
|
expect(label).toBeDefined();
|
|
187
187
|
expect(label.innerHTML).toContain(LABEL);
|
|
188
|
-
input = child.childNodes[2];
|
|
188
|
+
input = child.childNodes[0].childNodes[2];
|
|
189
189
|
expect(input.tagName).toEqual('INPUT');
|
|
190
190
|
expect(input.classList).toContain('govuk-input');
|
|
191
191
|
expect(input.id).toEqual("".concat(COLLECTION_ID, "[0].").concat(FIELD_ID));
|
|
@@ -51,10 +51,10 @@ describe('utils.Component.get', function () {
|
|
|
51
51
|
expect(formGroup.tagName).toEqual('DIV');
|
|
52
52
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
53
53
|
var label = undefined;
|
|
54
|
-
formGroup.childNodes.forEach(function (node) {
|
|
54
|
+
formGroup.childNodes[0].childNodes.forEach(function (node) {
|
|
55
55
|
// Check if it's an element.
|
|
56
|
-
if (node instanceof Element && node.tagName === '
|
|
57
|
-
label = node;
|
|
56
|
+
if (node instanceof Element && node.tagName === 'LEGEND') {
|
|
57
|
+
label = node.childNodes[0];
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
expect(label).toBeDefined();
|
|
@@ -61,11 +61,11 @@ describe('utils.Component.get', function () {
|
|
|
61
61
|
expect(formGroup.tagName).toEqual('DIV');
|
|
62
62
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
63
63
|
var label = undefined;
|
|
64
|
-
formGroup.childNodes.forEach(function (node) {
|
|
64
|
+
formGroup.childNodes[0].childNodes.forEach(function (node) {
|
|
65
65
|
// Check if it's an element.
|
|
66
66
|
if (node instanceof Element) {
|
|
67
|
-
if (node.tagName === '
|
|
68
|
-
label = node;
|
|
67
|
+
if (node.tagName === 'LEGEND') {
|
|
68
|
+
label = node.childNodes[0];
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
});
|
|
@@ -58,13 +58,7 @@ describe('utils.Component.get', function () {
|
|
|
58
58
|
|
|
59
59
|
expect(formGroup.tagName).toEqual('DIV');
|
|
60
60
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
61
|
-
var label =
|
|
62
|
-
formGroup.childNodes.forEach(function (node) {
|
|
63
|
-
// Check if it's an element.
|
|
64
|
-
if (node instanceof Element && node.tagName === 'LABEL') {
|
|
65
|
-
label = node;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
61
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
68
62
|
expect(label).toBeDefined();
|
|
69
63
|
expect(label.innerHTML).toContain(LABEL);
|
|
70
64
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
@@ -51,10 +51,10 @@ describe('utils.Component.get', function () {
|
|
|
51
51
|
expect(formGroup.tagName).toEqual('DIV');
|
|
52
52
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
53
53
|
var label = undefined;
|
|
54
|
-
formGroup.childNodes.forEach(function (node) {
|
|
54
|
+
formGroup.childNodes[0].childNodes.forEach(function (node) {
|
|
55
55
|
// Check if it's an element.
|
|
56
|
-
if (node instanceof Element && node.tagName === '
|
|
57
|
-
label = node;
|
|
56
|
+
if (node instanceof Element && node.tagName === 'LEGEND') {
|
|
57
|
+
label = node.childNodes[0];
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
expect(label).toBeDefined();
|
|
@@ -52,7 +52,7 @@ describe('utils.Component.get', function () {
|
|
|
52
52
|
|
|
53
53
|
expect(formGroup.tagName).toEqual('DIV');
|
|
54
54
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
55
|
-
var label = formGroup.childNodes[0];
|
|
55
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
56
56
|
expect(label.innerHTML).toContain(LABEL);
|
|
57
57
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
58
58
|
expect(textarea.tagName).toEqual('TEXTAREA');
|
|
@@ -50,7 +50,7 @@ describe('utils.Component.get', function () {
|
|
|
50
50
|
|
|
51
51
|
expect(formGroup.tagName).toEqual('DIV');
|
|
52
52
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
53
|
-
var label = formGroup.childNodes[0];
|
|
53
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
54
54
|
expect(label.innerHTML).toContain(LABEL);
|
|
55
55
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
56
56
|
expect(timeInput.tagName).toEqual('DIV');
|
|
@@ -78,12 +78,12 @@ describe('utils.Component.get', function () {
|
|
|
78
78
|
expect(part.item.tagName).toEqual('DIV');
|
|
79
79
|
expect(part.item.classList).toContain('govuk-date-input__item');
|
|
80
80
|
|
|
81
|
-
var _part$item$childNodes = _slicedToArray(part.item.childNodes, 2),
|
|
81
|
+
var _part$item$childNodes = _slicedToArray(part.item.childNodes[0].childNodes, 2),
|
|
82
82
|
label = _part$item$childNodes[0],
|
|
83
83
|
input = _part$item$childNodes[1];
|
|
84
84
|
|
|
85
|
-
expect(label.tagName).toEqual('LABEL');
|
|
86
|
-
expect(label.classList).toContain('govuk-label');
|
|
85
|
+
expect(label.childNodes[0].tagName).toEqual('LABEL');
|
|
86
|
+
expect(label.childNodes[0].classList).toContain('govuk-label');
|
|
87
87
|
expect(label.textContent).toEqual(part.label);
|
|
88
88
|
expect(input.tagName).toEqual('INPUT');
|
|
89
89
|
expect(input.id).toEqual("".concat(ID, "-").concat(part.id)); // Put something in the input and make sure it fires.
|
|
@@ -37,7 +37,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
37
37
|
* @returns The first encountered error with the component.
|
|
38
38
|
*/
|
|
39
39
|
var validateComponent = function validateComponent(component, outerData, formData) {
|
|
40
|
-
var _component$data$optio;
|
|
40
|
+
var _fd$keycloakContext, _component$data$optio;
|
|
41
41
|
|
|
42
42
|
var fd = formData || outerData;
|
|
43
43
|
|
|
@@ -64,7 +64,8 @@ var validateComponent = function validateComponent(component, outerData, formDat
|
|
|
64
64
|
return (0, _validateCollection.default)(component, value, fd);
|
|
65
65
|
|
|
66
66
|
case _models.ComponentTypes.EMAIL:
|
|
67
|
-
|
|
67
|
+
var userEmail = fd === null ? '' : (_fd$keycloakContext = fd.keycloakContext) === null || _fd$keycloakContext === void 0 ? void 0 : _fd$keycloakContext.email;
|
|
68
|
+
error = (0, _validateEmail.default)(value, component.label, userEmail);
|
|
68
69
|
break;
|
|
69
70
|
|
|
70
71
|
case _models.ComponentTypes.DATE:
|
|
@@ -15,20 +15,28 @@ var HODS_EMAIL_REGEX = /^[a-z0-9._-]+@(digital\.)?homeoffice.gov.uk$/i;
|
|
|
15
15
|
* validateRequired (Validate.required) for that sort of validation.
|
|
16
16
|
* @param {*} value The value to validate.
|
|
17
17
|
* @param {string} label The label to use in any error message.
|
|
18
|
+
* @param {string} userEmail The user email to use for validation.
|
|
18
19
|
* @returns An error if the email address is invalid.
|
|
19
20
|
*/
|
|
20
21
|
|
|
21
22
|
var validateEmail = function validateEmail(value) {
|
|
22
23
|
var label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
24
|
+
var userEmail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
23
25
|
|
|
24
26
|
if (!!value) {
|
|
27
|
+
var name = label ? label.toLowerCase() : 'email address';
|
|
28
|
+
|
|
25
29
|
if (typeof value === 'string') {
|
|
30
|
+
// The following is an interim fix pending a mechanism for validating against specific values
|
|
31
|
+
if (['Line manager email', 'Delegate email address'].includes(label) && value.toLowerCase() === userEmail) {
|
|
32
|
+
return "".concat(label, " cannot be the same as the user email address");
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
if (HODS_EMAIL_REGEX.test(value)) {
|
|
27
36
|
return undefined;
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
39
|
|
|
31
|
-
var name = label ? label.toLowerCase() : 'email address';
|
|
32
40
|
return "Enter ".concat(name, " in the correct format, like jane.doe@homeoffice.gov.uk");
|
|
33
41
|
}
|
|
34
42
|
|
|
@@ -52,6 +52,14 @@ describe('utils', function () {
|
|
|
52
52
|
var DEFAULT_ERROR = 'Enter email address in the correct format, like jane.doe@homeoffice.gov.uk';
|
|
53
53
|
expect((0, _validateEmail.default)(['bob'], undefined)).toEqual(DEFAULT_ERROR);
|
|
54
54
|
});
|
|
55
|
+
it('should return an error when line manager email is same as user email', function () {
|
|
56
|
+
var USER_EMAIL_ERROR = 'Line manager email cannot be the same as the user email address';
|
|
57
|
+
expect((0, _validateEmail.default)('joe.bloggs@digital.homeoffice.gov.uk', 'Line manager email', 'joe.bloggs@digital.homeoffice.gov.uk')).toEqual(USER_EMAIL_ERROR);
|
|
58
|
+
});
|
|
59
|
+
it('should return an error when delegate email is same as user email', function () {
|
|
60
|
+
var USER_EMAIL_ERROR = 'Delegate email address cannot be the same as the user email address';
|
|
61
|
+
expect((0, _validateEmail.default)('joe.bloggs@digital.homeoffice.gov.uk', 'Delegate email address', 'joe.bloggs@digital.homeoffice.gov.uk')).toEqual(USER_EMAIL_ERROR);
|
|
62
|
+
});
|
|
55
63
|
});
|
|
56
64
|
});
|
|
57
65
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "4.29.0-
|
|
3
|
+
"version": "4.29.0-beta",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"post-compile": "rimraf dist/*.test.* dist/**/*.test.* dist/**/*.stories.* dist/docs dist/assets"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@ukhomeoffice/cop-react-components": "2.
|
|
19
|
+
"@ukhomeoffice/cop-react-components": "2.5.0",
|
|
20
20
|
"axios": "^0.23.0",
|
|
21
21
|
"dayjs": "^1.11.0",
|
|
22
22
|
"govuk-frontend": "^4.3.1",
|