@defra-fish/gafl-webapp-service 1.22.0-rc.21 → 1.22.0-rc.25
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra-fish/gafl-webapp-service",
|
|
3
|
-
"version": "1.22.0-rc.
|
|
3
|
+
"version": "1.22.0-rc.25",
|
|
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.22.0-rc.
|
|
40
|
-
"@defra-fish/connectors-lib": "1.22.0-rc.
|
|
39
|
+
"@defra-fish/business-rules-lib": "1.22.0-rc.25",
|
|
40
|
+
"@defra-fish/connectors-lib": "1.22.0-rc.25",
|
|
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.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "9fd368085a0574ed74a88ba476a2bff69e8554e2"
|
|
80
80
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { UTM, QUERYSTRING_LICENCE_KEY } from '../../constants'
|
|
2
|
+
import urlHandler from '../url-handler'
|
|
3
|
+
import { ATTRIBUTION, IDENTIFY } from '../../uri'
|
|
4
|
+
|
|
5
|
+
jest.mock('../../constants', () => ({
|
|
6
|
+
UTM: {
|
|
7
|
+
CAMPAIGN: 'utmcampaign',
|
|
8
|
+
MEDIUM: 'utmmedium',
|
|
9
|
+
CONTENT: 'utmcontent',
|
|
10
|
+
SOURCE: 'utmsource',
|
|
11
|
+
TERM: 'utmterm'
|
|
12
|
+
}
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
jest.mock('../../uri', () => ({
|
|
16
|
+
ATTRIBUTION: { uri: '/attribution-url' },
|
|
17
|
+
IDENTIFY: { uri: '/renewal-url' }
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
describe('The url handler', () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
jest.clearAllMocks()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('returns identify if no licence key', async () => {
|
|
26
|
+
const query = {
|
|
27
|
+
[UTM.CAMPAIGN]: 'renewals',
|
|
28
|
+
[QUERYSTRING_LICENCE_KEY]: null
|
|
29
|
+
}
|
|
30
|
+
const responseToolkit = generateResponseToolkitMock()
|
|
31
|
+
await urlHandler(generateRequestMock(query), responseToolkit)
|
|
32
|
+
expect(responseToolkit.redirect).toHaveBeenCalledWith(IDENTIFY.uri)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it.each([
|
|
36
|
+
['B2F11U'],
|
|
37
|
+
['AH56F6'],
|
|
38
|
+
['GH330P']
|
|
39
|
+
])('6 digit reference number exists and returns ATTRIBUTION', async licenceKey => {
|
|
40
|
+
const query = {
|
|
41
|
+
[UTM.CAMPAIGN]: 'renewals',
|
|
42
|
+
[QUERYSTRING_LICENCE_KEY]: licenceKey
|
|
43
|
+
}
|
|
44
|
+
const responseToolkit = generateResponseToolkitMock()
|
|
45
|
+
await urlHandler(generateRequestMock(query), responseToolkit)
|
|
46
|
+
const regExMatch = new RegExp(`^${ATTRIBUTION.uri}/${licenceKey}$`)
|
|
47
|
+
expect(responseToolkit.redirect).toHaveBeenCalledWith(expect.stringMatching(regExMatch))
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it.each([
|
|
51
|
+
['B2F11UH5D'],
|
|
52
|
+
['AH56'],
|
|
53
|
+
['GH330PPTD']
|
|
54
|
+
])('reference number is not 6 digits and returns back to IDENTIFY', async licenceKey => {
|
|
55
|
+
const query = {
|
|
56
|
+
[UTM.CAMPAIGN]: 'renewals',
|
|
57
|
+
[QUERYSTRING_LICENCE_KEY]: licenceKey
|
|
58
|
+
}
|
|
59
|
+
const responseToolkit = generateResponseToolkitMock()
|
|
60
|
+
await urlHandler(generateRequestMock(query), responseToolkit)
|
|
61
|
+
expect(responseToolkit.redirect).toHaveBeenCalledWith(IDENTIFY.uri)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const generateRequestMock = (query, status = {}) => ({
|
|
65
|
+
query,
|
|
66
|
+
cache: jest.fn(() => ({
|
|
67
|
+
helpers: {
|
|
68
|
+
status: {
|
|
69
|
+
get: jest.fn(() => status),
|
|
70
|
+
set: jest.fn()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}))
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const generateResponseToolkitMock = () => ({
|
|
77
|
+
redirect: jest.fn()
|
|
78
|
+
})
|
|
79
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { QUERYSTRING_LICENCE_KEY } from '../constants.js'
|
|
2
|
+
import { initialiseAnalyticsSessionData } from '../processors/analytics.js'
|
|
3
|
+
import { IDENTIFY, ATTRIBUTION } from '../uri.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Attribution route handler
|
|
7
|
+
* @param request
|
|
8
|
+
* @param h
|
|
9
|
+
* @returns {Promise}
|
|
10
|
+
*/
|
|
11
|
+
export default async (request, h) => {
|
|
12
|
+
await initialiseAnalyticsSessionData(request)
|
|
13
|
+
if (request.query[QUERYSTRING_LICENCE_KEY]) {
|
|
14
|
+
const refNumber = request.query[QUERYSTRING_LICENCE_KEY]
|
|
15
|
+
const sixDigit = /^[A-Za-z0-9]{6}$/.test(refNumber)
|
|
16
|
+
if (sixDigit) {
|
|
17
|
+
return h.redirect(`${ATTRIBUTION.uri}/${refNumber}`)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return h.redirect(IDENTIFY.uri)
|
|
21
|
+
}
|
package/src/locales/cy.json
CHANGED
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"cookie_banner_preamble": "Mae'r wefan hon ond yn storio'r cwcis sy'n hanfodol i wneud iddi weithio. Darllenwch fwy am ",
|
|
130
130
|
"cookies_body_how_we_manage_1": "Find out ",
|
|
131
131
|
"cookies_body_how_we_manage_link": "how to manage cookies on the Information Commissioners' website",
|
|
132
|
-
"cookies_body_small_files": "When you use the Get a Fishing Licence service, we put small files known as
|
|
132
|
+
"cookies_body_small_files": "When you use the Get a Fishing Licence service, we put small files known as cookies onto your computer.",
|
|
133
133
|
"cookies_body_used_for_bulletpoint_1": "remember what notifications you've seen so that you're not shown them more than once",
|
|
134
134
|
"cookies_body_used_for_bulletpoint_2": "to protect the service against malicious activity",
|
|
135
135
|
"cookies_body_used_for_bulletpoint_3": "to ensure that you have a consistent experience when we make changes to the service",
|
package/src/locales/en.json
CHANGED
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"cookie_banner_preamble": "This website only stores the cookies that are essential to make it work. Read more about ",
|
|
131
131
|
"cookies_body_how_we_manage_1": "Find out ",
|
|
132
132
|
"cookies_body_how_we_manage_link": "how to manage cookies on the Information Commissioners' website",
|
|
133
|
-
"cookies_body_small_files": "When you use the Get a Fishing Licence service, we put small files known as
|
|
133
|
+
"cookies_body_small_files": "When you use the Get a Fishing Licence service, we put small files known as cookies onto your computer.",
|
|
134
134
|
"cookies_body_used_for_bulletpoint_1": "remember what notifications you've seen so that you're not shown them more than once",
|
|
135
135
|
"cookies_body_used_for_bulletpoint_2": "to protect the service against malicious activity",
|
|
136
136
|
"cookies_body_used_for_bulletpoint_3": "to ensure that you have a consistent experience when we make changes to the service",
|