@defra-fish/gafl-webapp-service 1.64.0 → 1.65.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra-fish/gafl-webapp-service",
3
- "version": "1.64.0",
3
+ "version": "1.65.0-rc.1",
4
4
  "description": "The websales frontend for the GAFL service",
5
5
  "type": "module",
6
6
  "engines": {
@@ -36,8 +36,8 @@
36
36
  "prepare": "gulp --gulpfile build/gulpfile.cjs"
37
37
  },
38
38
  "dependencies": {
39
- "@defra-fish/business-rules-lib": "1.64.0",
40
- "@defra-fish/connectors-lib": "1.64.0",
39
+ "@defra-fish/business-rules-lib": "1.65.0-rc.1",
40
+ "@defra-fish/connectors-lib": "1.65.0-rc.1",
41
41
  "@defra/hapi-gapi": "2.0.0",
42
42
  "@hapi/boom": "9.1.2",
43
43
  "@hapi/catbox-redis": "6.0.2",
@@ -79,5 +79,5 @@
79
79
  "./gafl-jest-matchers.js"
80
80
  ]
81
81
  },
82
- "gitHead": "d6a3d30c7a20169fdf5afb1a93eb1d411fe96abf"
82
+ "gitHead": "3e4014cd3d4fae6d6dc6b7f5b338821a572286fb"
83
83
  }
@@ -182,6 +182,7 @@
182
182
  "client_error_payment_start_again_pre": "Neu, os byddai’n well gennych, gallwch waredu’r drwydded hon a ",
183
183
  "client_error_payment_start_again": "dechrau eto",
184
184
  "concession_applied": "Consesiwn wedi’i gynnwys",
185
+ "confirm_continue": "Confirm and continue",
185
186
  "contact_summary_change": "Newid",
186
187
  "contact_summary_email": "e-bost i ",
187
188
  "contact_summary_hidden_address": "cyfeiriad",
@@ -786,8 +787,17 @@
786
787
  "role_required_body_2": "Please contact your Microsoft Dynamics administrator to request access.",
787
788
  "role_required_title": "Role required",
788
789
  "rp_cancel_complete_title": "Cancel your recurring card payment agreement - complete",
789
- "rp_cancel_confirm_title": "Cancel your recurring card payment agreement - confirm",
790
- "rp_cancel_details_title": "Cancel your recurring card payment agreement - details",
790
+ "rp_cancel_confirm_accept": "Yes, cancel my recurring payment agreement",
791
+ "rp_cancel_confirm_body": "Your current licence will reman valid until it expires on ",
792
+ "rp_cancel_confirm_reject": "No, I've changed my mind",
793
+ "rp_cancel_confirm_title": "Confirm you want to cancel",
794
+ "rp_cancel_details_last_purchased": "Last licence purchased",
795
+ "rp_cancel_details_licence_holder": "Licence holder",
796
+ "rp_cancel_details_licence_type": "Licence type",
797
+ "rp_cancel_details_licence_valid_until": "Licence valid until",
798
+ "rp_cancel_details_payment_card": "Payment card (last 4 digits)",
799
+ "rp_cancel_details_title": "Check your details",
800
+ "rp_cancel_details_summary_title": "If you need help checking your details",
791
801
  "save_changes": "Cadw newidiadau",
792
802
  "server_error_title_suffix": " - GOV.UK",
793
803
  "server_error_bulletpoint_1": "Os ydych chi wedi gofyn am hysbysiad dros e-bost neu neges destun, dylai’r hysbysiad gyrraedd o fewn 3 awr os bydd y taliad wedi cael ei gymryd.",
@@ -182,6 +182,7 @@
182
182
  "client_error_payment_start_again_pre": "Or, if you wish, you can discard this licence and ",
183
183
  "client_error_payment_start_again": "start again",
184
184
  "concession_applied": "Concession applied",
185
+ "confirm_continue": "Confirm and continue",
185
186
  "contact_summary_change": "Change",
186
187
  "contact_summary_email": "Email to ",
187
188
  "contact_summary_hidden_address": "address",
@@ -786,8 +787,17 @@
786
787
  "role_required_body_2": "Please contact your Microsoft Dynamics administrator to request access.",
