@defra-fish/gafl-webapp-service 1.21.0 → 1.22.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/handlers/__tests__/error-handler.spec.js +53 -0
- package/src/handlers/agreed-handler.js +0 -2
- package/src/handlers/error-handler.js +1 -0
- package/src/pages/contact/contact/contact.njk +3 -2
- package/src/pages/errors/client-error.njk +9 -19
- package/src/pages/terms-and-conditions/terms-and-conditions.njk +3 -3
- package/src/processors/api-transaction.js +0 -3
- package/src/processors/__tests__/permission-helper.spec.js +0 -81
- package/src/processors/permission-helper.js +0 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra-fish/gafl-webapp-service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.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.22.0-rc.3",
|
|
40
|
+
"@defra-fish/connectors-lib": "1.22.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": "6870c58b973649f21cd7edc8088d86ed1fad789d"
|
|
79
79
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { errorHandler } from '../error-handler.js'
|
|
2
|
+
import { CLIENT_ERROR } from '../../uri.js'
|
|
3
|
+
|
|
4
|
+
const mockView = jest.fn(() => ({
|
|
5
|
+
code: jest.fn()
|
|
6
|
+
}))
|
|
7
|
+
const h = {
|
|
8
|
+
view: mockView
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('error-handler', () => {
|
|
12
|
+
describe('errorHandler', () => {
|
|
13
|
+
it('should pass the referer to the view if it is present', async () => {
|
|
14
|
+
const request = {
|
|
15
|
+
headers: {
|
|
16
|
+
referer: 'http://example.com'
|
|
17
|
+
},
|
|
18
|
+
response: {
|
|
19
|
+
isBoom: true,
|
|
20
|
+
output: {
|
|
21
|
+
statusCode: 400
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
await errorHandler(request, h)
|
|
26
|
+
expect(mockView).toBeCalledWith(
|
|
27
|
+
CLIENT_ERROR.page,
|
|
28
|
+
expect.objectContaining({
|
|
29
|
+
referer: 'http://example.com'
|
|
30
|
+
})
|
|
31
|
+
)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('should not pass the referer to the view if it is not present', async () => {
|
|
35
|
+
const request = {
|
|
36
|
+
headers: {},
|
|
37
|
+
response: {
|
|
38
|
+
isBoom: true,
|
|
39
|
+
output: {
|
|
40
|
+
statusCode: 400
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
await errorHandler(request, h)
|
|
45
|
+
expect(mockView).toBeCalledWith(
|
|
46
|
+
CLIENT_ERROR.page,
|
|
47
|
+
expect.not.objectContaining({
|
|
48
|
+
referer: 'http://example.com'
|
|
49
|
+
})
|
|
50
|
+
)
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
})
|
|
@@ -18,7 +18,6 @@ import { preparePayment } from '../processors/payment.js'
|
|
|
18
18
|
import { COMPLETION_STATUS } from '../constants.js'
|
|
19
19
|
import { ORDER_COMPLETE, PAYMENT_CANCELLED, PAYMENT_FAILED } from '../uri.js'
|
|
20
20
|
import { PAYMENT_JOURNAL_STATUS_CODES, GOVUK_PAY_ERROR_STATUS_CODES } from '@defra-fish/business-rules-lib'
|
|
21
|
-
import { logStartDateError } from '../processors/permission-helper.js'
|
|
22
21
|
const debug = db('webapp:agreed-handler')
|
|
23
22
|
|
|
24
23
|
/**
|
|
@@ -195,7 +194,6 @@ const finaliseTransaction = async (request, transaction, status) => {
|
|
|
195
194
|
transaction.permissions[i].endDate = response.permissions[i].endDate
|
|
196
195
|
debug(`Setting obfuscated dob: ${response.permissions[i].licensee.obfuscatedDob}`)
|
|
197
196
|
transaction.permissions[i].licensee.obfuscatedDob = response.permissions[i].licensee.obfuscatedDob
|
|
198
|
-
logStartDateError(response.permissions[i], request)
|
|
199
197
|
}
|
|
200
198
|
status[COMPLETION_STATUS.finalised] = true
|
|
201
199
|
await request.cache().helpers.status.set(status)
|
|
@@ -18,6 +18,7 @@ export const errorHandler = async (request, h) => {
|
|
|
18
18
|
*/
|
|
19
19
|
return h
|
|
20
20
|
.view(CLIENT_ERROR.page, {
|
|
21
|
+
referer: request?.headers?.referer,
|
|
21
22
|
clientError: request.response.output.payload,
|
|
22
23
|
path: request.path,
|
|
23
24
|
uri: { new: NEW_TRANSACTION.uri, controller: CONTROLLER.uri, agreed: AGREED.uri }
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
{% from "input/macro.njk" import govukInput %}
|
|
4
4
|
{% from "warning-text/macro.njk" import govukWarningText %}
|
|
5
5
|
|
|
6
|
-
{% set title = 'How should we contact you?' %}
|
|
6
|
+
{% set title = 'How should we contact the licence holder about reminders and important changes?' if data.isPhysical else 'How should we contact you?' %}
|
|
7
7
|
{% set errorMsg = 'Choose how you would like to be contacted' %}
|
|
8
8
|
{% set emailError = 'Enter your email address in the correct format, like name@example.com' %}
|
|
9
9
|
{% set mobileError = "Enter your UK mobile number like '07700 900 900'" %}
|
|
@@ -138,7 +138,8 @@
|
|
|
138
138
|
|
|
139
139
|
{% block pageContent %}
|
|
140
140
|
{% if data.isPhysical %}
|
|
141
|
-
<p class="govuk-body-m">This is where we will send
|
|
141
|
+
<p class="govuk-body-m">This is where we will send renewal reminders when your licence is ending.</p>
|
|
142
|
+
<p class="govuk-body-m">We will also send important information like byelaw updates.</p>
|
|
142
143
|
{% else %}
|
|
143
144
|
{% if data.isJunior %}
|
|
144
145
|
<p class="govuk-body-m">We don't provide physical cards for junior licences.</p>
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
{% from "fieldset/macro.njk" import govukFieldset %}
|
|
3
3
|
{% from "button/macro.njk" import govukButton %}
|
|
4
4
|
|
|
5
|
-
{% block pageTitle %}A problem has occurred{% endblock %}
|
|
6
|
-
|
|
7
5
|
{% set title = '' %}
|
|
8
6
|
{% if clientError.statusCode === 400 %}
|
|
9
7
|
{% set title = 'Bad request' %}
|
|
@@ -15,33 +13,25 @@
|
|
|
15
13
|
{% set title = 'Page not found' %}
|
|
16
14
|
{% endif %}
|
|
17
15
|
|
|
16
|
+
{% block pageTitle %}Sorry, there is a problem with the service - {{title}}{% endblock %}
|
|
17
|
+
|
|
18
18
|
{% block content %}
|
|
19
19
|
<div class="govuk-grid-row">
|
|
20
20
|
<div class="govuk-grid-column-two-thirds">
|
|
21
21
|
{% call govukFieldset({
|
|
22
22
|
legend: {
|
|
23
|
-
text: "
|
|
23
|
+
text: "Sorry, there is a problem with the service",
|
|
24
24
|
classes: "govuk-fieldset__legend--l govuk-!-margin-bottom-6",
|
|
25
25
|
isPageHeading: true
|
|
26
26
|
}
|
|
27
27
|
}) %}
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
<p class="govuk-body
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
attributes: { id: "try-again" },
|
|
35
|
-
preventDoubleClick: true,
|
|
36
|
-
name: "try-again",
|
|
37
|
-
text: "Try again",
|
|
38
|
-
href: uri.controller,
|
|
39
|
-
classes: "govuk-!-margin-top-5"
|
|
40
|
-
}) }}
|
|
41
|
-
{% endif %}
|
|
42
|
-
|
|
28
|
+
<p class="govuk-body-m">
|
|
29
|
+
You can <a class="govuk-link" href="{{referer if referer else 'javascript:history.back()'}}">try to get back to your application</a>.
|
|
30
|
+
</p>
|
|
31
|
+
<p class="govuk-body">
|
|
32
|
+
If that does not work, you will have to <a class="govuk-link" href="{{ uri.new }}">start again</a>. Sorry.
|
|
33
|
+
</p>
|
|
43
34
|
{% endcall %}
|
|
44
|
-
<p class="govuk-body-m"><a class="govuk-link" href="{{ uri.new }}">Start again</a></p>
|
|
45
35
|
</div>
|
|
46
36
|
</div>
|
|
47
37
|
{% endblock %}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
{%
|
|
14
14
|
set errorMap = {
|
|
15
15
|
'agree': {
|
|
16
|
-
'any.required': { ref: '#agree', text: 'You have not agreed to the
|
|
16
|
+
'any.required': { ref: '#agree', text: 'You have not agreed to the licence conditions' }
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
%}
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
{{ govukCheckboxes({
|
|
59
59
|
idPrefix: "agree",
|
|
60
60
|
name: "agree",
|
|
61
|
-
errorMessage: { text: 'You must agree to the
|
|
61
|
+
errorMessage: { text: 'You must agree to the licence conditions to continue' } if error,
|
|
62
62
|
items: [
|
|
63
63
|
{
|
|
64
64
|
value: "yes",
|
|
65
|
-
text: "I agree to the
|
|
65
|
+
text: "I agree to the licence conditions"
|
|
66
66
|
}
|
|
67
67
|
]
|
|
68
68
|
}) }}
|
|
@@ -6,7 +6,6 @@ import * as concessionHelper from '../processors/concession-helper.js'
|
|
|
6
6
|
import { countries } from './refdata-helper.js'
|
|
7
7
|
import { salesApi } from '@defra-fish/connectors-lib'
|
|
8
8
|
import { licenceToStart } from '../pages/licence-details/licence-to-start/update-transaction.js'
|
|
9
|
-
import { logStartDateError } from './permission-helper.js'
|
|
10
9
|
|
|
11
10
|
export const prepareApiTransactionPayload = async request => {
|
|
12
11
|
const transactionCache = await request.cache().helpers.transaction.get()
|
|
@@ -30,8 +29,6 @@ export const prepareApiTransactionPayload = async request => {
|
|
|
30
29
|
})
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
logStartDateError(permission, request)
|
|
34
|
-
|
|
35
32
|
// Calculate the concession (proof entry) - disabled takes precedence
|
|
36
33
|
if (concessionHelper.hasDisabled(p)) {
|
|
37
34
|
permission.concessions = [
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import moment from 'moment'
|
|
2
|
-
import { logStartDateError } from '../permission-helper.js'
|
|
3
|
-
|
|
4
|
-
const consoleError = console.error
|
|
5
|
-
|
|
6
|
-
describe('logStartDateError', () => {
|
|
7
|
-
beforeAll(() => {
|
|
8
|
-
console.error = jest.fn()
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
beforeEach(jest.clearAllMocks)
|
|
12
|
-
|
|
13
|
-
afterAll(() => {
|
|
14
|
-
console.error = consoleError
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('logs if start date is before issue date', async () => {
|
|
18
|
-
const samplePermission = {
|
|
19
|
-
startDate: '2021-08-10T04:05:54Z',
|
|
20
|
-
issueDate: '2021-08-10T14:05:54Z'
|
|
21
|
-
}
|
|
22
|
-
await logStartDateError(samplePermission, getFakeRequest())
|
|
23
|
-
expect(console.error).toHaveBeenCalledWith('permission start date before issue date: ', samplePermission)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('logs if start date is before current time, if no issue date is provided', async () => {
|
|
27
|
-
const samplePermission = {
|
|
28
|
-
startDate: moment()
|
|
29
|
-
.subtract(5, 'hours')
|
|
30
|
-
.toISOString()
|
|
31
|
-
}
|
|
32
|
-
await logStartDateError(samplePermission, getFakeRequest())
|
|
33
|
-
expect(console.error).toHaveBeenCalledWith('permission start date before current time: ', samplePermission)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it("doesn't log if start date is after issue date", async () => {
|
|
37
|
-
const samplePermission = {
|
|
38
|
-
startDate: '2021-08-10T14:35:54Z',
|
|
39
|
-
issueDate: '2021-08-10T14:05:54Z'
|
|
40
|
-
}
|
|
41
|
-
await logStartDateError(samplePermission, getFakeRequest())
|
|
42
|
-
expect(console.error).not.toHaveBeenCalled()
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it("doesn't log if start date is after current date", async () => {
|
|
46
|
-
const samplePermission = {
|
|
47
|
-
startDate: moment()
|
|
48
|
-
.add(30, 'minutes')
|
|
49
|
-
.toISOString()
|
|
50
|
-
}
|
|
51
|
-
await logStartDateError(samplePermission, getFakeRequest())
|
|
52
|
-
expect(console.error).not.toHaveBeenCalled()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it("doesn't log if it's a POCL import", async () => {
|
|
56
|
-
const samplePermission = {
|
|
57
|
-
startDate: moment()
|
|
58
|
-
.subtract(5, 'hours')
|
|
59
|
-
.toISOString(),
|
|
60
|
-
dataSource: { id: 910400000 }
|
|
61
|
-
}
|
|
62
|
-
await logStartDateError(samplePermission, getFakeRequest())
|
|
63
|
-
expect(console.error).not.toHaveBeenCalled()
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
const getFakeRequest = () => ({
|
|
67
|
-
cache: jest.fn(() => ({
|
|
68
|
-
helpers: {
|
|
69
|
-
transaction: {
|
|
70
|
-
get: jest.fn(() => ({}))
|
|
71
|
-
},
|
|
72
|
-
page: {
|
|
73
|
-
get: jest.fn(() => ({}))
|
|
74
|
-
},
|
|
75
|
-
status: {
|
|
76
|
-
get: jest.fn(() => ({}))
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}))
|
|
80
|
-
})
|
|
81
|
-
})
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import moment from 'moment'
|
|
2
|
-
const POCL_DATA_SOURCE_ID = 910400000
|
|
3
|
-
|
|
4
|
-
export const logStartDateError = async (permission, request) => {
|
|
5
|
-
const { startDate, issueDate } = permission
|
|
6
|
-
const startDateBeforeTargetDate = moment(startDate).isBefore(issueDate || undefined)
|
|
7
|
-
const isPOCLImport = permission?.dataSource?.id === POCL_DATA_SOURCE_ID
|
|
8
|
-
if (startDateBeforeTargetDate && !isPOCLImport) {
|
|
9
|
-
console.error(`permission start date before ${issueDate ? 'issue date' : 'current time'}: `, permission)
|
|
10
|
-
console.log('page cache', JSON.stringify(await request.cache().helpers.page.get()))
|
|
11
|
-
console.log('transaction cache', JSON.stringify(await request.cache().helpers.transaction.get()))
|
|
12
|
-
console.log('status cache', JSON.stringify(await request.cache().helpers.status.get()))
|
|
13
|
-
}
|
|
14
|
-
}
|