@defra-fish/gafl-webapp-service 1.19.0 → 1.20.0-rc.3
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/pages/concessions/date-of-birth/__tests__/update-transaction.spec.js +13 -11
- package/src/pages/concessions/date-of-birth/update-transaction.js +5 -3
- package/src/pages/contact/contact/result-function.js +2 -1
- package/src/pages/renewals/identify/__tests__/identity.spec.js +5 -2
- package/src/pages/renewals/identify/route.js +4 -2
- package/src/pages/summary/licence-summary/__tests__/result-function.spec.js +12 -0
- package/src/pages/summary/licence-summary/result-function.js +6 -2
- package/src/pages/summary/licence-summary/route.js +0 -1
- package/src/pages/terms-and-conditions/route.js +0 -1
- package/src/processors/__tests__/payment.spec.js +2 -2
- package/src/processors/__tests__/renewals-write-cache.spec.js +141 -6
- package/src/processors/renewals-write-cache.js +4 -9
- package/src/routes/__tests__/back-links.spec.js +4 -0
- package/src/routes/journey-definition.js +9 -1
- package/src/session-cache/__tests__/session-manager.spec.js +5 -8
- package/src/session-cache/session-manager.js +2 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra-fish/gafl-webapp-service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0-rc.3",
|
|
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.20.0-rc.3",
|
|
40
|
+
"@defra-fish/connectors-lib": "1.20.0-rc.3",
|
|
41
41
|
"@defra/hapi-gapi": "^1.1.0",
|
|
42
42
|
"@hapi/boom": "^9.1.2",
|
|
43
43
|
"@hapi/catbox-redis": "^6.0.2",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"gulp-sourcemaps": "^3.0.0",
|
|
76
76
|
"node-sass": "^6.0.0"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "23fb6c7823dfc065b8e305230e32ae8b095c1fd5"
|
|
79
79
|
}
|
|
@@ -17,11 +17,11 @@ const VALID_PAYLOAD = {
|
|
|
17
17
|
'date-of-birth-day': '1'
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const transactionHelperMock =
|
|
20
|
+
const transactionHelperMock = {
|
|
21
21
|
get: jest.fn(),
|
|
22
22
|
getCurrentPermission: jest.fn(() => ({ licensee: {} })),
|
|
23
23
|
setCurrentPermission: jest.fn()
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
25
|
|
|
26
26
|
describe('updateTransaction', () => {
|
|
27
27
|
beforeEach(jest.clearAllMocks)
|
|
@@ -64,24 +64,26 @@ describe('updateTransaction', () => {
|
|
|
64
64
|
})
|
|
65
65
|
|
|
66
66
|
it('logs an error if page cache does not match payload', async () => {
|
|
67
|
-
expect(consoleErrorSpy).toBeCalledWith(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
67
|
+
expect(consoleErrorSpy).toBeCalledWith('DOB page cache payload does not match current permission payload', {
|
|
68
|
+
dobPageCache: { payload: VALID_PAYLOAD },
|
|
69
|
+
payload: { test: 'payload' }
|
|
70
|
+
})
|
|
71
71
|
})
|
|
72
72
|
})
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
const createRequestMock =
|
|
75
|
+
const createRequestMock = payload => ({
|
|
76
76
|
cache: jest.fn(() => ({
|
|
77
77
|
helpers: {
|
|
78
78
|
page: {
|
|
79
79
|
get: jest.fn(() => ({
|
|
80
|
-
permissions: [
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
permissions: [
|
|
81
|
+
{
|
|
82
|
+
[DATE_OF_BIRTH.page]: {
|
|
83
|
+
payload: VALID_PAYLOAD
|
|
84
|
+
}
|
|
83
85
|
}
|
|
84
|
-
|
|
86
|
+
]
|
|
85
87
|
})),
|
|
86
88
|
getCurrentPermission: jest.fn(() => ({ payload: payload || { test: 'payload' } }))
|
|
87
89
|
},
|
|
@@ -4,8 +4,7 @@ import { ageConcessionHelper } from '../../../processors/concession-helper.js'
|
|
|
4
4
|
import { cacheDateFormat } from '../../../processors/date-and-time-display.js'
|
|
5
5
|
import { onLengthChange } from '../../licence-details/licence-length/update-transaction.js'
|
|
6
6
|
|
|
7
|
-
const pageCacheMatchesPayload = (pageCache, payload) =>
|
|
8
|
-
JSON.stringify(pageCache[DATE_OF_BIRTH.page].payload) === JSON.stringify(payload)
|
|
7
|
+
const pageCacheMatchesPayload = (pageCache, payload) => JSON.stringify(pageCache[DATE_OF_BIRTH.page].payload) === JSON.stringify(payload)
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Transfer the validated page object
|
|
@@ -25,7 +24,10 @@ export default async request => {
|
|
|
25
24
|
const dobPageCache = pageCache.permissions.find(perm => !!perm[DATE_OF_BIRTH.page])
|
|
26
25
|
|
|
27
26
|
if (!pageCacheMatchesPayload(dobPageCache, payload)) {
|
|
28
|
-
console.error('DOB page cache payload does not match current permission payload', {
|
|
27
|
+
console.error('DOB page cache payload does not match current permission payload', {
|
|
28
|
+
dobPageCache: dobPageCache[DATE_OF_BIRTH.page],
|
|
29
|
+
payload
|
|
30
|
+
})
|
|
29
31
|
console.log('page cache', JSON.stringify(await request.cache().helpers.page.get()))
|
|
30
32
|
console.log('transaction cache', JSON.stringify(await request.cache().helpers.transaction.get()))
|
|
31
33
|
console.log('status cache', JSON.stringify(await request.cache().helpers.status.get()))
|
|
@@ -2,5 +2,6 @@ import { CONTACT_SUMMARY_SEEN, CommonResults } from '../../../constants.js'
|
|
|
2
2
|
|
|
3
3
|
export default async request => {
|
|
4
4
|
const status = await request.cache().helpers.status.getCurrentPermission()
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
return status.fromSummary === CONTACT_SUMMARY_SEEN || status.renewal ? CommonResults.SUMMARY : CommonResults.OK
|
|
6
7
|
}
|
|
@@ -43,12 +43,15 @@ mockSalesApi()
|
|
|
43
43
|
salesApi.countries.getAll = jest.fn(() => Promise.resolve(mockDefraCountries))
|
|
44
44
|
|
|
45
45
|
describe('The easy renewal identification page', () => {
|
|
46
|
-
it('
|
|
46
|
+
it('redirects to identify page when called with an invalid permission reference', async () => {
|
|
47
47
|
const data = await injectWithCookies('GET', RENEWAL_PUBLIC.uri.replace('{referenceNumber}', 'not-a-valid-reference-number'))
|
|
48
48
|
expect(data.statusCode).toBe(302)
|
|
49
49
|
expect(data.headers.location).toBe(IDENTIFY.uri)
|
|
50
50
|
const data2 = await injectWithCookies('GET', IDENTIFY.uri)
|
|
51
|
-
expect(data2.statusCode).toBe(
|
|
51
|
+
expect(data2.statusCode).toBe(302)
|
|
52
|
+
expect(data2.headers.location).toBe(IDENTIFY.uri)
|
|
53
|
+
const data3 = await injectWithCookies('GET', IDENTIFY.uri)
|
|
54
|
+
expect(data3.statusCode).toBe(200)
|
|
52
55
|
})
|
|
53
56
|
|
|
54
57
|
it('returns successfully when called with a valid reference ', async () => {
|
|
@@ -2,7 +2,8 @@ import { IDENTIFY, AUTHENTICATE } from '../../../uri.js'
|
|
|
2
2
|
import pageRoute from '../../../routes/page-route.js'
|
|
3
3
|
import Joi from 'joi'
|
|
4
4
|
import { validation } from '@defra-fish/business-rules-lib'
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
import GetDataRedirect from '../../../handlers/get-data-redirect.js'
|
|
6
7
|
|
|
7
8
|
const getData = async request => {
|
|
8
9
|
// If we are supplied a permission number, validate it or throw 400
|
|
@@ -13,7 +14,8 @@ const getData = async request => {
|
|
|
13
14
|
.permissionNumberUniqueComponentValidator(Joi)
|
|
14
15
|
.validate(permission.referenceNumber)
|
|
15
16
|
if (validatePermissionNumber.error) {
|
|
16
|
-
|
|
17
|
+
await request.cache().helpers.status.setCurrentPermission({ referenceNumber: null })
|
|
18
|
+
throw new GetDataRedirect(IDENTIFY.uri)
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -33,6 +33,18 @@ describe('licence-summary > result-function', () => {
|
|
|
33
33
|
expect(result).toBe(showDigitalLicencePages.YES)
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
+
it('should return the summary screen, if licence is in renewal, is 12 months and postal fulfilment is false', async () => {
|
|
37
|
+
mockStatusCacheGet.mockImplementationOnce(() => ({ renewal: true }))
|
|
38
|
+
mockTransactionPageGet.mockImplementationOnce(() => ({
|
|
39
|
+
licenceLength: '12M',
|
|
40
|
+
licensee: {
|
|
41
|
+
postalFulfilment: false
|
|
42
|
+
}
|
|
43
|
+
}))
|
|
44
|
+
const result = await resultFunction(mockRequest)
|
|
45
|
+
expect(result).toBe(CommonResults.SUMMARY)
|
|
46
|
+
})
|
|
47
|
+
|
|
36
48
|
it('should return ok, if licence is 12 months and postal fulfilment is true', async () => {
|
|
37
49
|
mockStatusCacheGet.mockImplementationOnce(() => ({}))
|
|
38
50
|
mockTransactionPageGet.mockImplementationOnce(() => ({
|
|
@@ -5,8 +5,12 @@ export default async request => {
|
|
|
5
5
|
const status = await request.cache().helpers.status.getCurrentPermission()
|
|
6
6
|
const permission = await request.cache().helpers.transaction.getCurrentPermission()
|
|
7
7
|
|
|
8
|
-
if (status.renewal
|
|
9
|
-
|
|
8
|
+
if (status.renewal) {
|
|
9
|
+
if (isPhysical(permission) && permission.licensee.postalFulfilment !== false) {
|
|
10
|
+
return showDigitalLicencePages.YES
|
|
11
|
+
} else {
|
|
12
|
+
return CommonResults.SUMMARY
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
return status.fromSummary === CONTACT_SUMMARY_SEEN ? CommonResults.SUMMARY : CommonResults.OK
|
|
@@ -5,7 +5,6 @@ import findPermit from '../find-permit.js'
|
|
|
5
5
|
import { displayStartTime, cacheDateFormat } from '../../../processors/date-and-time-display.js'
|
|
6
6
|
import * as concessionHelper from '../../../processors/concession-helper.js'
|
|
7
7
|
import { licenceTypeDisplay } from '../../../processors/licence-type-display.js'
|
|
8
|
-
import { getTrackingProductDetailsFromTransaction } from '../../../processors/analytics.js'
|
|
9
8
|
import {
|
|
10
9
|
LICENCE_SUMMARY,
|
|
11
10
|
LICENCE_LENGTH,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import pageRoute from '../../routes/page-route.js'
|
|
2
2
|
import * as mappings from '../../processors/mapping-constants.js'
|
|
3
|
-
import { getTrackingProductDetailsFromTransaction } from '../../processors/analytics.js'
|
|
4
3
|
import Joi from 'joi'
|
|
5
4
|
import { TERMS_AND_CONDITIONS, CONTACT_SUMMARY, LICENCE_SUMMARY } from '../../uri.js'
|
|
6
5
|
import { nextPage } from '../../routes/next-page.js'
|
|
@@ -39,7 +39,7 @@ describe('preparePayment', () => {
|
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
describe('provides the correct return url', () => {
|
|
42
|
-
it.each(['http', 'https'])(
|
|
42
|
+
it.each(['http', 'https'])('uses SSL when "x-forwarded-proto" header is present, proto "%s"', proto => {
|
|
43
43
|
const request = createRequest({ headers: { 'x-forwarded-proto': proto } })
|
|
44
44
|
result = preparePayment(request, transaction)
|
|
45
45
|
expect(result.return_url).toBe(`${proto}://localhost:1234/buy/agreed`)
|
|
@@ -49,7 +49,7 @@ describe('preparePayment', () => {
|
|
|
49
49
|
['http', 'localhost:4321'],
|
|
50
50
|
['https', 'otherhost:8888'],
|
|
51
51
|
['http', 'samplehost:4444']
|
|
52
|
-
])(
|
|
52
|
+
])('uses request data when "x-forwarded-proto" header is not present, protocol "%s", host "%s"', (protocol, host) => {
|
|
53
53
|
const request = createRequest({ headers: {}, protocol, host })
|
|
54
54
|
result = preparePayment(request, transaction)
|
|
55
55
|
expect(result.return_url).toBe(`${protocol}://${host}/buy/agreed`)
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { salesApi } from '@defra-fish/connectors-lib'
|
|
2
2
|
import moment from 'moment'
|
|
3
3
|
|
|
4
|
-
import { setUpCacheFromAuthenticationResult } from '../renewals-write-cache'
|
|
4
|
+
import { setUpCacheFromAuthenticationResult, setUpPayloads } from '../renewals-write-cache'
|
|
5
5
|
import mockConcessions from '../../__mocks__/data/concessions'
|
|
6
|
+
import { ADDRESS_LOOKUP, CONTACT, LICENCE_TYPE, NAME } from '../../uri'
|
|
6
7
|
|
|
7
8
|
jest.mock('@defra-fish/connectors-lib')
|
|
8
9
|
salesApi.concessions.getAll.mockResolvedValue(mockConcessions)
|
|
9
10
|
|
|
10
11
|
describe('renewals-write-cache', () => {
|
|
11
|
-
beforeEach(jest.clearAllMocks)
|
|
12
|
-
|
|
13
12
|
describe('setUpCacheFromAuthenticationResult', () => {
|
|
14
13
|
const mockStatusCacheSet = jest.fn()
|
|
15
14
|
const mockTransactionCacheGet = jest.fn()
|
|
@@ -73,6 +72,7 @@ describe('renewals-write-cache', () => {
|
|
|
73
72
|
|
|
74
73
|
beforeEach(() => {
|
|
75
74
|
mockTransactionCacheGet.mockImplementationOnce(() => ({}))
|
|
75
|
+
jest.clearAllMocks()
|
|
76
76
|
})
|
|
77
77
|
|
|
78
78
|
it('should set licence length to 12M, as only 12 month licences can be renewed', async () => {
|
|
@@ -230,14 +230,149 @@ describe('renewals-write-cache', () => {
|
|
|
230
230
|
)
|
|
231
231
|
})
|
|
232
232
|
|
|
233
|
-
it('should set renewal
|
|
233
|
+
it('should set renewal on the status cache', async () => {
|
|
234
234
|
await setUpCacheFromAuthenticationResult(mockRequest, authenticationResult)
|
|
235
235
|
expect(mockStatusCacheSet).toHaveBeenCalledWith(
|
|
236
236
|
expect.objectContaining({
|
|
237
|
-
renewal: true
|
|
238
|
-
fromSummary: 'contact-summary'
|
|
237
|
+
renewal: true
|
|
239
238
|
})
|
|
240
239
|
)
|
|
241
240
|
})
|
|
242
241
|
})
|
|
242
|
+
|
|
243
|
+
describe('setupPayloads', () => {
|
|
244
|
+
const mockTransactionCacheGet = jest.fn()
|
|
245
|
+
const mockPageCacheSet = jest.fn()
|
|
246
|
+
|
|
247
|
+
const mockRequest = {
|
|
248
|
+
cache: () => ({
|
|
249
|
+
helpers: {
|
|
250
|
+
transaction: {
|
|
251
|
+
getCurrentPermission: mockTransactionCacheGet
|
|
252
|
+
},
|
|
253
|
+
page: {
|
|
254
|
+
setCurrentPermission: mockPageCacheSet
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
})
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const permission = {
|
|
261
|
+
licenceType: 'salmon-and-sea-trout',
|
|
262
|
+
licensee: {
|
|
263
|
+
birthDate: '2004-01-13',
|
|
264
|
+
email: 'email@gmail.com',
|
|
265
|
+
firstName: 'First',
|
|
266
|
+
lastName: 'Last',
|
|
267
|
+
postcode: 'SN15 3PG',
|
|
268
|
+
premises: '1',
|
|
269
|
+
preferredMethodOfConfirmation: 'Email'
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
beforeEach(jest.clearAllMocks)
|
|
274
|
+
|
|
275
|
+
it('should set the licence-type on the licence-type page to salmon-and-sea-trout in the cache, if licenceType is Salmon and sea trout', async () => {
|
|
276
|
+
mockTransactionCacheGet.mockImplementationOnce(() => permission)
|
|
277
|
+
await setUpPayloads(mockRequest)
|
|
278
|
+
expect(mockPageCacheSet).toBeCalledWith(LICENCE_TYPE.page, {
|
|
279
|
+
payload: {
|
|
280
|
+
'licence-type': 'salmon-and-sea-trout'
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
it('should set the licence-type on the licence-type page to trout-and-coarse-2-rod in the cache, if licenceType is Trout and coarse and numberOfRods is 2', async () => {
|
|
286
|
+
mockTransactionCacheGet.mockImplementationOnce(() => ({
|
|
287
|
+
...permission,
|
|
288
|
+
licenceType: 'Trout and coarse',
|
|
289
|
+
numberOfRods: '2'
|
|
290
|
+
}))
|
|
291
|
+
await setUpPayloads(mockRequest)
|
|
292
|
+
expect(mockPageCacheSet).toBeCalledWith(LICENCE_TYPE.page, {
|
|
293
|
+
payload: {
|
|
294
|
+
'licence-type': 'trout-and-coarse-2-rod'
|
|
295
|
+
}
|
|
296
|
+
})
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
it('should set the licence-type on the licence-type page to trout-and-coarse-3-rod in the cache, if licenceType is Trout and coarse and numberOfRods is 3', async () => {
|
|
300
|
+
mockTransactionCacheGet.mockImplementationOnce(() => ({
|
|
301
|
+
...permission,
|
|
302
|
+
licenceType: 'Trout and coarse',
|
|
303
|
+
numberOfRods: '3'
|
|
304
|
+
}))
|
|
305
|
+
await setUpPayloads(mockRequest)
|
|
306
|
+
expect(mockPageCacheSet).toBeCalledWith(LICENCE_TYPE.page, {
|
|
307
|
+
payload: {
|
|
308
|
+
'licence-type': 'trout-and-coarse-3-rod'
|
|
309
|
+
}
|
|
310
|
+
})
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
it('should set the first-name and last-name on the name page in the cache', async () => {
|
|
314
|
+
mockTransactionCacheGet.mockImplementationOnce(() => permission)
|
|
315
|
+
await setUpPayloads(mockRequest)
|
|
316
|
+
expect(mockPageCacheSet).toBeCalledWith(NAME.page, {
|
|
317
|
+
payload: {
|
|
318
|
+
'first-name': 'First',
|
|
319
|
+
'last-name': 'Last'
|
|
320
|
+
}
|
|
321
|
+
})
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
it('should set the premises and postcode on the address-lookup page in the cache', async () => {
|
|
325
|
+
mockTransactionCacheGet.mockImplementationOnce(() => permission)
|
|
326
|
+
await setUpPayloads(mockRequest)
|
|
327
|
+
expect(mockPageCacheSet).toBeCalledWith(ADDRESS_LOOKUP.page, {
|
|
328
|
+
payload: {
|
|
329
|
+
premises: '1',
|
|
330
|
+
postcode: 'SN15 3PG'
|
|
331
|
+
}
|
|
332
|
+
})
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
it('should set the how-contacted to email with an email on the contact page in the cache, if preferredMethodOfConfirmation is Email', async () => {
|
|
336
|
+
mockTransactionCacheGet.mockImplementationOnce(() => permission)
|
|
337
|
+
await setUpPayloads(mockRequest)
|
|
338
|
+
expect(mockPageCacheSet).toBeCalledWith(CONTACT.page, {
|
|
339
|
+
payload: {
|
|
340
|
+
'how-contacted': 'email',
|
|
341
|
+
email: 'email@gmail.com'
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
it('should set the how-contacted to text with a phone number on the contact page in the cache, if preferredMethodOfConfirmation is Text', async () => {
|
|
347
|
+
mockTransactionCacheGet.mockImplementationOnce(() => ({
|
|
348
|
+
...permission,
|
|
349
|
+
licensee: {
|
|
350
|
+
preferredMethodOfConfirmation: 'Text',
|
|
351
|
+
mobilePhone: '07700900900'
|
|
352
|
+
}
|
|
353
|
+
}))
|
|
354
|
+
await setUpPayloads(mockRequest)
|
|
355
|
+
expect(mockPageCacheSet).toBeCalledWith(CONTACT.page, {
|
|
356
|
+
payload: {
|
|
357
|
+
'how-contacted': 'text',
|
|
358
|
+
text: '07700900900'
|
|
359
|
+
}
|
|
360
|
+
})
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
it('should set the how-contacted to none on the contact page in the cache, if preferredMethodOfConfirmation is Letter', async () => {
|
|
364
|
+
mockTransactionCacheGet.mockImplementationOnce(() => ({
|
|
365
|
+
...permission,
|
|
366
|
+
licensee: {
|
|
367
|
+
preferredMethodOfConfirmation: 'Letter'
|
|
368
|
+
}
|
|
369
|
+
}))
|
|
370
|
+
await setUpPayloads(mockRequest)
|
|
371
|
+
expect(mockPageCacheSet).toBeCalledWith(CONTACT.page, {
|
|
372
|
+
payload: {
|
|
373
|
+
'how-contacted': 'none'
|
|
374
|
+
}
|
|
375
|
+
})
|
|
376
|
+
})
|
|
377
|
+
})
|
|
243
378
|
})
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import moment from 'moment-timezone'
|
|
2
2
|
import db from 'debug'
|
|
3
|
-
import { LICENCE_TYPE, NAME,
|
|
3
|
+
import { LICENCE_TYPE, NAME, ADDRESS_LOOKUP, CONTACT } from '../uri.js'
|
|
4
4
|
import { SERVICE_LOCAL_TIME } from '@defra-fish/business-rules-lib'
|
|
5
5
|
import * as constants from './mapping-constants.js'
|
|
6
6
|
import { ageConcessionHelper, addDisabled } from './concession-helper.js'
|
|
7
|
-
import { CONTACT_SUMMARY_SEEN } from '../constants.js'
|
|
8
7
|
import { licenceToStart } from '../pages/licence-details/licence-to-start/update-transaction.js'
|
|
9
8
|
import { licenseTypes } from '../pages/licence-details/licence-type/route.js'
|
|
10
9
|
import { salesApi } from '@defra-fish/connectors-lib'
|
|
@@ -66,7 +65,7 @@ export const setUpCacheFromAuthenticationResult = async (request, authentication
|
|
|
66
65
|
// Add appropriate age concessions
|
|
67
66
|
ageConcessionHelper(permission)
|
|
68
67
|
await request.cache().helpers.transaction.setCurrentPermission(permission)
|
|
69
|
-
await request.cache().helpers.status.setCurrentPermission({ renewal: true
|
|
68
|
+
await request.cache().helpers.status.setCurrentPermission({ renewal: true })
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
export const setUpPayloads = async request => {
|
|
@@ -96,14 +95,10 @@ export const setUpPayloads = async request => {
|
|
|
96
95
|
}
|
|
97
96
|
})
|
|
98
97
|
|
|
99
|
-
await request.cache().helpers.page.setCurrentPermission(
|
|
98
|
+
await request.cache().helpers.page.setCurrentPermission(ADDRESS_LOOKUP.page, {
|
|
100
99
|
payload: {
|
|
101
100
|
premises: permission.licensee.premises,
|
|
102
|
-
|
|
103
|
-
locality: permission.licensee.locality,
|
|
104
|
-
town: permission.licensee.town,
|
|
105
|
-
postcode: permission.licensee.postcode,
|
|
106
|
-
'country-code': permission.licensee.countryCode
|
|
101
|
+
postcode: permission.licensee.postcode
|
|
107
102
|
}
|
|
108
103
|
})
|
|
109
104
|
|
|
@@ -120,6 +120,10 @@ describe('The licence-fulfilment page', () => {
|
|
|
120
120
|
const n = journeyDefinition.find(n => n.current.page === LICENCE_FULFILMENT.page)
|
|
121
121
|
expect(n.backLink({ fromSummary: CONTACT_SUMMARY_SEEN })).toBe(CONTACT_SUMMARY.uri)
|
|
122
122
|
})
|
|
123
|
+
it('has a back-link to the licence-summary page if in renewal', () => {
|
|
124
|
+
const n = journeyDefinition.find(n => n.current.page === LICENCE_FULFILMENT.page)
|
|
125
|
+
expect(n.backLink({ renewal: true })).toBe(LICENCE_SUMMARY.uri)
|
|
126
|
+
})
|
|
123
127
|
})
|
|
124
128
|
|
|
125
129
|
describe('The licence-confirmation page', () => {
|
|
@@ -239,7 +239,15 @@ export default [
|
|
|
239
239
|
page: LICENCE_CONFIRMATION_METHOD
|
|
240
240
|
}
|
|
241
241
|
},
|
|
242
|
-
backLink:
|
|
242
|
+
backLink: status => {
|
|
243
|
+
if (status.fromSummary === CONTACT_SUMMARY_SEEN) {
|
|
244
|
+
return CONTACT_SUMMARY.uri
|
|
245
|
+
} else if (status.renewal) {
|
|
246
|
+
return LICENCE_SUMMARY.uri
|
|
247
|
+
} else {
|
|
248
|
+
return ADDRESS_LOOKUP.uri
|
|
249
|
+
}
|
|
250
|
+
}
|
|
243
251
|
},
|
|
244
252
|
{
|
|
245
253
|
current: LICENCE_CONFIRMATION_METHOD,
|
|
@@ -28,20 +28,17 @@ describe('isStaticResource', () => {
|
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
describe('includesRegex', () => {
|
|
31
|
-
const regexArray = [/^\/buy\/renew\/identify$/, /^\/renew
|
|
32
|
-
it.each(['/buy/renew/identify', '/renew/ABC123', '/renew/123123', '/renew/ABCDEF'])(
|
|
31
|
+
const regexArray = [/^\/buy\/renew\/identify$/, /^\/renew\/.*$/]
|
|
32
|
+
it.each(['/buy/renew/identify', '/renew/ABC123', '/renew/123123', '/renew/ABCDEF', '/renew/anytext'])(
|
|
33
33
|
'returns true if one of the regexes is matched %s',
|
|
34
34
|
async path => {
|
|
35
35
|
expect(includesRegex(path, regexArray)).toBeTruthy()
|
|
36
36
|
}
|
|
37
37
|
)
|
|
38
38
|
|
|
39
|
-
it.each(['/buy/renew', '/buy', '/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
expect(includesRegex(path, regexArray)).toBeFalsy()
|
|
43
|
-
}
|
|
44
|
-
)
|
|
39
|
+
it.each(['/buy/renew', '/buy', '/rene', '/buy/order-complete'])('returns false if one of the regexes is not matched %s', async path => {
|
|
40
|
+
expect(includesRegex(path, regexArray)).toBeFalsy()
|
|
41
|
+
})
|
|
45
42
|
})
|
|
46
43
|
|
|
47
44
|
describe('Use session cookie', () => {
|
|
@@ -38,7 +38,7 @@ const agreedHandlerProtectionExemptSet = [
|
|
|
38
38
|
]
|
|
39
39
|
|
|
40
40
|
// regex for /renew/{referenceNumber?} and /buy/renew/identify
|
|
41
|
-
const startProtectionExemptSet = [/^\/renew
|
|
41
|
+
const startProtectionExemptSet = [/^\/renew\/.*$/, /^\/buy\/renew\/identify$/]
|
|
42
42
|
|
|
43
43
|
const staticMatcherPublic = /^(?:\/public\/.*|\/robots.txt|\/favicon.ico)/
|
|
44
44
|
const staticMatcherOidc = /^\/oidc\/.*/
|
|
@@ -46,9 +46,7 @@ const staticMatcherOidc = /^\/oidc\/.*/
|
|
|
46
46
|
export const isStaticResource = request => staticMatcherPublic.test(request.path)
|
|
47
47
|
export const useSessionCookie = request => !isStaticResource(request) && !staticMatcherOidc.test(request.path)
|
|
48
48
|
|
|
49
|
-
export const includesRegex = (str, regexArray) =>
|
|
50
|
-
return regexArray.some(regex => regex.test(str))
|
|
51
|
-
}
|
|
49
|
+
export const includesRegex = (str, regexArray) => regexArray.some(regex => regex.test(str))
|
|
52
50
|
|
|
53
51
|
/**
|
|
54
52
|
* If there is no session cookie create it and initialize user cache contexts
|