787
788
  "role_required_title": "Role required",
788
789
  "rp_cancel_complete_title": "Cancel your recurring card payment agreement - complete",
789
- "rp_cancel_confirm_title": "Cancel your recurring card payment agreement - confirm",
790
- "rp_cancel_details_title": "Cancel your recurring card payment agreement - details",
790
+ "rp_cancel_confirm_accept": "Yes, cancel my recurring payment agreement",
791
+ "rp_cancel_confirm_body": "Your current licence will reman valid until it expires on ",
792
+ "rp_cancel_confirm_reject": "No, I've changed my mind",
793
+ "rp_cancel_confirm_title": "Confirm you want to cancel",
794
+ "rp_cancel_details_last_purchased": "Last licence purchased",
795
+ "rp_cancel_details_licence_holder": "Licence holder",
796
+ "rp_cancel_details_licence_type": "Licence type",
797
+ "rp_cancel_details_licence_valid_until": "Licence valid until",
798
+ "rp_cancel_details_payment_card": "Payment card (last 4 digits)",
799
+ "rp_cancel_details_title": "Check your details",
800
+ "rp_cancel_details_summary_title": "If you need help checking your details",
791
801
  "save_changes": "Save changes",
792
802
  "server_error_title_suffix": " - GOV.UK",
793
803
  "server_error_bulletpoint_1": "If you have requested an email or text notification, this should be delivered in 3 hours if a payment has been taken.",
@@ -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
- <div class="govuk-grid-row">
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.continue,
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, CANCEL_RP_COMPLETE } from '../../../../uri.js'
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
  )
