@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.
Files changed (30) hide show
  1. package/package.json +4 -4
  2. package/src/handlers/__tests__/cancel-recurring-payment-authentication-handler.spec.js +62 -45
  3. package/src/handlers/cancel-recurring-payment-authentication-handler.js +33 -25
  4. package/src/handlers/result-functions.js +5 -2
  5. package/src/locales/cy.json +37 -8
  6. package/src/locales/en.json +42 -1
  7. package/src/pages/journey-goal/__tests__/result-function.spec.js +33 -0
  8. package/src/pages/journey-goal/__tests__/route.spec.js +50 -0
  9. package/src/pages/journey-goal/journey-goal.njk +52 -0
  10. package/src/pages/journey-goal/result-function.js +21 -0
  11. package/src/pages/journey-goal/route.js +10 -0
  12. package/src/pages/recurring-payments/cancel/agreement-not-found/__tests__/route.spec.js +129 -0
  13. package/src/pages/recurring-payments/cancel/agreement-not-found/cancel-rp-agreement-not-found.njk +15 -0
  14. package/src/pages/recurring-payments/cancel/agreement-not-found/route.js +23 -0
  15. package/src/pages/recurring-payments/cancel/{confirm/__tests__/route.test.js → already-cancelled/__tests__/route.spec.js} +39 -30
  16. package/src/pages/recurring-payments/cancel/already-cancelled/already-cancelled.njk +28 -0
  17. package/src/pages/recurring-payments/cancel/already-cancelled/route.js +25 -0
  18. package/src/pages/recurring-payments/cancel/confirm/__tests__/route.spec.js +122 -0
  19. package/src/pages/recurring-payments/cancel/confirm/cancel-rp-confirm.njk +31 -10
  20. package/src/pages/recurring-payments/cancel/confirm/route.js +15 -2
  21. package/src/pages/recurring-payments/cancel/details/__tests__/route.spec.js +70 -8
  22. package/src/pages/recurring-payments/cancel/details/route.js +12 -4
  23. package/src/pages/recurring-payments/cancel/licence-not-found/__tests__/route.spec.js +21 -0
  24. package/src/pages/recurring-payments/cancel/licence-not-found/licence-not-found.njk +27 -0
  25. package/src/pages/recurring-payments/cancel/licence-not-found/route.js +4 -0
  26. package/src/routes/__tests__/__snapshots__/telesales-routes.spec.js.snap +96 -0
  27. package/src/routes/__tests__/back-links.spec.js +67 -2
  28. package/src/routes/journey-definition.js +74 -9
  29. package/src/routes/telesales-routes.js +15 -5
  30. package/src/uri.js +11 -0
@@ -1,16 +1,24 @@
1
1
  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
+ import moment from 'moment-timezone'
5
+ import { cacheDateFormat, dateDisplayFormat } from '../../../../processors/date-and-time-display.js'
4
6
 
