@defra/forms-engine-plugin 0.1.8 → 0.1.10
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/.server/server/forms/report-a-terrorist.json +7 -7
- package/.server/server/forms/runner-components-test.json +10 -10
- package/.server/server/forms/test.yaml +363 -0
- package/.server/server/utils/file-form-service.js +134 -0
- package/.server/server/utils/file-form-service.js.map +1 -0
- package/.server/server/utils/file-form-service.test.js +52 -0
- package/.server/server/utils/file-form-service.test.js.map +1 -0
- package/README.md +3 -1
- package/package.json +6 -3
- package/src/server/forms/report-a-terrorist.json +7 -7
- package/src/server/forms/runner-components-test.json +10 -10
- package/src/server/forms/test.yaml +363 -0
- package/src/server/plugins/engine/components/AutocompleteField.test.ts +5 -5
- package/src/server/plugins/engine/components/CheckboxesField.test.ts +7 -7
- package/src/server/plugins/engine/components/List.test.ts +3 -0
- package/src/server/plugins/engine/components/RadiosField.test.ts +5 -5
- package/src/server/plugins/engine/components/SelectField.test.ts +5 -5
- package/src/server/plugins/engine/pageControllers/QuestionPageController.test.ts +4 -0
- package/src/server/utils/file-form-service.js +144 -0
- package/src/server/utils/file-form-service.test.js +79 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { FormStatus } from "../routes/types.js";
|
|
2
|
+
import { FileFormService } from "./file-form-service.js";
|
|
3
|
+
|
|
4
|
+
// Create the metadata which is shared for all forms
|
|
5
|
+
const now = new Date();
|
|
6
|
+
const user = {
|
|
7
|
+
id: 'user',
|
|
8
|
+
displayName: 'Username'
|
|
9
|
+
};
|
|
10
|
+
const author = {
|
|
11
|
+
createdAt: now,
|
|
12
|
+
createdBy: user,
|
|
13
|
+
updatedAt: now,
|
|
14
|
+
updatedBy: user
|
|
15
|
+
};
|
|
16
|
+
const metadata = {
|
|
17
|
+
id: '95e92559-968d-44ae-8666-2b1ad3dffd31',
|
|
18
|
+
slug: 'example-form',
|
|
19
|
+
title: 'Example form',
|
|
20
|
+
organisation: 'Defra',
|
|
21
|
+
teamName: 'Team name',
|
|
22
|
+
teamEmail: 'team@defra.gov.uk',
|
|
23
|
+
submissionGuidance: "Thanks for your submission, we'll be in touch",
|
|
24
|
+
notificationEmail: 'email@domain.com',
|
|
25
|
+
...author,
|
|
26
|
+
live: author
|
|
27
|
+
};
|
|
28
|
+
describe('File Form Service', () => {
|
|
29
|
+
it('should load JSON files from disk', async () => {
|
|
30
|
+
const loader = new FileFormService();
|
|
31
|
+
const definition = await loader.addForm('src/server/forms/test.json', metadata);
|
|
32
|
+
const formsService = loader.toFormsService();
|
|
33
|
+
expect(await formsService.getFormMetadata(metadata.slug)).toBe(metadata);
|
|
34
|
+
expect(await formsService.getFormDefinition(metadata.id, FormStatus.Draft)).toBe(definition);
|
|
35
|
+
expect(() => loader.getFormMetadata('invalid-slug')).toThrow("Form metadata 'invalid-slug' not found");
|
|
36
|
+
expect(() => loader.getFormDefinition('invalid-id')).toThrow("Form definition 'invalid-id' not found");
|
|
37
|
+
});
|
|
38
|
+
it('should load YAML files from disk', async () => {
|
|
39
|
+
const loader = new FileFormService();
|
|
40
|
+
const definition = await loader.addForm('src/server/forms/test.yaml', metadata);
|
|
41
|
+
const formsService = loader.toFormsService();
|
|
42
|
+
expect(await formsService.getFormMetadata(metadata.slug)).toBe(metadata);
|
|
43
|
+
expect(await formsService.getFormDefinition(metadata.id, FormStatus.Draft)).toBe(definition);
|
|
44
|
+
expect(() => loader.getFormMetadata('invalid-slug')).toThrow("Form metadata 'invalid-slug' not found");
|
|
45
|
+
expect(() => loader.getFormDefinition('invalid-id')).toThrow("Form definition 'invalid-id' not found");
|
|
46
|
+
});
|
|
47
|
+
it("should throw if the file isn't JSON or YAML", async () => {
|
|
48
|
+
const loader = new FileFormService();
|
|
49
|
+
await expect(loader.addForm('src/server/forms/test.txt', metadata)).rejects.toThrow("Invalid file extension '.txt'");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=file-form-service.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-form-service.test.js","names":["FormStatus","FileFormService","now","Date","user","id","displayName","author","createdAt","createdBy","updatedAt","updatedBy","metadata","slug","title","organisation","teamName","teamEmail","submissionGuidance","notificationEmail","live","describe","it","loader","definition","addForm","formsService","toFormsService","expect","getFormMetadata","toBe","getFormDefinition","Draft","toThrow","rejects"],"sources":["../../../src/server/utils/file-form-service.test.js"],"sourcesContent":["import { FormStatus } from '~/src/server/routes/types.js'\nimport { FileFormService } from '~/src/server/utils/file-form-service.js'\n\n// Create the metadata which is shared for all forms\nconst now = new Date()\nconst user = { id: 'user', displayName: 'Username' }\nconst author = {\n createdAt: now,\n createdBy: user,\n updatedAt: now,\n updatedBy: user\n}\n\nconst metadata = {\n id: '95e92559-968d-44ae-8666-2b1ad3dffd31',\n slug: 'example-form',\n title: 'Example form',\n organisation: 'Defra',\n teamName: 'Team name',\n teamEmail: 'team@defra.gov.uk',\n submissionGuidance: \"Thanks for your submission, we'll be in touch\",\n notificationEmail: 'email@domain.com',\n ...author,\n live: author\n}\n\ndescribe('File Form Service', () => {\n it('should load JSON files from disk', async () => {\n const loader = new FileFormService()\n\n const definition = await loader.addForm(\n 'src/server/forms/test.json',\n metadata\n )\n\n const formsService = loader.toFormsService()\n expect(await formsService.getFormMetadata(metadata.slug)).toBe(metadata)\n expect(\n await formsService.getFormDefinition(metadata.id, FormStatus.Draft)\n ).toBe(definition)\n\n expect(() => loader.getFormMetadata('invalid-slug')).toThrow(\n \"Form metadata 'invalid-slug' not found\"\n )\n expect(() => loader.getFormDefinition('invalid-id')).toThrow(\n \"Form definition 'invalid-id' not found\"\n )\n })\n\n it('should load YAML files from disk', async () => {\n const loader = new FileFormService()\n\n const definition = await loader.addForm(\n 'src/server/forms/test.yaml',\n metadata\n )\n\n const formsService = loader.toFormsService()\n expect(await formsService.getFormMetadata(metadata.slug)).toBe(metadata)\n expect(\n await formsService.getFormDefinition(metadata.id, FormStatus.Draft)\n ).toBe(definition)\n\n expect(() => loader.getFormMetadata('invalid-slug')).toThrow(\n \"Form metadata 'invalid-slug' not found\"\n )\n expect(() => loader.getFormDefinition('invalid-id')).toThrow(\n \"Form definition 'invalid-id' not found\"\n )\n })\n\n it(\"should throw if the file isn't JSON or YAML\", async () => {\n const loader = new FileFormService()\n\n await expect(\n loader.addForm('src/server/forms/test.txt', metadata)\n ).rejects.toThrow(\"Invalid file extension '.txt'\")\n })\n})\n"],"mappings":"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","ignoreList":[]}
|
package/README.md
CHANGED
|
@@ -18,7 +18,9 @@ It is designed to be embedded in the frontend of a digital service and provide a
|
|
|
18
18
|
|
|
19
19
|
## Demo of DXT
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
If you are within the Defra network, [see a live demo](https://forms-engine-plugin-example-ui.dev.cdp-int.defra.cloud/example-form).
|
|
22
|
+
|
|
23
|
+
If you aren't within the Defra network, [see our example UI and run it locally](https://github.com/DEFRA/forms-engine-plugin-example-ui).
|
|
22
24
|
|
|
23
25
|
## Installation
|
|
24
26
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra/forms-engine-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Defra forms engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"./file-upload.min.js": "./.public/javascripts/file-upload.min.js",
|
|
22
22
|
"./file-upload.min.js.map": "./.public/javascripts/file-upload.min.js.map",
|
|
23
23
|
"./application.min.css": "./.public/stylesheets/application.min.css",
|
|
24
|
+
"./file-form-service.js": "./.server/server/utils/file-form-service.js",
|
|
24
25
|
"./controllers/*": "./.server/server/plugins/engine/pageControllers/*",
|
|
25
26
|
"./services/*": "./.server/server/plugins/engine/services/*",
|
|
26
27
|
"./package.json": "./package.json"
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"dev:debug": "concurrently \"npm run client:watch\" \"npm run server:watch:debug\" --kill-others --names \"client,server\" --prefix-colors \"red.dim,blue.dim\"",
|
|
34
35
|
"format": "npm run format:check -- --write",
|
|
35
36
|
"format:check": "prettier --cache --cache-location .cache/prettier --cache-strategy content --check \"**/*.{cjs,js,json,md,mjs,scss,ts}\"",
|
|
37
|
+
"generate-schema-docs": "node scripts/generate-schema-docs.js",
|
|
36
38
|
"postinstall": "npm run setup:husky",
|
|
37
39
|
"lint": "npm run lint:editorconfig && npm run lint:js && npm run lint:types",
|
|
38
40
|
"lint:editorconfig": "editorconfig-checker",
|
|
@@ -60,7 +62,7 @@
|
|
|
60
62
|
},
|
|
61
63
|
"license": "SEE LICENSE IN LICENSE",
|
|
62
64
|
"dependencies": {
|
|
63
|
-
"@defra/forms-model": "^3.0.
|
|
65
|
+
"@defra/forms-model": "^3.0.438",
|
|
64
66
|
"@defra/hapi-tracing": "^1.0.0",
|
|
65
67
|
"@elastic/ecs-pino-format": "^1.5.0",
|
|
66
68
|
"@hapi/boom": "^10.0.1",
|
|
@@ -102,7 +104,8 @@
|
|
|
102
104
|
"pino": "^9.6.0",
|
|
103
105
|
"pino-pretty": "^13.0.0",
|
|
104
106
|
"proxy-agent": "^6.5.0",
|
|
105
|
-
"resolve": "^1.22.10"
|
|
107
|
+
"resolve": "^1.22.10",
|
|
108
|
+
"yaml": "^2.7.1"
|
|
106
109
|
},
|
|
107
110
|
"devDependencies": {
|
|
108
111
|
"@babel/cli": "^7.26.4",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"schema": {}
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
|
-
"name": "
|
|
57
|
+
"name": "ajdOpV",
|
|
58
58
|
"options": {},
|
|
59
59
|
"type": "Details",
|
|
60
60
|
"title": "Help me take a screenshot",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"schema": {}
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
|
-
"name": "
|
|
65
|
+
"name": "LUBRMD",
|
|
66
66
|
"options": {},
|
|
67
67
|
"type": "RadiosField",
|
|
68
68
|
"title": "Do you have any evidence?",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"title": "Is there anything else you can tell us?",
|
|
93
93
|
"components": [
|
|
94
94
|
{
|
|
95
|
-
"name": "
|
|
95
|
+
"name": "HETMBo",
|
|
96
96
|
"title": "Html",
|
|
97
97
|
"options": {},
|
|
98
98
|
"type": "Html",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"schema": {}
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
|
-
"name": "
|
|
103
|
+
"name": "evZxIJ",
|
|
104
104
|
"options": {
|
|
105
105
|
"required": false
|
|
106
106
|
},
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"title": "Yes I have evidence",
|
|
142
142
|
"components": [
|
|
143
143
|
{
|
|
144
|
-
"name": "
|
|
144
|
+
"name": "koExae",
|
|
145
145
|
"options": {
|
|
146
146
|
"required": false
|
|
147
147
|
},
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
"conditions": [
|
|
231
231
|
{
|
|
232
232
|
"field": {
|
|
233
|
-
"name": "PMXq1s.
|
|
233
|
+
"name": "PMXq1s.LUBRMD",
|
|
234
234
|
"type": "RadiosField",
|
|
235
235
|
"display": "Do you have any evidence? in PMXq1s"
|
|
236
236
|
},
|
|
@@ -252,7 +252,7 @@
|
|
|
252
252
|
"conditions": [
|
|
253
253
|
{
|
|
254
254
|
"field": {
|
|
255
|
-
"name": "PMXq1s.
|
|
255
|
+
"name": "PMXq1s.LUBRMD",
|
|
256
256
|
"type": "RadiosField",
|
|
257
257
|
"display": "Do you have any evidence? in PMXq1s"
|
|
258
258
|
},
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"path": "/do-you-own-a-vehicle",
|
|
7
7
|
"components": [
|
|
8
8
|
{
|
|
9
|
-
"name": "
|
|
9
|
+
"name": "qqbRwx",
|
|
10
10
|
"options": {},
|
|
11
11
|
"type": "YesNoField",
|
|
12
12
|
"title": "Do you own a vehicle?",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"title": "What address is the vehicle registered to?",
|
|
33
33
|
"components": [
|
|
34
34
|
{
|
|
35
|
-
"name": "
|
|
35
|
+
"name": "sFRxaX",
|
|
36
36
|
"options": {},
|
|
37
37
|
"type": "UkAddressField",
|
|
38
38
|
"title": "What address is the vehicle registered to?",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"schema": {}
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
|
-
"name": "
|
|
49
|
+
"name": "ZxGuyn",
|
|
50
50
|
"options": {},
|
|
51
51
|
"type": "CheckboxesField",
|
|
52
52
|
"title": "Which Clean Air Zones are you claiming an exemption for?",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"title": "Clean Air Zone (CAZ) Exemption",
|
|
67
67
|
"components": [
|
|
68
68
|
{
|
|
69
|
-
"name": "
|
|
69
|
+
"name": "MOBxxt",
|
|
70
70
|
"title": "Html",
|
|
71
71
|
"options": {},
|
|
72
72
|
"type": "Html",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"title": "Details about your vehicle",
|
|
87
87
|
"components": [
|
|
88
88
|
{
|
|
89
|
-
"name": "
|
|
89
|
+
"name": "xZVmNx",
|
|
90
90
|
"options": {},
|
|
91
91
|
"type": "AutocompleteField",
|
|
92
92
|
"title": "What is the make of you vehicle?",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"schema": {}
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
|
-
"name": "
|
|
97
|
+
"name": "gHSgox",
|
|
98
98
|
"options": {},
|
|
99
99
|
"type": "TextField",
|
|
100
100
|
"title": "Vehicle Model",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"schema": {}
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
|
-
"name": "
|
|
105
|
+
"name": "xLZxto",
|
|
106
106
|
"options": {},
|
|
107
107
|
"type": "DatePartsField",
|
|
108
108
|
"title": "Date you purchased the vehicle?",
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"schema": {}
|
|
153
153
|
},
|
|
154
154
|
{
|
|
155
|
-
"name": "
|
|
155
|
+
"name": "xzLxbB",
|
|
156
156
|
"options": {},
|
|
157
157
|
"type": "TelephoneNumberField",
|
|
158
158
|
"title": "Contact number",
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
"title": "final steps",
|
|
172
172
|
"components": [
|
|
173
173
|
{
|
|
174
|
-
"name": "
|
|
174
|
+
"name": "fkdxav",
|
|
175
175
|
"options": {},
|
|
176
176
|
"type": "List",
|
|
177
177
|
"title": "Declaration",
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
"schema": {}
|
|
180
180
|
},
|
|
181
181
|
{
|
|
182
|
-
"name": "
|
|
182
|
+
"name": "LxxAYe",
|
|
183
183
|
"options": {},
|
|
184
184
|
"type": "EmailAddressField",
|
|
185
185
|
"title": "Your email address",
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
---
|
|
2
|
+
startPage: "/start"
|
|
3
|
+
pages:
|
|
4
|
+
- title: Start
|
|
5
|
+
path: "/start"
|
|
6
|
+
components: []
|
|
7
|
+
next:
|
|
8
|
+
- path: "/uk-passport"
|
|
9
|
+
controller: StartPageController
|
|
10
|
+
- path: "/uk-passport"
|
|
11
|
+
components:
|
|
12
|
+
- type: YesNoField
|
|
13
|
+
name: ukPassport
|
|
14
|
+
title: Do you have a UK passport?
|
|
15
|
+
options:
|
|
16
|
+
required: true
|
|
17
|
+
schema: {}
|
|
18
|
+
section: checkBeforeYouStart
|
|
19
|
+
next:
|
|
20
|
+
- path: "/how-many-people"
|
|
21
|
+
- path: "/no-uk-passport"
|
|
22
|
+
condition: doesntHaveUKPassport
|
|
23
|
+
title: Do you have a UK passport?
|
|
24
|
+
- path: "/no-uk-passport"
|
|
25
|
+
title: You're not eligible for this service
|
|
26
|
+
components:
|
|
27
|
+
- type: Html
|
|
28
|
+
name: html
|
|
29
|
+
title: Html
|
|
30
|
+
content: >-
|
|
31
|
+
<p class="govuk-body">
|
|
32
|
+
If you still think you're eligible please contact the Foreign and Commonwealth Office.
|
|
33
|
+
</p>
|
|
34
|
+
options: {}
|
|
35
|
+
schema: {}
|
|
36
|
+
next: []
|
|
37
|
+
- path: "/how-many-people"
|
|
38
|
+
section: applicantDetails
|
|
39
|
+
components:
|
|
40
|
+
- options:
|
|
41
|
+
classes: govuk-input--width-10
|
|
42
|
+
required: true
|
|
43
|
+
type: SelectField
|
|
44
|
+
name: numberOfApplicants
|
|
45
|
+
title: How many applicants are there?
|
|
46
|
+
list: numberOfApplicants
|
|
47
|
+
next:
|
|
48
|
+
- path: "/applicant-one"
|
|
49
|
+
title: How many applicants are there?
|
|
50
|
+
- path: "/applicant-one"
|
|
51
|
+
title: Applicant 1
|
|
52
|
+
section: applicantOneDetails
|
|
53
|
+
components:
|
|
54
|
+
- type: Html
|
|
55
|
+
name: html
|
|
56
|
+
title: Html
|
|
57
|
+
content: <p class="govuk-body">Provide the details as they appear on your passport.</p>
|
|
58
|
+
options: {}
|
|
59
|
+
schema: {}
|
|
60
|
+
- type: TextField
|
|
61
|
+
name: firstName
|
|
62
|
+
title: First name
|
|
63
|
+
options:
|
|
64
|
+
required: true
|
|
65
|
+
schema: {}
|
|
66
|
+
- options:
|
|
67
|
+
required: false
|
|
68
|
+
optionalText: false
|
|
69
|
+
type: TextField
|
|
70
|
+
name: middleName
|
|
71
|
+
title: Middle name
|
|
72
|
+
hint: If you have a middle name on your passport you must include it here
|
|
73
|
+
schema: {}
|
|
74
|
+
- type: TextField
|
|
75
|
+
name: lastName
|
|
76
|
+
title: Surname
|
|
77
|
+
options:
|
|
78
|
+
required: true
|
|
79
|
+
schema: {}
|
|
80
|
+
next:
|
|
81
|
+
- path: "/applicant-one-address"
|
|
82
|
+
- path: "/applicant-one-address"
|
|
83
|
+
section: applicantOneDetails
|
|
84
|
+
components:
|
|
85
|
+
- type: UkAddressField
|
|
86
|
+
name: address
|
|
87
|
+
title: Address
|
|
88
|
+
options:
|
|
89
|
+
required: true
|
|
90
|
+
schema: {}
|
|
91
|
+
next:
|
|
92
|
+
- path: "/applicant-two"
|
|
93
|
+
condition: moreThanOneApplicant
|
|
94
|
+
- path: "/contact-details"
|
|
95
|
+
title: Address
|
|
96
|
+
- path: "/applicant-two"
|
|
97
|
+
title: Applicant 2
|
|
98
|
+
section: applicantTwoDetails
|
|
99
|
+
components:
|
|
100
|
+
- type: Html
|
|
101
|
+
name: html
|
|
102
|
+
title: Html
|
|
103
|
+
content: <p class="govuk-body">Provide the details as they appear on your passport.</p>
|
|
104
|
+
options: {}
|
|
105
|
+
schema: {}
|
|
106
|
+
- type: TextField
|
|
107
|
+
name: firstName
|
|
108
|
+
title: First name
|
|
109
|
+
options:
|
|
110
|
+
required: true
|
|
111
|
+
schema: {}
|
|
112
|
+
- options:
|
|
113
|
+
required: false
|
|
114
|
+
optionalText: false
|
|
115
|
+
type: TextField
|
|
116
|
+
name: middleName
|
|
117
|
+
title: Middle name
|
|
118
|
+
hint: If you have a middle name on your passport you must include it here
|
|
119
|
+
schema: {}
|
|
120
|
+
- type: TextField
|
|
121
|
+
name: lastName
|
|
122
|
+
title: Surname
|
|
123
|
+
options:
|
|
124
|
+
required: true
|
|
125
|
+
schema: {}
|
|
126
|
+
next:
|
|
127
|
+
- path: "/applicant-two-address"
|
|
128
|
+
- path: "/applicant-two-address"
|
|
129
|
+
section: applicantTwoDetails
|
|
130
|
+
components:
|
|
131
|
+
- type: UkAddressField
|
|
132
|
+
name: address
|
|
133
|
+
title: Address
|
|
134
|
+
options:
|
|
135
|
+
required: true
|
|
136
|
+
schema: {}
|
|
137
|
+
next:
|
|
138
|
+
- path: "/applicant-three"
|
|
139
|
+
condition: moreThanTwoApplicants
|
|
140
|
+
- path: "/contact-details"
|
|
141
|
+
title: Address
|
|
142
|
+
- path: "/applicant-three"
|
|
143
|
+
title: Applicant 3
|
|
144
|
+
section: applicantThreeDetails
|
|
145
|
+
components:
|
|
146
|
+
- type: Html
|
|
147
|
+
name: html
|
|
148
|
+
title: Html
|
|
149
|
+
content: <p class="govuk-body">Provide the details as they appear on your passport.</p>
|
|
150
|
+
options: {}
|
|
151
|
+
schema: {}
|
|
152
|
+
- type: TextField
|
|
153
|
+
name: firstName
|
|
154
|
+
title: First name
|
|
155
|
+
options:
|
|
156
|
+
required: true
|
|
157
|
+
schema: {}
|
|
158
|
+
- options:
|
|
159
|
+
required: false
|
|
160
|
+
optionalText: false
|
|
161
|
+
type: TextField
|
|
162
|
+
name: middleName
|
|
163
|
+
title: Middle name
|
|
164
|
+
hint: If you have a middle name on your passport you must include it here
|
|
165
|
+
schema: {}
|
|
166
|
+
- type: TextField
|
|
167
|
+
name: lastName
|
|
168
|
+
title: Surname
|
|
169
|
+
options:
|
|
170
|
+
required: true
|
|
171
|
+
schema: {}
|
|
172
|
+
next:
|
|
173
|
+
- path: "/applicant-three-address"
|
|
174
|
+
- path: "/applicant-three-address"
|
|
175
|
+
section: applicantThreeDetails
|
|
176
|
+
components:
|
|
177
|
+
- type: UkAddressField
|
|
178
|
+
name: address
|
|
179
|
+
title: Address
|
|
180
|
+
options:
|
|
181
|
+
required: true
|
|
182
|
+
schema: {}
|
|
183
|
+
next:
|
|
184
|
+
- path: "/applicant-four"
|
|
185
|
+
condition: moreThanThreeApplicants
|
|
186
|
+
- path: "/contact-details"
|
|
187
|
+
title: Address
|
|
188
|
+
- path: "/applicant-four"
|
|
189
|
+
title: Applicant 4
|
|
190
|
+
section: applicantFourDetails
|
|
191
|
+
components:
|
|
192
|
+
- type: Html
|
|
193
|
+
name: html
|
|
194
|
+
title: Html
|
|
195
|
+
content: <p class="govuk-body">Provide the details as they appear on your passport.</p>
|
|
196
|
+
options: {}
|
|
197
|
+
schema: {}
|
|
198
|
+
- type: TextField
|
|
199
|
+
name: firstName
|
|
200
|
+
title: First name
|
|
201
|
+
options:
|
|
202
|
+
required: true
|
|
203
|
+
schema: {}
|
|
204
|
+
- options:
|
|
205
|
+
required: false
|
|
206
|
+
optionalText: false
|
|
207
|
+
type: TextField
|
|
208
|
+
name: middleName
|
|
209
|
+
title: Middle name
|
|
210
|
+
hint: If you have a middle name on your passport you must include it here
|
|
211
|
+
schema: {}
|
|
212
|
+
- type: TextField
|
|
213
|
+
name: lastName
|
|
214
|
+
title: Surname
|
|
215
|
+
options:
|
|
216
|
+
required: true
|
|
217
|
+
schema: {}
|
|
218
|
+
next:
|
|
219
|
+
- path: "/applicant-four-address"
|
|
220
|
+
- path: "/applicant-four-address"
|
|
221
|
+
section: applicantFourDetails
|
|
222
|
+
components:
|
|
223
|
+
- type: UkAddressField
|
|
224
|
+
name: address
|
|
225
|
+
title: Address
|
|
226
|
+
options:
|
|
227
|
+
required: true
|
|
228
|
+
schema: {}
|
|
229
|
+
next:
|
|
230
|
+
- path: "/contact-details"
|
|
231
|
+
title: Address
|
|
232
|
+
- path: "/contact-details"
|
|
233
|
+
section: applicantDetails
|
|
234
|
+
components:
|
|
235
|
+
- type: TelephoneNumberField
|
|
236
|
+
name: phoneNumber
|
|
237
|
+
title: Phone number
|
|
238
|
+
hint: If you haven't got a UK phone number, include country code
|
|
239
|
+
options:
|
|
240
|
+
required: true
|
|
241
|
+
schema: {}
|
|
242
|
+
- type: EmailAddressField
|
|
243
|
+
name: emailAddress
|
|
244
|
+
title: Your email address
|
|
245
|
+
options:
|
|
246
|
+
required: true
|
|
247
|
+
schema: {}
|
|
248
|
+
next:
|
|
249
|
+
- path: "/summary"
|
|
250
|
+
title: Applicant contact details
|
|
251
|
+
- path: "/summary"
|
|
252
|
+
controller: SummaryPageController
|
|
253
|
+
title: Summary
|
|
254
|
+
components: []
|
|
255
|
+
next: []
|
|
256
|
+
lists:
|
|
257
|
+
- name: numberOfApplicants
|
|
258
|
+
title: Number of people
|
|
259
|
+
type: number
|
|
260
|
+
items:
|
|
261
|
+
- text: '1'
|
|
262
|
+
value: 1
|
|
263
|
+
description: ''
|
|
264
|
+
condition: ''
|
|
265
|
+
- text: '2'
|
|
266
|
+
value: 2
|
|
267
|
+
description: ''
|
|
268
|
+
condition: ''
|
|
269
|
+
- text: '3'
|
|
270
|
+
value: 3
|
|
271
|
+
description: ''
|
|
272
|
+
condition: ''
|
|
273
|
+
- text: '4'
|
|
274
|
+
value: 4
|
|
275
|
+
description: ''
|
|
276
|
+
condition: ''
|
|
277
|
+
sections:
|
|
278
|
+
- name: checkBeforeYouStart
|
|
279
|
+
title: Check before you start
|
|
280
|
+
- name: applicantDetails
|
|
281
|
+
title: Applicant details
|
|
282
|
+
- name: applicantOneDetails
|
|
283
|
+
title: Applicant 1
|
|
284
|
+
- name: applicantTwoDetails
|
|
285
|
+
title: Applicant 2
|
|
286
|
+
- name: applicantThreeDetails
|
|
287
|
+
title: Applicant 3
|
|
288
|
+
- name: applicantFourDetails
|
|
289
|
+
title: Applicant 4
|
|
290
|
+
phaseBanner: {}
|
|
291
|
+
declaration: <p class="govuk-body">All the answers you have provided are true to the
|
|
292
|
+
best of your knowledge.</p>
|
|
293
|
+
conditions:
|
|
294
|
+
- name: hasUKPassport
|
|
295
|
+
displayName: hasUKPassport
|
|
296
|
+
value:
|
|
297
|
+
name: hasUKPassport
|
|
298
|
+
conditions:
|
|
299
|
+
- field:
|
|
300
|
+
name: checkBeforeYouStart.ukPassport
|
|
301
|
+
type: YesNoField
|
|
302
|
+
display: Do you have a UK passport?
|
|
303
|
+
operator: is
|
|
304
|
+
value:
|
|
305
|
+
type: Value
|
|
306
|
+
value: 'true'
|
|
307
|
+
display: 'true'
|
|
308
|
+
- name: doesntHaveUKPassport
|
|
309
|
+
displayName: doesntHaveUKPassport
|
|
310
|
+
value:
|
|
311
|
+
name: doesntHaveUKPassport
|
|
312
|
+
conditions:
|
|
313
|
+
- field:
|
|
314
|
+
name: checkBeforeYouStart.ukPassport
|
|
315
|
+
type: YesNoField
|
|
316
|
+
display: Do you have a UK passport?
|
|
317
|
+
operator: is
|
|
318
|
+
value:
|
|
319
|
+
type: Value
|
|
320
|
+
value: 'false'
|
|
321
|
+
display: 'false'
|
|
322
|
+
- name: moreThanOneApplicant
|
|
323
|
+
displayName: moreThanOneApplicant
|
|
324
|
+
value:
|
|
325
|
+
name: moreThanOneApplicant
|
|
326
|
+
conditions:
|
|
327
|
+
- field:
|
|
328
|
+
name: applicantDetails.numberOfApplicants
|
|
329
|
+
type: SelectField
|
|
330
|
+
display: How many applicants are there?
|
|
331
|
+
operator: is more than
|
|
332
|
+
value:
|
|
333
|
+
type: Value
|
|
334
|
+
value: '1'
|
|
335
|
+
display: '1'
|
|
336
|
+
- name: moreThanTwoApplicants
|
|
337
|
+
displayName: moreThanTwoApplicants
|
|
338
|
+
value:
|
|
339
|
+
name: moreThanTwoApplicants
|
|
340
|
+
conditions:
|
|
341
|
+
- field:
|
|
342
|
+
name: applicantDetails.numberOfApplicants
|
|
343
|
+
type: SelectField
|
|
344
|
+
display: How many applicants are there?
|
|
345
|
+
operator: is more than
|
|
346
|
+
value:
|
|
347
|
+
type: Value
|
|
348
|
+
value: '2'
|
|
349
|
+
display: '2'
|
|
350
|
+
- name: moreThanThreeApplicants
|
|
351
|
+
displayName: moreThanThreeApplicants
|
|
352
|
+
value:
|
|
353
|
+
name: moreThanThreeApplicants
|
|
354
|
+
conditions:
|
|
355
|
+
- field:
|
|
356
|
+
name: applicantDetails.numberOfApplicants
|
|
357
|
+
type: SelectField
|
|
358
|
+
display: How many applicants are there?
|
|
359
|
+
operator: is more than
|
|
360
|
+
value:
|
|
361
|
+
type: Value
|
|
362
|
+
value: '3'
|
|
363
|
+
display: '3'
|
|
@@ -172,7 +172,7 @@ describe.each([
|
|
|
172
172
|
|
|
173
173
|
describe('State', () => {
|
|
174
174
|
it.each([...options.examples])('returns text from state', (item) => {
|
|
175
|
-
const state1 = getFormState(item.
|
|
175
|
+
const state1 = getFormState(item.value)
|
|
176
176
|
const state2 = getFormState(null)
|
|
177
177
|
|
|
178
178
|
const answer1 = getAnswer(field, state1)
|
|
@@ -183,7 +183,7 @@ describe.each([
|
|
|
183
183
|
})
|
|
184
184
|
|
|
185
185
|
it.each([...options.examples])('returns payload from state', (item) => {
|
|
186
|
-
const state1 = getFormState(item.
|
|
186
|
+
const state1 = getFormState(item.value)
|
|
187
187
|
const state2 = getFormState(null)
|
|
188
188
|
|
|
189
189
|
const payload1 = field.getFormDataFromState(state1)
|
|
@@ -194,7 +194,7 @@ describe.each([
|
|
|
194
194
|
})
|
|
195
195
|
|
|
196
196
|
it.each([...options.examples])('returns value from state', (item) => {
|
|
197
|
-
const state1 = getFormState(item.
|
|
197
|
+
const state1 = getFormState(item.value)
|
|
198
198
|
const state2 = getFormState(null)
|
|
199
199
|
|
|
200
200
|
const value1 = field.getFormValueFromState(state1)
|
|
@@ -207,7 +207,7 @@ describe.each([
|
|
|
207
207
|
it.each([...options.examples])(
|
|
208
208
|
'returns context for conditions and form submission',
|
|
209
209
|
(item) => {
|
|
210
|
-
const state1 = getFormState(item.
|
|
210
|
+
const state1 = getFormState(item.value)
|
|
211
211
|
const state2 = getFormState(null)
|
|
212
212
|
|
|
213
213
|
const value1 = field.getContextValueFromState(state1)
|
|
@@ -225,7 +225,7 @@ describe.each([
|
|
|
225
225
|
const value1 = field.getStateFromValidForm(payload1)
|
|
226
226
|
const value2 = field.getStateFromValidForm(payload2)
|
|
227
227
|
|
|
228
|
-
expect(value1).toEqual(getFormState(item.
|
|
228
|
+
expect(value1).toEqual(getFormState(item.value))
|
|
229
229
|
expect(value2).toEqual(getFormState(null))
|
|
230
230
|
})
|
|
231
231
|
})
|