@@ -0,0 +1,131 @@
1
+ import pageRoute from '../../../../../routes/page-route.js'
2
+ import { CANCEL_RP_DETAILS, CANCEL_RP_CONFIRM } from '../../../../../uri.js'
3
+ import { addLanguageCodeToUri } from '../../../../../processors/uri-helper.js'
4
+ import { getData } from '../route.js'
5
+
6
+ jest.mock('../../../../../routes/page-route.js')
7
+ jest.mock('../../../../../uri.js', () => ({
8
+ ...jest.requireActual('../../../../../uri.js'),
9
+ CANCEL_RP_DETAILS: { page: Symbol('cancel-rp-details-page'), uri: Symbol('cancel-rp-details-uri') },
10
+ CANCEL_RP_CONFIRM: { uri: Symbol('cancel-rp-confirm-uri') }
11
+ }))
12
+ jest.mock('../../../../../processors/uri-helper.js')
13
+
14
+ describe('route', () => {
15
+ beforeEach(jest.clearAllMocks)
16
+
17
+ describe('pageRoute receives expected arguments', () => {
18
+ it('should call the pageRoute with cancel-rp-details, /buy/cancel-recurring-payment/details, dateOfBirthValidator, nextPage and getData', async () => {
19
+ jest.isolateModules(() => {
20
+ require('../route.js')
21
+ expect(pageRoute).toHaveBeenCalledWith(
22
+ CANCEL_RP_DETAILS.page,
23
+ CANCEL_RP_DETAILS.uri,
24
+ expect.any(Function),
25
+ expect.any(Function),
26
+ expect.any(Function)
27
+ )
28
+ })
29
+ })
30
+ })
31
+
32
+ it('calls addLanguageCodeToUri with request object', async () => {
33
+ jest.isolateModules(() => {
34
+ require('../route.js')
35
+ })
36
+ const [[, , , completion]] = pageRoute.mock.calls
37
+ const sampleRequest = Symbol('sample request')
38
+ completion(sampleRequest)
39
+ expect(addLanguageCodeToUri).toHaveBeenCalledWith(sampleRequest, expect.anything())
40
+ })
41
+
42
+ it('calls addLanguageCodeToUri with CANCEL_RP_AUTHENTICATE uri', () => {
43
+ jest.isolateModules(() => {
44
+ require('../route.js')
45
+ })
46
+ const [[, , , completion]] = pageRoute.mock.calls
47
+ completion({})
48
+ expect(addLanguageCodeToUri).toHaveBeenCalledWith(expect.anything(), CANCEL_RP_CONFIRM.uri)
49
+ })
50
+
51
+ it('returns the value of addLanguageCodeToUri', () => {
52
+ jest.isolateModules(() => {
53
+ require('../route.js')
54
+ })
55
+ const [[, , , completion]] = pageRoute.mock.calls
56
+ const expectedCompletionRedirect = Symbol('expected-completion-redirect')
57
+ addLanguageCodeToUri.mockReturnValueOnce(expectedCompletionRedirect)
58
+
59
+ const completionRedirect = completion({})
60
+
61
+ expect(completionRedirect).toBe(expectedCompletionRedirect)
62
+ })
63
+
64
+ const getSampleCatalog = () => ({
65
+ rp_cancel_details_licence_holder: 'Licence holder',
66
+ rp_cancel_details_licence_type: 'Licence type',
67
+ rp_cancel_details_payment_card: 'Payment card',
68
+ rp_cancel_details_last_purchased: 'Last purchased',
69
+ rp_cancel_details_licence_valid_until: 'Valid until'
70
+ })
71
+
72
+ const getSamplePermission = () => ({
73
+ permission: {
74
+ licensee: {
75
+ firstName: 'John',
76
+ lastName: 'Smith'
77
+ },
78
+ permit: {
79
+ description: 'Salmon and sea trout'
80
+ },
81
+ endDate: '01-01-2026',
82
+ referenceNumber: 'abc123'
83
+ },
84
+ recurringPayment: {
85
+ lastDigitsCardNumbers: 1234
86
+ }
87
+ })
88
+
89
+ const createMockRequest = ({ currentPermission = getSamplePermission(), catalog = getSampleCatalog() } = {}) => ({
90
+ cache: () => ({
91
+ helpers: {
92
+ transaction: {
93
+ getCurrentPermission: jest.fn().mockResolvedValue(currentPermission)
94
+ }
95
+ }
96
+ }),
97
+ i18n: {
98
+ getCatalog: () => catalog
99
+ }
100
+ })
101
+
102
+ describe('getData', () => {
103
+ beforeEach(() => {
104
+ jest.clearAllMocks()
105
+ })
106
+
107
+ it('returns request.i18n.getCatalog()', async () => {
108
+ const mssgs = getSampleCatalog()
109
+ const mockRequest = createMockRequest({ catalog: mssgs })
110
+
111
+ const result = await getData(mockRequest)
112
+
113
+ expect(result.mssgs).toEqual(mssgs)
114
+ })
115
+
116
+ it('returns summaryTable with expected data', async () => {
117
+ const mssgs = getSampleCatalog()
118
+ const mockRequest = createMockRequest({ catalog: mssgs })
119
+
120
+ const result = await getData(mockRequest)
121
+
122
+ expect(result.summaryTable).toEqual([
123
+ { key: { text: mssgs.rp_cancel_details_licence_holder }, value: { text: 'John Smith' } },
124
+ { key: { text: mssgs.rp_cancel_details_licence_type }, value: { text: 'Salmon and sea trout' } },
125
+ { key: { text: mssgs.rp_cancel_details_payment_card }, value: { text: 1234 } },
126
+ { key: { text: mssgs.rp_cancel_details_last_purchased }, value: { text: 'abc123' } },
127
+ { key: { text: mssgs.rp_cancel_details_licence_valid_until }, value: { text: '01-01-2026' } }
128
+ ])
129
+ })
130
+ })
131
+ })
@@ -2,22 +2,70 @@
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 %}
6
+ {% from "summary-list/macro.njk" import govukSummaryList %}
7
+ {% from "details/macro.njk" import govukDetails %}
5
8
 
6
9
  {% set title = mssgs.rp_cancel_details_title %}
7
10
  {% block pageTitle %}{{ pageTitle(title, error, mssgs) }}{% endblock %}
8
11
 
