@defra-fish/gafl-webapp-service 1.75.0-rc.8 → 1.75.0

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.75.0-rc.8",
3
+ "version": "1.75.0",
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.75.0-rc.8",
40
- "@defra-fish/connectors-lib": "1.75.0-rc.8",
39
+ "@defra-fish/business-rules-lib": "1.75.0",
40
+ "@defra-fish/connectors-lib": "1.75.0",
41
41
  "@defra/hapi-gapi": "2.0.0",
42
42
  "@hapi/boom": "9.1.2",
43
43
  "@hapi/catbox-redis": "6.0.2",
@@ -72,12 +72,12 @@
72
72
  "gulp-minify": "3.1.0",
73
73
  "gulp-sass": "5.1.0",
74
74
  "gulp-sourcemaps": "3.0.0",
75
- "sass": "1.102.0"
75
+ "sass": "1.69.3"
76
76
  },
77
77
  "jest": {
78
78
  "setupFilesAfterEnv": [
79
79
  "./gafl-jest-matchers.js"
80
80
  ]
81
81
  },
82
- "gitHead": "0d112029a9843bf54baa5f719d5ea8d32ef33f43"
82
+ "gitHead": "0fec5ec015fb288eabf13f366319bcb9214e81c0"
83
83
  }
@@ -1,6 +1,7 @@
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 { licenceTypeDisplay } from '../../../../../processors/licence-type-display.js'
4
5
  import { getData } from '../route.js'
5
6
  import moment from 'moment-timezone'
6
7
  import { cacheDateFormat, dateDisplayFormat } from '../../../../../processors/date-and-time-display.js'
@@ -12,6 +13,7 @@ jest.mock('../../../../../uri.js', () => ({
12
13
  CANCEL_RP_CONFIRM: { uri: Symbol('cancel-rp-confirm-uri') }
13
14
  }))
14
15
  jest.mock('../../../../../processors/uri-helper.js')
