@defra-fish/gafl-webapp-service 1.65.0-rc.0 → 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 +16 -0
- package/src/locales/en.json +16 -0
- package/src/pages/recurring-payments/cancel/{confirm/__tests__/route.test.js → agreement-not-found/__tests__/route.spec.js} +47 -24
- 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/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/__tests__/__snapshots__/telesales-routes.spec.js.snap +16 -0
- package/src/routes/journey-definition.js +8 -2
- 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
|
@@ -788,6 +788,22 @@
|
|
|
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_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).",
|
|
803
|
+
"rp_cancel_confirm_accept": "Yes, cancel my recurring payment agreement",
|
|
804
|
+
"rp_cancel_confirm_body": "Your current licence will reman valid until it expires on ",
|
|
805
|
+
"rp_cancel_confirm_reject": "No, I've changed my mind",
|
|
806
|
+
"rp_cancel_confirm_title": "Confirm you want to cancel",
|
|
791
807
|
"rp_cancel_details_last_purchased": "Last licence purchased",
|
|
792
808
|
"rp_cancel_details_licence_holder": "Licence holder",
|
|
793
809
|
"rp_cancel_details_licence_type": "Licence type",
|
package/src/locales/en.json
CHANGED
|
@@ -788,6 +788,22 @@
|
|
|
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_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).",
|
|
803
|
+
"rp_cancel_confirm_accept": "Yes, cancel my recurring payment agreement",
|
|
804
|
+
"rp_cancel_confirm_body": "Your current licence will reman valid until it expires on ",
|
|
805
|
+
"rp_cancel_confirm_reject": "No, I've changed my mind",
|
|
806
|
+
"rp_cancel_confirm_title": "Confirm you want to cancel",
|
|
791
807
|
"rp_cancel_details_last_purchased": "Last licence purchased",
|
|
792
808
|
"rp_cancel_details_licence_holder": "Licence holder",
|
|
793
809
|
"rp_cancel_details_licence_type": "Licence type",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import pageRoute from '../../../../../routes/page-route.js'
|
|
2
|
-
import {
|
|
3
|
-
import { addLanguageCodeToUri } from '../../../../../processors/uri-helper.js'
|
|
2
|
+
import { CANCEL_RP_AGREEMENT_NOT_FOUND, CANCEL_RP_IDENTIFY } from '../../../../../uri.js'
|
|
4
3
|
|
|
5
4
|
require('../route.js')
|
|
6
5
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -9,17 +8,27 @@ const [[_v, _p, validator, completion, getData]] = pageRoute.mock.calls
|
|
|
9
8
|
jest.mock('../../../../../routes/page-route.js')
|
|
10
9
|
jest.mock('../../../../../uri.js', () => ({
|
|
11
10
|
...jest.requireActual('../../../../../uri.js'),
|
|
12
|
-
|
|
13
|
-
|
|
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') }
|
|
14
13
|
}))
|
|
15
14
|
jest.mock('../../../../../processors/uri-helper.js')
|
|
16
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
|
+
|
|
17
26
|
describe('pageRoute receives expected arguments', () => {
|
|
18
|
-
it('passes
|
|
27
|
+
it('passes CANCEL_RP_AGREEMENT_NOT_FOUND.page as the view name', () => {
|
|
19
28
|
jest.isolateModules(() => {
|
|
20
29
|
require('../route.js')
|
|
21
30
|
expect(pageRoute).toHaveBeenCalledWith(
|
|
22
|
-
|
|
31
|
+
CANCEL_RP_AGREEMENT_NOT_FOUND.page,
|
|
23
32
|
expect.anything(),
|
|
24
33
|
expect.anything(),
|
|
25
34
|
expect.anything(),
|
|
@@ -28,12 +37,12 @@ describe('pageRoute receives expected arguments', () => {
|
|
|
28
37
|
})
|
|
29
38
|
})
|
|
30
39
|
|
|
31
|
-
it('passes
|
|
40
|
+
it('passes CANCEL_RP_AGREEMENT_NOT_FOUND.uri as the path', () => {
|
|
32
41
|
jest.isolateModules(() => {
|
|
33
42
|
require('../route.js')
|
|
34
43
|
expect(pageRoute).toHaveBeenCalledWith(
|
|
35
44
|
expect.anything(),
|
|
36
|
-
|
|
45
|
+
CANCEL_RP_AGREEMENT_NOT_FOUND.uri,
|
|
37
46
|
expect.anything(),
|
|
38
47
|
expect.anything(),
|
|
39
48
|
expect.anything()
|
|
@@ -81,26 +90,40 @@ describe('pageRoute receives expected arguments', () => {
|
|
|
81
90
|
})
|
|
82
91
|
})
|
|
83
92
|
|
|
84
|
-
describe('
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
+
)
|
|
91
102
|
})
|
|
92
103
|
|
|
93
|
-
it('
|
|
94
|
-
|
|
95
|
-
|
|
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
|
+
)
|
|
96
112
|
})
|
|
97
113
|
|
|
98
|
-
it('
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
+
})
|
|
103
120
|
|
|
104
|
-
|
|
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
|
+
)
|
|
105
128
|
})
|
|
106
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
|
+
)
|
|
@@ -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
|
)
|
|
@@ -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'
|
|
@@ -455,7 +456,12 @@ export default [
|
|
|
455
456
|
next: {
|
|
456
457
|
[CommonResults.OK]: {
|
|
457
458
|
page: CANCEL_RP_COMPLETE
|
|
458
|
-
}
|
|
459
|
+
},
|
|
460
|
+
backLink: CANCEL_RP_DETAILS.uri
|
|
459
461
|
}
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
current: CANCEL_RP_AGREEMENT_NOT_FOUND,
|
|
465
|
+
backLink: CANCEL_RP_IDENTIFY.uri
|
|
460
466
|
}
|
|
461
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
|