@defra-fish/gafl-webapp-service 1.25.0 → 1.26.0-rc.2
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/package.json +4 -4
- package/src/handlers/new-session-handler.js +2 -1
- package/src/locales/cy.json +4 -4
- package/src/pages/contact/address/select/__tests__/route.spec.js +41 -1
- package/src/pages/contact/address/select/route.js +6 -2
- package/src/pages/summary/contact-summary/__tests__/__snapshots__/route.spec.js.snap +101 -36
- package/src/pages/summary/contact-summary/__tests__/route.spec.js +87 -14
- package/src/pages/summary/contact-summary/route.js +25 -12
- package/src/pages/summary/licence-summary/__tests__/route.spec.js +41 -17
- package/src/pages/summary/licence-summary/route.js +11 -8
- package/src/routes/__tests__/misc-routes.spec.js +30 -2
- package/src/routes/journey-definition.js +3 -0
- package/src/routes/misc-routes.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra-fish/gafl-webapp-service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0-rc.2",
|
|
4
4
|
"description": "The websales frontend for the GAFL service",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"prepare": "gulp --gulpfile build/gulpfile.cjs"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@defra-fish/business-rules-lib": "1.
|
|
40
|
-
"@defra-fish/connectors-lib": "1.
|
|
39
|
+
"@defra-fish/business-rules-lib": "1.26.0-rc.2",
|
|
40
|
+
"@defra-fish/connectors-lib": "1.26.0-rc.2",
|
|
41
41
|
"@defra/hapi-gapi": "^1.1.0",
|
|
42
42
|
"@hapi/boom": "^9.1.2",
|
|
43
43
|
"@hapi/catbox-redis": "^6.0.2",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"gulp-sourcemaps": "^3.0.0",
|
|
77
77
|
"node-sass": "^6.0.1"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "18ce5b8127253c6d844197ba6eda5d1d5264f966"
|
|
80
80
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CONTROLLER } from '../uri.js'
|
|
2
2
|
import { initialiseAnalyticsSessionData } from '../processors/analytics.js'
|
|
3
|
+
import { addLanguageCodeToUri } from '../processors/uri-helper.js'
|
|
3
4
|
|
|
4
5
|
export default async (request, h) => {
|
|
5
6
|
// The user may have an existing session, in which case we need to examine this for attribution and/or clientId
|
|
6
7
|
const existingCacheStatus = await request.cache().helpers.status.get()
|
|
7
8
|
await request.cache().initialize()
|
|
8
9
|
await initialiseAnalyticsSessionData(request, existingCacheStatus)
|
|
9
|
-
return h.redirect(CONTROLLER.uri)
|
|
10
|
+
return h.redirect(addLanguageCodeToUri(request, CONTROLLER.uri))
|
|
10
11
|
}
|
package/src/locales/cy.json
CHANGED
|
@@ -84,14 +84,14 @@
|
|
|
84
84
|
"address_lookup_crown_copyright": "© Hawlfrant y goron a hawliau cronfa ddata 2022 ",
|
|
85
85
|
"address_lookup_error_empty_name_num": "Nodwch rif neu enw adeilad",
|
|
86
86
|
"address_lookup_error_empty_postcode": "Nodwch god post",
|
|
87
|
-
"address_lookup_error_max_name_num": "
|
|
88
|
-
"address_lookup_error_pattern_postcode": "
|
|
89
|
-
"address_lookup_manually_enter": "
|
|
87
|
+
"address_lookup_error_max_name_num": "Mae’n rhaid i rif neu enw’r adeilad fod yn llai na 50 nod",
|
|
88
|
+
"address_lookup_error_pattern_postcode": "Rhowch god post yn y DU. Os mae’r cyfeiriad y tu allan i’r DU, teipiwch y cyfeiriad.",
|
|
89
|
+
"address_lookup_manually_enter": "Rhowch eich cyfeiriad",
|
|
90
90
|
"address_lookup_name_num_hint": "Er enghraifft, 47, Fflat 2a neu Rose Cottage",
|
|
91
91
|
"address_lookup_name_num_label": "Rhif neu enw’r adeilad",
|
|
92
92
|
"address_lookup_postcode_hint": "Er enghraifft, WA4 1AB",
|
|
93
93
|
"address_lookup_postcode_label": "Cod post",
|
|
94
|
-
"address_lookup_title_other": "
|
|
94
|
+
"address_lookup_title_other": "Chwiliwch am eu cyfeiriad",
|
|
95
95
|
"address_lookup_title_you": "Dewch o hyd i’ch cyfeiriad",
|
|
96
96
|
"address_select_error_choose": "Dewisiwch gyfeiriad",
|
|
97
97
|
"address_select_addresses": " chyfeiriad",
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { getData } from '../route'
|
|
2
|
+
import { addLanguageCodeToUri } from '../../../../../processors/uri-helper.js'
|
|
3
|
+
import { ADDRESS_LOOKUP } from '../../../../../uri.js'
|
|
4
|
+
|
|
5
|
+
jest.mock('../../../../../processors/uri-helper.js')
|
|
2
6
|
|
|
3
7
|
describe('address-select > route', () => {
|
|
4
8
|
const mockTransactionCacheGet = jest.fn()
|
|
@@ -13,7 +17,10 @@ describe('address-select > route', () => {
|
|
|
13
17
|
getCurrentPermission: jest.fn(() => ({}))
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
|
-
})
|
|
20
|
+
}),
|
|
21
|
+
url: {
|
|
22
|
+
search: ''
|
|
23
|
+
}
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
describe('getData', () => {
|
|
@@ -28,5 +35,38 @@ describe('address-select > route', () => {
|
|
|
28
35
|
const result = await getData(mockRequest)
|
|
29
36
|
expect(result.isLicenceForYou).toBeFalsy()
|
|
30
37
|
})
|
|
38
|
+
|
|
39
|
+
it('should return the addressLookup page uri', async () => {
|
|
40
|
+
mockTransactionCacheGet.mockImplementationOnce(() => ({
|
|
41
|
+
licenceStartDate: '2021-07-01',
|
|
42
|
+
numberOfRods: '3',
|
|
43
|
+
licenceType: 'Salmon and sea trout',
|
|
44
|
+
licenceLength: '12M',
|
|
45
|
+
licensee: {
|
|
46
|
+
firstName: 'Graham',
|
|
47
|
+
lastName: 'Willis',
|
|
48
|
+
birthDate: '1946-01-01'
|
|
49
|
+
},
|
|
50
|
+
permit: {
|
|
51
|
+
cost: 6
|
|
52
|
+
}
|
|
53
|
+
}))
|
|
54
|
+
|
|
55
|
+
const returnValue = Symbol('return value')
|
|
56
|
+
addLanguageCodeToUri.mockReturnValueOnce(returnValue)
|
|
57
|
+
|
|
58
|
+
const result = await getData(mockRequest)
|
|
59
|
+
const ret = result.lookupPage
|
|
60
|
+
|
|
61
|
+
expect(ret).toEqual(returnValue)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('addLanguageCodeToUri is called with the expected arguments for address lookup', async () => {
|
|
65
|
+
mockTransactionCacheGet.mockImplementationOnce(() => ({ isLicenceForYou: true }))
|
|
66
|
+
|
|
67
|
+
await getData(mockRequest)
|
|
68
|
+
|
|
69
|
+
expect(addLanguageCodeToUri).toHaveBeenCalledWith(mockRequest, ADDRESS_LOOKUP.uri)
|
|
70
|
+
})
|
|
31
71
|
})
|
|
32
72
|
})
|
|
@@ -2,6 +2,7 @@ import { ADDRESS_SELECT, ADDRESS_LOOKUP, ADDRESS_ENTRY } from '../../../../uri.j
|
|
|
2
2
|
import pageRoute from '../../../../routes/page-route.js'
|
|
3
3
|
import Joi from 'joi'
|
|
4
4
|
import { nextPage } from '../../../../routes/next-page.js'
|
|
5
|
+
import { addLanguageCodeToUri } from '../../../../processors/uri-helper.js'
|
|
5
6
|
|
|
6
7
|
export const getData = async request => {
|
|
7
8
|
const { addresses, searchTerms } = await request.cache().helpers.addressLookup.getCurrentPermission()
|
|
@@ -11,7 +12,7 @@ export const getData = async request => {
|
|
|
11
12
|
isLicenceForYou,
|
|
12
13
|
addresses,
|
|
13
14
|
searchTerms,
|
|
14
|
-
lookupPage: ADDRESS_LOOKUP.uri,
|
|
15
|
+
lookupPage: addLanguageCodeToUri(request, ADDRESS_LOOKUP.uri),
|
|
15
16
|
entryPage: ADDRESS_ENTRY.uri
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -20,7 +21,10 @@ export default pageRoute(
|
|
|
20
21
|
ADDRESS_SELECT.page,
|
|
21
22
|
ADDRESS_SELECT.uri,
|
|
22
23
|
Joi.object({
|
|
23
|
-
address: Joi.number()
|
|
24
|
+
address: Joi.number()
|
|
25
|
+
.integer()
|
|
26
|
+
.min(0)
|
|
27
|
+
.required()
|
|
24
28
|
}).options({ abortEarly: false, allowUnknown: true }),
|
|
25
29
|
nextPage,
|
|
26
30
|
getData
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`contact-summary > route getLicenseeDetailsSummaryRows should have the newsletter
|
|
3
|
+
exports[`contact-summary > route getLicenseeDetailsSummaryRows should have the newsletter is set have preferred method and if isLicenceForYou is true 1`] = `
|
|
4
4
|
Array [
|
|
5
5
|
Object {
|
|
6
6
|
"actions": Object {
|
|
@@ -9,7 +9,7 @@ Array [
|
|
|
9
9
|
"attributes": Object {
|
|
10
10
|
"id": "change-address",
|
|
11
11
|
},
|
|
12
|
-
"href":
|
|
12
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
13
13
|
"text": "Change",
|
|
14
14
|
"visuallyHiddenText": "address",
|
|
15
15
|
},
|
|
@@ -29,7 +29,7 @@ Array [
|
|
|
29
29
|
"attributes": Object {
|
|
30
30
|
"id": "change-contact",
|
|
31
31
|
},
|
|
32
|
-
"href":
|
|
32
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
33
33
|
"text": "Change",
|
|
34
34
|
"visuallyHiddenText": "contact",
|
|
35
35
|
},
|
|
@@ -49,7 +49,7 @@ Array [
|
|
|
49
49
|
"attributes": Object {
|
|
50
50
|
"id": "change-newsletter",
|
|
51
51
|
},
|
|
52
|
-
"href":
|
|
52
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
53
53
|
"text": "Change",
|
|
54
54
|
"visuallyHiddenText": "newsletter",
|
|
55
55
|
},
|
|
@@ -65,7 +65,7 @@ Array [
|
|
|
65
65
|
]
|
|
66
66
|
`;
|
|
67
67
|
|
|
68
|
-
exports[`contact-summary > route getLicenseeDetailsSummaryRows should
|
|
68
|
+
exports[`contact-summary > route getLicenseeDetailsSummaryRows should have the newsletter set to no if have preferred method and if isLicenceForYou is true 1`] = `
|
|
69
69
|
Array [
|
|
70
70
|
Object {
|
|
71
71
|
"actions": Object {
|
|
@@ -74,7 +74,7 @@ Array [
|
|
|
74
74
|
"attributes": Object {
|
|
75
75
|
"id": "change-address",
|
|
76
76
|
},
|
|
77
|
-
"href":
|
|
77
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
78
78
|
"text": "Change",
|
|
79
79
|
"visuallyHiddenText": "address",
|
|
80
80
|
},
|
|
@@ -94,7 +94,7 @@ Array [
|
|
|
94
94
|
"attributes": Object {
|
|
95
95
|
"id": "change-contact",
|
|
96
96
|
},
|
|
97
|
-
"href":
|
|
97
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
98
98
|
"text": "Change",
|
|
99
99
|
"visuallyHiddenText": "contact",
|
|
100
100
|
},
|
|
@@ -107,6 +107,71 @@ Array [
|
|
|
107
107
|
"text": "Make a note on confirmation",
|
|
108
108
|
},
|
|
109
109
|
},
|
|
110
|
+
Object {
|
|
111
|
+
"actions": Object {
|
|
112
|
+
"items": Array [
|
|
113
|
+
Object {
|
|
114
|
+
"attributes": Object {
|
|
115
|
+
"id": "change-newsletter",
|
|
116
|
+
},
|
|
117
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
118
|
+
"text": "Change",
|
|
119
|
+
"visuallyHiddenText": "newsletter",
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
"key": Object {
|
|
124
|
+
"text": "Newsletter",
|
|
125
|
+
},
|
|
126
|
+
"value": Object {
|
|
127
|
+
"text": "No",
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
]
|
|
131
|
+
`;
|
|
132
|
+
|
|
133
|
+
exports[`contact-summary > route getLicenseeDetailsSummaryRows should not have the newsletter row if isLicenceForYou is false 1`] = `
|
|
134
|
+
Array [
|
|
135
|
+
Object {
|
|
136
|
+
"actions": Object {
|
|
137
|
+
"items": Array [
|
|
138
|
+
Object {
|
|
139
|
+
"attributes": Object {
|
|
140
|
+
"id": "change-address",
|
|
141
|
+
},
|
|
142
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
143
|
+
"text": "Change",
|
|
144
|
+
"visuallyHiddenText": "address",
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
"key": Object {
|
|
149
|
+
"text": "Address",
|
|
150
|
+
},
|
|
151
|
+
"value": Object {
|
|
152
|
+
"text": "14 Howecroft Court, Eastmead Lane, Bristol, BS9 1HJ, GB",
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
Object {
|
|
156
|
+
"actions": Object {
|
|
157
|
+
"items": Array [
|
|
158
|
+
Object {
|
|
159
|
+
"attributes": Object {
|
|
160
|
+
"id": "change-contact",
|
|
161
|
+
},
|
|
162
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
163
|
+
"text": "Change",
|
|
164
|
+
"visuallyHiddenText": "contact",
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
"key": Object {
|
|
169
|
+
"text": "Licence details",
|
|
170
|
+
},
|
|
171
|
+
"value": Object {
|
|
172
|
+
"text": "Text messages to undefined",
|
|
173
|
+
},
|
|
174
|
+
},
|
|
110
175
|
]
|
|
111
176
|
`;
|
|
112
177
|
|
|
@@ -119,7 +184,7 @@ Array [
|
|
|
119
184
|
"attributes": Object {
|
|
120
185
|
"id": "change-address",
|
|
121
186
|
},
|
|
122
|
-
"href":
|
|
187
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
123
188
|
"text": "Change",
|
|
124
189
|
"visuallyHiddenText": "address",
|
|
125
190
|
},
|
|
@@ -139,7 +204,7 @@ Array [
|
|
|
139
204
|
"attributes": Object {
|
|
140
205
|
"id": "change-contact",
|
|
141
206
|
},
|
|
142
|
-
"href":
|
|
207
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
143
208
|
"text": "Change",
|
|
144
209
|
"visuallyHiddenText": "contact",
|
|
145
210
|
},
|
|
@@ -164,7 +229,7 @@ Array [
|
|
|
164
229
|
"attributes": Object {
|
|
165
230
|
"id": "change-address",
|
|
166
231
|
},
|
|
167
|
-
"href":
|
|
232
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
168
233
|
"text": "Change",
|
|
169
234
|
"visuallyHiddenText": "address",
|
|
170
235
|
},
|
|
@@ -184,7 +249,7 @@ Array [
|
|
|
184
249
|
"attributes": Object {
|
|
185
250
|
"id": "change-contact",
|
|
186
251
|
},
|
|
187
|
-
"href":
|
|
252
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
188
253
|
"text": "Change",
|
|
189
254
|
"visuallyHiddenText": "contact",
|
|
190
255
|
},
|
|
@@ -209,7 +274,7 @@ Array [
|
|
|
209
274
|
"attributes": Object {
|
|
210
275
|
"id": "change-address",
|
|
211
276
|
},
|
|
212
|
-
"href":
|
|
277
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
213
278
|
"text": "Change",
|
|
214
279
|
"visuallyHiddenText": "address",
|
|
215
280
|
},
|
|
@@ -229,7 +294,7 @@ Array [
|
|
|
229
294
|
"attributes": Object {
|
|
230
295
|
"id": "change-contact",
|
|
231
296
|
},
|
|
232
|
-
"href":
|
|
297
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
233
298
|
"text": "Change",
|
|
234
299
|
"visuallyHiddenText": "contact",
|
|
235
300
|
},
|
|
@@ -239,7 +304,7 @@ Array [
|
|
|
239
304
|
"text": "Licence details",
|
|
240
305
|
},
|
|
241
306
|
"value": Object {
|
|
242
|
-
"text": "
|
|
307
|
+
"text": "Make a note on confirmation",
|
|
243
308
|
},
|
|
244
309
|
},
|
|
245
310
|
]
|
|
@@ -254,7 +319,7 @@ Array [
|
|
|
254
319
|
"attributes": Object {
|
|
255
320
|
"id": "change-address",
|
|
256
321
|
},
|
|
257
|
-
"href":
|
|
322
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
258
323
|
"text": "Change",
|
|
259
324
|
"visuallyHiddenText": "address",
|
|
260
325
|
},
|
|
@@ -274,7 +339,7 @@ Array [
|
|
|
274
339
|
"attributes": Object {
|
|
275
340
|
"id": "change-licence-fulfilment-option",
|
|
276
341
|
},
|
|
277
|
-
"href":
|
|
342
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
278
343
|
"text": "Change",
|
|
279
344
|
"visuallyHiddenText": "licence fulfilment option",
|
|
280
345
|
},
|
|
@@ -294,7 +359,7 @@ Array [
|
|
|
294
359
|
"attributes": Object {
|
|
295
360
|
"id": "change-licence-confirmation-option",
|
|
296
361
|
},
|
|
297
|
-
"href":
|
|
362
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
298
363
|
"text": "Change",
|
|
299
364
|
"visuallyHiddenText": "licence confirmation option",
|
|
300
365
|
},
|
|
@@ -314,7 +379,7 @@ Array [
|
|
|
314
379
|
"attributes": Object {
|
|
315
380
|
"id": "change-contact",
|
|
316
381
|
},
|
|
317
|
-
"href":
|
|
382
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
318
383
|
"text": "Change",
|
|
319
384
|
"visuallyHiddenText": "contact",
|
|
320
385
|
},
|
|
@@ -339,7 +404,7 @@ Array [
|
|
|
339
404
|
"attributes": Object {
|
|
340
405
|
"id": "change-address",
|
|
341
406
|
},
|
|
342
|
-
"href":
|
|
407
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
343
408
|
"text": "Change",
|
|
344
409
|
"visuallyHiddenText": "address",
|
|
345
410
|
},
|
|
@@ -359,7 +424,7 @@ Array [
|
|
|
359
424
|
"attributes": Object {
|
|
360
425
|
"id": "change-licence-fulfilment-option",
|
|
361
426
|
},
|
|
362
|
-
"href":
|
|
427
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
363
428
|
"text": "Change",
|
|
364
429
|
"visuallyHiddenText": "licence fulfilment option",
|
|
365
430
|
},
|
|
@@ -379,7 +444,7 @@ Array [
|
|
|
379
444
|
"attributes": Object {
|
|
380
445
|
"id": "change-licence-confirmation-option",
|
|
381
446
|
},
|
|
382
|
-
"href":
|
|
447
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
383
448
|
"text": "Change",
|
|
384
449
|
"visuallyHiddenText": "licence confirmation option",
|
|
385
450
|
},
|
|
@@ -389,7 +454,7 @@ Array [
|
|
|
389
454
|
"text": "Licence Confirmation",
|
|
390
455
|
},
|
|
391
456
|
"value": Object {
|
|
392
|
-
"text": "
|
|
457
|
+
"text": "Note of licence",
|
|
393
458
|
},
|
|
394
459
|
},
|
|
395
460
|
Object {
|
|
@@ -399,7 +464,7 @@ Array [
|
|
|
399
464
|
"attributes": Object {
|
|
400
465
|
"id": "change-contact",
|
|
401
466
|
},
|
|
402
|
-
"href":
|
|
467
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
403
468
|
"text": "Change",
|
|
404
469
|
"visuallyHiddenText": "contact",
|
|
405
470
|
},
|
|
@@ -409,7 +474,7 @@ Array [
|
|
|
409
474
|
"text": "Contact",
|
|
410
475
|
},
|
|
411
476
|
"value": Object {
|
|
412
|
-
"text": "
|
|
477
|
+
"text": "By post",
|
|
413
478
|
},
|
|
414
479
|
},
|
|
415
480
|
]
|
|
@@ -424,7 +489,7 @@ Array [
|
|
|
424
489
|
"attributes": Object {
|
|
425
490
|
"id": "change-address",
|
|
426
491
|
},
|
|
427
|
-
"href":
|
|
492
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
428
493
|
"text": "Change",
|
|
429
494
|
"visuallyHiddenText": "address",
|
|
430
495
|
},
|
|
@@ -444,7 +509,7 @@ Array [
|
|
|
444
509
|
"attributes": Object {
|
|
445
510
|
"id": "change-licence-fulfilment-option",
|
|
446
511
|
},
|
|
447
|
-
"href":
|
|
512
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
448
513
|
"text": "Change",
|
|
449
514
|
"visuallyHiddenText": "licence fulfilment option",
|
|
450
515
|
},
|
|
@@ -464,7 +529,7 @@ Array [
|
|
|
464
529
|
"attributes": Object {
|
|
465
530
|
"id": "change-licence-confirmation-option",
|
|
466
531
|
},
|
|
467
|
-
"href":
|
|
532
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
468
533
|
"text": "Change",
|
|
469
534
|
"visuallyHiddenText": "licence confirmation option",
|
|
470
535
|
},
|
|
@@ -484,7 +549,7 @@ Array [
|
|
|
484
549
|
"attributes": Object {
|
|
485
550
|
"id": "change-contact",
|
|
486
551
|
},
|
|
487
|
-
"href":
|
|
552
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
488
553
|
"text": "Change",
|
|
489
554
|
"visuallyHiddenText": "contact",
|
|
490
555
|
},
|
|
@@ -509,7 +574,7 @@ Array [
|
|
|
509
574
|
"attributes": Object {
|
|
510
575
|
"id": "change-address",
|
|
511
576
|
},
|
|
512
|
-
"href":
|
|
577
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
513
578
|
"text": "Change",
|
|
514
579
|
"visuallyHiddenText": "address",
|
|
515
580
|
},
|
|
@@ -529,7 +594,7 @@ Array [
|
|
|
529
594
|
"attributes": Object {
|
|
530
595
|
"id": "change-licence-confirmation-option",
|
|
531
596
|
},
|
|
532
|
-
"href":
|
|
597
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
533
598
|
"text": "Change",
|
|
534
599
|
"visuallyHiddenText": "licence confirmation option",
|
|
535
600
|
},
|
|
@@ -549,7 +614,7 @@ Array [
|
|
|
549
614
|
"attributes": Object {
|
|
550
615
|
"id": "change-contact",
|
|
551
616
|
},
|
|
552
|
-
"href":
|
|
617
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
553
618
|
"text": "Change",
|
|
554
619
|
"visuallyHiddenText": "contact",
|
|
555
620
|
},
|
|
@@ -574,7 +639,7 @@ Array [
|
|
|
574
639
|
"attributes": Object {
|
|
575
640
|
"id": "change-address",
|
|
576
641
|
},
|
|
577
|
-
"href":
|
|
642
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
578
643
|
"text": "Change",
|
|
579
644
|
"visuallyHiddenText": "address",
|
|
580
645
|
},
|
|
@@ -594,7 +659,7 @@ Array [
|
|
|
594
659
|
"attributes": Object {
|
|
595
660
|
"id": "change-licence-confirmation-option",
|
|
596
661
|
},
|
|
597
|
-
"href":
|
|
662
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
598
663
|
"text": "Change",
|
|
599
664
|
"visuallyHiddenText": "licence confirmation option",
|
|
600
665
|
},
|
|
@@ -604,7 +669,7 @@ Array [
|
|
|
604
669
|
"text": "Licence",
|
|
605
670
|
},
|
|
606
671
|
"value": Object {
|
|
607
|
-
"text": "
|
|
672
|
+
"text": "Note of licence",
|
|
608
673
|
},
|
|
609
674
|
},
|
|
610
675
|
Object {
|
|
@@ -614,7 +679,7 @@ Array [
|
|
|
614
679
|
"attributes": Object {
|
|
615
680
|
"id": "change-contact",
|
|
616
681
|
},
|
|
617
|
-
"href":
|
|
682
|
+
"href": Symbol(addLanguageCodeToUri),
|
|
618
683
|
"text": "Change",
|
|
619
684
|
"visuallyHiddenText": "contact",
|
|
620
685
|
},
|
|
@@ -624,7 +689,7 @@ Array [
|
|
|
624
689
|
"text": "Contact",
|
|
625
690
|
},
|
|
626
691
|
"value": Object {
|
|
627
|
-
"text": "
|
|
692
|
+
"text": "By post",
|
|
628
693
|
},
|
|
629
694
|
},
|
|
630
695
|
]
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { getLicenseeDetailsSummaryRows, checkNavigation } from '../route'
|
|
2
2
|
import GetDataRedirect from '../../../../handlers/get-data-redirect.js'
|
|
3
|
-
import { LICENCE_FULFILMENT, LICENCE_CONFIRMATION_METHOD } from '../../../../uri.js'
|
|
3
|
+
import { ADDRESS_LOOKUP, CONTACT, LICENCE_FULFILMENT, LICENCE_CONFIRMATION_METHOD, NEWSLETTER } from '../../../../uri.js'
|
|
4
|
+
import { HOW_CONTACTED } from '../../../../processors/mapping-constants.js'
|
|
5
|
+
import { addLanguageCodeToUri } from '../../../../processors/uri-helper.js'
|
|
6
|
+
|
|
7
|
+
jest.mock('../../../../processors/uri-helper.js', () => ({
|
|
8
|
+
addLanguageCodeToUri: jest.fn(() => Symbol('addLanguageCodeToUri'))
|
|
9
|
+
}))
|
|
10
|
+
|
|
11
|
+
jest.mock('../../../../processors/mapping-constants', () => ({
|
|
12
|
+
HOW_CONTACTED: {
|
|
13
|
+
email: 'Email',
|
|
14
|
+
none: 'Prefer not to be contacted'
|
|
15
|
+
}
|
|
16
|
+
}))
|
|
4
17
|
|
|
5
18
|
const address = {
|
|
6
19
|
firstName: 'Fester',
|
|
@@ -11,6 +24,13 @@ const address = {
|
|
|
11
24
|
postcode: 'BS9 1HJ'
|
|
12
25
|
}
|
|
13
26
|
|
|
27
|
+
const generateRequestMock = query => ({
|
|
28
|
+
query,
|
|
29
|
+
url: {
|
|
30
|
+
search: ''
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
14
34
|
describe('contact-summary > route', () => {
|
|
15
35
|
describe('getLicenseeDetailsSummaryRows', () => {
|
|
16
36
|
describe('when purchasing a 12 month (physical licence) with postal fulfilment', () => {
|
|
@@ -26,7 +46,7 @@ describe('contact-summary > route', () => {
|
|
|
26
46
|
preferredMethodOfNewsletter: 'Prefer not to be contacted'
|
|
27
47
|
}
|
|
28
48
|
}
|
|
29
|
-
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB')
|
|
49
|
+
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB', generateRequestMock())
|
|
30
50
|
expect(summaryTable).toMatchSnapshot()
|
|
31
51
|
})
|
|
32
52
|
|
|
@@ -42,7 +62,7 @@ describe('contact-summary > route', () => {
|
|
|
42
62
|
preferredMethodOfNewsletter: 'Yes'
|
|
43
63
|
}
|
|
44
64
|
}
|
|
45
|
-
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB')
|
|
65
|
+
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB', generateRequestMock())
|
|
46
66
|
expect(summaryTable).toMatchSnapshot()
|
|
47
67
|
})
|
|
48
68
|
|
|
@@ -56,7 +76,7 @@ describe('contact-summary > route', () => {
|
|
|
56
76
|
preferredMethodOfReminder: 'Letter'
|
|
57
77
|
}
|
|
58
78
|
}
|
|
59
|
-
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB')
|
|
79
|
+
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB', generateRequestMock())
|
|
60
80
|
expect(summaryTable).toMatchSnapshot()
|
|
61
81
|
})
|
|
62
82
|
})
|
|
@@ -74,7 +94,7 @@ describe('contact-summary > route', () => {
|
|
|
74
94
|
preferredMethodOfNewsletter: 'Prefer not to be contacted'
|
|
75
95
|
}
|
|
76
96
|
}
|
|
77
|
-
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB')
|
|
97
|
+
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB', generateRequestMock())
|
|
78
98
|
expect(summaryTable).toMatchSnapshot()
|
|
79
99
|
})
|
|
80
100
|
|
|
@@ -87,10 +107,10 @@ describe('contact-summary > route', () => {
|
|
|
87
107
|
preferredMethodOfConfirmation: 'Text',
|
|
88
108
|
preferredMethodOfReminder: 'Text',
|
|
89
109
|
mobilePhone: '07700900900',
|
|
90
|
-
preferredMethodOfNewsletter: '
|
|
110
|
+
preferredMethodOfNewsletter: 'Text'
|
|
91
111
|
}
|
|
92
112
|
}
|
|
93
|
-
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB')
|
|
113
|
+
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB', generateRequestMock())
|
|
94
114
|
expect(summaryTable).toMatchSnapshot()
|
|
95
115
|
})
|
|
96
116
|
})
|
|
@@ -107,7 +127,7 @@ describe('contact-summary > route', () => {
|
|
|
107
127
|
preferredMethodOfNewsletter: 'Prefer not to be contacted'
|
|
108
128
|
}
|
|
109
129
|
}
|
|
110
|
-
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB')
|
|
130
|
+
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB', generateRequestMock())
|
|
111
131
|
expect(summaryTable).toMatchSnapshot()
|
|
112
132
|
})
|
|
113
133
|
|
|
@@ -123,7 +143,7 @@ describe('contact-summary > route', () => {
|
|
|
123
143
|
preferredMethodOfNewsletter: 'Yes'
|
|
124
144
|
}
|
|
125
145
|
}
|
|
126
|
-
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB')
|
|
146
|
+
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB', generateRequestMock())
|
|
127
147
|
expect(summaryTable).toMatchSnapshot()
|
|
128
148
|
})
|
|
129
149
|
|
|
@@ -138,20 +158,46 @@ describe('contact-summary > route', () => {
|
|
|
138
158
|
preferredMethodOfNewsletter: 'Yes'
|
|
139
159
|
}
|
|
140
160
|
}
|
|
141
|
-
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB')
|
|
161
|
+
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB', generateRequestMock())
|
|
142
162
|
expect(summaryTable).toMatchSnapshot()
|
|
143
163
|
})
|
|
144
164
|
})
|
|
145
165
|
|
|
146
|
-
it('should have the newsletter
|
|
166
|
+
it('should have the newsletter is set have preferred method and if isLicenceForYou is true', () => {
|
|
147
167
|
const permission = {
|
|
148
168
|
licenceLength: '1D',
|
|
149
169
|
licensee: {
|
|
150
|
-
...address
|
|
170
|
+
...address,
|
|
171
|
+
postalFulfilment: false,
|
|
172
|
+
preferredMethodOfConfirmation: 'Prefer not to be contacted',
|
|
173
|
+
preferredMethodOfReminder: 'Prefer not to be contacted',
|
|
174
|
+
preferredMethodOfNewsletter: 'Email'
|
|
151
175
|
},
|
|
152
176
|
isLicenceForYou: true
|
|
153
177
|
}
|
|
154
|
-
const
|
|
178
|
+
const query = {
|
|
179
|
+
[HOW_CONTACTED.email]: 'Email'
|
|
180
|
+
}
|
|
181
|
+
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB', generateRequestMock(query))
|
|
182
|
+
expect(summaryTable).toMatchSnapshot()
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
it('should have the newsletter set to no if have preferred method and if isLicenceForYou is true', () => {
|
|
186
|
+
const permission = {
|
|
187
|
+
licenceLength: '1D',
|
|
188
|
+
licensee: {
|
|
189
|
+
...address,
|
|
190
|
+
postalFulfilment: false,
|
|
191
|
+
preferredMethodOfConfirmation: 'Prefer not to be contacted',
|
|
192
|
+
preferredMethodOfReminder: 'Prefer not to be contacted',
|
|
193
|
+
preferredMethodOfNewsletter: 'Prefer not to be contacted'
|
|
194
|
+
},
|
|
195
|
+
isLicenceForYou: true
|
|
196
|
+
}
|
|
197
|
+
const query = {
|
|
198
|
+
[HOW_CONTACTED.email]: 'Prefer not to be contacted'
|
|
199
|
+
}
|
|
200
|
+
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB', generateRequestMock(query))
|
|
155
201
|
expect(summaryTable).toMatchSnapshot()
|
|
156
202
|
})
|
|
157
203
|
|
|
@@ -163,9 +209,36 @@ describe('contact-summary > route', () => {
|
|
|
163
209
|
},
|
|
164
210
|
isLicenceForYou: false
|
|
165
211
|
}
|
|
166
|
-
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB')
|
|
212
|
+
const summaryTable = getLicenseeDetailsSummaryRows(permission, 'GB', generateRequestMock())
|
|
167
213
|
expect(summaryTable).toMatchSnapshot()
|
|
168
214
|
})
|
|
215
|
+
|
|
216
|
+
describe('addLanguageCodeToUri', () => {
|
|
217
|
+
beforeEach(jest.clearAllMocks)
|
|
218
|
+
|
|
219
|
+
it.each([[ADDRESS_LOOKUP.uri], [LICENCE_FULFILMENT.uri], [LICENCE_CONFIRMATION_METHOD.uri], [CONTACT.uri], [NEWSLETTER.uri]])(
|
|
220
|
+
'test addLanguageCodeToUri is called correctly',
|
|
221
|
+
async urlToCheck => {
|
|
222
|
+
const permission = {
|
|
223
|
+
permit: {
|
|
224
|
+
cost: 1
|
|
225
|
+
},
|
|
226
|
+
licenceLength: '12M',
|
|
227
|
+
isLicenceForYou: true,
|
|
228
|
+
licensee: {
|
|
229
|
+
birthDate: '1996-01-01',
|
|
230
|
+
postalFulfilment: true
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const mockRequest = generateRequestMock
|
|
235
|
+
|
|
236
|
+
getLicenseeDetailsSummaryRows(permission, 'GB', mockRequest)
|
|
237
|
+
|
|
238
|
+
expect(addLanguageCodeToUri).toHaveBeenCalledWith(mockRequest, urlToCheck)
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
})
|
|
169
242
|
})
|
|
170
243
|
|
|
171
244
|
describe('checkNavigation', () => {
|
|
@@ -5,6 +5,7 @@ import { HOW_CONTACTED } from '../../../processors/mapping-constants.js'
|
|
|
5
5
|
import { CONTACT_SUMMARY_SEEN } from '../../../constants.js'
|
|
6
6
|
import { isPhysical } from '../../../processors/licence-type-display.js'
|
|
7
7
|
import { nextPage } from '../../../routes/next-page.js'
|
|
8
|
+
import { addLanguageCodeToUri } from '../../../processors/uri-helper.js'
|
|
8
9
|
|
|
9
10
|
import {
|
|
10
11
|
CONTACT_SUMMARY,
|
|
@@ -50,7 +51,7 @@ const getData = async request => {
|
|
|
50
51
|
const countryName = await countries.nameFromCode(permission.licensee.countryCode)
|
|
51
52
|
|
|
52
53
|
return {
|
|
53
|
-
summaryTable: getLicenseeDetailsSummaryRows(permission, countryName),
|
|
54
|
+
summaryTable: getLicenseeDetailsSummaryRows(permission, countryName, request),
|
|
54
55
|
uri: {
|
|
55
56
|
licenceSummary: LICENCE_SUMMARY.uri
|
|
56
57
|
}
|
|
@@ -59,10 +60,16 @@ const getData = async request => {
|
|
|
59
60
|
|
|
60
61
|
export default pageRoute(CONTACT_SUMMARY.page, CONTACT_SUMMARY.uri, null, nextPage, getData)
|
|
61
62
|
|
|
62
|
-
export const getLicenseeDetailsSummaryRows = (permission, countryName) => {
|
|
63
|
+
export const getLicenseeDetailsSummaryRows = (permission, countryName, request) => {
|
|
63
64
|
const licenseeSummaryArray = [
|
|
64
|
-
getRow(
|
|
65
|
-
|
|
65
|
+
getRow(
|
|
66
|
+
'Address',
|
|
67
|
+
getAddressText(permission.licensee, countryName),
|
|
68
|
+
addLanguageCodeToUri(request, ADDRESS_LOOKUP.uri),
|
|
69
|
+
'address',
|
|
70
|
+
'change-address'
|
|
71
|
+
),
|
|
72
|
+
...getContactDetails(permission, request)
|
|
66
73
|
]
|
|
67
74
|
|
|
68
75
|
if (permission.isLicenceForYou) {
|
|
@@ -70,7 +77,7 @@ export const getLicenseeDetailsSummaryRows = (permission, countryName) => {
|
|
|
70
77
|
getRow(
|
|
71
78
|
'Newsletter',
|
|
72
79
|
permission.licensee.preferredMethodOfNewsletter !== HOW_CONTACTED.none ? 'Yes' : 'No',
|
|
73
|
-
NEWSLETTER.uri,
|
|
80
|
+
addLanguageCodeToUri(request, NEWSLETTER.uri),
|
|
74
81
|
'newsletter',
|
|
75
82
|
'change-newsletter'
|
|
76
83
|
)
|
|
@@ -100,22 +107,28 @@ const CONTACT_TEXT_PHYSICAL = {
|
|
|
100
107
|
|
|
101
108
|
const CHANGE_CONTACT = 'change-contact'
|
|
102
109
|
|
|
103
|
-
const getContactDetails = permission => {
|
|
110
|
+
const getContactDetails = (permission, request) => {
|
|
104
111
|
if (isPhysical(permission)) {
|
|
105
112
|
if (permission.licensee.postalFulfilment) {
|
|
106
113
|
return [
|
|
107
|
-
getRow(
|
|
114
|
+
getRow(
|
|
115
|
+
'Licence',
|
|
116
|
+
'By post',
|
|
117
|
+
addLanguageCodeToUri(request, LICENCE_FULFILMENT.uri),
|
|
118
|
+
'licence fulfilment option',
|
|
119
|
+
'change-licence-fulfilment-option'
|
|
120
|
+
),
|
|
108
121
|
getRow(
|
|
109
122
|
'Licence Confirmation',
|
|
110
123
|
getContactText(permission.licensee.preferredMethodOfConfirmation, permission.licensee),
|
|
111
|
-
LICENCE_CONFIRMATION_METHOD.uri,
|
|
124
|
+
addLanguageCodeToUri(request, LICENCE_CONFIRMATION_METHOD.uri),
|
|
112
125
|
'licence confirmation option',
|
|
113
126
|
'change-licence-confirmation-option'
|
|
114
127
|
),
|
|
115
128
|
getRow(
|
|
116
129
|
'Contact',
|
|
117
130
|
getContactText(permission.licensee.preferredMethodOfReminder, permission.licensee, CONTACT_TEXT_PHYSICAL),
|
|
118
|
-
CONTACT.uri,
|
|
131
|
+
addLanguageCodeToUri(request, CONTACT.uri),
|
|
119
132
|
'contact',
|
|
120
133
|
CHANGE_CONTACT
|
|
121
134
|
)
|
|
@@ -125,14 +138,14 @@ const getContactDetails = permission => {
|
|
|
125
138
|
getRow(
|
|
126
139
|
'Licence',
|
|
127
140
|
getContactText(permission.licensee.preferredMethodOfConfirmation, permission.licensee),
|
|
128
|
-
LICENCE_FULFILMENT.uri,
|
|
141
|
+
addLanguageCodeToUri(request, LICENCE_FULFILMENT.uri),
|
|
129
142
|
'licence confirmation option',
|
|
130
143
|
'change-licence-confirmation-option'
|
|
131
144
|
),
|
|
132
145
|
getRow(
|
|
133
146
|
'Contact',
|
|
134
147
|
getContactText(permission.licensee.preferredMethodOfReminder, permission.licensee, CONTACT_TEXT_PHYSICAL),
|
|
135
|
-
CONTACT.uri,
|
|
148
|
+
addLanguageCodeToUri(request, CONTACT.uri),
|
|
136
149
|
'contact',
|
|
137
150
|
CHANGE_CONTACT
|
|
138
151
|
)
|
|
@@ -143,7 +156,7 @@ const getContactDetails = permission => {
|
|
|
143
156
|
getRow(
|
|
144
157
|
'Licence details',
|
|
145
158
|
getContactText(permission.licensee.preferredMethodOfReminder, permission.licensee, CONTACT_TEXT_NON_PHYSICAL),
|
|
146
|
-
CONTACT.uri,
|
|
159
|
+
addLanguageCodeToUri(request, CONTACT.uri),
|
|
147
160
|
'contact',
|
|
148
161
|
CHANGE_CONTACT
|
|
149
162
|
)
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { getFromSummary, getData } from '../route'
|
|
2
2
|
import { LICENCE_SUMMARY_SEEN, CONTACT_SUMMARY_SEEN } from '../../../../constants.js'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
DATE_OF_BIRTH,
|
|
5
|
+
DISABILITY_CONCESSION,
|
|
6
|
+
LICENCE_LENGTH,
|
|
7
|
+
LICENCE_TO_START,
|
|
8
|
+
LICENCE_TYPE,
|
|
9
|
+
NAME,
|
|
10
|
+
NEW_TRANSACTION,
|
|
11
|
+
RENEWAL_START_DATE
|
|
12
|
+
} from '../../../../uri.js'
|
|
4
13
|
import GetDataRedirect from '../../../../handlers/get-data-redirect.js'
|
|
5
14
|
import '../../find-permit.js'
|
|
6
15
|
import { licenceTypeDisplay } from '../../../../processors/licence-type-display.js'
|
|
16
|
+
import { addLanguageCodeToUri } from '../../../../processors/uri-helper.js'
|
|
7
17
|
|
|
8
18
|
jest.mock('../../find-permit.js')
|
|
9
19
|
jest.mock('../../../../processors/licence-type-display.js')
|
|
20
|
+
jest.mock('../../../../processors/uri-helper.js')
|
|
10
21
|
|
|
11
22
|
describe('licence-summary > route', () => {
|
|
12
23
|
beforeEach(jest.clearAllMocks)
|
|
@@ -64,26 +75,39 @@ describe('licence-summary > route', () => {
|
|
|
64
75
|
getCatalog: () => ({
|
|
65
76
|
licence_type_radio_salmon: 'Salmon and sea trout'
|
|
66
77
|
})
|
|
67
|
-
}
|
|
78
|
+
},
|
|
79
|
+
url: {
|
|
80
|
+
search: ''
|
|
81
|
+
},
|
|
82
|
+
path: ''
|
|
68
83
|
}
|
|
69
84
|
|
|
70
|
-
it(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
it.each([
|
|
86
|
+
[NAME.uri],
|
|
87
|
+
[LICENCE_LENGTH.uri],
|
|
88
|
+
[LICENCE_TYPE.uri],
|
|
89
|
+
[LICENCE_TO_START.uri],
|
|
90
|
+
[DATE_OF_BIRTH.uri],
|
|
91
|
+
[DISABILITY_CONCESSION.uri],
|
|
92
|
+
[RENEWAL_START_DATE.uri],
|
|
93
|
+
[LICENCE_TO_START.uri],
|
|
94
|
+
[NEW_TRANSACTION.uri]
|
|
95
|
+
])('addLanguageCodeToUri is called with the expected arguments', async uri => {
|
|
96
|
+
const permission = {
|
|
97
|
+
permit: {
|
|
98
|
+
cost: 1
|
|
99
|
+
},
|
|
76
100
|
licensee: {
|
|
77
|
-
|
|
78
|
-
lastName: 'Willis',
|
|
79
|
-
birthDate: '1946-01-01'
|
|
101
|
+
birthDate: '1996-01-01'
|
|
80
102
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
103
|
+
isRenewal: true
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
mockTransactionCacheGet.mockImplementationOnce(() => permission)
|
|
107
|
+
|
|
108
|
+
await getData(mockRequest)
|
|
109
|
+
|
|
110
|
+
expect(addLanguageCodeToUri).toHaveBeenCalledWith(mockRequest, uri)
|
|
87
111
|
})
|
|
88
112
|
|
|
89
113
|
it('should return a redirect error if firstName is not included on the licensee', async () => {
|
|
@@ -20,6 +20,7 @@ import { START_AFTER_PAYMENT_MINUTES, SERVICE_LOCAL_TIME } from '@defra-fish/bus
|
|
|
20
20
|
import { LICENCE_SUMMARY_SEEN } from '../../../constants.js'
|
|
21
21
|
import { CONCESSION, CONCESSION_PROOF } from '../../../processors/mapping-constants.js'
|
|
22
22
|
import { nextPage } from '../../../routes/next-page.js'
|
|
23
|
+
import { addLanguageCodeToUri } from '../../../processors/uri-helper.js'
|
|
23
24
|
|
|
24
25
|
// Extracted to keep sonar happy
|
|
25
26
|
const checkNavigation = permission => {
|
|
@@ -77,14 +78,16 @@ export const getData = async request => {
|
|
|
77
78
|
cost: permission.permit.cost,
|
|
78
79
|
birthDateStr: moment(permission.licensee.birthDate, cacheDateFormat).format('Do MMMM YYYY'),
|
|
79
80
|
uri: {
|
|
80
|
-
name: NAME.uri,
|
|
81
|
-
licenceLength: LICENCE_LENGTH.uri,
|
|
82
|
-
licenceType: LICENCE_TYPE.uri,
|
|
83
|
-
licenceToStart: LICENCE_TO_START.uri,
|
|
84
|
-
dateOfBirth: DATE_OF_BIRTH.uri,
|
|
85
|
-
disabilityConcession: DISABILITY_CONCESSION.uri,
|
|
86
|
-
licenceStartDate: permission.isRenewal
|
|
87
|
-
|
|
81
|
+
name: addLanguageCodeToUri(request, NAME.uri),
|
|
82
|
+
licenceLength: addLanguageCodeToUri(request, LICENCE_LENGTH.uri),
|
|
83
|
+
licenceType: addLanguageCodeToUri(request, LICENCE_TYPE.uri),
|
|
84
|
+
licenceToStart: addLanguageCodeToUri(request, LICENCE_TO_START.uri),
|
|
85
|
+
dateOfBirth: addLanguageCodeToUri(request, DATE_OF_BIRTH.uri),
|
|
86
|
+
disabilityConcession: addLanguageCodeToUri(request, DISABILITY_CONCESSION.uri),
|
|
87
|
+
licenceStartDate: permission.isRenewal
|
|
88
|
+
? addLanguageCodeToUri(request, RENEWAL_START_DATE.uri)
|
|
89
|
+
: addLanguageCodeToUri(request, LICENCE_TO_START.uri),
|
|
90
|
+
clear: addLanguageCodeToUri(request, NEW_TRANSACTION.uri)
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
93
|
}
|
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
import { start, stop, injectWithCookies, initialize } from '../../__mocks__/test-utils-system.js'
|
|
2
|
-
import { REFUND_POLICY, ACCESSIBILITY_STATEMENT, COOKIES, PRIVACY_POLICY, RENEWAL_PUBLIC, IDENTIFY } from '../../uri.js'
|
|
2
|
+
import { REFUND_POLICY, ACCESSIBILITY_STATEMENT, COOKIES, PRIVACY_POLICY, RENEWAL_PUBLIC, IDENTIFY, CONTROLLER } from '../../uri.js'
|
|
3
|
+
import { addLanguageCodeToUri } from '../../processors/uri-helper.js'
|
|
4
|
+
|
|
5
|
+
jest.mock('../../processors/uri-helper.js')
|
|
6
|
+
|
|
7
|
+
const mockTransactionCacheGet = jest.fn(() => ({
|
|
8
|
+
licenceStartDate: '2021-07-01',
|
|
9
|
+
numberOfRods: '3',
|
|
10
|
+
licenceType: 'Salmon and sea trout',
|
|
11
|
+
licenceLength: '12M',
|
|
12
|
+
licensee: {
|
|
13
|
+
firstName: 'Graham',
|
|
14
|
+
lastName: 'Willis',
|
|
15
|
+
birthDate: '1946-01-01'
|
|
16
|
+
},
|
|
17
|
+
permit: {
|
|
18
|
+
cost: 6
|
|
19
|
+
}
|
|
20
|
+
}))
|
|
21
|
+
|
|
22
|
+
const mockRequest = {
|
|
23
|
+
cache: () => ({
|
|
24
|
+
helpers: {
|
|
25
|
+
transaction: {
|
|
26
|
+
getCurrentPermission: mockTransactionCacheGet
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}
|
|
3
31
|
|
|
4
32
|
// Start application before running the test case
|
|
5
33
|
beforeAll(() => new Promise(resolve => start(resolve)))
|
|
@@ -12,7 +40,7 @@ describe('The miscellaneous route handlers', () => {
|
|
|
12
40
|
it('redirect to the main controller when / is requested', async () => {
|
|
13
41
|
const data = await injectWithCookies('GET', '/')
|
|
14
42
|
expect(data.statusCode).toBe(302)
|
|
15
|
-
expect(data.headers.location).toBe(
|
|
43
|
+
expect(data.headers.location).toBe(addLanguageCodeToUri(mockRequest, CONTROLLER.uri))
|
|
16
44
|
})
|
|
17
45
|
|
|
18
46
|
it('return the refund policy page when requested', async () => {
|
|
@@ -48,7 +48,7 @@ export default [
|
|
|
48
48
|
{
|
|
49
49
|
method: 'GET',
|
|
50
50
|
path: '/',
|
|
51
|
-
handler: async (request, h) => h.redirect(CONTROLLER.uri)
|
|
51
|
+
handler: async (request, h) => h.redirect(addLanguageCodeToUri(request, CONTROLLER.uri))
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
method: 'GET',
|
|
@@ -92,7 +92,7 @@ export default [
|
|
|
92
92
|
path: ADD_PERMISSION.uri,
|
|
93
93
|
handler: async (request, h) => {
|
|
94
94
|
await addPermission(request)
|
|
95
|
-
return h.redirect(CONTROLLER.uri)
|
|
95
|
+
return h.redirect(addLanguageCodeToUri(request, CONTROLLER.uri))
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
{
|