5
- const getLicenseeDetailsSummaryRows = (currentPermission, mssgs) => [
7
+ const getLicenseeDetailsSummaryRows = (currentPermission, mssgs, locale) => [
6
8
  {
7
9
  key: { text: mssgs.rp_cancel_details_licence_holder },
8
10
  value: { text: `${currentPermission.permission.licensee.firstName} ${currentPermission.permission.licensee.lastName}` }
9
11
  },
10
12
  { key: { text: mssgs.rp_cancel_details_licence_type }, value: { text: currentPermission.permission.permit.description } },
11
- { key: { text: mssgs.rp_cancel_details_payment_card }, value: { text: currentPermission.recurringPayment.lastDigitsCardNumbers } },
13
+ {
14
+ key: { text: mssgs.rp_cancel_details_payment_card },
15
+ value: { text: `**** **** **** ${currentPermission.recurringPayment.lastDigitsCardNumbers}` }
16
+ },
12
17
  { key: { text: mssgs.rp_cancel_details_last_purchased }, value: { text: currentPermission.permission.referenceNumber } },
13
- { key: { text: mssgs.rp_cancel_details_licence_valid_until }, value: { text: currentPermission.permission.endDate } }
18
+ {
19
+ key: { text: mssgs.rp_cancel_details_licence_valid_until },
20
+ value: { text: moment(currentPermission.permission.endDate, cacheDateFormat, locale).format(dateDisplayFormat) }
21
+ }
14
22
  ]
15
23
 
16
24
  export const getData = async request => {
@@ -19,7 +27,7 @@ export const getData = async request => {
19
27
 
20
28
  return {
21
29
  mssgs,
22
- summaryTable: getLicenseeDetailsSummaryRows(currentPermission, mssgs)
30
+ summaryTable: getLicenseeDetailsSummaryRows(currentPermission, mssgs, request.locale)
23
31
  }
24
32
  }
25
33
 
@@ -0,0 +1,21 @@
1
+ import pageRoute from '../../../../../routes/page-route.js'
2
+ import { CANCEL_RP_LICENCE_NOT_FOUND } from '../../../../../uri.js'
3
+ import '../route.js'
4
+
5
+ jest.mock('../../../../../routes/page-route.js', () => jest.fn())
6
+ jest.mock('../../../../../uri.js', () => ({
7
+ CANCEL_RP_LICENCE_NOT_FOUND: {
8
+ page: Symbol('licence-not-found page'),
9
+ uri: Symbol('licence-not-found uri')
10
+ }
11
+ }))
12
+
13
+ describe('CANCEL_RP_LICENCE_NOT_FOUND route', () => {
14
+ it('passes CANCEL_RP_LICENCE_NOT_FOUND.page as the first argument to pageRoute', () => {
15
+ expect(pageRoute).toHaveBeenCalledWith(CANCEL_RP_LICENCE_NOT_FOUND.page, expect.anything())
16
+ })
17
+
18
+ it('passes CANCEL_RP_LICENCE_NOT_FOUND.uri as the second argument to pageRoute', () => {
19
+ expect(pageRoute).toHaveBeenCalledWith(expect.anything(), CANCEL_RP_LICENCE_NOT_FOUND.uri)
20
+ })
21
+ })
@@ -0,0 +1,27 @@
1
+ {% extends "layout.njk" %}
2
+ {% extends "standard-form.njk" %}
3
+
4
+ {% set title = mssgs.licence_not_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.licence_not_found_title }}</h1>
10
+ <p class="govuk-body">
11
+ {{ mssgs.licence_not_found_body_1 }}
12
+ <a class="govuk-link" href="/buy/renew/identify">{{ mssgs.licence_not_found_body_previous_page }}</a>{{ mssgs.full_stop }}
13
+ </p>
14
+ <p class="govuk-body">
15
+ {{ mssgs.licence_not_found_rp_body_1}}
16
+ </p>
17
+ <ul class="govuk-list govuk-list--bullet">
18
+ <li> {{ mssgs.licence_not_found_rp_bullet_point_1 }} <a href="mailto:enquiries@environment-agency.gov.uk"> {{ mssgs.licence_not_found_body_ea_link }}
19
+ </a> {{ mssgs.licence_not_found_rp_bullet_point_1_2 }} </li>
20
+
21
+ <li> {{ mssgs.licence_not_found_rp_bullet_point_2 }} <a href="https://www.gov.uk/call-charges" target="_blank" rel="noopener"> {{ mssgs.licence_not_found_body_call_charges_link }}
22
+ </a>{{ mssgs.full_stop }} </li>
23
+ </ul>
24
+
25
+ </div>
26
+ </div>
27
+ {% endblock %}
@@ -0,0 +1,4 @@
1
+ import { CANCEL_RP_LICENCE_NOT_FOUND } from '../../../../uri.js'
2
+ import pageRoute from '../../../../routes/page-route.js'
3
+
4
+ export default pageRoute(CANCEL_RP_LICENCE_NOT_FOUND.page, CANCEL_RP_LICENCE_NOT_FOUND.uri)
@@ -36,6 +36,22 @@ Object {
36
36
  },
37
37
  "path": "/oidc/role-required",
38
38
  },
39
+ Object {
40
+ "handler": [Function],
41
+ "method": "GET",
42
+ "path": "/buy/journey-goal",
43
+ },
44
+ Object {
45
+ "handler": [Function],
46
+ "method": "POST",
47
+ "options": Object {
48
+ "validate": Object {
49
+ "failAction": [Function],
50
+ "payload": [Function],
51
+ },
52
+ },
53
+ "path": "/buy/journey-goal",
54
+ },
39
55
  Object {
40
56
  "handler": [Function],
41
57
  "method": "GET",
@@ -100,6 +116,54 @@ Object {
100
116
  },
101
117
  "path": "/buy/cancel-recurring-payment/complete",
102
118
  },
