@defra-fish/gafl-webapp-service 1.65.0-rc.7 → 1.65.0-rc.9

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.65.0-rc.7",
3
+ "version": "1.65.0-rc.9",
4
4
  "description": "The websales frontend for the GAFL service",
5
5
  "type": "module",
6
6
  "engines": {
@@ -36,8 +36,8 @@
36
36
  "prepare": "gulp --gulpfile build/gulpfile.cjs"
37
37
  },
38
38
  "dependencies": {
39
- "@defra-fish/business-rules-lib": "1.65.0-rc.7",
40
- "@defra-fish/connectors-lib": "1.65.0-rc.7",
39
+ "@defra-fish/business-rules-lib": "1.65.0-rc.9",
40
+ "@defra-fish/connectors-lib": "1.65.0-rc.9",
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": "721154c38cb9bfb554f3a3ff428ccd18cc7351c3"
82
+ "gitHead": "52a2c512cac3348e094ea6e420d76f159b767f53"
83
83
  }
@@ -2,6 +2,7 @@ import pageRoute from '../../../../../routes/page-route.js'
2
2
  import { CANCEL_RP_CONFIRM, CANCEL_RP_COMPLETE, CANCEL_RP_IDENTIFY } from '../../../../../uri.js'
3
3
  import { addLanguageCodeToUri } from '../../../../../processors/uri-helper.js'
4
4
  import moment from 'moment-timezone'
5
+ import { dateDisplayFormat } from '../../../../../processors/date-and-time-display.js'
5
6
 
6
7
  require('../route.js')
7
8
 
@@ -17,6 +18,10 @@ jest.mock('../../../../../uri.js', () => ({
17
18
  }))
18
19
  jest.mock('../../../../../processors/uri-helper.js')
19
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
+ }))
20
25
 
21
26
  describe('pageRoute receives expected arguments', () => {
22
27
  it('passes expected arguments to pageRoute', () => {
@@ -64,7 +69,7 @@ describe('getData function', () => {
64
69
  })
65
70
 
66
71
  const mockRequest = () => {
67
- const getCurrentPermission = jest.fn(() => ({ recurringPayment: { endDate: '2025-02-15' } }))
72
+ const getCurrentPermission = jest.fn(() => ({ permission: { endDate: '2025-02-15' } }))
68
73
 
69
74
  return {
70
75
  locale: 'en',
@@ -109,4 +114,9 @@ describe('getData function', () => {
109
114
 
110
115
  expect(data.licenceExpiry).toEqual('19th November, 2025')
111
116
  })
117
+
118
+ it('uses expected date format', async () => {
119
+ await getData(mockRequest())
120
+ expect(moment.mock.results[0].value.format).toHaveBeenCalledWith(dateDisplayFormat)
121
+ })
112
122
  })
@@ -21,21 +21,23 @@
21
21
  }
22
22
  }) %}
23
23
 
24
- <p class="govuk-body-m">{{ mssgs.rp_cancel_confirm_body }}</p>
24
+ <p class="govuk-body-m">{{ mssgs.rp_cancel_confirm_body }}{{ data.licenceExpiry }}</p>
25
25
 
26
26
  <div class="govuk-grid-row">
27
27
  <div class="govuk-grid-column-two-thirds">
28
28
  <form method="post" class="govuk-!-margin-bottom-6">
29
- {{ govukButton({
30
- attributes: { id: 'continue' },
31
- preventDoubleClick: true,
32
- name: "continue",
33
- text: mssgs.rp_cancel_confirm_accept,
34
- classes: "govuk-!-margin-top-1"
35
- }) }}
36
- {{ csrf() }}
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>
37
40
  </form>
38
- <p class="govuk-body no-print"><a class="govuk-link" href="{{ data.uri.cancelRpIdentify }}">{{ mssgs.rp_cancel_confirm_reject }}</a></p>
39
41
  </div>
40
42
  </div>
41
43
 
@@ -1,14 +1,14 @@
1
1
  import pageRoute from '../../../../routes/page-route.js'
2
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'
4
+ import { cacheDateFormat, dateDisplayFormat } from '../../../../processors/date-and-time-display.js'
5
5
  import moment from 'moment-timezone'
6
6
 
7
7
  const getData = async request => {
8
- const permission = await request.cache().helpers.transaction.getCurrentPermission()
8
+ const { permission } = await request.cache().helpers.transaction.getCurrentPermission()
9
9
 
10
10
  return {
11
- licenceExpiry: moment(permission.recurringPayment.endDate, cacheDateFormat, request.locale).format('Do MMMM, YYYY'),
11
+ licenceExpiry: moment(permission.endDate, cacheDateFormat, request.locale).format(dateDisplayFormat),
12
12
  uri: {
13
13
  cancelRpIdentify: addLanguageCodeToUri(request, CANCEL_RP_IDENTIFY.uri)
14
14
  }
@@ -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 mockRequest = createMockRequest({ catalog: mssgs })
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
- { 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' } }
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
  })
@@ -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
 
@@ -503,9 +503,9 @@ export default [
503
503
  next: {
504
504
  [CommonResults.OK]: {
505
505
  page: CANCEL_RP_COMPLETE
506
- },
507
- backLink: CANCEL_RP_DETAILS.uri
508
- }
506
+ }
507
+ },
508
+ backLink: CANCEL_RP_DETAILS.uri
509
509
  },
510
510
  {
511
511
  current: CANCEL_RP_AGREEMENT_NOT_FOUND,