@defra-fish/gafl-webapp-service 1.65.0-rc.0 → 1.65.0-rc.10
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 +62 -45
- package/src/handlers/cancel-recurring-payment-authentication-handler.js +33 -25
- package/src/handlers/result-functions.js +5 -2
- package/src/locales/cy.json +37 -8
- package/src/locales/en.json +42 -1
- package/src/pages/journey-goal/__tests__/result-function.spec.js +33 -0
- package/src/pages/journey-goal/__tests__/route.spec.js +50 -0
- package/src/pages/journey-goal/journey-goal.njk +52 -0
- package/src/pages/journey-goal/result-function.js +21 -0
- package/src/pages/journey-goal/route.js +10 -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/pages/recurring-payments/cancel/{confirm/__tests__/route.test.js → already-cancelled/__tests__/route.spec.js} +39 -30
- package/src/pages/recurring-payments/cancel/already-cancelled/already-cancelled.njk +28 -0
- package/src/pages/recurring-payments/cancel/already-cancelled/route.js +25 -0
- package/src/pages/recurring-payments/cancel/confirm/__tests__/route.spec.js +122 -0
- package/src/pages/recurring-payments/cancel/confirm/cancel-rp-confirm.njk +31 -10
- package/src/pages/recurring-payments/cancel/confirm/route.js +15 -2
- package/src/pages/recurring-payments/cancel/details/__tests__/route.spec.js +70 -8
- package/src/pages/recurring-payments/cancel/details/route.js +12 -4
- package/src/pages/recurring-payments/cancel/licence-not-found/__tests__/route.spec.js +21 -0
- package/src/pages/recurring-payments/cancel/licence-not-found/licence-not-found.njk +27 -0
- package/src/pages/recurring-payments/cancel/licence-not-found/route.js +4 -0
- package/src/routes/__tests__/__snapshots__/telesales-routes.spec.js.snap +96 -0
- package/src/routes/__tests__/back-links.spec.js +67 -2
- package/src/routes/journey-definition.js +74 -9
- package/src/routes/telesales-routes.js +15 -5
- package/src/uri.js +11 -0
|
@@ -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
|
+
)
|
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
import pageRoute from '../../../../../routes/page-route.js'
|
|
2
|
-
import {
|
|
3
|
-
import { addLanguageCodeToUri } from '../../../../../processors/uri-helper.js'
|
|
2
|
+
import { CANCEL_RP_ALREADY_CANCELLED } from '../../../../../uri.js'
|
|
4
3
|
|
|
5
4
|
require('../route.js')
|
|
5
|
+
|
|
6
6
|
// eslint-disable-next-line no-unused-vars
|
|
7
|
-
const
|
|
7
|
+
const getData = pageRoute.mock.calls[0][4]
|
|
8
8
|
|
|
9
|
-
jest.mock('../../../../../routes/page-route.js')
|
|
9
|
+
jest.mock('../../../../../routes/page-route.js', () => jest.fn())
|
|
10
10
|
jest.mock('../../../../../uri.js', () => ({
|
|
11
11
|
...jest.requireActual('../../../../../uri.js'),
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
CANCEL_RP_ALREADY_CANCELLED: {
|
|
13
|
+
page: Symbol('cancel-rp-already-cancelled page'),
|
|
14
|
+
uri: Symbol('cancel-rp-already-cancelled uri')
|
|
15
|
+
}
|
|
14
16
|
}))
|
|
15
17
|
jest.mock('../../../../../processors/uri-helper.js')
|
|
16
18
|
|
|
19
|
+
const getSampleRequest = referenceNumber => ({
|
|
20
|
+
cache: jest.fn(() => ({
|
|
21
|
+
helpers: {
|
|
22
|
+
page: {
|
|
23
|
+
getCurrentPermission: jest.fn(() => ({ payload: { referenceNumber, endDate: '2025:10:03:03:33:33' } }))
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}))
|
|
27
|
+
})
|
|
28
|
+
|
|
17
29
|
describe('pageRoute receives expected arguments', () => {
|
|
18
|
-
it('passes
|
|
30
|
+
it('passes CANCEL_RP_ALREADY_CANCELLED.page as the view name', () => {
|
|
19
31
|
jest.isolateModules(() => {
|
|
20
32
|
require('../route.js')
|
|
21
33
|
expect(pageRoute).toHaveBeenCalledWith(
|
|
22
|
-
|
|
34
|
+
CANCEL_RP_ALREADY_CANCELLED.page,
|
|
23
35
|
expect.anything(),
|
|
24
36
|
expect.anything(),
|
|
25
37
|
expect.anything(),
|
|
@@ -28,12 +40,12 @@ describe('pageRoute receives expected arguments', () => {
|
|
|
28
40
|
})
|
|
29
41
|
})
|
|
30
42
|
|
|
31
|
-
it('passes
|
|
43
|
+
it('passes CANCEL_RP_ALREADY_CANCELLED.uri as the path', () => {
|
|
32
44
|
jest.isolateModules(() => {
|
|
33
45
|
require('../route.js')
|
|
34
46
|
expect(pageRoute).toHaveBeenCalledWith(
|
|
35
47
|
expect.anything(),
|
|
36
|
-
|
|
48
|
+
CANCEL_RP_ALREADY_CANCELLED.uri,
|
|
37
49
|
expect.anything(),
|
|
38
50
|
expect.anything(),
|
|
39
51
|
expect.anything()
|
|
@@ -67,7 +79,7 @@ describe('pageRoute receives expected arguments', () => {
|
|
|
67
79
|
})
|
|
68
80
|
})
|
|
69
81
|
|
|
70
|
-
it('passes
|
|
82
|
+
it('passes getData to pageRoute', () => {
|
|
71
83
|
jest.isolateModules(() => {
|
|
72
84
|
require('../route.js')
|
|
73
85
|
expect(pageRoute).toHaveBeenCalledWith(
|
|
@@ -81,26 +93,23 @@ describe('pageRoute receives expected arguments', () => {
|
|
|
81
93
|
})
|
|
82
94
|
})
|
|
83
95
|
|
|
84
|
-
describe('
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
describe('getData', () => {
|
|
97
|
+
it('returns reference number from payload', async () => {
|
|
98
|
+
const referenceNumber = 'RP0310'
|
|
99
|
+
expect(await getData(getSampleRequest(referenceNumber))).toEqual(
|
|
100
|
+
expect.objectContaining({
|
|
101
|
+
referenceNumber
|
|
102
|
+
})
|
|
103
|
+
)
|
|
91
104
|
})
|
|
92
105
|
|
|
93
|
-
it('
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const completionRedirect = completion({})
|
|
103
|
-
|
|
104
|
-
expect(completionRedirect).toBe(expectedCompletionRedirect)
|
|
106
|
+
it('transforms end date to display format', async () => {
|
|
107
|
+
const endDate = '2025-10-03T03:33:33.000Z'
|
|
108
|
+
const request = getSampleRequest()
|
|
109
|
+
request.cache().helpers.page.getCurrentPermission.mockResolvedValueOnce({
|
|
110
|
+
payload: { referenceNumber: 'RP0310', endDate }
|
|
111
|
+
})
|
|
112
|
+
const data = await getData(request)
|
|
113
|
+
expect(data.endDate).toEqual('3 October 2025')
|
|
105
114
|
})
|
|
106
115
|
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{% extends "layout.njk" %}
|
|
2
|
+
{% from "page-title.njk" import pageTitle %}
|
|
3
|
+
|
|
4
|
+
{% set title = mssgs.rp_cancel_already_cancelled_title %}
|
|
5
|
+
{% block pageTitle %}{{ pageTitle(title, mssgs) }}{% endblock %}
|
|
6
|
+
|
|
7
|
+
{% block content %}
|
|
8
|
+
<div class="govuk-grid-row">
|
|
9
|
+
<div class="govuk-grid-column-two-thirds">
|
|
10
|
+
<h1 class="govuk-heading-l">{{ mssgs.rp_licence_already_cancelled_heading }}</h1>
|
|
11
|
+
<p class="govuk-body">
|
|
12
|
+
{{ mssgs.rp_licence_already_cancelled_body_1 }}{{ data.referenceNumber }}{{ mssgs.rp_licence_already_cancelled_body_1_1 }}{{ data.endDate }}{{ mssgs.rp_licence_already_cancelled_body_1_2 }}
|
|
13
|
+
<a href="/" class="govuk-link" target="_blank" rel="noopener"> {{ mssgs.rp_licence_already_cancelled_body_link }}</a>{{ mssgs.full_stop }}
|
|
14
|
+
</p>
|
|
15
|
+
<p class="govuk-body">
|
|
16
|
+
{{ mssgs.rp_licence_already_cancelled_body_2_1 }}
|
|
17
|
+
<a href="mailto:enquiries@environment-agency.gov.uk"> {{ mssgs.rp_licence_already_cancelled_body_ea_link }}</a>
|
|
18
|
+
{{ mssgs.rp_licence_already_cancelled_body_2_2 }}
|
|
19
|
+
<a href="https://www.gov.uk/call-charges" target="_blank" rel="noopener"> {{ mssgs.licence_not_found_body_call_charges_link }}</a>{{ mssgs.full_stop }}
|
|
20
|
+
</p>
|
|
21
|
+
<p class="govuk-body">
|
|
22
|
+
<a class="govuk-link" href="/buy/cancel-recurring-payment/identify"> {{ mssgs.rp_licence_already_cancelled_body_3_1 }}
|
|
23
|
+
</a>{{ mssgs.rp_licence_already_cancelled_body_3_2 }}
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
{% endblock %}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import pageRoute from '../../../../routes/page-route.js'
|
|
2
|
+
import { SERVICE_LOCAL_TIME } from '@defra-fish/business-rules-lib'
|
|
3
|
+
import { CANCEL_RP_ALREADY_CANCELLED, CANCEL_RP_IDENTIFY } from '../../../../uri.js'
|
|
4
|
+
import { cacheDateFormat, dateDisplayFormat } from '../../../../processors/date-and-time-display.js'
|
|
5
|
+
import moment from 'moment-timezone'
|
|
6
|
+
|
|
7
|
+
const getData = async request => {
|
|
8
|
+
const {
|
|
9
|
+
payload: { referenceNumber, endDate }
|
|
10
|
+
} = await request.cache().helpers.page.getCurrentPermission(CANCEL_RP_IDENTIFY.page)
|
|
11
|
+
const endDateString = moment(endDate, cacheDateFormat).tz(SERVICE_LOCAL_TIME).format(dateDisplayFormat)
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
referenceNumber,
|
|
15
|
+
endDate: endDateString
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default pageRoute(
|
|
20
|
+
CANCEL_RP_ALREADY_CANCELLED.page,
|
|
21
|
+
CANCEL_RP_ALREADY_CANCELLED.uri,
|
|
22
|
+
() => {},
|
|
23
|
+
() => {},
|
|
24
|
+
getData
|
|
25
|
+
)
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
import { dateDisplayFormat } from '../../../../../processors/date-and-time-display.js'
|
|
6
|
+
|
|
7
|
+
require('../route.js')
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line no-unused-vars
|
|
10
|
+
const [[_v, _p, validator, completion, getData]] = pageRoute.mock.calls
|
|
11
|
+
|
|
12
|
+
jest.mock('../../../../../routes/page-route.js')
|
|
13
|
+
jest.mock('../../../../../uri.js', () => ({
|
|
14
|
+
...jest.requireActual('../../../../../uri.js'),
|
|
15
|
+
CANCEL_RP_CONFIRM: { page: Symbol('cancel-rp-confirm-page'), uri: Symbol('cancel-rp-confirm-uri') },
|
|
16
|
+
CANCEL_RP_COMPLETE: { uri: Symbol('cancel-rp-complete-uri') },
|
|
17
|
+
CANCEL_RP_IDENTIFY: { uri: Symbol('cancel-rp-identify-uri') }
|
|
18
|
+
}))
|
|
19
|
+
jest.mock('../../../../../processors/uri-helper.js')
|
|
20
|
+
jest.mock('moment-timezone')
|
|
21
|
+
jest.mock('../../../../../processors/date-and-time-display.js', () => ({
|
|
22
|
+
cacheDateFormat: Symbol('cache date format'),
|
|
23
|
+
dateDisplayFormat: Symbol('date display format')
|
|
24
|
+
}))
|
|
25
|
+
|
|
26
|
+
describe('pageRoute receives expected arguments', () => {
|
|
27
|
+
it('passes expected arguments to pageRoute', () => {
|
|
28
|
+
jest.isolateModules(() => {
|
|
29
|
+
require('../route.js')
|
|
30
|
+
expect(pageRoute).toHaveBeenCalledWith(
|
|
31
|
+
CANCEL_RP_CONFIRM.page,
|
|
32
|
+
CANCEL_RP_CONFIRM.uri,
|
|
33
|
+
expect.any(Function),
|
|
34
|
+
expect.any(Function),
|
|
35
|
+
expect.any(Function)
|
|
36
|
+
)
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
describe('completion function', () => {
|
|
42
|
+
beforeEach(jest.clearAllMocks)
|
|
43
|
+
|
|
44
|
+
it('calls addLanguageCodeToUri with request object', () => {
|
|
45
|
+
const sampleRequest = Symbol('sample request')
|
|
46
|
+
completion(sampleRequest)
|
|
47
|
+
expect(addLanguageCodeToUri).toHaveBeenCalledWith(sampleRequest, expect.anything())
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('calls addLanguageCodeToUri with CANCEL_RP_COMPLETE uri', () => {
|
|
51
|
+
completion({})
|
|
52
|
+
expect(addLanguageCodeToUri).toHaveBeenCalledWith(expect.anything(), CANCEL_RP_COMPLETE.uri)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('returns the value of addLanguageCodeToUri', () => {
|
|
56
|
+
const expecetdUri = Symbol('cancel-rp-complete-uri')
|
|
57
|
+
addLanguageCodeToUri.mockReturnValueOnce(expecetdUri)
|
|
58
|
+
|
|
59
|
+
const completionRedirect = completion({})
|
|
60
|
+
|
|
61
|
+
expect(completionRedirect).toBe(expecetdUri)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
describe('getData function', () => {
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
jest.clearAllMocks()
|
|
68
|
+
moment.mockReturnValue({ format: jest.fn(() => '18th November, 2025') })
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const mockRequest = () => {
|
|
72
|
+
const getCurrentPermission = jest.fn(() => ({ permission: { endDate: '2025-02-15' } }))
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
locale: 'en',
|
|
76
|
+
cache: () => ({
|
|
77
|
+
helpers: {
|
|
78
|
+
transaction: {
|
|
79
|
+
getCurrentPermission
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
it('calls addLanguageCodeToUri with request object', async () => {
|
|
87
|
+
const request = mockRequest()
|
|
88
|
+
await getData(request)
|
|
89
|
+
expect(addLanguageCodeToUri).toHaveBeenCalledWith(request, expect.anything())
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('calls addLanguageCodeToUri with CANCEL_RP_IDENTIFY uri', async () => {
|
|
93
|
+
const request = mockRequest()
|
|
94
|
+
await getData(request)
|
|
95
|
+
expect(addLanguageCodeToUri).toHaveBeenCalledWith(expect.anything(), CANCEL_RP_IDENTIFY.uri)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('cancelRpIdentify uri is equal to return of addLanguageCodeToUri for CANCEL_RP_IDENTIFY page', async () => {
|
|
99
|
+
const expectedUri = Symbol('expected-cancel-rp-identify-uri')
|
|
100
|
+
addLanguageCodeToUri.mockReturnValueOnce(expectedUri)
|
|
101
|
+
|
|
102
|
+
const data = await getData(mockRequest())
|
|
103
|
+
|
|
104
|
+
expect(data.uri).toEqual({
|
|
105
|
+
cancelRpIdentify: expectedUri
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('returns licenceExpiry in correct format', async () => {
|
|
110
|
+
const mockFormat = jest.fn().mockReturnValue('19th November, 2025')
|
|
111
|
+
moment.mockReturnValue({ format: mockFormat })
|
|
112
|
+
|
|
113
|
+
const data = await getData(mockRequest())
|
|
114
|
+
|
|
115
|
+
expect(data.licenceExpiry).toEqual('19th November, 2025')
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
it('uses expected date format', async () => {
|
|
119
|
+
await getData(mockRequest())
|
|
120
|
+
expect(moment.mock.results[0].value.format).toHaveBeenCalledWith(dateDisplayFormat)
|
|
121
|
+
})
|
|
122
|
+
})
|
|
@@ -2,23 +2,44 @@
|
|
|
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 }}{{ data.licenceExpiry }}</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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
<div class="govuk-button-group">
|
|
30
|
+
{{ govukButton({
|
|
31
|
+
attributes: { id: 'continue' },
|
|
32
|
+
preventDoubleClick: true,
|
|
33
|
+
name: "continue",
|
|
34
|
+
text: mssgs.rp_cancel_confirm_accept,
|
|
35
|
+
classes: "govuk-!-margin-top-1"
|
|
36
|
+
}) }}
|
|
37
|
+
{{ csrf() }}
|
|
38
|
+
<p class="govuk-body no-print"><a class="govuk-link" href="{{ data.uri.cancelRpIdentify }}">{{ mssgs.rp_cancel_confirm_reject }}</a></p>
|
|
39
|
+
</div>
|
|
21
40
|
</form>
|
|
22
41
|
</div>
|
|
23
|
-
</div>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
{% endcall %}
|
|
24
45
|
{% 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, dateDisplayFormat } 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.endDate, cacheDateFormat, request.locale).format(dateDisplayFormat),
|
|
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
|
)
|
|
@@ -2,6 +2,8 @@ import pageRoute from '../../../../../routes/page-route.js'
|
|
|
2
2
|
import { CANCEL_RP_DETAILS, CANCEL_RP_CONFIRM } from '../../../../../uri.js'
|
|
3
3
|
import { addLanguageCodeToUri } from '../../../../../processors/uri-helper.js'
|
|
4
4
|
import { getData } from '../route.js'
|
|
5
|
+
import moment from 'moment-timezone'
|
|
6
|
+
import { cacheDateFormat, dateDisplayFormat } from '../../../../../processors/date-and-time-display.js'
|
|
5
7
|
|
|
6
8
|
jest.mock('../../../../../routes/page-route.js')
|
|
7
9
|
jest.mock('../../../../../uri.js', () => ({
|
|
@@ -10,6 +12,15 @@ jest.mock('../../../../../uri.js', () => ({
|
|
|
10
12
|
CANCEL_RP_CONFIRM: { uri: Symbol('cancel-rp-confirm-uri') }
|
|
11
13
|
}))
|
|
12
14
|
jest.mock('../../../../../processors/uri-helper.js')
|
|
15
|
+
jest.mock('moment-timezone', () =>
|
|
16
|
+
jest.fn(() => ({
|
|
17
|
+
format: jest.fn()
|
|
18
|
+
}))
|
|
19
|
+
)
|
|
20
|
+
jest.mock('../../../../../processors/date-and-time-display.js', () => ({
|
|
21
|
+
cacheDateFormat: Symbol('cache-date-format'),
|
|
22
|
+
dateDisplayFormat: Symbol('date-display-format')
|
|
23
|
+
}))
|
|
13
24
|
|
|
14
25
|
describe('route', () => {
|
|
15
26
|
beforeEach(jest.clearAllMocks)
|
|
@@ -82,7 +93,7 @@ describe('route', () => {
|
|
|
82
93
|
referenceNumber: 'abc123'
|
|
83
94
|
},
|
|
84
95
|
recurringPayment: {
|
|
85
|
-
lastDigitsCardNumbers: 1234
|
|
96
|
+
lastDigitsCardNumbers: '1234'
|
|
86
97
|
}
|
|
87
98
|
})
|
|
88
99
|
|
|
@@ -96,7 +107,8 @@ describe('route', () => {
|
|
|
96
107
|
}),
|
|
97
108
|
i18n: {
|
|
98
109
|
getCatalog: () => catalog
|
|
99
|
-
}
|
|
110
|
+
},
|
|
111
|
+
locale: Symbol('en-GB')
|
|
100
112
|
})
|
|
101
113
|
|
|
102
114
|
describe('getData', () => {
|
|
@@ -115,17 +127,67 @@ describe('route', () => {
|
|
|
115
127
|
|
|
116
128
|
it('returns summaryTable with expected data', async () => {
|
|
117
129
|
const mssgs = getSampleCatalog()
|
|
118
|
-
const
|
|
130
|
+
const sampleData = {
|
|
131
|
+
permission: {
|
|
132
|
+
licensee: {
|
|
133
|
+
firstName: 'Brenin',
|
|
134
|
+
lastName: 'Pysgotwr'
|
|
135
|
+
},
|
|
136
|
+
permit: {
|
|
137
|
+
description: 'Wellies and old shopping trollies'
|
|
138
|
+
},
|
|
139
|
+
endDate: '21-03-2026',
|
|
140
|
+
referenceNumber: 'aaa-111-bbb-222'
|
|
141
|
+
},
|
|
142
|
+
recurringPayment: {
|
|
143
|
+
lastDigitsCardNumbers: '9999'
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const sampleFormattedDate = Symbol('formatted-end-date')
|
|
147
|
+
const mockRequest = createMockRequest({ catalog: mssgs, currentPermission: sampleData })
|
|
148
|
+
moment.mockReturnValueOnce({
|
|
149
|
+
format: () => sampleFormattedDate
|
|
150
|
+
})
|
|
119
151
|
|
|
120
152
|
const result = await getData(mockRequest)
|
|
121
153
|
|
|
122
154
|
expect(result.summaryTable).toEqual([
|
|
123
|
-
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
{ key: { text: mssgs.
|
|
155
|
+
{
|
|
156
|
+
key: { text: mssgs.rp_cancel_details_licence_holder },
|
|
157
|
+
value: { text: `${sampleData.permission.licensee.firstName} ${sampleData.permission.licensee.lastName}` }
|
|
158
|
+
},
|
|
159
|
+
{ key: { text: mssgs.rp_cancel_details_licence_type }, value: { text: sampleData.permission.permit.description } },
|
|
160
|
+
{
|
|
161
|
+
key: { text: mssgs.rp_cancel_details_payment_card },
|
|
162
|
+
value: { text: `**** **** **** ${sampleData.recurringPayment.lastDigitsCardNumbers}` }
|
|
163
|
+
},
|
|
164
|
+
{ key: { text: mssgs.rp_cancel_details_last_purchased }, value: { text: sampleData.permission.referenceNumber } },
|
|
165
|
+
{ key: { text: mssgs.rp_cancel_details_licence_valid_until }, value: { text: sampleFormattedDate } }
|
|
128
166
|
])
|
|
129
167
|
})
|
|
168
|
+
|
|
169
|
+
it('passes cache date format and request locale to moment', async () => {
|
|
170
|
+
const data = getSamplePermission()
|
|
171
|
+
data.permission.endDate = Symbol('end-date')
|
|
172
|
+
const mockRequest = createMockRequest({ currentPermission: data })
|
|
173
|
+
|
|
174
|
+
await getData(mockRequest)
|
|
175
|
+
|
|
176
|
+
expect(moment).toHaveBeenCalledWith(data.permission.endDate, cacheDateFormat, mockRequest.locale)
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('requests correct date format', async () => {
|
|
180
|
+
const data = getSamplePermission()
|
|
181
|
+
data.permission.endDate = Symbol('end-date')
|
|
182
|
+
const mockRequest = createMockRequest({ currentPermission: data })
|
|
183
|
+
const format = jest.fn()
|
|
184
|
+
moment.mockReturnValueOnce({
|
|
185
|
+
format
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
await getData(mockRequest)
|
|
189
|
+
|
|
190
|
+
expect(format).toHaveBeenCalledWith(dateDisplayFormat)
|
|
191
|
+
})
|
|
130
192
|
})
|
|
131
193
|
})
|