@defra-fish/gafl-webapp-service 1.65.0-rc.0 → 1.65.0-rc.1
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/locales/cy.json +4 -1
- package/src/locales/en.json +4 -1
- package/src/pages/recurring-payments/cancel/confirm/__tests__/route.spec.js +112 -0
- package/src/pages/recurring-payments/cancel/confirm/cancel-rp-confirm.njk +22 -3
- package/src/pages/recurring-payments/cancel/confirm/route.js +15 -2
- package/src/routes/journey-definition.js +2 -1
- package/src/pages/recurring-payments/cancel/confirm/__tests__/route.test.js +0 -106
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra-fish/gafl-webapp-service",
|
|
3
|
-
"version": "1.65.0-rc.
|
|
3
|
+
"version": "1.65.0-rc.1",
|
|
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.65.0-rc.
|
|
40
|
-
"@defra-fish/connectors-lib": "1.65.0-rc.
|
|
39
|
+
"@defra-fish/business-rules-lib": "1.65.0-rc.1",
|
|
40
|
+
"@defra-fish/connectors-lib": "1.65.0-rc.1",
|
|
41
41
|
"@defra/hapi-gapi": "2.0.0",
|
|
42
42
|
"@hapi/boom": "9.1.2",
|
|
43
43
|
"@hapi/catbox-redis": "6.0.2",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"./gafl-jest-matchers.js"
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "3e4014cd3d4fae6d6dc6b7f5b338821a572286fb"
|
|
83
83
|
}
|
package/src/locales/cy.json
CHANGED
|
@@ -787,7 +787,10 @@
|
|
|
787
787
|
"role_required_body_2": "Please contact your Microsoft Dynamics administrator to request access.",
|
|
788
788
|
"role_required_title": "Role required",
|
|
789
789
|
"rp_cancel_complete_title": "Cancel your recurring card payment agreement - complete",
|
|
790
|
-
"
|
|
790
|
+
"rp_cancel_confirm_accept": "Yes, cancel my recurring payment agreement",
|
|
791
|
+
"rp_cancel_confirm_body": "Your current licence will reman valid until it expires on ",
|
|
792
|
+
"rp_cancel_confirm_reject": "No, I've changed my mind",
|
|
793
|
+
"rp_cancel_confirm_title": "Confirm you want to cancel",
|
|
791
794
|
"rp_cancel_details_last_purchased": "Last licence purchased",
|
|
792
795
|
"rp_cancel_details_licence_holder": "Licence holder",
|
|
793
796
|
"rp_cancel_details_licence_type": "Licence type",
|
package/src/locales/en.json
CHANGED
|
@@ -787,7 +787,10 @@
|
|
|
787
787
|
"role_required_body_2": "Please contact your Microsoft Dynamics administrator to request access.",
|
|
788
788
|
"role_required_title": "Role required",
|
|
789
789
|
"rp_cancel_complete_title": "Cancel your recurring card payment agreement - complete",
|
|
790
|
-
"
|
|
790
|
+
"rp_cancel_confirm_accept": "Yes, cancel my recurring payment agreement",
|
|
791
|
+
"rp_cancel_confirm_body": "Your current licence will reman valid until it expires on ",
|
|
792
|
+
"rp_cancel_confirm_reject": "No, I've changed my mind",
|
|
793
|
+
"rp_cancel_confirm_title": "Confirm you want to cancel",
|
|
791
794
|
"rp_cancel_details_last_purchased": "Last licence purchased",
|
|
792
795
|
"rp_cancel_details_licence_holder": "Licence holder",
|
|
793
796
|
"rp_cancel_details_licence_type": "Licence type",
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import pageRoute from '../../../../../routes/page-route.js'
|
|
2
|
+
import { CANCEL_RP_CONFIRM, CANCEL_RP_COMPLETE, CANCEL_RP_IDENTIFY } from '../../../../../uri.js'
|
|
3
|
+
import { addLanguageCodeToUri } from '../../../../../processors/uri-helper.js'
|
|
4
|
+
import moment from 'moment-timezone'
|
|
5
|
+
|
|
6
|
+
require('../route.js')
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line no-unused-vars
|
|
9
|
+
const [[_v, _p, validator, completion, getData]] = pageRoute.mock.calls
|
|
10
|
+
|
|
11
|
+
jest.mock('../../../../../routes/page-route.js')
|
|
12
|
+
jest.mock('../../../../../uri.js', () => ({
|
|
13
|
+
...jest.requireActual('../../../../../uri.js'),
|
|
14
|
+
CANCEL_RP_CONFIRM: { page: Symbol('cancel-rp-confirm-page'), uri: Symbol('cancel-rp-confirm-uri') },
|
|
15
|
+
CANCEL_RP_COMPLETE: { uri: Symbol('cancel-rp-complete-uri') },
|
|
16
|
+
CANCEL_RP_IDENTIFY: { uri: Symbol('cancel-rp-identify-uri') }
|
|
17
|
+
}))
|
|
18
|
+
jest.mock('../../../../../processors/uri-helper.js')
|
|
19
|
+
jest.mock('moment-timezone')
|
|
20
|
+
|
|
21
|
+
describe('pageRoute receives expected arguments', () => {
|
|
22
|
+
it('passes expected arguments to pageRoute', () => {
|
|
23
|
+
jest.isolateModules(() => {
|
|
24
|
+
require('../route.js')
|
|
25
|
+
expect(pageRoute).toHaveBeenCalledWith(
|
|
26
|
+
CANCEL_RP_CONFIRM.page,
|
|
27
|
+
CANCEL_RP_CONFIRM.uri,
|
|
28
|
+
expect.any(Function),
|
|
29
|
+
expect.any(Function),
|
|
30
|
+
expect.any(Function)
|
|
31
|
+
)
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
describe('completion function', () => {
|
|
37
|
+
beforeEach(jest.clearAllMocks)
|
|
38
|
+
|
|
39
|
+
it('calls addLanguageCodeToUri with request object', () => {
|
|
40
|
+
const sampleRequest = Symbol('sample request')
|
|
41
|
+
completion(sampleRequest)
|
|
42
|
+
expect(addLanguageCodeToUri).toHaveBeenCalledWith(sampleRequest, expect.anything())
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('calls addLanguageCodeToUri with CANCEL_RP_COMPLETE uri', () => {
|
|
46
|
+
completion({})
|
|
47
|
+
expect(addLanguageCodeToUri).toHaveBeenCalledWith(expect.anything(), CANCEL_RP_COMPLETE.uri)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('returns the value of addLanguageCodeToUri', () => {
|
|
51
|
+
const expecetdUri = Symbol('cancel-rp-complete-uri')
|
|
52
|
+
addLanguageCodeToUri.mockReturnValueOnce(expecetdUri)
|
|
53
|
+
|
|
54
|
+
const completionRedirect = completion({})
|
|
55
|
+
|
|
56
|
+
expect(completionRedirect).toBe(expecetdUri)
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
describe('getData function', () => {
|
|
61
|
+
beforeEach(() => {
|
|
62
|
+
jest.clearAllMocks()
|
|
63
|
+
moment.mockReturnValue({ format: jest.fn(() => '18th November, 2025') })
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const mockRequest = () => {
|
|
67
|
+
const getCurrentPermission = jest.fn(() => ({ recurringPayment: { endDate: '2025-02-15' } }))
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
locale: 'en',
|
|
71
|
+
cache: () => ({
|
|
72
|
+
helpers: {
|
|
73
|
+
transaction: {
|
|
74
|
+
getCurrentPermission
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
it('calls addLanguageCodeToUri with request object', async () => {
|
|
82
|
+
const request = mockRequest()
|
|
83
|
+
await getData(request)
|
|
84
|
+
expect(addLanguageCodeToUri).toHaveBeenCalledWith(request, expect.anything())
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('calls addLanguageCodeToUri with CANCEL_RP_IDENTIFY uri', async () => {
|
|
88
|
+
const request = mockRequest()
|
|
89
|
+
await getData(request)
|
|
90
|
+
expect(addLanguageCodeToUri).toHaveBeenCalledWith(expect.anything(), CANCEL_RP_IDENTIFY.uri)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('cancelRpIdentify uri is equal to return of addLanguageCodeToUri for CANCEL_RP_IDENTIFY page', async () => {
|
|
94
|
+
const expectedUri = Symbol('expected-cancel-rp-identify-uri')
|
|
95
|
+
addLanguageCodeToUri.mockReturnValueOnce(expectedUri)
|
|
96
|
+
|
|
97
|
+
const data = await getData(mockRequest())
|
|
98
|
+
|
|
99
|
+
expect(data.uri).toEqual({
|
|
100
|
+
cancelRpIdentify: expectedUri
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('returns licenceExpiry in correct format', async () => {
|
|
105
|
+
const mockFormat = jest.fn().mockReturnValue('19th November, 2025')
|
|
106
|
+
moment.mockReturnValue({ format: mockFormat })
|
|
107
|
+
|
|
108
|
+
const data = await getData(mockRequest())
|
|
109
|
+
|
|
110
|
+
expect(data.licenceExpiry).toEqual('19th November, 2025')
|
|
111
|
+
})
|
|
112
|
+
})
|
|
@@ -2,23 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
{% from "button/macro.njk" import govukButton %}
|
|
4
4
|
{% from "page-title.njk" import pageTitle %}
|
|
5
|
+
{% from "fieldset/macro.njk" import govukFieldset %}
|
|
5
6
|
|
|
6
7
|
{% set title = mssgs.rp_cancel_confirm_title %}
|
|
7
8
|
{% block pageTitle %}{{ pageTitle(title, error, mssgs) }}{% endblock %}
|
|
8
9
|
|
|
9
10
|
{% block content %}
|
|
10
|
-
|
|
11
|
+
{% set legendHtml %}
|
|
12
|
+
<span class="govuk-caption-l">{{ mssgs.cancel_rp_identify_caption }}</span>
|
|
13
|
+
{{ title }}
|
|
14
|
+
{% endset %}
|
|
15
|
+
|
|
16
|
+
{% call govukFieldset({
|
|
17
|
+
legend: {
|
|
18
|
+
html: legendHtml,
|
|
19
|
+
classes: "govuk-fieldset__legend--l govuk-!-margin-bottom-3",
|
|
20
|
+
isPageHeading: true
|
|
21
|
+
}
|
|
22
|
+
}) %}
|
|
23
|
+
|
|
24
|
+
<p class="govuk-body-m">{{ mssgs.rp_cancel_confirm_body }}</p>
|
|
25
|
+
|
|
26
|
+
<div class="govuk-grid-row">
|
|
11
27
|
<div class="govuk-grid-column-two-thirds">
|
|
12
28
|
<form method="post" class="govuk-!-margin-bottom-6">
|
|
13
29
|
{{ govukButton({
|
|
14
30
|
attributes: { id: 'continue' },
|
|
15
31
|
preventDoubleClick: true,
|
|
16
32
|
name: "continue",
|
|
17
|
-
text: mssgs.
|
|
33
|
+
text: mssgs.rp_cancel_confirm_accept,
|
|
18
34
|
classes: "govuk-!-margin-top-1"
|
|
19
35
|
}) }}
|
|
20
36
|
{{ csrf() }}
|
|
21
37
|
</form>
|
|
38
|
+
<p class="govuk-body no-print"><a class="govuk-link" href="{{ data.uri.cancelRpIdentify }}">{{ mssgs.rp_cancel_confirm_reject }}</a></p>
|
|
22
39
|
</div>
|
|
23
|
-
</div>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
{% endcall %}
|
|
24
43
|
{% endblock %}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import pageRoute from '../../../../routes/page-route.js'
|
|
2
|
-
import { CANCEL_RP_CONFIRM,
|
|
2
|
+
import { CANCEL_RP_COMPLETE, CANCEL_RP_CONFIRM, CANCEL_RP_IDENTIFY } from '../../../../uri.js'
|
|
3
3
|
import { addLanguageCodeToUri } from '../../../../processors/uri-helper.js'
|
|
4
|
+
import { cacheDateFormat } from '../../../../processors/date-and-time-display.js'
|
|
5
|
+
import moment from 'moment-timezone'
|
|
6
|
+
|
|
7
|
+
const getData = async request => {
|
|
8
|
+
const permission = await request.cache().helpers.transaction.getCurrentPermission()
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
licenceExpiry: moment(permission.recurringPayment.endDate, cacheDateFormat, request.locale).format('Do MMMM, YYYY'),
|
|
12
|
+
uri: {
|
|
13
|
+
cancelRpIdentify: addLanguageCodeToUri(request, CANCEL_RP_IDENTIFY.uri)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
4
17
|
|
|
5
18
|
export default pageRoute(
|
|
6
19
|
CANCEL_RP_CONFIRM.page,
|
|
7
20
|
CANCEL_RP_CONFIRM.uri,
|
|
8
21
|
() => {},
|
|
9
22
|
request => addLanguageCodeToUri(request, CANCEL_RP_COMPLETE.uri),
|
|
10
|
-
|
|
23
|
+
getData
|
|
11
24
|
)
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import pageRoute from '../../../../../routes/page-route.js'
|
|
2
|
-
import { CANCEL_RP_CONFIRM, CANCEL_RP_COMPLETE } from '../../../../../uri.js'
|
|
3
|
-
import { addLanguageCodeToUri } from '../../../../../processors/uri-helper.js'
|
|
4
|
-
|
|
5
|
-
require('../route.js')
|
|
6
|
-
// eslint-disable-next-line no-unused-vars
|
|
7
|
-
const [[_v, _p, validator, completion, getData]] = pageRoute.mock.calls
|
|
8
|
-
|
|
9
|
-
jest.mock('../../../../../routes/page-route.js')
|
|
10
|
-
jest.mock('../../../../../uri.js', () => ({
|
|
11
|
-
...jest.requireActual('../../../../../uri.js'),
|
|
12
|
-
CANCEL_RP_CONFIRM: { page: Symbol('cancel-rp-confirm-page'), uri: Symbol('cancel-rp-confirm-uri') },
|
|
13
|
-
CANCEL_RP_COMPLETE: { uri: Symbol('cancel-rp-complete-uri') }
|
|
14
|
-
}))
|
|
15
|
-
jest.mock('../../../../../processors/uri-helper.js')
|
|
16
|
-
|
|
17
|
-
describe('pageRoute receives expected arguments', () => {
|
|
18
|
-
it('passes CANCEL_RP_CONFIRM.page as the view name', () => {
|
|
19
|
-
jest.isolateModules(() => {
|
|
20
|
-
require('../route.js')
|
|
21
|
-
expect(pageRoute).toHaveBeenCalledWith(
|
|
22
|
-
CANCEL_RP_CONFIRM.page,
|
|
23
|
-
expect.anything(),
|
|
24
|
-
expect.anything(),
|
|
25
|
-
expect.anything(),
|
|
26
|
-
expect.anything()
|
|
27
|
-
)
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('passes CANCEL_RP_CONFIRM.uri as the path', () => {
|
|
32
|
-
jest.isolateModules(() => {
|
|
33
|
-
require('../route.js')
|
|
34
|
-
expect(pageRoute).toHaveBeenCalledWith(
|
|
35
|
-
expect.anything(),
|
|
36
|
-
CANCEL_RP_CONFIRM.uri,
|
|
37
|
-
expect.anything(),
|
|
38
|
-
expect.anything(),
|
|
39
|
-
expect.anything()
|
|
40
|
-
)
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('passes a function as the validator', () => {
|
|
45
|
-
jest.isolateModules(() => {
|
|
46
|
-
require('../route.js')
|
|
47
|
-
expect(pageRoute).toHaveBeenCalledWith(
|
|
48
|
-
expect.anything(),
|
|
49
|
-
expect.anything(),
|
|
50
|
-
expect.any(Function),
|
|
51
|
-
expect.anything(),
|
|
52
|
-
expect.anything()
|
|
53
|
-
)
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
it('passes a function to generate redirect location on completion', () => {
|
|
58
|
-
jest.isolateModules(() => {
|
|
59
|
-
require('../route.js')
|
|
60
|
-
expect(pageRoute).toHaveBeenCalledWith(
|
|
61
|
-
expect.anything(),
|
|
62
|
-
expect.anything(),
|
|
63
|
-
expect.anything(),
|
|
64
|
-
expect.any(Function),
|
|
65
|
-
expect.anything()
|
|
66
|
-
)
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('passes a function to get the page data', () => {
|
|
71
|
-
jest.isolateModules(() => {
|
|
72
|
-
require('../route.js')
|
|
73
|
-
expect(pageRoute).toHaveBeenCalledWith(
|
|
74
|
-
expect.anything(),
|
|
75
|
-
expect.anything(),
|
|
76
|
-
expect.anything(),
|
|
77
|
-
expect.anything(),
|
|
78
|
-
expect.any(Function)
|
|
79
|
-
)
|
|
80
|
-
})
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
describe('completion function', () => {
|
|
85
|
-
beforeEach(jest.clearAllMocks)
|
|
86
|
-
|
|
87
|
-
it('calls addLanguageCodeToUri with request object', () => {
|
|
88
|
-
const sampleRequest = Symbol('sample request')
|
|
89
|
-
completion(sampleRequest)
|
|
90
|
-
expect(addLanguageCodeToUri).toHaveBeenCalledWith(sampleRequest, expect.anything())
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
it('calls addLanguageCodeToUri with CANCEL_RP_AUTHENTICATE uri', () => {
|
|
94
|
-
completion({})
|
|
95
|
-
expect(addLanguageCodeToUri).toHaveBeenCalledWith(expect.anything(), CANCEL_RP_COMPLETE.uri)
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
it('returns the value of addLanguageCodeToUri', () => {
|
|
99
|
-
const expectedCompletionRedirect = Symbol('expected-completion-redirect')
|
|
100
|
-
addLanguageCodeToUri.mockReturnValueOnce(expectedCompletionRedirect)
|
|
101
|
-
|
|
102
|
-
const completionRedirect = completion({})
|
|
103
|
-
|
|
104
|
-
expect(completionRedirect).toBe(expectedCompletionRedirect)
|
|
105
|
-
})
|
|
106
|
-
})
|