16
+ jest.mock('../../../../../processors/licence-type-display.js')
15
17
  jest.mock('moment-timezone', () =>
16
18
  jest.fn(() => ({
17
19
  format: jest.fn()
@@ -77,7 +79,10 @@ describe('route', () => {
77
79
  rp_cancel_details_licence_type: 'Licence type',
78
80
  rp_cancel_details_payment_card: 'Payment card',
79
81
  rp_cancel_details_last_purchased: 'Last purchased',
80
- rp_cancel_details_licence_valid_until: 'Valid until'
82
+ rp_cancel_details_licence_valid_until: 'Valid until',
83
+ licence_type_radio_salmon_payment_summary: 'Salmon and sea trout',
84
+ licence_type_radio_trout_two_rod_payment_summary: 'Trout and coarse (up to 2 rods)',
85
+ licence_type_radio_trout_three_rod_payment_summary: 'Trout and coarse (up to 3 rods)'
81
86
  })
82
87
 
83
88
  const getSamplePermission = () => ({
@@ -87,7 +92,9 @@ describe('route', () => {
87
92
  lastName: 'Smith'
88
93
  },
89
94
  permit: {
90
- description: 'Salmon and sea trout'
95
+ description: 'Salmon and sea trout',
96
+ permitSubtype: { label: 'Salmon and sea trout' },
97
+ numberOfRods: 2
91
98
  },
92
99
  endDate: '01-01-2026',
93
100
  referenceNumber: 'abc123'
@@ -134,7 +141,9 @@ describe('route', () => {
134
141
  lastName: 'Pysgotwr'
135
142
  },
136
143
  permit: {
137
- description: 'Wellies and old shopping trollies'
144
+ description: 'Wellies and old shopping trollies',
145
+ permitSubtype: { label: 'Trout and coarse' },
146
+ numberOfRods: 2
138
147
  },
139
148
  endDate: '21-03-2026',
140
149
  referenceNumber: 'aaa-111-bbb-222'
@@ -144,10 +153,12 @@ describe('route', () => {
144
153
  }
145
154
  }
146
155
  const sampleFormattedDate = Symbol('formatted-end-date')
156
+ const sampleLicenceTypeDisplayResult = Symbol('licence-type-display-result')
147
157
  const mockRequest = createMockRequest({ catalog: mssgs, currentPermission: sampleData })
148
158
  moment.mockReturnValueOnce({
149
159
  format: () => sampleFormattedDate
150
160
  })
161
+ licenceTypeDisplay.mockReturnValueOnce(sampleLicenceTypeDisplayResult)
151
162
 
152
163
  const result = await getData(mockRequest)
153
164
 
@@ -156,7 +167,7 @@ describe('route', () => {
156
167
  key: { text: mssgs.rp_cancel_details_licence_holder },
157
168
  value: { text: `${sampleData.permission.licensee.firstName} ${sampleData.permission.licensee.lastName}` }
158
169
  },
159
- { key: { text: mssgs.rp_cancel_details_licence_type }, value: { text: sampleData.permission.permit.description } },
170
+ { key: { text: mssgs.rp_cancel_details_licence_type }, value: { text: sampleLicenceTypeDisplayResult } },
160
171
  {
161
172
  key: { text: mssgs.rp_cancel_details_payment_card },
162
173
  value: { text: `**** **** **** ${sampleData.recurringPayment.lastDigitsCardNumbers}` }
@@ -166,6 +177,54 @@ describe('route', () => {
166
177
  ])
167
178
  })
168
179
 
180
+ describe('licence type summary row', () => {
181
+ it.each([['Salmon and sea trout'], ['Trout and coarse']])(
182
+ 'calls licenceTypeDisplay with licenceType set to permitSubtype.label of %s',
183
+ async label => {
184
+ const sampleData = getSamplePermission()
185
+ sampleData.permission.permit.permitSubtype = { label }
186
+ const mockRequest = createMockRequest({ currentPermission: sampleData })
187
+
188
+ await getData(mockRequest)
189
+
190
+ expect(licenceTypeDisplay).toHaveBeenCalledWith({ licenceType: label, numberOfRods: '2' }, expect.anything())
191
+ }
192
+ )
193
+
194
+ it('calls licenceTypeDisplay with numberOfRods converted to a string', async () => {
195
+ const sampleData = getSamplePermission()
196
+ sampleData.permission.permit.numberOfRods = 3
197
+ const mockRequest = createMockRequest({ currentPermission: sampleData })
198
+
199
+ await getData(mockRequest)
200
+
201
+ expect(licenceTypeDisplay).toHaveBeenCalledWith({ licenceType: 'Salmon and sea trout', numberOfRods: '3' }, expect.anything())
202
+ })
203
+
204
+ it('calls licenceTypeDisplay with request.i18n.getCatalog() result as the second argument', async () => {
205
+ const mssgs = getSampleCatalog()
206
+ const mockRequest = createMockRequest({ catalog: mssgs })
207
+
208
+ await getData(mockRequest)
209
+
210
+ expect(licenceTypeDisplay).toHaveBeenCalledWith(expect.anything(), mssgs)
211
+ })
212
+
213
+ it('returns licence type row with licenceTypeDisplay return value as the value text', async () => {
214
+ const mssgs = getSampleCatalog()
215
+ const sampleLicenceTypeDisplayResult = Symbol('licence-type-display-result')
216
+ licenceTypeDisplay.mockReturnValueOnce(sampleLicenceTypeDisplayResult)
217
+ const mockRequest = createMockRequest({ catalog: mssgs })
218
+
219
+ const result = await getData(mockRequest)
220
+
221
+ expect(result.summaryTable[1]).toEqual({
222
+ key: { text: mssgs.rp_cancel_details_licence_type },
223
+ value: { text: sampleLicenceTypeDisplayResult }
224
+ })
225
+ })
226
+ })
227
+
169
228
  it('passes cache date format and request locale to moment', async () => {
170
229
  const data = getSamplePermission()
171
230
  data.permission.endDate = Symbol('end-date')
@@ -3,13 +3,25 @@ import { CANCEL_RP_DETAILS, CANCEL_RP_CONFIRM } from '../../../../uri.js'
3
3
  import { addLanguageCodeToUri } from '../../../../processors/uri-helper.js'
4
4
  import moment from 'moment-timezone'
5
5
  import { cacheDateFormat, dateDisplayFormat } from '../../../../processors/date-and-time-display.js'
6
+ import { licenceTypeDisplay } from '../../../../processors/licence-type-display.js'
6
7
 
7
8
  const getLicenseeDetailsSummaryRows = (currentPermission, mssgs, locale) => [
8
9
  {
9
10
  key: { text: mssgs.rp_cancel_details_licence_holder },
10
11
  value: { text: `${currentPermission.permission.licensee.firstName} ${currentPermission.permission.licensee.lastName}` }
11
12
  },
12
- { key: { text: mssgs.rp_cancel_details_licence_type }, value: { text: currentPermission.permission.permit.description } },
13
+ {
14
+ key: { text: mssgs.rp_cancel_details_licence_type },
15
+ value: {
16
+ text: licenceTypeDisplay(
17
+ {
18
+ licenceType: currentPermission.permission.permit.permitSubtype.label,
19
+ numberOfRods: String(currentPermission.permission.permit.numberOfRods)
20
+ },
21
+ mssgs
22
+ )
23
+ }
24
+ },
13
25
  {
14
26
  key: { text: mssgs.rp_cancel_details_payment_card },
15
27
  value: { text: `**** **** **** ${currentPermission.recurringPayment.lastDigitsCardNumbers}` }
@@ -10,7 +10,11 @@ describe('setUpCancelRecurringPaymentCacheFromAuthenticationResult', () => {
10
10
  lastName: 'Pysgotwr',
11
11
  preferredMethodOfConfirmation: { id: 910400000, label: 'Email', description: 'Email' }
12
12
  },
13
- permit: { description: 'Coarse 6 month 15 Rod Licence (Half)' },
13
+ permit: {
14
+ description: 'Coarse 12 month 3 Rod Licence (Full)',
15
+ permitSubtype: { label: 'Trout and coarse' },
16
+ numberOfRods: 3
17
+ },
14
18
  recurringPayment: { lastDigitsCardNumbers: '5678' }
15
19
  }
16
20
 
@@ -48,8 +52,15 @@ describe('setUpCancelRecurringPaymentCacheFromAuthenticationResult', () => {
48
52
  it.each([
49
53
  ['referenceNumber', '23270624-2WC3FSD-ABNCY4'],
50
54
  ['endDate', '2024-12-31'],
51
- ['permit', { description: 'Coarse 12 month 2 Rod Licence (Full)' }]
52
- ])("Adds permission %s, value '%s', to transaction cache", async (fieldName, fieldValue) => {
55
+ [
56
+ 'permit',
57
+ {
58
+ description: 'Coarse 12 month 3 Rod Licence (Full)',
59
+ permitSubtype: { label: 'Trout and coarse' },
60
+ numberOfRods: 3
61
+ }
62
+ ]
63
+ ])('adds permission %s to transaction cache', async (fieldName, fieldValue) => {
53
64
  const setCurrentPermission = jest.fn()
54
65
  const mockRequest = getSampleRequest(setCurrentPermission)
55
66
  const authResult = getSampleAuthResult({ [fieldName]: fieldValue })
@@ -65,7 +76,7 @@ describe('setUpCancelRecurringPaymentCacheFromAuthenticationResult', () => {
65
76
  )
66
77
  })
67
78
 
68
- it('Adds licensee firstName, lastName and preferredMethodOfConfirmation label to transaction cache', async () => {
79
+ it('adds licensee firstName, lastName and preferredMethodOfConfirmation label to transaction cache', async () => {
69
80
  const setCurrentPermission = jest.fn()
70
81
  const mockRequest = getSampleRequest(setCurrentPermission)
71
82
  const authResult = getSampleAuthResult({
@@ -90,7 +101,7 @@ describe('setUpCancelRecurringPaymentCacheFromAuthenticationResult', () => {
90
101
  it.each([
91
102
  ['licensee', { anotherProperty: 'Should not be there' }],
92
103
  ['permit', { altProp: 'Should not be here' }]
93
- ])('Omits extraneous properties from permission %s', async (fieldName, fieldValue) => {
104
+ ])('omits extraneous properties from permission %s', async (fieldName, fieldValue) => {
94
105
  const setCurrentPermission = jest.fn()
95
106
  const mockRequest = getSampleRequest(setCurrentPermission)
96
107
 
@@ -100,8 +111,8 @@ describe('setUpCancelRecurringPaymentCacheFromAuthenticationResult', () => {
100
111
 
101
112
  expect(setCurrentPermission).toHaveBeenCalledWith(
102
113
  expect.objectContaining({
103
- permission: expect.not.objectContaining({
104
- [fieldName]: fieldValue
114
+ permission: expect.objectContaining({
115
+ [fieldName]: expect.not.objectContaining(fieldValue)
105
116
  })
106
117
  })
107
118
  )
@@ -11,7 +11,11 @@ export const setupCancelRecurringPaymentCacheFromAuthResult = async (request, au
11
11
  lastName: licensee.lastName,
12
12
  preferredMethodOfConfirmation: licensee.preferredMethodOfConfirmation?.label
13
13
  },
14
- permit: { description: permit.description }
14
+ permit: {
15
+ description: permit.description,
16
+ permitSubtype: permit.permitSubtype,
17
+ numberOfRods: permit.numberOfRods
18
+ }
15
19
  },
16
20
  recurringPayment: {
17
21
  id: recurringPayment.id,