119
+ Object {
120
+ "handler": [Function],
121
+ "method": "GET",
122
+ "path": "/buy/cancel-recurring-payment/agreement-not-found",
123
+ },
124
+ Object {
125
+ "handler": [Function],
126
+ "method": "POST",
127
+ "options": Object {
128
+ "validate": Object {
129
+ "failAction": [Function],
130
+ "payload": [Function],
131
+ },
132
+ },
133
+ "path": "/buy/cancel-recurring-payment/agreement-not-found",
134
+ },
135
+ Object {
136
+ "handler": [Function],
137
+ "method": "GET",
138
+ "path": "/buy/cancel-recurring-payment/already-cancelled",
139
+ },
140
+ Object {
141
+ "handler": [Function],
142
+ "method": "POST",
143
+ "options": Object {
144
+ "validate": Object {
145
+ "failAction": [Function],
146
+ "payload": [Function],
147
+ },
148
+ },
149
+ "path": "/buy/cancel-recurring-payment/already-cancelled",
150
+ },
151
+ Object {
152
+ "handler": [Function],
153
+ "method": "GET",
154
+ "path": "/buy/cancel-recurring-payment/licence-not-found",
155
+ },
156
+ Object {
157
+ "handler": [Function],
158
+ "method": "POST",
159
+ "options": Object {
160
+ "validate": Object {
161
+ "failAction": [Function],
162
+ "payload": undefined,
163
+ },
164
+ },
165
+ "path": "/buy/cancel-recurring-payment/licence-not-found",
166
+ },
103
167
  ],
104
168
  }
105
169
  `;
@@ -140,6 +204,22 @@ Object {
140
204
  },
141
205
  "path": "/oidc/role-required",
142
206
  },
207
+ Object {
208
+ "handler": [Function],
209
+ "method": "GET",
210
+ "path": "/buy/journey-goal",
211
+ },
212
+ Object {
213
+ "handler": [Function],
214
+ "method": "POST",
215
+ "options": Object {
216
+ "validate": Object {
217
+ "failAction": [Function],
218
+ "payload": [Function],
219
+ },
220
+ },
221
+ "path": "/buy/journey-goal",
222
+ },
143
223
  ],
144
224
  }
145
225
  `;
@@ -180,6 +260,22 @@ Object {
180
260
  },
181
261
  "path": "/oidc/role-required",
182
262
  },
263
+ Object {
264
+ "handler": [Function],
265
+ "method": "GET",
266
+ "path": "/buy/journey-goal",
267
+ },
268
+ Object {
269
+ "handler": [Function],
270
+ "method": "POST",
271
+ "options": Object {
272
+ "validate": Object {
273
+ "failAction": [Function],
274
+ "payload": [Function],
275
+ },
276
+ },
277
+ "path": "/buy/journey-goal",
278
+ },
183
279
  ],
184
280
  }
