@defra-fish/gafl-webapp-service 1.65.0-rc.1 → 1.65.0-rc.2
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__/cancel-recurring-payment-authentication-handler.spec.js +50 -41
- package/src/handlers/cancel-recurring-payment-authentication-handler.js +19 -25
- package/src/locales/cy.json +13 -0
- package/src/locales/en.json +13 -0
- package/src/pages/recurring-payments/cancel/agreement-not-found/__tests__/route.spec.js +129 -0
- package/src/pages/recurring-payments/cancel/agreement-not-found/cancel-rp-agreement-not-found.njk +15 -0
- package/src/pages/recurring-payments/cancel/agreement-not-found/route.js +23 -0
- package/src/routes/__tests__/__snapshots__/telesales-routes.spec.js.snap +16 -0
- package/src/routes/journey-definition.js +6 -1
- package/src/routes/telesales-routes.js +2 -4
- package/src/uri.js +4 -0
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.2",
|
|
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.2",
|
|
40
|
+
"@defra-fish/connectors-lib": "1.65.0-rc.2",
|
|
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": "2f8e3ec17ed29caf89f585324d8dd4b725ff4586"
|
|
83
83
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import handler from '../cancel-recurring-payment-authentication-handler'
|
|
2
|
-
import { CANCEL_RP_IDENTIFY, CANCEL_RP_DETAILS } from '../../uri.js'
|
|
3
|
-
import { addLanguageCodeToUri } from '../../processors/uri-helper.js'
|
|
2
|
+
import { CANCEL_RP_IDENTIFY, CANCEL_RP_DETAILS, CANCEL_RP_AGREEMENT_NOT_FOUND } from '../../uri.js'
|
|
4
3
|
import { salesApi } from '@defra-fish/connectors-lib'
|
|
5
4
|
|
|
6
5
|
jest.mock('../../processors/uri-helper.js')
|
|
@@ -19,7 +18,8 @@ jest.mock('@defra-fish/business-rules-lib', () => ({
|
|
|
19
18
|
}))
|
|
20
19
|
jest.mock('../../uri.js', () => ({
|
|
21
20
|
CANCEL_RP_IDENTIFY: { page: 'cancel-rp-identify page', uri: Symbol('cancel-rp-identify-uri') },
|
|
22
|
-
CANCEL_RP_DETAILS: { uri: Symbol('cancel-rp-details-uri') }
|
|
21
|
+
CANCEL_RP_DETAILS: { uri: Symbol('cancel-rp-details-uri') },
|
|
22
|
+
CANCEL_RP_AGREEMENT_NOT_FOUND: { uri: Symbol('cancel-rp-agreement-not-found-uri') }
|
|
23
23
|
}))
|
|
24
24
|
jest.mock('../../processors/recurring-payments-write-cache.js')
|
|
25
25
|
|
|
@@ -52,22 +52,15 @@ const getSampleRequest = (payloadOverride = {}) => {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const
|
|
56
|
-
redirectWithLanguageCode: jest.fn()
|
|
55
|
+
const getSampleResponseToolkit = () => ({
|
|
56
|
+
redirectWithLanguageCode: jest.fn(() => 'redirected')
|
|
57
57
|
})
|
|
58
58
|
|
|
59
|
-
const invokeHandlerWithMocks = async ({
|
|
60
|
-
if (
|
|
59
|
+
const invokeHandlerWithMocks = async ({ h = getSampleResponseToolkit(), salesApiResponse } = {}) => {
|
|
60
|
+
if (salesApiResponse) {
|
|
61
61
|
salesApi.authenticateRecurringPayment.mockResolvedValueOnce(salesApiResponse)
|
|
62
62
|
}
|
|
63
|
-
if (decoratedIdentifyUri) {
|
|
64
|
-
addLanguageCodeToUri.mockReturnValueOnce(decoratedIdentifyUri)
|
|
65
|
-
}
|
|
66
63
|
const request = getSampleRequest()
|
|
67
|
-
const h = getSampleResponseTooklkit()
|
|
68
|
-
if (decoratedIdentifyUri) {
|
|
69
|
-
h.redirect = jest.fn().mockReturnValue('redirect-response')
|
|
70
|
-
}
|
|
71
64
|
const result = await handler(request, h)
|
|
72
65
|
return { request, h, result }
|
|
73
66
|
}
|
|
@@ -106,13 +99,24 @@ describe('Cancel RP Authentication Handler', () => {
|
|
|
106
99
|
})
|
|
107
100
|
|
|
108
101
|
describe('Unsuccessful authentication - no match', () => {
|
|
109
|
-
it('redirects to the
|
|
110
|
-
const { h } = await invokeHandlerWithMocks({ salesApiResponse: null
|
|
111
|
-
expect(h.
|
|
102
|
+
it('redirects to the CANCEL_RP_IDENTIFY.uri', async () => {
|
|
103
|
+
const { h } = await invokeHandlerWithMocks({ salesApiResponse: null })
|
|
104
|
+
expect(h.redirectWithLanguageCode).toHaveBeenCalledWith(CANCEL_RP_IDENTIFY.uri)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('returns value of redirect', async () => {
|
|
108
|
+
const h = getSampleResponseToolkit()
|
|
109
|
+
const redirectResult = Symbol('redirected')
|
|
110
|
+
h.redirectWithLanguageCode.mockReturnValueOnce(redirectResult)
|
|
111
|
+
const { result } = await invokeHandlerWithMocks({
|
|
112
|
+
h,
|
|
113
|
+
salesApiResponse: null
|
|
114
|
+
})
|
|
115
|
+
expect(result).toBe(redirectResult)
|
|
112
116
|
})
|
|
113
117
|
|
|
114
118
|
it('sets page cache error and preserves payload', async () => {
|
|
115
|
-
const { request } = await invokeHandlerWithMocks({ salesApiResponse: null
|
|
119
|
+
const { request } = await invokeHandlerWithMocks({ salesApiResponse: null })
|
|
116
120
|
expect(request.cache().helpers.page.setCurrentPermission).toHaveBeenCalledWith(
|
|
117
121
|
CANCEL_RP_IDENTIFY.page,
|
|
118
122
|
expect.objectContaining({
|
|
@@ -123,7 +127,7 @@ describe('Cancel RP Authentication Handler', () => {
|
|
|
123
127
|
})
|
|
124
128
|
|
|
125
129
|
it('marks status as unauthorised', async () => {
|
|
126
|
-
const { request } = await invokeHandlerWithMocks({ salesApiResponse: null
|
|
130
|
+
const { request } = await invokeHandlerWithMocks({ salesApiResponse: null })
|
|
127
131
|
expect(request.cache().helpers.status.setCurrentPermission).toHaveBeenCalledWith(
|
|
128
132
|
expect.objectContaining({ authentication: { authorised: false } })
|
|
129
133
|
)
|
|
@@ -131,26 +135,23 @@ describe('Cancel RP Authentication Handler', () => {
|
|
|
131
135
|
})
|
|
132
136
|
|
|
133
137
|
describe('Unsuccessful authentication - no recurring payment agreement', () => {
|
|
134
|
-
it('redirects to the
|
|
138
|
+
it('redirects to the CANCEL_RP_AGREEMENT_NOT_FOUND.uri', async () => {
|
|
135
139
|
const { h } = await invokeHandlerWithMocks({
|
|
136
140
|
salesApiResponse: { permission: { id: 'perm-id' }, recurringPayment: null },
|
|
137
141
|
decoratedIdentifyUri: 'decorated-identify-uri'
|
|
138
142
|
})
|
|
139
|
-
expect(h.
|
|
143
|
+
expect(h.redirectWithLanguageCode).toHaveBeenCalledWith(CANCEL_RP_AGREEMENT_NOT_FOUND.uri)
|
|
140
144
|
})
|
|
141
145
|
|
|
142
|
-
it('
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
it('returns value of redirect', async () => {
|
|
147
|
+
const h = getSampleResponseToolkit()
|
|
148
|
+
const redirectResult = Symbol('redirected')
|
|
149
|
+
h.redirectWithLanguageCode.mockReturnValueOnce(redirectResult)
|
|
150
|
+
const { result } = await invokeHandlerWithMocks({
|
|
151
|
+
h,
|
|
152
|
+
salesApiResponse: { permission: { id: 'perm-id' }, recurringPayment: null }
|
|
146
153
|
})
|
|
147
|
-
expect(
|
|
148
|
-
CANCEL_RP_IDENTIFY.page,
|
|
149
|
-
expect.objectContaining({
|
|
150
|
-
payload: expect.any(Object),
|
|
151
|
-
error: { recurringPayment: 'not-set-up' }
|
|
152
|
-
})
|
|
153
|
-
)
|
|
154
|
+
expect(result).toBe(redirectResult)
|
|
154
155
|
})
|
|
155
156
|
|
|
156
157
|
it('marks status as unauthorised', async () => {
|
|
@@ -165,18 +166,27 @@ describe('Cancel RP Authentication Handler', () => {
|
|
|
165
166
|
})
|
|
166
167
|
|
|
167
168
|
describe('Unsuccessful authentication - RCP cancelled', () => {
|
|
168
|
-
it('redirects to the
|
|
169
|
+
it('redirects to the CANCEL_RP_IDENTIFY.uri', async () => {
|
|
169
170
|
const { h } = await invokeHandlerWithMocks({
|
|
170
|
-
salesApiResponse: { permission: { id: 'perm-id' }, recurringPayment: { id: 'rcp-id', status: 1, cancelledDate: '2024-01-01' } }
|
|
171
|
-
decoratedIdentifyUri: 'decorated-identify-uri'
|
|
171
|
+
salesApiResponse: { permission: { id: 'perm-id' }, recurringPayment: { id: 'rcp-id', status: 1, cancelledDate: '2024-01-01' } }
|
|
172
172
|
})
|
|
173
|
-
expect(h.
|
|
173
|
+
expect(h.redirectWithLanguageCode).toHaveBeenCalledWith(CANCEL_RP_IDENTIFY.uri)
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('returns value of redirect', async () => {
|
|
177
|
+
const h = getSampleResponseToolkit()
|
|
178
|
+
const redirectResult = Symbol('redirected')
|
|
179
|
+
h.redirectWithLanguageCode.mockReturnValueOnce(redirectResult)
|
|
180
|
+
const { result } = await invokeHandlerWithMocks({
|
|
181
|
+
h,
|
|
182
|
+
salesApiResponse: { permission: { id: 'perm-id' }, recurringPayment: { id: 'rcp-id', status: 1, cancelledDate: '2024-01-01' } }
|
|
183
|
+
})
|
|
184
|
+
expect(result).toBe(redirectResult)
|
|
174
185
|
})
|
|
175
186
|
|
|
176
187
|
it('sets page cache error for RCP cancelled', async () => {
|
|
177
188
|
const { request } = await invokeHandlerWithMocks({
|
|
178
|
-
salesApiResponse: { permission: { id: 'perm-id' }, recurringPayment: { id: 'rcp-id', status: 1, cancelledDate: '2024-01-01' } }
|
|
179
|
-
decoratedIdentifyUri: 'decorated-identify-uri'
|
|
189
|
+
salesApiResponse: { permission: { id: 'perm-id' }, recurringPayment: { id: 'rcp-id', status: 1, cancelledDate: '2024-01-01' } }
|
|
180
190
|
})
|
|
181
191
|
expect(request.cache().helpers.page.setCurrentPermission).toHaveBeenCalledWith(
|
|
182
192
|
CANCEL_RP_IDENTIFY.page,
|
|
@@ -189,8 +199,7 @@ describe('Cancel RP Authentication Handler', () => {
|
|
|
189
199
|
|
|
190
200
|
it('marks status as unauthorised', async () => {
|
|
191
201
|
const { request } = await invokeHandlerWithMocks({
|
|
192
|
-
salesApiResponse: { permission: { id: 'perm-id' }, recurringPayment: { id: 'rcp-id', status: 1, cancelledDate: '2024-01-01' } }
|
|
193
|
-
decoratedIdentifyUri: 'decorated-identify-uri'
|
|
202
|
+
salesApiResponse: { permission: { id: 'perm-id' }, recurringPayment: { id: 'rcp-id', status: 1, cancelledDate: '2024-01-01' } }
|
|
194
203
|
})
|
|
195
204
|
expect(request.cache().helpers.status.setCurrentPermission).toHaveBeenCalledWith(
|
|
196
205
|
expect.objectContaining({ authentication: { authorised: false } })
|
|
@@ -207,7 +216,7 @@ describe('Cancel RP Authentication Handler', () => {
|
|
|
207
216
|
request.cache().helpers.status.getCurrentPermission.mockReturnValueOnce({
|
|
208
217
|
referenceNumber: 'A1B2C3'
|
|
209
218
|
})
|
|
210
|
-
const h =
|
|
219
|
+
const h = getSampleResponseToolkit()
|
|
211
220
|
await handler(request, h)
|
|
212
221
|
expect(salesApi.authenticateRecurringPayment).toHaveBeenCalledWith('A1B2C3', expect.anything(), expect.anything())
|
|
213
222
|
})
|
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
import { CANCEL_RP_IDENTIFY, CANCEL_RP_DETAILS } from '../../src/uri.js'
|
|
2
|
-
import { addLanguageCodeToUri } from '../processors/uri-helper.js'
|
|
1
|
+
import { CANCEL_RP_IDENTIFY, CANCEL_RP_DETAILS, CANCEL_RP_AGREEMENT_NOT_FOUND } from '../../src/uri.js'
|
|
3
2
|
import { salesApi } from '@defra-fish/connectors-lib'
|
|
4
3
|
import { validation } from '@defra-fish/business-rules-lib'
|
|
5
4
|
import { setupCancelRecurringPaymentCacheFromAuthResult } from '../processors/recurring-payments-write-cache.js'
|
|
6
5
|
import Joi from 'joi'
|
|
7
6
|
|
|
8
|
-
const
|
|
9
|
-
page
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
status: {
|
|
14
|
-
referenceNumber,
|
|
15
|
-
authentication: { authorised: false }
|
|
16
|
-
},
|
|
17
|
-
redirectPath: CANCEL_RP_IDENTIFY.uri
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const applyAuthFailure = async (request, h, failure) => {
|
|
21
|
-
await request.cache().helpers.page.setCurrentPermission(failure.page.page, failure.page.data)
|
|
22
|
-
await request.cache().helpers.status.setCurrentPermission(failure.status)
|
|
23
|
-
return h.redirect(addLanguageCodeToUri(request, failure.redirectPath))
|
|
7
|
+
const applyAuthFailure = async (request, h, { pageData, redirectUri, statusData }) => {
|
|
8
|
+
await request.cache().helpers.page.setCurrentPermission(CANCEL_RP_IDENTIFY.page, pageData)
|
|
9
|
+
await request.cache().helpers.status.setCurrentPermission(statusData)
|
|
10
|
+
return h.redirectWithLanguageCode(redirectUri)
|
|
24
11
|
}
|
|
25
12
|
|
|
26
13
|
const cancelRecurringPaymentAuthenticationHandler = async (request, h) => {
|
|
@@ -36,16 +23,23 @@ const cancelRecurringPaymentAuthenticationHandler = async (request, h) => {
|
|
|
36
23
|
|
|
37
24
|
const authenticationResult = await salesApi.authenticateRecurringPayment(referenceNumber, dateOfBirth, postcode)
|
|
38
25
|
|
|
39
|
-
const
|
|
26
|
+
const context = {
|
|
27
|
+
pageData: { payload },
|
|
28
|
+
statusData: { referenceNumber, authentication: { authorised: false } },
|
|
29
|
+
redirectUri: CANCEL_RP_IDENTIFY.uri
|
|
30
|
+
}
|
|
40
31
|
|
|
41
32
|
if (!authenticationResult) {
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
context.pageData.error = { referenceNumber: 'not-found' }
|
|
34
|
+
} else if (!authenticationResult.recurringPayment) {
|
|
35
|
+
context.pageData.errorRedirect = true
|
|
36
|
+
context.redirectUri = CANCEL_RP_AGREEMENT_NOT_FOUND.uri
|
|
37
|
+
} else if (authenticationResult.recurringPayment.cancelledDate) {
|
|
38
|
+
context.pageData.error = { recurringPayment: 'rcp-cancelled' }
|
|
46
39
|
}
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
|
|
41
|
+
if (context.pageData.error || context.pageData.errorRedirect) {
|
|
42
|
+
return applyAuthFailure(request, h, context)
|
|
49
43
|
}
|
|
50
44
|
|
|
51
45
|
await setupCancelRecurringPaymentCacheFromAuthResult(request, authenticationResult)
|
package/src/locales/cy.json
CHANGED
|
@@ -787,6 +787,19 @@
|
|
|
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
|
+
"rp_cancel_confirm_title": "Cancel your recurring card payment agreement - confirm",
|
|
791
|
+
"rp_cancel_details_title": "Cancel your recurring card payment agreement - details",
|
|
792
|
+
"rp_cancel_identify_title": "Cancel your recurring card payment agreement - identify",
|
|
793
|
+
"rp_cancel_no_agreement_found_title": "Agreement not found - Cancel your recurring card payment",
|
|
794
|
+
"rp_cancel_no_agreement_found_heading": "There is no recurring card payment linked to this licence",
|
|
795
|
+
"rp_cancel_no_agreement_found_licence_will_not_renew_1": "Licence ending ",
|
|
796
|
+
"rp_cancel_no_agreement_found_licence_will_not_renew_2": " will not renew automatically.",
|
|
797
|
+
"rp_cancel_no_agreement_found_go_back_link": "Go back",
|
|
798
|
+
"rp_cancel_no_agreement_found_go_back_instruction": " to cancel the recurring card payment for a different licence.",
|
|
799
|
+
"rp_cancel_no_agreement_found_need_help_1": "If you need help email ",
|
|
800
|
+
"rp_cancel_no_agreement_found_need_help_email": "enquiries@environment-agency.gov.uk",
|
|
801
|
+
"rp_cancel_no_agreement_found_need_help_2": " or call 03708 506 506 (8am to 6pm, Monday to Friday, except public holidays). ",
|
|
802
|
+
"rp_cancel_no_agreement_found_call_charges_link": "View call charges (opens in new tab).",
|
|
790
803
|
"rp_cancel_confirm_accept": "Yes, cancel my recurring payment agreement",
|
|
791
804
|
"rp_cancel_confirm_body": "Your current licence will reman valid until it expires on ",
|
|
792
805
|
"rp_cancel_confirm_reject": "No, I've changed my mind",
|
package/src/locales/en.json
CHANGED
|
@@ -787,6 +787,19 @@
|
|
|
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
|
+
"rp_cancel_confirm_title": "Cancel your recurring card payment agreement - confirm",
|
|
791
|
+
"rp_cancel_details_title": "Cancel your recurring card payment agreement - details",
|
|
792
|
+
"rp_cancel_identify_title": "Cancel your recurring card payment agreement - identify",
|
|
793
|
+
"rp_cancel_no_agreement_found_title": "Agreement not found - Cancel your recurring card payment",
|
|
794
|
+
"rp_cancel_no_agreement_found_heading": "There is no recurring card payment linked to this licence",
|
|
795
|
+
"rp_cancel_no_agreement_found_licence_will_not_renew_1": "Licence ending ",
|
|
796
|
+
"rp_cancel_no_agreement_found_licence_will_not_renew_2": " will not renew automatically.",
|
|
797
|
+
"rp_cancel_no_agreement_found_go_back_link": "Go back",
|
|
798
|
+
"rp_cancel_no_agreement_found_go_back_instruction": " to cancel the recurring card payment for a different licence.",
|
|
799
|
+
"rp_cancel_no_agreement_found_need_help_1": "If you need help email ",
|
|
800
|
+
"rp_cancel_no_agreement_found_need_help_email": "enquiries@environment-agency.gov.uk",
|
|
801
|
+
"rp_cancel_no_agreement_found_need_help_2": " or call 03708 506 506 (8am to 6pm, Monday to Friday, except public holidays). ",
|
|
802
|
+
"rp_cancel_no_agreement_found_call_charges_link": "View call charges (opens in new tab).",
|
|
790
803
|
"rp_cancel_confirm_accept": "Yes, cancel my recurring payment agreement",
|
|
791
804
|
"rp_cancel_confirm_body": "Your current licence will reman valid until it expires on ",
|
|
792
805
|
"rp_cancel_confirm_reject": "No, I've changed my mind",
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import pageRoute from '../../../../../routes/page-route.js'
|
|
2
|
+
import { CANCEL_RP_AGREEMENT_NOT_FOUND, CANCEL_RP_IDENTIFY } from '../../../../../uri.js'
|
|
3
|
+
|
|
4
|
+
require('../route.js')
|
|
5
|
+
// eslint-disable-next-line no-unused-vars
|
|
6
|
+
const [[_v, _p, validator, completion, getData]] = pageRoute.mock.calls
|
|
7
|
+
|
|
8
|
+
jest.mock('../../../../../routes/page-route.js')
|
|
9
|
+
jest.mock('../../../../../uri.js', () => ({
|
|
10
|
+
...jest.requireActual('../../../../../uri.js'),
|
|
11
|
+
CANCEL_RP_IDENTIFY: { page: Symbol('cancel-rp-identify-page') },
|
|
12
|
+
CANCEL_RP_AGREEMENT_NOT_FOUND: { page: Symbol('cancel-rp-agreement-not-found-page'), uri: Symbol('cancel-rp-agreement-not-found-uri') }
|
|
13
|
+
}))
|
|
14
|
+
jest.mock('../../../../../processors/uri-helper.js')
|
|
15
|
+
|
|
16
|
+
const getSampleRequest = (referenceNumber = 'RP12345678') => ({
|
|
17
|
+
cache: jest.fn(() => ({
|
|
18
|
+
helpers: {
|
|
19
|
+
page: {
|
|
20
|
+
getCurrentPermission: jest.fn(() => ({ payload: { referenceNumber } }))
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}))
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
describe('pageRoute receives expected arguments', () => {
|
|
27
|
+
it('passes CANCEL_RP_AGREEMENT_NOT_FOUND.page as the view name', () => {
|
|
28
|
+
jest.isolateModules(() => {
|
|
29
|
+
require('../route.js')
|
|
30
|
+
expect(pageRoute).toHaveBeenCalledWith(
|
|
31
|
+
CANCEL_RP_AGREEMENT_NOT_FOUND.page,
|
|
32
|
+
expect.anything(),
|
|
33
|
+
expect.anything(),
|
|
34
|
+
expect.anything(),
|
|
35
|
+
expect.anything()
|
|
36
|
+
)
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('passes CANCEL_RP_AGREEMENT_NOT_FOUND.uri as the path', () => {
|
|
41
|
+
jest.isolateModules(() => {
|
|
42
|
+
require('../route.js')
|
|
43
|
+
expect(pageRoute).toHaveBeenCalledWith(
|
|
44
|
+
expect.anything(),
|
|
45
|
+
CANCEL_RP_AGREEMENT_NOT_FOUND.uri,
|
|
46
|
+
expect.anything(),
|
|
47
|
+
expect.anything(),
|
|
48
|
+
expect.anything()
|
|
49
|
+
)
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('passes a function as the validator', () => {
|
|
54
|
+
jest.isolateModules(() => {
|
|
55
|
+
require('../route.js')
|
|
56
|
+
expect(pageRoute).toHaveBeenCalledWith(
|
|
57
|
+
expect.anything(),
|
|
58
|
+
expect.anything(),
|
|
59
|
+
expect.any(Function),
|
|
60
|
+
expect.anything(),
|
|
61
|
+
expect.anything()
|
|
62
|
+
)
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('passes a function to generate redirect location on completion', () => {
|
|
67
|
+
jest.isolateModules(() => {
|
|
68
|
+
require('../route.js')
|
|
69
|
+
expect(pageRoute).toHaveBeenCalledWith(
|
|
70
|
+
expect.anything(),
|
|
71
|
+
expect.anything(),
|
|
72
|
+
expect.anything(),
|
|
73
|
+
expect.any(Function),
|
|
74
|
+
expect.anything()
|
|
75
|
+
)
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('passes a function to get the page data', () => {
|
|
80
|
+
jest.isolateModules(() => {
|
|
81
|
+
require('../route.js')
|
|
82
|
+
expect(pageRoute).toHaveBeenCalledWith(
|
|
83
|
+
expect.anything(),
|
|
84
|
+
expect.anything(),
|
|
85
|
+
expect.anything(),
|
|
86
|
+
expect.anything(),
|
|
87
|
+
expect.any(Function)
|
|
88
|
+
)
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
describe('getData', () => {
|
|
94
|
+
it('passes call charges link in list of urls', async () => {
|
|
95
|
+
expect(await getData(getSampleRequest())).toEqual(
|
|
96
|
+
expect.objectContaining({
|
|
97
|
+
links: expect.objectContaining({
|
|
98
|
+
callCharges: 'https://www.gov.uk/call-charges'
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('passes contact us email in list of urls', async () => {
|
|
105
|
+
expect(await getData(getSampleRequest())).toEqual(
|
|
106
|
+
expect.objectContaining({
|
|
107
|
+
links: expect.objectContaining({
|
|
108
|
+
contactUs: 'mailto:enquiries@environment-agency.gov.uk'
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
)
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('requests page data from CANCEL_RP_IDENTIFY page', async () => {
|
|
115
|
+
const request = getSampleRequest()
|
|
116
|
+
await getData(request)
|
|
117
|
+
const [{ value: pageCache }] = request.cache.mock.results
|
|
118
|
+
expect(pageCache.helpers.page.getCurrentPermission).toHaveBeenCalledWith(CANCEL_RP_IDENTIFY.page)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('passes reference number from CANCEL_RP_IDENTIFY page data', async () => {
|
|
122
|
+
const referenceNumber = 'RP87654321'
|
|
123
|
+
expect(await getData(getSampleRequest(referenceNumber))).toEqual(
|
|
124
|
+
expect.objectContaining({
|
|
125
|
+
referenceNumber
|
|
126
|
+
})
|
|
127
|
+
)
|
|
128
|
+
})
|
|
129
|
+
})
|
package/src/pages/recurring-payments/cancel/agreement-not-found/cancel-rp-agreement-not-found.njk
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{% extends "layout.njk" %}
|
|
2
|
+
{% extends "standard-form.njk" %}
|
|
3
|
+
|
|
4
|
+
{% set title = mssgs.rp_cancel_no_agreement_found_title %}
|
|
5
|
+
|
|
6
|
+
{% block content %}
|
|
7
|
+
<div class="govuk-grid-row">
|
|
8
|
+
<div class="govuk-grid-column-two-thirds">
|
|
9
|
+
<h1 class="govuk-heading-l">{{ mssgs.rp_cancel_no_agreement_found_heading }}</h1>
|
|
10
|
+
<p class="govuk-body">{{ mssgs.rp_cancel_no_agreement_found_licence_will_not_renew_1 }}{{ data.referenceNumber }}{{ mssgs.rp_cancel_no_agreement_found_licence_will_not_renew_2 }}</p>
|
|
11
|
+
<p class="govuk-body"><a class="govuk-link" href="{{ backRef }}">{{ mssgs.rp_cancel_no_agreement_found_go_back_link }}</a>{{ mssgs.rp_cancel_no_agreement_found_go_back_instruction }}</p>
|
|
12
|
+
<p class="govuk-body">{{ mssgs.rp_cancel_no_agreement_found_need_help_1 }}<a class="govuk-link" href="mailto:{{ data.links.contactUs }}">{{ mssgs.rp_cancel_no_agreement_found_need_help_email }}</a>{{ mssgs.rp_cancel_no_agreement_found_need_help_2 }}<a class="govuk-link" href="{{ data.links.callCharges }}" target="_blank">{{ mssgs.rp_cancel_no_agreement_found_call_charges_link }}</a></p>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
{% endblock %}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import pageRoute from '../../../../routes/page-route.js'
|
|
2
|
+
import { CANCEL_RP_AGREEMENT_NOT_FOUND, CANCEL_RP_IDENTIFY } from '../../../../uri.js'
|
|
3
|
+
|
|
4
|
+
const getData = async request => {
|
|
5
|
+
const {
|
|
6
|
+
payload: { referenceNumber }
|
|
7
|
+
} = await request.cache().helpers.page.getCurrentPermission(CANCEL_RP_IDENTIFY.page)
|
|
8
|
+
return {
|
|
9
|
+
referenceNumber,
|
|
10
|
+
links: {
|
|
11
|
+
callCharges: 'https://www.gov.uk/call-charges',
|
|
12
|
+
contactUs: 'mailto:enquiries@environment-agency.gov.uk'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default pageRoute(
|
|
18
|
+
CANCEL_RP_AGREEMENT_NOT_FOUND.page,
|
|
19
|
+
CANCEL_RP_AGREEMENT_NOT_FOUND.uri,
|
|
20
|
+
() => {},
|
|
21
|
+
() => {},
|
|
22
|
+
getData
|
|
23
|
+
)
|
|
@@ -100,6 +100,22 @@ Object {
|
|
|
100
100
|
},
|
|
101
101
|
"path": "/buy/cancel-recurring-payment/complete",
|
|
102
102
|
},
|
|
103
|
+
Object {
|
|
104
|
+
"handler": [Function],
|
|
105
|
+
"method": "GET",
|
|
106
|
+
"path": "/buy/cancel-recurring-payment/agreement-not-found",
|
|
107
|
+
},
|
|
108
|
+
Object {
|
|
109
|
+
"handler": [Function],
|
|
110
|
+
"method": "POST",
|
|
111
|
+
"options": Object {
|
|
112
|
+
"validate": Object {
|
|
113
|
+
"failAction": [Function],
|
|
114
|
+
"payload": [Function],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
"path": "/buy/cancel-recurring-payment/agreement-not-found",
|
|
118
|
+
},
|
|
103
119
|
],
|
|
104
120
|
}
|
|
105
121
|
`;
|
|
@@ -33,7 +33,8 @@ import {
|
|
|
33
33
|
CANCEL_RP_IDENTIFY,
|
|
34
34
|
CANCEL_RP_DETAILS,
|
|
35
35
|
CANCEL_RP_CONFIRM,
|
|
36
|
-
CANCEL_RP_COMPLETE
|
|
36
|
+
CANCEL_RP_COMPLETE,
|
|
37
|
+
CANCEL_RP_AGREEMENT_NOT_FOUND
|
|
37
38
|
} from '../uri.js'
|
|
38
39
|
|
|
39
40
|
import { CommonResults, CONTACT_SUMMARY_SEEN, ShowDigitalLicencePages } from '../constants.js'
|
|
@@ -458,5 +459,9 @@ export default [
|
|
|
458
459
|
},
|
|
459
460
|
backLink: CANCEL_RP_DETAILS.uri
|
|
460
461
|
}
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
current: CANCEL_RP_AGREEMENT_NOT_FOUND,
|
|
465
|
+
backLink: CANCEL_RP_IDENTIFY.uri
|
|
461
466
|
}
|
|
462
467
|
]
|
|
@@ -4,6 +4,7 @@ import cancelRPIdentify from '../pages/recurring-payments/cancel/identify/route.
|
|
|
4
4
|
import cancelRPDetails from '../pages/recurring-payments/cancel/details/route.js'
|
|
5
5
|
import cancelRPConfirm from '../pages/recurring-payments/cancel/confirm/route.js'
|
|
6
6
|
import cancelRPComplete from '../pages/recurring-payments/cancel/complete/route.js'
|
|
7
|
+
import cancelRPAgreementNotFound from '../pages/recurring-payments/cancel/agreement-not-found/route.js'
|
|
7
8
|
|
|
8
9
|
const telesalesRoutes = [
|
|
9
10
|
{
|
|
@@ -32,9 +33,6 @@ const telesalesRoutes = [
|
|
|
32
33
|
]
|
|
33
34
|
|
|
34
35
|
if (process.env.SHOW_CANCELLATION_JOURNEY === 'true') {
|
|
35
|
-
telesalesRoutes.push(...cancelRPIdentify)
|
|
36
|
-
telesalesRoutes.push(...cancelRPDetails)
|
|
37
|
-
telesalesRoutes.push(...cancelRPConfirm)
|
|
38
|
-
telesalesRoutes.push(...cancelRPComplete)
|
|
36
|
+
telesalesRoutes.push(...cancelRPIdentify, ...cancelRPDetails, ...cancelRPConfirm, ...cancelRPComplete, ...cancelRPAgreementNotFound)
|
|
39
37
|
}
|
|
40
38
|
export default telesalesRoutes
|
package/src/uri.js
CHANGED
|
@@ -67,6 +67,10 @@ export const CANCEL_RP_AUTHENTICATE = { uri: '/buy/cancel-recurring-payment/auth
|
|
|
67
67
|
export const CANCEL_RP_DETAILS = { uri: '/buy/cancel-recurring-payment/details', page: 'cancel-rp-details' }
|
|
68
68
|
export const CANCEL_RP_CONFIRM = { uri: '/buy/cancel-recurring-payment/confirm', page: 'cancel-rp-confirm' }
|
|
69
69
|
export const CANCEL_RP_COMPLETE = { uri: '/buy/cancel-recurring-payment/complete', page: 'cancel-rp-complete' }
|
|
70
|
+
export const CANCEL_RP_AGREEMENT_NOT_FOUND = {
|
|
71
|
+
uri: '/buy/cancel-recurring-payment/agreement-not-found',
|
|
72
|
+
page: 'cancel-rp-agreement-not-found'
|
|
73
|
+
}
|
|
70
74
|
|
|
71
75
|
/**
|
|
72
76
|
* These are informational static pages
|