12
+ {% set licenseDetailsSummary %}
13
+ {% set legendHtml %}
14
+ <span class="govuk-caption-l">{{ mssgs.cancel_rp_identify_caption }}</span>
15
+ {{ title }}
16
+ {% endset %}
17
+
18
+ {% call govukFieldset({
19
+ legend: {
20
+ html: legendHtml,
21
+ classes: "govuk-fieldset__legend--l govuk-!-margin-bottom-3",
22
+ isPageHeading: true
23
+ }
24
+ }) %}
25
+ {{ govukSummaryList({
26
+ classes: 'licence-summary-list',
27
+ rows: data.summaryTable
28
+ }) }}
29
+ {% endcall %}
30
+ {% endset -%}
31
+
32
+ {% set detailsHtml %}
33
+ <p class="govuk-body">
34
+ {{ mssgs.refund_bulletpoint_1_2 }}
35
+ </p>
36
+ <p class="govuk-body">
37
+ {{ mssgs.refund_bulletpoint_1_3 }}
38
+ </p>
39
+ <p class="govuk-body">
40
+ {{ mssgs.refund_bulletpoint_1_4 }}
41
+ </p>
42
+ <p class="govuk-body govuk-!-margin-bottom-0">
43
+ <a class="govuk-link" href="https://www.gov.uk/call-charges" target="_blank" rel="noreferrer noopener">
44
+ {{ mssgs.refund_bulletpoint_1_5 }}
45
+ </a>
46
+ </p>
47
+ {% endset %}
48
+
9
49
  {% block content %}
10
50
  <div class="govuk-grid-row">
11
51
  <div class="govuk-grid-column-two-thirds">
12
- <form method="post" class="govuk-!-margin-bottom-6">
13
- {{ govukButton({
14
- attributes: { id: 'continue' },
15
- preventDoubleClick: true,
16
- name: "continue",
17
- text: mssgs.continue,
18
- classes: "govuk-!-margin-top-1"
19
- }) }}
20
- {{ csrf() }}
52
+ <form method="post">
53
+ {{ licenseDetailsSummary | trim | safe }}
54
+
55
+ {{ govukButton({
56
+ attributes: { id: 'continue' },
57
+ preventDoubleClick: true,
58
+ name: "continue",
59
+ text: mssgs.confirm_continue,
60
+ classes: "govuk-!-margin-top-5"
61
+ }) }}
62
+
63
+ {{ govukDetails({
64
+ summaryText: mssgs.rp_cancel_details_summary_title,
65
+ html: detailsHtml
66
+ }) }}
67
+
68
+ {{ csrf() }}
21
69
  </form>
22
70
  </div>
23
71
  </div>
@@ -2,10 +2,31 @@ 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
 
5
+ const getLicenseeDetailsSummaryRows = (currentPermission, mssgs) => [
6
+ {
7
+ key: { text: mssgs.rp_cancel_details_licence_holder },
8
+ value: { text: `${currentPermission.permission.licensee.firstName} ${currentPermission.permission.licensee.lastName}` }
9
+ },
10
+ { 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 } },
12
+ { 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 } }
14
+ ]
15
+
16
+ export const getData = async request => {
17
+ const currentPermission = await request.cache().helpers.transaction.getCurrentPermission()
18
+ const mssgs = request.i18n.getCatalog()
19
+
20
+ return {
21
+ mssgs,
22
+ summaryTable: getLicenseeDetailsSummaryRows(currentPermission, mssgs)
23
+ }
24
+ }
25
+
5
26
  export default pageRoute(
6
27
  CANCEL_RP_DETAILS.page,
7
28
  CANCEL_RP_DETAILS.uri,
8
29
  () => {},
9
30
  request => addLanguageCodeToUri(request, CANCEL_RP_CONFIRM.uri),
10
- () => {}
31
+ getData
11
32
  )
@@ -447,14 +447,16 @@ export default [
447
447
  [CommonResults.OK]: {
448
448
  page: CANCEL_RP_CONFIRM
449
449
  }
450
- }
450
+ },
451
+ backLink: CANCEL_RP_IDENTIFY.uri
451
452
  },
452
453
  {
453
454
  current: CANCEL_RP_CONFIRM,
454
455
  next: {
455
456
  [CommonResults.OK]: {
456
457
  page: CANCEL_RP_COMPLETE
457
- }
458
+ },
459
+ backLink: CANCEL_RP_DETAILS.uri
458
460
  }
459
461
  }
460
462
  ]