185
281
  `;
@@ -17,27 +17,64 @@ import {
17
17
  CONTACT,
18
18
  NEWSLETTER,
19
19
  CHOOSE_PAYMENT,
20
- TERMS_AND_CONDITIONS
20
+ TERMS_AND_CONDITIONS,
21
+ JOURNEY_GOAL
21
22
  } from '../../uri.js'
22
23
  import { LICENCE_SUMMARY_SEEN, CONTACT_SUMMARY_SEEN } from '../../constants.js'
23
24
  import { isPhysical } from '../../processors/licence-type-display.js'
24
25
  jest.mock('../../processors/licence-type-display.js')
25
26
 
27
+ describe('The journey-goal page', () => {
28
+ it('has no back-link', () => {
29
+ jest.isolateModules(() => {
30
+ process.env.CHANNEL = 'telesales'
31
+ const isolatedJourneyDefinition = require('../journey-definition.js').default
32
+ const isolatedJourneyGoal = isolatedJourneyDefinition.find(n => n.current.page === JOURNEY_GOAL.page)
33
+ expect(isolatedJourneyGoal.backLink({})).not.toBeTruthy()
34
+ delete process.env.CHANNEL
35
+ })
36
+ })
37
+ })
38
+
26
39
  describe('The licence-for page', () => {
27
40
  const n = journeyDefinition.find(n => n.current.page === LICENCE_FOR.page)
28
- it('has no back-link on initial viewing', () => {
41
+
42
+ it('has no back-link on initial viewing in websales journey', () => {
29
43
  expect(n.backLink({})).not.toBeTruthy()
30
44
  })
45
+
31
46
  it('has a back-link to the license summary if the summary is seen', () => {
32
47
  expect(n.backLink({ fromSummary: LICENCE_SUMMARY_SEEN })).toBe(LICENCE_SUMMARY.uri)
33
48
  })
49
+
50
+ it('has a back-link to the journey-goal page in telesales journey', () => {
51
+ jest.isolateModules(() => {
52
+ process.env.CHANNEL = 'telesales'
53
+ const isolatedJourneyDefinition = require('../journey-definition.js').default
54
+ const isolatedJourneyGoal = isolatedJourneyDefinition.find(n => n.current.page === LICENCE_FOR.page)
55
+ expect(isolatedJourneyGoal.backLink({})).toBe(JOURNEY_GOAL.uri)
56
+ delete process.env.CHANNEL
57
+ })
58
+ })
59
+
60
+ it('has a back-link to the licence summary in telesales journey if the summary is seen', () => {
61
+ jest.isolateModules(() => {
62
+ process.env.CHANNEL = 'telesales'
63
+ const isolatedJourneyDefinition = require('../journey-definition.js').default
64
+ const isolatedJourneyGoal = isolatedJourneyDefinition.find(n => n.current.page === LICENCE_FOR.page)
65
+ expect(isolatedJourneyGoal.backLink({ fromSummary: LICENCE_SUMMARY_SEEN })).toBe(LICENCE_SUMMARY.uri)
66
+ delete process.env.CHANNEL
67
+ })
68
+ })
34
69
  })
35
70
 
36
71
  describe('The date-of-birth page', () => {
37
72
  const n = journeyDefinition.find(n => n.current.page === DATE_OF_BIRTH.page)
73
+
38
74
  it('has a back-link to the name page on initial viewing', () => {
39
75
  expect(n.backLink({})).toBe(NAME.uri)
40
76
  })
77
+
41
78
  it('has a back-link to the licence summary if the summary is seen', () => {
42
79
  expect(n.backLink({ fromSummary: LICENCE_SUMMARY_SEEN })).toBe(LICENCE_SUMMARY.uri)
43
80
  })
@@ -45,9 +82,11 @@ describe('The date-of-birth page', () => {
45
82
 
46
83
  describe('The licence-to-start page', () => {
47
84
  const n = journeyDefinition.find(n => n.current.page === LICENCE_TO_START.page)
85
+
48
86
  it('has a back-link to the disability concessions page on initial viewing', () => {
49
87
  expect(n.backLink({})).toBe(DISABILITY_CONCESSION.uri)
50
88
  })
89
+
51
90
  it('has a back-link to the license summary if the summary is seen', () => {
52
91
  expect(n.backLink({ fromSummary: LICENCE_SUMMARY_SEEN })).toBe(LICENCE_SUMMARY.uri)
53
92
  })
@@ -55,9 +94,11 @@ describe('The licence-to-start page', () => {
55
94
 
56
95
  describe('The disability-concession page', () => {
57
96
  const n = journeyDefinition.find(n => n.current.page === DISABILITY_CONCESSION.page)
97
+
58
98
  it('has a back-link to the date-of-birth page on initial viewing', () => {
59
99
  expect(n.backLink({})).toBe(DATE_OF_BIRTH.uri)
60
100
  })
101
+
61
102
  it('has a back-link to the license summary if the summary is seen', () => {
62
103
  expect(n.backLink({ fromSummary: LICENCE_SUMMARY_SEEN })).toBe(LICENCE_SUMMARY.uri)
63
104
  })
@@ -65,9 +106,11 @@ describe('The disability-concession page', () => {
65
106
 
66
107
  describe('The licence-type page', () => {
67
108
  const n = journeyDefinition.find(n => n.current.page === LICENCE_TYPE.page)
109
+
68
110
  it('has a back-link to the disability-concession page on initial viewing', () => {
69
111
  expect(n.backLink({})).toBe(LICENCE_TO_START.uri)
70
112
  })
113
+
71
114
  it('has a back-link to the license summary if the summary is seen', () => {
72
115
  expect(n.backLink({ fromSummary: LICENCE_SUMMARY_SEEN })).toBe(LICENCE_SUMMARY.uri)
73
116
  })
@@ -75,9 +118,11 @@ describe('The licence-type page', () => {
75
118
 
76
119
  describe('The licence-length page', () => {
77
120
  const n = journeyDefinition.find(n => n.current.page === LICENCE_LENGTH.page)
121
+
78
122
  it('has a back-link to the licence-type page on initial viewing', () => {
79
123
  expect(n.backLink({})).toBe(LICENCE_TYPE.uri)
80
124
  })
125
+
81
126
  it('has a back-link to the license summary if the summary is seen', () => {
82
127
  expect(n.backLink({ fromSummary: LICENCE_SUMMARY_SEEN })).toBe(LICENCE_SUMMARY.uri)
83
128
  })
@@ -85,9 +130,11 @@ describe('The licence-length page', () => {
85
130
 
86
131
  describe('The licence-start-time page', () => {
87
132
  const n = journeyDefinition.find(n => n.current.page === LICENCE_START_TIME.page)
133
+
88
134
  it('has a back-link to the licence-length page on initial viewing', () => {
89
135
  expect(n.backLink({})).toBe(LICENCE_LENGTH.uri)
90
136
  })
137
+
91
138
  it('has a back-link to the licence-to-start page if the summary is seen', () => {
92
139
  expect(n.backLink({ fromSummary: LICENCE_SUMMARY_SEEN })).toBe(LICENCE_TO_START.uri)
93
140
  })
@@ -95,9 +142,11 @@ describe('The licence-start-time page', () => {
95
142
 
96
143
  describe('The name page', () => {
97
144
  const n = journeyDefinition.find(n => n.current.page === NAME.page)
145
+
98
146
  it('has a back-link to the licence-summary page if the licence-summary is seen', () => {
99
147
  expect(n.backLink({ fromSummary: LICENCE_SUMMARY_SEEN })).toBe(LICENCE_SUMMARY.uri)
100
148
  })
149
+
101
150
  it('has a back-link to the licence-for page if the contact summary has not been seen', () => {
102
151
  expect(n.backLink({})).toBe(LICENCE_FOR.uri)
103
152
  })
@@ -105,9 +154,11 @@ describe('The name page', () => {
105
154
 
106
155
  describe('The address-lookup page', () => {
107
156
  const n = journeyDefinition.find(n => n.current.page === ADDRESS_LOOKUP.page)
157
+
108
158
  it('has a back-link to the licence-summary page if the contact summary has not been seen', () => {
109
159
  expect(n.backLink({})).toBe(LICENCE_SUMMARY.uri)
110
160
  })
161
+
111
162
  it('has a back-link to the contact-summary page if the contact-summary is seen', () => {
112
163
  expect(n.backLink({ fromSummary: CONTACT_SUMMARY_SEEN })).toBe(CONTACT_SUMMARY.uri)
113
164
  })
@@ -115,9 +166,11 @@ describe('The address-lookup page', () => {
115
166
 
116
167
  describe('The address-entry page', () => {
117
168
  const n = journeyDefinition.find(n => n.current.page === ADDRESS_ENTRY.page)
169
+
118
170
  it('has a back-link to the address-lookup page if the contact summary has not been seen', () => {
119
171
  expect(n.backLink({})).toBe(ADDRESS_LOOKUP.uri)
120
172
  })
173
+
121
174
  it('has a back-link to the contact-summary page if the contact-summary is seen', () => {
122
175
  expect(n.backLink({ fromSummary: CONTACT_SUMMARY_SEEN })).toBe(CONTACT_SUMMARY.uri)
123
176
  })
@@ -128,10 +181,12 @@ describe('The licence-fulfilment page', () => {
128
181
  const n = journeyDefinition.find(n => n.current.page === LICENCE_FULFILMENT.page)
129
182
  expect(n.backLink({})).toBe(ADDRESS_LOOKUP.uri)
130
183
  })
184
+
131
185
  it('has a back-link to the contact-summary page if the contact-summary is seen', () => {
132
186
  const n = journeyDefinition.find(n => n.current.page === LICENCE_FULFILMENT.page)
133
187
  expect(n.backLink({ fromSummary: CONTACT_SUMMARY_SEEN })).toBe(CONTACT_SUMMARY.uri)
134
188
  })
189
+
135
190
  it('has a back-link to the licence-summary page if in renewal', () => {
136
191
  const n = journeyDefinition.find(n => n.current.page === LICENCE_FULFILMENT.page)
137
192
  expect(n.backLink({}, { isRenewal: true })).toBe(LICENCE_SUMMARY.uri)
@@ -143,14 +198,17 @@ describe('The licence-confirmation page', () => {
143
198
  const n = journeyDefinition.find(n => n.current.page === LICENCE_CONFIRMATION_METHOD.page)
144
199
  expect(n.backLink({})).toBe(LICENCE_FULFILMENT.uri)
145
200
  })
201
+
146
202
  it('has a back-link to the licence-fulfilment page if the contact-summary has been seen and the last sumbitted page is licence-fulfilment', () => {
147
203
  const n = journeyDefinition.find(n => n.current.page === LICENCE_CONFIRMATION_METHOD.page)
148
204
  expect(n.backLink({ fromSummary: CONTACT_SUMMARY_SEEN, currentPage: LICENCE_FULFILMENT.page })).toBe(LICENCE_FULFILMENT.uri)
149
205
  })
206
+
150
207
  it('has a back-link to the licence-fulfilment page if the contact-summary has been seen and the last sumbitted page is licence-confirmation-method', () => {
151
208
  const n = journeyDefinition.find(n => n.current.page === LICENCE_CONFIRMATION_METHOD.page)
152
209
  expect(n.backLink({ fromSummary: CONTACT_SUMMARY_SEEN, currentPage: LICENCE_CONFIRMATION_METHOD.page })).toBe(LICENCE_FULFILMENT.uri)
153
210
  })
211
+
154
212
  it('has a back-link to the contact-summary page if the contact-summary is seen', () => {
155
213
  const n = journeyDefinition.find(n => n.current.page === LICENCE_CONFIRMATION_METHOD.page)
156
214
  expect(n.backLink({ fromSummary: CONTACT_SUMMARY_SEEN })).toBe(CONTACT_SUMMARY.uri)
@@ -159,18 +217,22 @@ describe('The licence-confirmation page', () => {
159
217
 
160
218
  describe('The contact page', () => {
161
219
  const n = journeyDefinition.find(n => n.current.page === CONTACT.page)
220
+
162
221
  it('has a back-link to the address-lookup page if the contact summary has not been seen and is not a physical licence', () => {
163
222
  expect(n.backLink({}, {})).toBe(ADDRESS_LOOKUP.uri)
164
223
  })
224
+
165
225
  it('has a back-link to the licence confirmation method page if the contact summary has not been seen and is a physical licence', () => {
166
226
  isPhysical.mockReturnValueOnce(true)
167
227
  expect(n.backLink({}, {})).toBe(LICENCE_CONFIRMATION_METHOD.uri)
168
228
  })
229
+
169
230
  it('has a back-link to the licence confirmation method page if the contact summary has been seen and the last submitted page is licence confirmation method', () => {
170
231
  expect(n.backLink({ currentPage: LICENCE_CONFIRMATION_METHOD.page, fromSummary: CONTACT_SUMMARY_SEEN })).toBe(
171
232
  LICENCE_CONFIRMATION_METHOD.uri
172
233
  )
173
234
  })
235
+
174
236
  it('has a back-link to the contact-summary page if the contact-summary is seen', () => {
175
237
  expect(n.backLink({ fromSummary: CONTACT_SUMMARY_SEEN })).toBe(CONTACT_SUMMARY.uri)
176
238
  })
@@ -178,9 +240,11 @@ describe('The contact page', () => {
178
240
 
179
241
  describe('The newsletter page', () => {
180
242
  const n = journeyDefinition.find(n => n.current.page === NEWSLETTER.page)
243
+
181
244
  it('has a back-link to the contact page if the contact summary has not been seen', () => {
182
245
  expect(n.backLink({})).toBe(CONTACT.uri)
183
246
  })
247
+
184
248
  it('has a back-link to the contact-summary page if the contact-summary is seen', () => {
185
249
  expect(n.backLink({ fromSummary: CONTACT_SUMMARY_SEEN })).toBe(CONTACT_SUMMARY.uri)
186
250
  })
@@ -188,6 +252,7 @@ describe('The newsletter page', () => {
188
252
 
189
253
  describe('The choose payment page', () => {
190
254
  const n = journeyDefinition.find(n => n.current.page === CHOOSE_PAYMENT.page)
255
+
191
256
  it('has a back-link to the terms and conditions page', () => {
192
257
  expect(n.backLink).toBe(TERMS_AND_CONDITIONS.uri)
193
258
  })
@@ -33,7 +33,11 @@ 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,
38
+ JOURNEY_GOAL,
39
+ CANCEL_RP_ALREADY_CANCELLED,
40
+ CANCEL_RP_LICENCE_NOT_FOUND
37
41
  } from '../uri.js'
38
42
 
39
43
  import { CommonResults, CONTACT_SUMMARY_SEEN, ShowDigitalLicencePages } from '../constants.js'
@@ -42,8 +46,34 @@ import { licenceToStartResults } from '../pages/licence-details/licence-to-start
42
46
  import { addressLookupResults } from '../pages/contact/address/lookup/result-function.js'
43
47
  import { ageConcessionResults } from '../pages/concessions/date-of-birth/result-function.js'
44
48
  import { licenceLengthResults } from '../pages/licence-details/licence-length/result-function.js'
49
+ import { journeyGoalResults } from '../pages/journey-goal/result-function.js'
45
50
  import { isPhysical } from '../processors/licence-type-display.js'
46
51
 
52
+ const getJourneyStart = () => {
53
+ if (process.env.CHANNEL === 'telesales') {
54
+ return [
55
+ {
56
+ current: { page: 'start' },
57
+ next: {
58
+ [CommonResults.OK]: {
59
+ page: JOURNEY_GOAL
60
+ }
61
+ }
62
+ }
63
+ ]
64
+ }
65
+ return [
66
+ {
67
+ current: { page: 'start' },
68
+ next: {
69
+ [CommonResults.OK]: {
70
+ page: LICENCE_FOR
71
+ }
72
+ }
73
+ }
74
+ ]
75
+ }
76
+
47
77
  /**
48
78
  * The structure of each atom is as follows
49
79
  * current - the current page
@@ -51,13 +81,22 @@ import { isPhysical } from '../processors/licence-type-display.js'
51
81
  * backLink - the location the back link, a uri literal, a function of the current status of a function of the status and transaction
52
82
  */
53
83
  export default [
84
+ ...getJourneyStart(),
85
+
54
86
  {
55
- current: { page: 'start' },
87
+ current: JOURNEY_GOAL,
56
88
  next: {
57
- [CommonResults.OK]: {
89
+ [journeyGoalResults.CANCEL_RECURRING_PAYMENT]: {
90
+ page: CANCEL_RP_IDENTIFY
91
+ },
92
+ [journeyGoalResults.RENEW_PERMISSION]: {
93
+ page: IDENTIFY
94
+ },
95
+ [journeyGoalResults.PURCHASE_PERMISSION]: {
58
96
  page: LICENCE_FOR
59
97
  }
60
- }
98
+ },
99
+ backLink: () => null
61
100
  },
62
101
 
63
102
  {
@@ -70,7 +109,15 @@ export default [
70
109
  page: LICENCE_SUMMARY
71
110
  }
72
111
  },
73
- backLink: s => (s.fromSummary ? LICENCE_SUMMARY.uri : null)
112
+ backLink: s => {
113
+ if (s.fromSummary) {
114
+ return LICENCE_SUMMARY.uri
115
+ }
116
+ if (process.env.CHANNEL === 'telesales') {
117
+ return JOURNEY_GOAL.uri
118
+ }
119
+ return null
120
+ }
74
121
  },
75
122
 
76
123
  {
@@ -418,9 +465,9 @@ export default [
418
465
  [CommonResults.OK]: {
419
466
  page: LICENCE_SUMMARY
420
467
  }
421
- }
468
+ },
469
+ ...(process.env.CHANNEL === 'telesales' ? { backLink: JOURNEY_GOAL.uri } : {})
422
470
  },
423
-
424
471
  {
425
472
  current: LICENCE_NOT_FOUND,
426
473
  backLink: IDENTIFY.uri
@@ -439,7 +486,8 @@ export default [
439
486
  [CommonResults.OK]: {
440
487
  page: CANCEL_RP_DETAILS
441
488
  }
442
- }
489
+ },
490
+ ...(process.env.CHANNEL === 'telesales' ? { backLink: JOURNEY_GOAL.uri } : {})
443
491
  },
444
492
  {
445
493
  current: CANCEL_RP_DETAILS,
@@ -456,6 +504,23 @@ export default [
456
504
  [CommonResults.OK]: {
457
505
  page: CANCEL_RP_COMPLETE
458
506
  }
459
- }
507
+ },
508
+ backLink: CANCEL_RP_DETAILS.uri
509
+ },
510
+ {
511
+ current: CANCEL_RP_AGREEMENT_NOT_FOUND,
512
+ backLink: CANCEL_RP_IDENTIFY.uri
513
+ },
514
+ {
515
+ current: CANCEL_RP_LICENCE_NOT_FOUND,
516
+ backLink: CANCEL_RP_IDENTIFY.uri
517
+ },
518
+ {
519
+ current: CANCEL_RP_ALREADY_CANCELLED,
520
+ backLink: CANCEL_RP_IDENTIFY.uri
521
+ },
522
+ {
523
+ current: CANCEL_RP_LICENCE_NOT_FOUND,
524
+ backLink: CANCEL_RP_IDENTIFY.uri
460
525
  }
461
526
  ]
@@ -1,9 +1,13 @@
1
1
  import { OIDC_SIGNIN, OIDC_ACCOUNT_DISABLED, OIDC_ROLE_REQUIRED, CONTROLLER } from '../uri.js'
2
2
  import { signIn } from '../handlers/oidc-handler.js'
3
+ import journeyGoal from '../pages/journey-goal/route.js'
3
4
  import cancelRPIdentify from '../pages/recurring-payments/cancel/identify/route.js'
4
5
  import cancelRPDetails from '../pages/recurring-payments/cancel/details/route.js'
5
6
  import cancelRPConfirm from '../pages/recurring-payments/cancel/confirm/route.js'
6
7
  import cancelRPComplete from '../pages/recurring-payments/cancel/complete/route.js'
8
+ import cancelRPAgreementNotFound from '../pages/recurring-payments/cancel/agreement-not-found/route.js'
9
+ import cancelRPLicenceNotFound from '../pages/recurring-payments/cancel/licence-not-found/route.js'
10
+ import cancelRPAlreadyCancelled from '../pages/recurring-payments/cancel/already-cancelled/route.js'
7
11
 
8
12
  const telesalesRoutes = [
9
13
  {
@@ -28,13 +32,19 @@ const telesalesRoutes = [
28
32
  path: OIDC_ROLE_REQUIRED.uri,
29
33
  handler: async (request, h) => h.view(OIDC_ROLE_REQUIRED.page, { uri: { buy: CONTROLLER.uri } }),
30
34
  options: { auth: false }
31
- }
35
+ },
36
+ ...journeyGoal
32
37
  ]
33
38
 
34
39
  if (process.env.SHOW_CANCELLATION_JOURNEY === 'true') {
35
- telesalesRoutes.push(...cancelRPIdentify)
36
- telesalesRoutes.push(...cancelRPDetails)
37
- telesalesRoutes.push(...cancelRPConfirm)
38
- telesalesRoutes.push(...cancelRPComplete)
40
+ telesalesRoutes.push(
41
+ ...cancelRPIdentify,
42
+ ...cancelRPDetails,
43
+ ...cancelRPConfirm,
44
+ ...cancelRPComplete,
45
+ ...cancelRPAgreementNotFound,
46
+ ...cancelRPAlreadyCancelled,
47
+ ...cancelRPLicenceNotFound
48
+ )
39
49
  }
40
50
  export default telesalesRoutes
package/src/uri.js CHANGED
@@ -62,11 +62,22 @@ export const ERROR_TESTING = { uri: '/buy/throw-error' }
62
62
  export const CHOOSE_PAYMENT = { uri: '/buy/choose-payment', page: 'choose-payment' }
63
63
  export const SET_UP_PAYMENT = { uri: '/buy/set-up-recurring-card-payment', page: 'set-up-payment' }
64
64
 
65
+ /**
66
+ * Recurring payments cancellation pages
67
+ */
65
68
  export const CANCEL_RP_IDENTIFY = { uri: '/buy/cancel-recurring-payment/identify', page: 'cancel-rp-identify' }
66
69
  export const CANCEL_RP_AUTHENTICATE = { uri: '/buy/cancel-recurring-payment/authenticate' }
67
70
  export const CANCEL_RP_DETAILS = { uri: '/buy/cancel-recurring-payment/details', page: 'cancel-rp-details' }
68
71
  export const CANCEL_RP_CONFIRM = { uri: '/buy/cancel-recurring-payment/confirm', page: 'cancel-rp-confirm' }
69
72
  export const CANCEL_RP_COMPLETE = { uri: '/buy/cancel-recurring-payment/complete', page: 'cancel-rp-complete' }
73
+ export const CANCEL_RP_AGREEMENT_NOT_FOUND = {
74
+ uri: '/buy/cancel-recurring-payment/agreement-not-found',
75
+ page: 'cancel-rp-agreement-not-found'
76
+ }
77
+ export const CANCEL_RP_LICENCE_NOT_FOUND = { uri: '/buy/cancel-recurring-payment/licence-not-found', page: 'licence-not-found' }
78
+ export const CANCEL_RP_ALREADY_CANCELLED = { uri: '/buy/cancel-recurring-payment/already-cancelled', page: 'already-cancelled' }
79
+
80
+ export const JOURNEY_GOAL = { uri: '/buy/journey-goal', page: 'journey-goal' }
70
81
 
71
82
  /**
72
83
  * These are informational static pages