@defra-fish/gafl-webapp-service 1.21.0 → 1.22.0-rc.0
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.
|
|
3
|
+
"version": "1.22.0-rc.0",
|
|
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.0",
|
|
40
|
+
"@defra-fish/connectors-lib": "1.22.0-rc.0",
|
|
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": "4229720833c36e305c1703bb5f34a54ad24d5825"
|
|
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,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 }
|
|
@@ -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 %}
|