@@ -1,106 +0,0 @@
1
- import pageRoute from '../../../../../routes/page-route.js'
2
- import { CANCEL_RP_CONFIRM, CANCEL_RP_COMPLETE } from '../../../../../uri.js'
3
- import { addLanguageCodeToUri } from '../../../../../processors/uri-helper.js'
4
-
5
- require('../route.js')
6
- // eslint-disable-next-line no-unused-vars
7
- const [[_v, _p, validator, completion, getData]] = pageRoute.mock.calls
8
-
9
- jest.mock('../../../../../routes/page-route.js')
10
- jest.mock('../../../../../uri.js', () => ({
11
- ...jest.requireActual('../../../../../uri.js'),
12
- CANCEL_RP_CONFIRM: { page: Symbol('cancel-rp-confirm-page'), uri: Symbol('cancel-rp-confirm-uri') },
13
- CANCEL_RP_COMPLETE: { uri: Symbol('cancel-rp-complete-uri') }
14
- }))
15
- jest.mock('../../../../../processors/uri-helper.js')
16
-
17
- describe('pageRoute receives expected arguments', () => {
18
- it('passes CANCEL_RP_CONFIRM.page as the view name', () => {
19
- jest.isolateModules(() => {
20
- require('../route.js')
21
- expect(pageRoute).toHaveBeenCalledWith(
22
- CANCEL_RP_CONFIRM.page,
23
- expect.anything(),
24
- expect.anything(),
25
- expect.anything(),
26
- expect.anything()
27
- )
28
- })
29
- })
30
-
31
- it('passes CANCEL_RP_CONFIRM.uri as the path', () => {
32
- jest.isolateModules(() => {
33
- require('../route.js')
34
- expect(pageRoute).toHaveBeenCalledWith(
35
- expect.anything(),
36
- CANCEL_RP_CONFIRM.uri,
37
- expect.anything(),
38
- expect.anything(),
39
- expect.anything()
40
- )
41
- })
42
- })
43
-
44
- it('passes a function as the validator', () => {
45
- jest.isolateModules(() => {
46
- require('../route.js')
47
- expect(pageRoute).toHaveBeenCalledWith(
48
- expect.anything(),
49
- expect.anything(),
50
- expect.any(Function),
51
- expect.anything(),
52
- expect.anything()
53
- )
54
- })
55
- })
56
-
57
- it('passes a function to generate redirect location on completion', () => {
58
- jest.isolateModules(() => {
59
- require('../route.js')
60
- expect(pageRoute).toHaveBeenCalledWith(
61
- expect.anything(),
62
- expect.anything(),
63
- expect.anything(),
64
- expect.any(Function),
65
- expect.anything()
66
- )
67
- })
68
- })
69
-
70
- it('passes a function to get the page data', () => {
71
- jest.isolateModules(() => {
72
- require('../route.js')
73
- expect(pageRoute).toHaveBeenCalledWith(
74
- expect.anything(),
75
- expect.anything(),
76
- expect.anything(),
77
- expect.anything(),
78
- expect.any(Function)
79
- )
80
- })
81
- })
82
- })
83
-
84
- describe('completion function', () => {
85
- beforeEach(jest.clearAllMocks)
86
-
87
- it('calls addLanguageCodeToUri with request object', () => {
88
- const sampleRequest = Symbol('sample request')
89
- completion(sampleRequest)
90
- expect(addLanguageCodeToUri).toHaveBeenCalledWith(sampleRequest, expect.anything())
91
- })
92
-
93
- it('calls addLanguageCodeToUri with CANCEL_RP_AUTHENTICATE uri', () => {
94
- completion({})
95
- expect(addLanguageCodeToUri).toHaveBeenCalledWith(expect.anything(), CANCEL_RP_COMPLETE.uri)
96
- })
97
-
98
- it('returns the value of addLanguageCodeToUri', () => {
99
- const expectedCompletionRedirect = Symbol('expected-completion-redirect')
100
- addLanguageCodeToUri.mockReturnValueOnce(expectedCompletionRedirect)
101
-
102
- const completionRedirect = completion({})
103
-
104
- expect(completionRedirect).toBe(expectedCompletionRedirect)
105
- })
106
- })
@@ -1,106 +0,0 @@
1
- import pageRoute from '../../../../../routes/page-route.js'
2
- import { CANCEL_RP_DETAILS, CANCEL_RP_CONFIRM } from '../../../../../uri.js'
3
- import { addLanguageCodeToUri } from '../../../../../processors/uri-helper.js'
4
-
5
- require('../route.js')
6
- // eslint-disable-next-line no-unused-vars
7
- const [[_v, _p, validator, completion, getData]] = pageRoute.mock.calls
8
-
9
- jest.mock('../../../../../routes/page-route.js')
10
- jest.mock('../../../../../uri.js', () => ({
11
- ...jest.requireActual('../../../../../uri.js'),
12
- CANCEL_RP_DETAILS: { page: Symbol('cancel-rp-details-page'), uri: Symbol('cancel-rp-details-uri') },
13
- CANCEL_RP_CONFIRM: { uri: Symbol('cancel-rp-confirm-uri') }
14
- }))
15
- jest.mock('../../../../../processors/uri-helper.js')
16
-
17
- describe('pageRoute receives expected arguments', () => {
18
- it('passes CANCEL_RP_DETAILS.page as the view name', () => {
19
- jest.isolateModules(() => {
20
- require('../route.js')
21
- expect(pageRoute).toHaveBeenCalledWith(
22
- CANCEL_RP_DETAILS.page,
23
- expect.anything(),
24
- expect.anything(),
25
- expect.anything(),
26
- expect.anything()
27
- )
28
- })
29
- })
30
-
31
- it('passes CANCEL_RP_DETAILS.uri as the path', () => {
32
- jest.isolateModules(() => {
33
- require('../route.js')
34
- expect(pageRoute).toHaveBeenCalledWith(
35
- expect.anything(),
36
- CANCEL_RP_DETAILS.uri,
37
- expect.anything(),
38
- expect.anything(),
39
- expect.anything()
40
- )
41
- })
42
- })
43
-
44
- it('passes a function as the validator', () => {
45
- jest.isolateModules(() => {
46
- require('../route.js')
47
- expect(pageRoute).toHaveBeenCalledWith(
48
- expect.anything(),
49
- expect.anything(),
50
- expect.any(Function),
51
- expect.anything(),
52
- expect.anything()
53
- )
54
- })
55
- })
56
-
57
- it('passes a function to generate redirect location on completion', () => {
58
- jest.isolateModules(() => {
59
- require('../route.js')
60
- expect(pageRoute).toHaveBeenCalledWith(
61
- expect.anything(),
62
- expect.anything(),
63
- expect.anything(),
64
- expect.any(Function),
65
- expect.anything()
66
- )
67
- })
68
- })
69
-
70
- it('passes a function to get the page data', () => {
71
- jest.isolateModules(() => {
72
- require('../route.js')
73
- expect(pageRoute).toHaveBeenCalledWith(
74
- expect.anything(),
75
- expect.anything(),
76
- expect.anything(),
77
- expect.anything(),
78
- expect.any(Function)
79
- )
80
- })
81
- })
82
- })
83
-
84
- describe('completion function', () => {
85
- beforeEach(jest.clearAllMocks)
86
-
87
- it('calls addLanguageCodeToUri with request object', () => {
88
- const sampleRequest = Symbol('sample request')
89
- completion(sampleRequest)
90
- expect(addLanguageCodeToUri).toHaveBeenCalledWith(sampleRequest, expect.anything())
91
- })
92
-
93
- it('calls addLanguageCodeToUri with CANCEL_RP_AUTHENTICATE uri', () => {
94
- completion({})
95
- expect(addLanguageCodeToUri).toHaveBeenCalledWith(expect.anything(), CANCEL_RP_CONFIRM.uri)
96
- })
97
-
98
- it('returns the value of addLanguageCodeToUri', () => {
99
- const expectedCompletionRedirect = Symbol('expected-completion-redirect')
100
- addLanguageCodeToUri.mockReturnValueOnce(expectedCompletionRedirect)
101
-
102
- const completionRedirect = completion({})
103
-
104
- expect(completionRedirect).toBe(expectedCompletionRedirect)
105
- })
106
- })