@planning-inspectorate/dynamic-forms 1.17.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.releaserc +14 -0
- package/README.md +68 -3
- package/package.json +2 -1
- package/src/components/address/index.njk +2 -19
- package/src/components/address/question.test.js +1 -1
- package/src/components/boolean/index.njk +4 -21
- package/src/components/checkbox/index.njk +3 -21
- package/src/components/conditional/textarea.njk +1 -1
- package/src/components/conditional/unit.njk +1 -1
- package/src/components/date/index.njk +3 -20
- package/src/components/date-period/index.njk +4 -21
- package/src/components/date-time/index.njk +4 -21
- package/src/components/identifier/index.njk +2 -19
- package/src/components/multi-field-input/index.njk +3 -20
- package/src/components/multi-field-input/question.test.js +3 -3
- package/src/components/number-entry/index.njk +7 -21
- package/src/components/radio/index.njk +8 -21
- package/src/components/select/index.njk +2 -19
- package/src/components/single-line-input/index.njk +4 -21
- package/src/components/task-list/index.njk +2 -8
- package/src/components/text-entry/index.njk +4 -21
- package/src/components/text-entry-redact/index.njk +2 -19
- package/src/components/text-entry-redact/question.test.js +4 -4
- package/src/components/unit-option-entry/index.njk +5 -20
- package/src/controller.js +2 -2
- package/src/controller.test.js +5 -5
- package/src/journey/journey.js +7 -7
- package/src/journey/journey.test.js +10 -10
- package/src/middleware/redirect-to-unanswered-question.test.js +1 -1
- package/src/validator/address-validator.js +1 -1
- package/src/validator/address-validator.test.js +1 -5
- package/test/journey.js +2 -2
- package/test/snapshots/add-insurance.html +1 -11
- package/test/snapshots/check-your-answers-not-started.html +0 -3
- package/test/snapshots/check-your-answers-with-answers.html +0 -3
- package/test/snapshots/companions.html +2 -15
- package/test/snapshots/departure-date.html +1 -11
- package/test/snapshots/holiday-activities.html +1 -11
- package/test/snapshots/holiday-arrival.html +2 -9
- package/test/snapshots/holiday-description.html +1 -11
- package/test/snapshots/holiday-destination.html +0 -10
- package/test/snapshots/holiday-period.html +2 -15
- package/test/snapshots/holiday-snack.html +1 -11
- package/test/snapshots/hotel-address.html +0 -7
- package/test/snapshots/luggage-weight-units.html +2 -17
- package/test/snapshots/nights.html +1 -12
- package/test/snapshots/secret-wish.html +0 -7
- package/test/snapshots/travel-class.html +1 -10
- package/test/snapshots/travel-insurance-type.html +0 -10
- package/test/views/layout-check-your-answers.njk +1 -1
- package/test/views/layout-journey.njk +1 -0
- package/test/views/layout-question.njk +0 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
|
-
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
|
|
4
3
|
{% from "govuk/components/select/macro.njk" import govukSelect %}
|
|
5
4
|
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
6
5
|
|
|
@@ -10,23 +9,7 @@
|
|
|
10
9
|
{{ super() }}
|
|
11
10
|
{% endblock %}
|
|
12
11
|
|
|
13
|
-
{% block
|
|
14
|
-
<div class="govuk-grid-row">
|
|
15
|
-
<div class="govuk-grid-column-two-thirds">
|
|
16
|
-
{% if errorSummary %}
|
|
17
|
-
{{ govukErrorSummary({
|
|
18
|
-
titleText: "There is a problem",
|
|
19
|
-
errorList: errorSummary,
|
|
20
|
-
attributes: {"data-cy": "error-wrapper"}
|
|
21
|
-
}) }}
|
|
22
|
-
{% endif %}
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
{{ super() }}
|
|
27
|
-
{% endblock before_content %}
|
|
28
|
-
|
|
29
|
-
{% block content %}
|
|
12
|
+
{% block dynQuestionContent %}
|
|
30
13
|
<div class="govuk-grid-row">
|
|
31
14
|
<div class="govuk-grid-column-two-thirds">
|
|
32
15
|
<form action="" method="POST" novalidate>
|
|
@@ -44,7 +27,7 @@
|
|
|
44
27
|
classes: "govuk-label--l",
|
|
45
28
|
isPageHeading: true
|
|
46
29
|
},
|
|
47
|
-
hint: {
|
|
30
|
+
hint: question.hint and {
|
|
48
31
|
text: question.hint
|
|
49
32
|
},
|
|
50
33
|
errorMessage: errors[question.fieldName] and {
|
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
|
-
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
|
|
4
3
|
{% from "govuk/components/input/macro.njk" import govukInput %}
|
|
5
4
|
{% from "govuk/components/label/macro.njk" import govukLabel %}
|
|
6
5
|
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
7
6
|
|
|
8
|
-
{% block
|
|
9
|
-
<div class="govuk-grid-row">
|
|
10
|
-
<div class="govuk-grid-column-two-thirds">
|
|
11
|
-
{% if errorSummary %}
|
|
12
|
-
{{ govukErrorSummary({
|
|
13
|
-
titleText: "There is a problem",
|
|
14
|
-
errorList: errorSummary,
|
|
15
|
-
attributes: {"data-cy": "error-wrapper"}
|
|
16
|
-
}) }}
|
|
17
|
-
{% endif %}
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
{{ super() }}
|
|
22
|
-
{% endblock before_content %}
|
|
23
|
-
|
|
24
|
-
{% block content %}
|
|
7
|
+
{% block dynQuestionContent %}
|
|
25
8
|
<div class="govuk-grid-row">
|
|
26
9
|
<div class="govuk-grid-column-two-thirds">
|
|
27
10
|
<form action="" method="post" novalidate>
|
|
28
|
-
<input type="hidden" name="_csrf" value="{{ _csrf }}">
|
|
11
|
+
{% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
|
|
29
12
|
{% if question.label %}
|
|
30
13
|
<h1 class="govuk-heading-l">
|
|
31
14
|
{{ question.question }}
|
|
@@ -51,7 +34,7 @@
|
|
|
51
34
|
id: question.fieldName,
|
|
52
35
|
name: question.fieldName,
|
|
53
36
|
value: question.value,
|
|
54
|
-
hint: { text: question.hint },
|
|
37
|
+
hint: question.hint and { text: question.hint },
|
|
55
38
|
errorMessage: errors[question.fieldName] and {
|
|
56
39
|
text: errors[question.fieldName].msg
|
|
57
40
|
},
|
|
@@ -75,7 +58,7 @@
|
|
|
75
58
|
id: question.fieldName,
|
|
76
59
|
name: question.fieldName,
|
|
77
60
|
value: question.value,
|
|
78
|
-
hint: { text: question.hint },
|
|
61
|
+
hint: question.hint and { text: question.hint },
|
|
79
62
|
errorMessage: errors[question.fieldName] and {
|
|
80
63
|
text: errors[question.fieldName].msg
|
|
81
64
|
},
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
|
+
|
|
2
3
|
{% from "govuk/components/summary-list/macro.njk" import govukSummaryList %}
|
|
3
4
|
{% from "govuk/components/tag/macro.njk" import govukTag %}
|
|
4
5
|
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
5
6
|
{% from "./task-list-multi-section.njk" import multiTaskList %}
|
|
6
7
|
{% from "./task-list-single-section.njk" import singleTaskList %}
|
|
7
8
|
|
|
8
|
-
{% block
|
|
9
|
-
{% block beforeTaskList %}
|
|
10
|
-
{% endblock %}
|
|
11
|
-
|
|
9
|
+
{% block dynTaskList %}
|
|
12
10
|
<style {% if cspNonce %}nonce={{ cspNonce }}{% endif %}>
|
|
13
11
|
.app-task-list {
|
|
14
12
|
padding-left: 0;
|
|
@@ -37,8 +35,4 @@
|
|
|
37
35
|
{% endif %}
|
|
38
36
|
</div>
|
|
39
37
|
</div>
|
|
40
|
-
|
|
41
|
-
{% block afterTaskList %}
|
|
42
|
-
{% endblock %}
|
|
43
|
-
|
|
44
38
|
{% endblock %}
|
|
@@ -1,32 +1,15 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
|
-
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
|
|
4
3
|
{% from "govuk/components/textarea/macro.njk" import govukTextarea %}
|
|
5
4
|
{% from "govuk/components/label/macro.njk" import govukLabel %}
|
|
6
5
|
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
7
6
|
{% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %}
|
|
8
7
|
|
|
9
|
-
{% block
|
|
10
|
-
<div class="govuk-grid-row">
|
|
11
|
-
<div class="govuk-grid-column-two-thirds">
|
|
12
|
-
{% if errorSummary %}
|
|
13
|
-
{{ govukErrorSummary({
|
|
14
|
-
titleText: "There is a problem",
|
|
15
|
-
errorList: errorSummary,
|
|
16
|
-
attributes: {"data-cy": "error-wrapper"}
|
|
17
|
-
}) }}
|
|
18
|
-
{% endif %}
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
|
|
22
|
-
{{ super() }}
|
|
23
|
-
{% endblock before_content %}
|
|
24
|
-
|
|
25
|
-
{% block content %}
|
|
8
|
+
{% block dynQuestionContent %}
|
|
26
9
|
<div class="govuk-grid-row">
|
|
27
10
|
<div class="govuk-grid-column-two-thirds">
|
|
28
11
|
<form action="" method="post" novalidate>
|
|
29
|
-
<input type="hidden" name="_csrf" value="{{ _csrf }}">
|
|
12
|
+
{% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
|
|
30
13
|
{% if question.label %}
|
|
31
14
|
<h1 class="govuk-heading-l">
|
|
32
15
|
{{ question.question }}
|
|
@@ -43,7 +26,7 @@
|
|
|
43
26
|
id: question.fieldName,
|
|
44
27
|
name: question.fieldName,
|
|
45
28
|
value: question.value,
|
|
46
|
-
hint: { text: question.hint },
|
|
29
|
+
hint: question.hint and { text: question.hint },
|
|
47
30
|
errorMessage: errors[question.fieldName] and {
|
|
48
31
|
text: errors[question.fieldName].msg
|
|
49
32
|
},
|
|
@@ -65,7 +48,7 @@
|
|
|
65
48
|
id: question.fieldName,
|
|
66
49
|
name: question.fieldName,
|
|
67
50
|
value: question.value,
|
|
68
|
-
hint: { text: question.hint },
|
|
51
|
+
hint: question.hint and { text: question.hint },
|
|
69
52
|
errorMessage: errors[question.fieldName] and {
|
|
70
53
|
text: errors[question.fieldName].msg
|
|
71
54
|
},
|
|
@@ -3,32 +3,15 @@
|
|
|
3
3
|
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
4
4
|
{% from "govuk/components/checkboxes/macro.njk" import govukCheckboxes %}
|
|
5
5
|
{% from "govuk/components/details/macro.njk" import govukDetails %}
|
|
6
|
-
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
|
|
7
6
|
{% from "govuk/components/label/macro.njk" import govukLabel %}
|
|
8
7
|
{% from "govuk/components/table/macro.njk" import govukTable %}
|
|
9
8
|
{% from "govuk/components/textarea/macro.njk" import govukTextarea %}
|
|
10
9
|
|
|
11
|
-
{% block
|
|
12
|
-
<div class="govuk-grid-row">
|
|
13
|
-
<div class="govuk-grid-column-two-thirds">
|
|
14
|
-
{% if errorSummary %}
|
|
15
|
-
{{ govukErrorSummary({
|
|
16
|
-
titleText: "There is a problem",
|
|
17
|
-
errorList: errorSummary,
|
|
18
|
-
attributes: {"data-cy": "error-wrapper"}
|
|
19
|
-
}) }}
|
|
20
|
-
{% endif %}
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
{{ super() }}
|
|
25
|
-
{% endblock before_content %}
|
|
26
|
-
|
|
27
|
-
{% block content %}
|
|
10
|
+
{% block dynQuestionContent %}
|
|
28
11
|
<div class="govuk-grid-row">
|
|
29
12
|
<div class="govuk-grid-column-two-thirds">
|
|
30
13
|
<form action="" method="post" novalidate>
|
|
31
|
-
<input type="hidden" name="_csrf" value="{{ _csrf }}">
|
|
14
|
+
{% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
|
|
32
15
|
|
|
33
16
|
{% if question.label %}
|
|
34
17
|
{{ govukLabel({
|
|
@@ -55,7 +55,7 @@ describe('./src/dynamic-forms/components/text-entry-redact/question.js', () => {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
const customViewData = {
|
|
58
|
-
layoutTemplate: 'views/layout-
|
|
58
|
+
layoutTemplate: 'views/layout-journey.njk',
|
|
59
59
|
question: {
|
|
60
60
|
question: 'Redaction Question',
|
|
61
61
|
fieldName: 'field-name',
|
|
@@ -94,7 +94,7 @@ describe('./src/dynamic-forms/components/text-entry-redact/question.js', () => {
|
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
const customViewData = {
|
|
97
|
-
layoutTemplate: 'views/layout-
|
|
97
|
+
layoutTemplate: 'views/layout-journey.njk',
|
|
98
98
|
question: {
|
|
99
99
|
question: 'Redaction Question',
|
|
100
100
|
fieldName: 'field-name',
|
|
@@ -134,7 +134,7 @@ describe('./src/dynamic-forms/components/text-entry-redact/question.js', () => {
|
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
const customViewData = {
|
|
137
|
-
layoutTemplate: 'views/layout-
|
|
137
|
+
layoutTemplate: 'views/layout-journey.njk',
|
|
138
138
|
question: {
|
|
139
139
|
question: 'Redaction Question',
|
|
140
140
|
fieldName: 'field-name',
|
|
@@ -181,7 +181,7 @@ describe('./src/dynamic-forms/components/text-entry-redact/question.js', () => {
|
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
183
|
const customViewData = {
|
|
184
|
-
layoutTemplate: 'views/layout-
|
|
184
|
+
layoutTemplate: 'views/layout-journey.njk',
|
|
185
185
|
question: {
|
|
186
186
|
question: 'Redaction Question',
|
|
187
187
|
fieldName: 'field-name',
|
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
{% extends layoutTemplate %}
|
|
2
2
|
|
|
3
|
-
{% from "govuk/components/error-summary/macro.njk" import govukErrorSummary %}
|
|
4
3
|
{% from "govuk/components/radios/macro.njk" import govukRadios %}
|
|
5
4
|
{% from "govuk/components/button/macro.njk" import govukButton %}
|
|
6
5
|
{% from "govuk/components/fieldset/macro.njk" import govukFieldset %}
|
|
7
6
|
|
|
8
|
-
{% block
|
|
9
|
-
<div class="govuk-grid-row">
|
|
10
|
-
<div class="govuk-grid-column-two-thirds">
|
|
11
|
-
{% if errorSummary %}
|
|
12
|
-
{{ govukErrorSummary({
|
|
13
|
-
titleText: "There is a problem",
|
|
14
|
-
errorList: errorSummary,
|
|
15
|
-
attributes: {"data-cy": "error-wrapper"}
|
|
16
|
-
}) }}
|
|
17
|
-
{% endif %}
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
{{ super() }}
|
|
22
|
-
{% endblock before_content %}
|
|
23
|
-
|
|
24
|
-
{% block content %}
|
|
7
|
+
{% block dynQuestionContent %}
|
|
25
8
|
<div class="govuk-grid-row">
|
|
26
9
|
<div class="govuk-grid-column-two-thirds">
|
|
27
10
|
<form action="" method="post" novalidate>
|
|
28
|
-
<input type="hidden" name="_csrf" value="{{ _csrf }}">
|
|
11
|
+
{% if _csrf %}<input type="hidden" name="_csrf" value="{{ _csrf }}">{% endif %}
|
|
29
12
|
|
|
30
13
|
{% call govukFieldset({
|
|
31
14
|
legend: {
|
|
@@ -35,7 +18,9 @@
|
|
|
35
18
|
}
|
|
36
19
|
}) %}
|
|
37
20
|
|
|
38
|
-
|
|
21
|
+
{%- if question.description %}
|
|
22
|
+
<p class="govuk-body">{{ question.description }}</p>
|
|
23
|
+
{%- endif -%}
|
|
39
24
|
{% if question.html %}
|
|
40
25
|
{% include question.html ignore missing %}
|
|
41
26
|
{% endif %}
|
package/src/controller.js
CHANGED
|
@@ -124,12 +124,12 @@ export async function list(req, res, pageCaption, viewData) {
|
|
|
124
124
|
summaryListData.sections.push(sectionView);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
return res.render(
|
|
127
|
+
return res.render('components/task-list/index', {
|
|
128
128
|
...viewData,
|
|
129
129
|
pageCaption,
|
|
130
130
|
summaryListData,
|
|
131
131
|
journeyComplete: journey.isComplete(),
|
|
132
|
-
layoutTemplate: journey.
|
|
132
|
+
layoutTemplate: journey.taskListTemplate,
|
|
133
133
|
journeyTitle: journey.journeyTitle
|
|
134
134
|
});
|
|
135
135
|
}
|
package/src/controller.test.js
CHANGED
|
@@ -156,7 +156,7 @@ const journeyParams = {
|
|
|
156
156
|
taskListUrl: 'task-list',
|
|
157
157
|
makeBaseUrl: () => `${mockBaseUrl}/${mockRef}`,
|
|
158
158
|
journeyTemplate: mockTemplateUrl,
|
|
159
|
-
|
|
159
|
+
taskListTemplate: mockListingPath,
|
|
160
160
|
journeyTitle: mockJourneyTitle
|
|
161
161
|
};
|
|
162
162
|
|
|
@@ -223,11 +223,11 @@ describe('dynamic-form/controller', () => {
|
|
|
223
223
|
const mockFn = res.render.mock;
|
|
224
224
|
assert.strictEqual(mockFn.callCount(), 1);
|
|
225
225
|
assert.deepStrictEqual(mockFn.calls[0].arguments, [
|
|
226
|
-
|
|
226
|
+
'components/task-list/index',
|
|
227
227
|
{
|
|
228
228
|
appeal,
|
|
229
229
|
summaryListData: mockSummaryListData,
|
|
230
|
-
layoutTemplate:
|
|
230
|
+
layoutTemplate: mockListingPath,
|
|
231
231
|
journeyComplete: false,
|
|
232
232
|
pageCaption: pageCaption,
|
|
233
233
|
journeyTitle: mockJourneyTitle
|
|
@@ -269,11 +269,11 @@ describe('dynamic-form/controller', () => {
|
|
|
269
269
|
|
|
270
270
|
assert.strictEqual(mockFn.callCount(), 1);
|
|
271
271
|
assert.deepStrictEqual(mockFn.calls[0].arguments, [
|
|
272
|
-
|
|
272
|
+
'components/task-list/index',
|
|
273
273
|
{
|
|
274
274
|
appeal,
|
|
275
275
|
summaryListData: mockSummaryListData,
|
|
276
|
-
layoutTemplate:
|
|
276
|
+
layoutTemplate: mockListingPath,
|
|
277
277
|
journeyComplete: false,
|
|
278
278
|
pageCaption: pageCaption,
|
|
279
279
|
journeyTitle: mockJourneyTitle
|
package/src/journey/journey.js
CHANGED
|
@@ -29,8 +29,8 @@ export class Journey {
|
|
|
29
29
|
taskListUrl = '';
|
|
30
30
|
/** @type {string} journeyTemplate - nunjucks template file used for */
|
|
31
31
|
journeyTemplate = '';
|
|
32
|
-
/** @type {string}
|
|
33
|
-
|
|
32
|
+
/** @type {string} taskListTemplate - nunjucks template file used for listing page */
|
|
33
|
+
taskListTemplate = '';
|
|
34
34
|
/** @type {string} informationPageViewPath - nunjucks template file used for pdf summary information page */
|
|
35
35
|
informationPageViewPath = '';
|
|
36
36
|
/** @type {boolean} defines how the next/previous question handles end of sections */
|
|
@@ -46,7 +46,7 @@ export class Journey {
|
|
|
46
46
|
* @param {string} [options.taskListUrl] - task list url - added to base url, can be left undefined
|
|
47
47
|
* @param {JourneyResponse} options.response - user's response
|
|
48
48
|
* @param {string} options.journeyTemplate - template used for all views
|
|
49
|
-
* @param {string} options.
|
|
49
|
+
* @param {string} options.taskListTemplate - path to njk view for listing page
|
|
50
50
|
* @param {string} [options.informationPageViewPath] - path to njk view for pdf summary page
|
|
51
51
|
* @param {string} options.journeyTitle - part of the title in the njk view
|
|
52
52
|
* @param {boolean} [options.returnToListing] - defines how the next/previous question handles end of sections
|
|
@@ -59,7 +59,7 @@ export class Journey {
|
|
|
59
59
|
taskListUrl,
|
|
60
60
|
response,
|
|
61
61
|
journeyTemplate,
|
|
62
|
-
|
|
62
|
+
taskListTemplate,
|
|
63
63
|
informationPageViewPath,
|
|
64
64
|
journeyTitle,
|
|
65
65
|
returnToListing,
|
|
@@ -86,10 +86,10 @@ export class Journey {
|
|
|
86
86
|
}
|
|
87
87
|
this.journeyTemplate = journeyTemplate;
|
|
88
88
|
|
|
89
|
-
if (!
|
|
90
|
-
throw new Error('
|
|
89
|
+
if (!taskListTemplate || typeof taskListTemplate !== 'string') {
|
|
90
|
+
throw new Error('taskListTemplate should be a string.');
|
|
91
91
|
}
|
|
92
|
-
this.
|
|
92
|
+
this.taskListTemplate = taskListTemplate;
|
|
93
93
|
|
|
94
94
|
this.informationPageViewPath = informationPageViewPath || '';
|
|
95
95
|
|
|
@@ -53,7 +53,7 @@ describe('Journey class', () => {
|
|
|
53
53
|
answers: {}
|
|
54
54
|
},
|
|
55
55
|
journeyTemplate: 'mock template',
|
|
56
|
-
|
|
56
|
+
taskListTemplate: 'mock path',
|
|
57
57
|
journeyTitle: 'mock title'
|
|
58
58
|
};
|
|
59
59
|
});
|
|
@@ -114,23 +114,23 @@ describe('Journey class', () => {
|
|
|
114
114
|
assert.throws(() => new Journey(constructorArgs), new Error('journeyTemplate should be a string.'));
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
it('should set
|
|
118
|
-
constructorArgs.
|
|
117
|
+
it('should set taskListTemplate', () => {
|
|
118
|
+
constructorArgs.taskListTemplate = 'test';
|
|
119
119
|
const journey = new Journey(constructorArgs);
|
|
120
120
|
|
|
121
|
-
assert.strictEqual(journey.
|
|
121
|
+
assert.strictEqual(journey.taskListTemplate, constructorArgs.taskListTemplate);
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
it('should error if
|
|
125
|
-
constructorArgs.
|
|
124
|
+
it('should error if taskListTemplate not provided', () => {
|
|
125
|
+
constructorArgs.taskListTemplate = '';
|
|
126
126
|
|
|
127
|
-
assert.throws(() => new Journey(constructorArgs), new Error('
|
|
127
|
+
assert.throws(() => new Journey(constructorArgs), new Error('taskListTemplate should be a string.'));
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
it('should error if
|
|
131
|
-
constructorArgs.
|
|
130
|
+
it('should error if taskListTemplate not a string', () => {
|
|
131
|
+
constructorArgs.taskListTemplate = 123;
|
|
132
132
|
|
|
133
|
-
assert.throws(() => new Journey(constructorArgs), new Error('
|
|
133
|
+
assert.throws(() => new Journey(constructorArgs), new Error('taskListTemplate should be a string.'));
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
it('should set journeyTitle', () => {
|
|
@@ -46,7 +46,7 @@ describe('redirectToUnansweredQuestion Middleware', () => {
|
|
|
46
46
|
const params = {
|
|
47
47
|
journeyId: 'id-1',
|
|
48
48
|
journeyTemplate: 'statement-template.njk',
|
|
49
|
-
|
|
49
|
+
taskListTemplate: 'dynamic-components/task-list/statement',
|
|
50
50
|
journeyTitle: 'Manage your appeals',
|
|
51
51
|
sections: [
|
|
52
52
|
new Section('', 'section-1')
|
|
@@ -143,7 +143,7 @@ export default class AddressValidator extends BaseValidator {
|
|
|
143
143
|
return validator
|
|
144
144
|
.isLength({ min: postcodeMinLength, max: postcodeMaxLength })
|
|
145
145
|
.bail()
|
|
146
|
-
.withMessage(`Postcode must be
|
|
146
|
+
.withMessage(`Postcode must be less than ${postcodeMaxLength} characters`)
|
|
147
147
|
.custom((postcode) => {
|
|
148
148
|
return validatePostcode(postcode);
|
|
149
149
|
});
|
|
@@ -6,7 +6,6 @@ import AddressValidator, {
|
|
|
6
6
|
addressLine1MaxLength,
|
|
7
7
|
addressLine2MaxLength,
|
|
8
8
|
postcodeMaxLength,
|
|
9
|
-
postcodeMinLength,
|
|
10
9
|
townCityMaxLength
|
|
11
10
|
} from './address-validator.js';
|
|
12
11
|
|
|
@@ -108,10 +107,7 @@ describe('AddressValidator', () => {
|
|
|
108
107
|
`Address line 2 must be ${addressLine2MaxLength} characters or less`
|
|
109
108
|
);
|
|
110
109
|
assert.strictEqual(errors.testField_townCity.msg, `Town or city must be ${townCityMaxLength} characters or less`);
|
|
111
|
-
assert.strictEqual(
|
|
112
|
-
errors.testField_postcode.msg,
|
|
113
|
-
`Postcode must be between ${postcodeMinLength} and ${postcodeMaxLength} characters`
|
|
114
|
-
);
|
|
110
|
+
assert.strictEqual(errors.testField_postcode.msg, `Postcode must be less than ${postcodeMaxLength} characters`);
|
|
115
111
|
});
|
|
116
112
|
});
|
|
117
113
|
|
package/test/journey.js
CHANGED
|
@@ -30,8 +30,8 @@ export function createJourney(questions, response) {
|
|
|
30
30
|
.addQuestion(questions.luggageWeight)
|
|
31
31
|
],
|
|
32
32
|
taskListUrl: 'check-your-answers',
|
|
33
|
-
journeyTemplate: 'views/layout-
|
|
34
|
-
|
|
33
|
+
journeyTemplate: 'views/layout-journey.njk',
|
|
34
|
+
taskListTemplate: 'views/layout-check-your-answers.njk',
|
|
35
35
|
journeyTitle: 'Holiday Booking',
|
|
36
36
|
returnToListing: false,
|
|
37
37
|
makeBaseUrl: () => '/',
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
<div class="govuk-grid-row">
|
|
2
|
-
<div class="govuk-grid-column-two-thirds">
|
|
3
|
-
</div>
|
|
4
|
-
</div>
|
|
5
|
-
|
|
6
|
-
|
|
7
1
|
<div class="govuk-grid-row">
|
|
8
2
|
<div class="govuk-grid-column-two-thirds">
|
|
9
3
|
<form action="" method="post" novalidate>
|
|
10
|
-
<input type="hidden" name="_csrf" value="">
|
|
11
4
|
<div class="govuk-form-group">
|
|
12
|
-
<fieldset class="govuk-fieldset"
|
|
5
|
+
<fieldset class="govuk-fieldset">
|
|
13
6
|
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
|
|
14
7
|
<h1 class="govuk-fieldset__heading">
|
|
15
8
|
Do you want to add travel insurance to your holiday?
|
|
16
9
|
</h1>
|
|
17
10
|
</legend>
|
|
18
|
-
<div id="addInsurance-hint" class="govuk-hint">
|
|
19
|
-
|
|
20
|
-
</div>
|
|
21
11
|
<div class="govuk-radios govuk-radios" data-module="govuk-radios">
|
|
22
12
|
<div class="govuk-radios__item">
|
|
23
13
|
<input class="govuk-radios__input" id="addInsurance" name="addInsurance" type="radio" value="yes" data-cy="answer-yes">
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
<div class="govuk-grid-row">
|
|
2
|
-
<div class="govuk-grid-column-two-thirds">
|
|
3
|
-
</div>
|
|
4
|
-
</div>
|
|
5
|
-
|
|
6
|
-
|
|
7
1
|
<div class="govuk-grid-row">
|
|
8
2
|
<div class="govuk-grid-column-two-thirds">
|
|
9
3
|
<form action="" method="post" novalidate>
|
|
10
|
-
<input type="hidden" name="_csrf" value="">
|
|
11
4
|
|
|
12
5
|
<fieldset class="govuk-fieldset">
|
|
13
6
|
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
|
|
@@ -22,20 +15,14 @@
|
|
|
22
15
|
<label class="govuk-label govuk-label" for="name">
|
|
23
16
|
Name
|
|
24
17
|
</label>
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
</div>
|
|
28
|
-
<input class="govuk-input govuk-input-!-width-three-quarters" id="name" name="name" type="text" aria-describedby="name-hint">
|
|
18
|
+
<input class="govuk-input govuk-input-!-width-three-quarters" id="name" name="name" type="text">
|
|
29
19
|
</div>
|
|
30
20
|
|
|
31
21
|
<div class="govuk-form-group">
|
|
32
22
|
<label class="govuk-label govuk-label" for="age">
|
|
33
23
|
Age
|
|
34
24
|
</label>
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
</div>
|
|
38
|
-
<input class="govuk-input govuk-input-!-width-three-quarters" id="age" name="age" type="text" aria-describedby="age-hint">
|
|
25
|
+
<input class="govuk-input govuk-input-!-width-three-quarters" id="age" name="age" type="text">
|
|
39
26
|
</div>
|
|
40
27
|
|
|
41
28
|
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
<div class="govuk-grid-row">
|
|
2
|
-
<div class="govuk-grid-column-two-thirds">
|
|
3
|
-
</div>
|
|
4
|
-
</div>
|
|
5
|
-
|
|
6
|
-
|
|
7
1
|
<div class="govuk-grid-row">
|
|
8
2
|
<div class="govuk-grid-column-two-thirds">
|
|
9
3
|
<form action="" method="post" novalidate>
|
|
10
|
-
<input type="hidden" name="_csrf" value="">
|
|
11
4
|
<div class="govuk-form-group">
|
|
12
|
-
<fieldset class="govuk-fieldset" role="group"
|
|
5
|
+
<fieldset class="govuk-fieldset" role="group">
|
|
13
6
|
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
|
|
14
7
|
<h1 class="govuk-fieldset__heading">
|
|
15
8
|
When do you want to start your holiday?
|
|
16
9
|
</h1>
|
|
17
10
|
</legend>
|
|
18
|
-
<div id="departureDate-hint" class="govuk-hint">
|
|
19
|
-
|
|
20
|
-
</div>
|
|
21
11
|
<div class="govuk-date-input" id="departureDate">
|
|
22
12
|
<div class="govuk-date-input__item">
|
|
23
13
|
<div class="govuk-form-group">
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
<div class="govuk-grid-row">
|
|
2
|
-
<div class="govuk-grid-column-two-thirds">
|
|
3
|
-
</div>
|
|
4
|
-
</div>
|
|
5
|
-
|
|
6
|
-
|
|
7
1
|
<div class="govuk-grid-row">
|
|
8
2
|
<div class="govuk-grid-column-two-thirds">
|
|
9
3
|
<form action="" method="post" novalidate>
|
|
10
|
-
<input type="hidden" name="_csrf" value="">
|
|
11
4
|
<div class="govuk-form-group">
|
|
12
|
-
<fieldset class="govuk-fieldset"
|
|
5
|
+
<fieldset class="govuk-fieldset">
|
|
13
6
|
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
|
|
14
7
|
<h1 class="govuk-fieldset__heading">
|
|
15
8
|
Which activities do you want to do on holiday?
|
|
16
9
|
</h1>
|
|
17
10
|
</legend>
|
|
18
|
-
<div id="holidayActivities-hint" class="govuk-hint">
|
|
19
|
-
|
|
20
|
-
</div>
|
|
21
11
|
<div class="govuk-checkboxes govuk-checkboxes" data-module="govuk-checkboxes">
|
|
22
12
|
<div class="govuk-checkboxes__item">
|
|
23
13
|
<input class="govuk-checkboxes__input" id="holidayActivities" name="holidayActivities" type="checkbox" value="swimming" data-cy="answer-swimming">
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
<div class="govuk-grid-row">
|
|
2
|
-
<div class="govuk-grid-column-two-thirds">
|
|
3
|
-
</div>
|
|
4
|
-
</div>
|
|
5
|
-
|
|
6
|
-
|
|
7
1
|
<style >
|
|
8
2
|
.pins-select--width-4 {
|
|
9
3
|
min-width: 4.5em !important;
|
|
@@ -14,7 +8,6 @@
|
|
|
14
8
|
<div class="govuk-grid-row">
|
|
15
9
|
<div class="govuk-grid-column-two-thirds">
|
|
16
10
|
<form action="" method="post" novalidate>
|
|
17
|
-
<input type="hidden" name="_csrf" value="">
|
|
18
11
|
<div class="govuk-form-group">
|
|
19
12
|
<fieldset class="govuk-fieldset" role="group">
|
|
20
13
|
<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
|
|
@@ -54,8 +47,8 @@
|
|
|
54
47
|
|
|
55
48
|
<div class="govuk-form-group">
|
|
56
49
|
<fieldset class="govuk-fieldset" role="group">
|
|
57
|
-
<div id="holidayArrival-hint" class="govuk-hint">For example, 9:30am or 2:55pm</div>
|
|
58
|
-
<div class="govuk-date-input" id=holidayArrival>
|
|
50
|
+
<div id="holidayArrival-time-hint" class="govuk-hint">For example, 9:30am or 2:55pm</div>
|
|
51
|
+
<div class="govuk-date-input" id="holidayArrival-time">
|
|
59
52
|
<div class="govuk-date-input__item">
|
|
60
53
|
<div class="govuk-form-group">
|
|
61
54
|
<label class="govuk-label" for="holidayArrival_hour">
|