@defra-fish/gafl-webapp-service 1.65.0-rc.7 → 1.65.0-rc.8
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.
|
|
3
|
+
"version": "1.65.0-rc.8",
|
|
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.
|
|
40
|
-
"@defra-fish/connectors-lib": "1.65.0-rc.
|
|
39
|
+
"@defra-fish/business-rules-lib": "1.65.0-rc.8",
|
|
40
|
+
"@defra-fish/connectors-lib": "1.65.0-rc.8",
|
|
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": "
|
|
82
|
+
"gitHead": "41bf97520a8285345a098fc58be3410f53d968d7"
|
|
83
83
|
}
|
|
@@ -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
|
})
|
|
@@ -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
|
-
{
|
|
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
|
-
{
|
|
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
|
|