@defra/forms-engine-plugin 0.1.9 → 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.
@@ -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.state)
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.state)
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.state)
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.state)
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.state))
228
+ expect(value1).toEqual(getFormState(item.value))
229
229
  expect(value2).toEqual(getFormState(null))
230
230
  })
231
231
  })
@@ -240,7 +240,7 @@ describe.each([
240
240
  it.each([...options.examples])(
241
241
  'returns text from state (single)',
242
242
  (item) => {
243
- const state1 = getFormState([item.state])
243
+ const state1 = getFormState([item.value])
244
244
  const state2 = getFormState(null)
245
245
 
246
246
  const answer1 = getAnswer(field, state1)
@@ -260,7 +260,7 @@ describe.each([
260
260
  const item1 = options.examples[0]
261
261
  const item2 = options.examples[2]
262
262
 
263
- const state = getFormState([item1.state, item2.state])
263
+ const state = getFormState([item1.value, item2.value])
264
264
  const answer = getAnswer(field, state)
265
265
 
266
266
  expect(answer).toBe(outdent`
@@ -272,7 +272,7 @@ describe.each([
272
272
  })
273
273
 
274
274
  it.each([...options.examples])('returns payload from state', (item) => {
275
- const state1 = getFormState([item.state])
275
+ const state1 = getFormState([item.value])
276
276
  const state2 = getFormState(null)
277
277
 
278
278
  const payload1 = field.getFormDataFromState(state1)
@@ -283,7 +283,7 @@ describe.each([
283
283
  })
284
284
 
285
285
  it.each([...options.examples])('returns value from state', (item) => {
286
- const state1 = getFormState([item.state])
286
+ const state1 = getFormState([item.value])
287
287
  const state2 = getFormState(null)
288
288
 
289
289
  const value1 = field.getFormValueFromState(state1)
@@ -296,13 +296,13 @@ describe.each([
296
296
  it.each([...options.examples])(
297
297
  'returns context for conditions and form submission',
298
298
  (item) => {
299
- const state1 = getFormState([item.state])
299
+ const state1 = getFormState([item.value])
300
300
  const state2 = getFormState(null)
301
301
 
302
302
  const value1 = field.getContextValueFromState(state1)
303
303
  const value2 = field.getContextValueFromState(state2)
304
304
 
305
- expect(value1).toEqual([item.state])
305
+ expect(value1).toEqual([item.value])
306
306
  expect(value2).toEqual([])
307
307
  }
308
308
  )
@@ -314,7 +314,7 @@ describe.each([
314
314
  const value1 = field.getStateFromValidForm(payload1)
315
315
  const value2 = field.getStateFromValidForm(payload2)
316
316
 
317
- expect(value1).toEqual(getFormState([item.state]))
317
+ expect(value1).toEqual(getFormState([item.value]))
318
318
  expect(value2).toEqual(getFormState(null))
319
319
  })
320
320
  })
@@ -52,18 +52,21 @@ describe('List', () => {
52
52
  it('returns list items', () => {
53
53
  expect(guidance).toHaveProperty('items', [
54
54
  {
55
+ id: '52fc51fc-c75a-4b08-9c9e-6bd99b9bc49b',
55
56
  text: '1 day',
56
57
  value: 1,
57
58
  description:
58
59
  'Valid for 24 hours from the start time that you select'
59
60
  },
60
61
  {
62
+ id: '56b7b34f-23b3-4446-ac8e-b2443d18588e',
61
63
  text: '8 day',
62
64
  value: 8,
63
65
  description:
64
66
  'Valid for 8 consecutive days from the start time that you select'
65
67
  },
66
68
  {
69
+ id: '1af54fbc-eec2-4e1e-bd53-2415abf62677',
67
70
  text: '12 months',
68
71
  value: 365,
69
72
  description:
@@ -170,7 +170,7 @@ describe.each([
170
170
 
171
171
  describe('State', () => {
172
172
  it.each([...options.examples])('returns text from state', (item) => {
173
- const state1 = getFormState(item.state)
173
+ const state1 = getFormState(item.value)
174
174
  const state2 = getFormState(null)
175
175
 
176
176
  const answer1 = getAnswer(field, state1)
@@ -181,7 +181,7 @@ describe.each([
181
181
  })
182
182
 
183
183
  it.each([...options.examples])('returns payload from state', (item) => {
184
- const state1 = getFormState(item.state)
184
+ const state1 = getFormState(item.value)
185
185
  const state2 = getFormState(null)
186
186
 
187
187
  const payload1 = field.getFormDataFromState(state1)
@@ -192,7 +192,7 @@ describe.each([
192
192
  })
193
193
 
194
194
  it.each([...options.examples])('returns value from state', (item) => {
195
- const state1 = getFormState(item.state)
195
+ const state1 = getFormState(item.value)
196
196
  const state2 = getFormState(null)
197
197
 
198
198
  const value1 = field.getFormValueFromState(state1)
@@ -205,7 +205,7 @@ describe.each([
205
205
  it.each([...options.examples])(
206
206
  'returns context for conditions and form submission',
207
207
  (item) => {
208
- const state1 = getFormState(item.state)
208
+ const state1 = getFormState(item.value)
209
209
  const state2 = getFormState(null)
210
210
 
211
211
  const value1 = field.getContextValueFromState(state1)
@@ -223,7 +223,7 @@ describe.each([
223
223
  const value1 = field.getStateFromValidForm(payload1)
224
224
  const value2 = field.getStateFromValidForm(payload2)
225
225
 
226
- expect(value1).toEqual(getFormState(item.state))
226
+ expect(value1).toEqual(getFormState(item.value))
227
227
  expect(value2).toEqual(getFormState(null))
228
228
  })
229
229
  })
@@ -171,7 +171,7 @@ describe.each([
171
171
 
172
172
  describe('State', () => {
173
173
  it.each([...options.examples])('returns text from state', (item) => {
174
- const state1 = getFormState(item.state)
174
+ const state1 = getFormState(item.value)
175
175
  const state2 = getFormState(null)
176
176
 
177
177
  const answer1 = getAnswer(field, state1)
@@ -182,7 +182,7 @@ describe.each([
182
182
  })
183
183
 
184
184
  it.each([...options.examples])('returns payload from state', (item) => {
185
- const state1 = getFormState(item.state)
185
+ const state1 = getFormState(item.value)
186
186
  const state2 = getFormState(null)
187
187
 
188
188
  const payload1 = field.getFormDataFromState(state1)
@@ -193,7 +193,7 @@ describe.each([
193
193
  })
194
194
 
195
195
  it.each([...options.examples])('returns value from state', (item) => {
196
- const state1 = getFormState(item.state)
196
+ const state1 = getFormState(item.value)
197
197
  const state2 = getFormState(null)
198
198
 
199
199
  const value1 = field.getFormValueFromState(state1)
@@ -206,7 +206,7 @@ describe.each([
206
206
  it.each([...options.examples])(
207
207
  'returns context for conditions and form submission',
208
208
  (item) => {
209
- const state1 = getFormState(item.state)
209
+ const state1 = getFormState(item.value)
210
210
  const state2 = getFormState(null)
211
211
 
212
212
  const value1 = field.getContextValueFromState(state1)
@@ -224,7 +224,7 @@ describe.each([
224
224
  const value1 = field.getStateFromValidForm(payload1)
225
225
  const value2 = field.getStateFromValidForm(payload2)
226
226
 
227
- expect(value1).toEqual(getFormState(item.state))
227
+ expect(value1).toEqual(getFormState(item.value))
228
228
  expect(value2).toEqual(getFormState(null))
229
229
  })
230
230
  })
@@ -443,6 +443,7 @@ describe('QuestionPageController', () => {
443
443
  expect(filtered[1].model.label?.text).toBe('Select from the list')
444
444
  expect(filtered[1].model.items).toEqual([
445
445
  {
446
+ id: expect.any(String),
446
447
  checked: false,
447
448
  condition: 'isBarnOwl',
448
449
  selected: false,
@@ -450,6 +451,7 @@ describe('QuestionPageController', () => {
450
451
  value: '1'
451
452
  },
452
453
  {
454
+ id: expect.any(String),
453
455
  checked: false,
454
456
  condition: 'isBarnOwl',
455
457
  selected: false,
@@ -499,6 +501,7 @@ describe('QuestionPageController', () => {
499
501
  expect(filtered[1].model.label?.text).toBe('Select from the list')
500
502
  expect(filtered[1].model.items).toEqual([
501
503
  {
504
+ id: expect.any(String),
502
505
  checked: false,
503
506
  condition: 'notBarnOwl',
504
507
  selected: false,
@@ -506,6 +509,7 @@ describe('QuestionPageController', () => {
506
509
  value: '3'
507
510
  },
508
511
  {
512
+ id: expect.any(String),
509
513
  checked: false,
510
514
  condition: 'notBarnOwl',
511
515
  selected: false,