@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.15.4 → 4.16.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.
Files changed (47) hide show
  1. package/dpr/components/_async/async-filters-form/view.njk +2 -2
  2. package/dpr/components/_catalogue/catalogue-list/utils.test.ts +1 -1
  3. package/dpr/components/_charts/chart/Buckets.js +2 -0
  4. package/dpr/components/_charts/chart/Buckets.js.map +7 -0
  5. package/dpr/components/_charts/chart/Buckets.ts +198 -0
  6. package/dpr/components/_charts/chart/DashboardVisualisation.js +2 -0
  7. package/dpr/components/_charts/chart/DashboardVisualisation.js.map +7 -0
  8. package/dpr/components/_charts/chart/DashboardVisualisation.ts +43 -0
  9. package/dpr/components/_charts/chart/heatmap/HeatmapChart.js +2 -0
  10. package/dpr/components/_charts/chart/heatmap/HeatmapChart.js.map +7 -0
  11. package/dpr/components/_charts/chart/heatmap/HeatmapChart.ts +144 -0
  12. package/dpr/components/_charts/utils.js +1 -1
  13. package/dpr/components/_charts/utils.js.map +3 -3
  14. package/dpr/components/_charts/utils.ts +1 -1
  15. package/dpr/components/_dashboards/dashboard/types.js.map +1 -1
  16. package/dpr/components/_dashboards/dashboard/types.ts +4 -4
  17. package/dpr/components/_dashboards/scorecard/Scorecard.js +2 -0
  18. package/dpr/components/_dashboards/scorecard/Scorecard.js.map +7 -0
  19. package/dpr/components/_dashboards/scorecard/Scorecard.ts +315 -0
  20. package/dpr/components/_dashboards/scorecard/types.js +1 -1
  21. package/dpr/components/_dashboards/scorecard/types.js.map +1 -1
  22. package/dpr/components/_dashboards/scorecard/types.ts +20 -1
  23. package/dpr/components/_dashboards/scorecard/utils.js +1 -1
  24. package/dpr/components/_dashboards/scorecard/utils.js.map +3 -3
  25. package/dpr/components/_dashboards/scorecard/utils.test.ts +8 -437
  26. package/dpr/components/_dashboards/scorecard/utils.ts +2 -265
  27. package/dpr/components/_dashboards/scorecard/view.njk +2 -2
  28. package/dpr/components/_filters/types.d.js.map +1 -1
  29. package/dpr/components/_filters/types.d.ts +1 -0
  30. package/dpr/components/_filters/utils.js +1 -1
  31. package/dpr/components/_filters/utils.js.map +3 -3
  32. package/dpr/components/_filters/utils.ts +17 -12
  33. package/dpr/routes/journeys/request-report/filters/tests.cy.js +1 -1
  34. package/dpr/routes/journeys/request-report/filters/tests.cy.js.map +3 -3
  35. package/dpr/routes/journeys/request-report/filters/tests.cy.ts +40 -0
  36. package/dpr/routes/journeys/view-report/async/dashboard/utils.js +1 -1
  37. package/dpr/routes/journeys/view-report/async/dashboard/utils.js.map +3 -3
  38. package/dpr/routes/journeys/view-report/async/dashboard/utils.ts +3 -2
  39. package/dpr/types/api.d.js.map +1 -1
  40. package/dpr/types/api.d.ts +2 -0
  41. package/dpr/utils/datasetHelper.js +1 -1
  42. package/dpr/utils/datasetHelper.js.map +2 -2
  43. package/dpr/utils/datasetHelper.ts +1 -1
  44. package/package.json +1 -1
  45. package/dpr/components/_charts/chart/heatmap/Heatmap.js +0 -2
  46. package/dpr/components/_charts/chart/heatmap/Heatmap.js.map +0 -7
  47. package/dpr/components/_charts/chart/heatmap/Heatmap.ts +0 -278
@@ -1,37 +1,17 @@
1
- import { mockTimeSeriesDataLastSixMonths } from '../../../../../test-app/mocks/mockClients/dashboards/data/data-quality-metrics/data'
2
- import { mockDietDataLastSixMonths } from '../../../../../test-app/mocks/mockClients/dashboards/data/test-data/data'
3
-
4
- import { DashboardDataResponse } from '../../../types/Metrics'
5
-
6
1
  import ScorecardUtils from './utils'
7
- import { Scorecard, ScorecardGroup } from './types'
8
-
9
- import {
10
- dietTotals,
11
- dataQualityAllCols,
12
- } from '../../../../../test-app/mocks/mockClients/dashboards/definitions/examples/visualisations/scorecards'
13
-
14
- import {
15
- mockScorecardDefinitionNationality,
16
- mockTargetScorecardDefinitionReligion,
17
- mockScorecardGroupReligionByEstablishment,
18
- } from '../../../../../test-app/mocks/mockClients/dashboards/definitions/data-quality/visualisations'
2
+ import { Scorecard } from './types'
19
3
 
20
- import { DashboardUIVisualisation, DashboardVisualisation, DashboardVisualisationType } from '../dashboard/types'
4
+ import { DashboardUIVisualisation, DashboardVisualisationType } from '../dashboard/types'
21
5
  import { ChartCardData } from '../../../types/Charts'
22
6
 
23
7
  describe('ScorecardUtils', () => {
24
- let mockDataQualityData: DashboardDataResponse[][]
25
- let mockDietData: DashboardDataResponse[]
26
8
  let scorecardData1: Scorecard
27
9
  let scorecardData2: Scorecard
28
10
 
29
11
  beforeEach(() => {
30
- mockDataQualityData = mockTimeSeriesDataLastSixMonths as unknown as DashboardDataResponse[][]
31
- mockDietData = mockDietDataLastSixMonths
32
12
  scorecardData1 = {
33
13
  rag: {
34
- color: 'red',
14
+ colour: 'red',
35
15
  score: 2,
36
16
  },
37
17
  title: 'No of prisoners with nationality',
@@ -46,7 +26,7 @@ describe('ScorecardUtils', () => {
46
26
 
47
27
  scorecardData2 = {
48
28
  rag: {
49
- color: 'red',
29
+ colour: 'red',
50
30
  score: 2,
51
31
  },
52
32
  title: 'No of prisoners with religion in SLI',
@@ -60,415 +40,6 @@ describe('ScorecardUtils', () => {
60
40
  }
61
41
  })
62
42
 
63
- describe('createScorecard', () => {
64
- it('should create single scorecard', () => {
65
- const scorecard: Scorecard = ScorecardUtils.createScorecard(
66
- mockScorecardDefinitionNationality as DashboardVisualisation,
67
- mockDataQualityData.flat(),
68
- )
69
-
70
- expect(scorecard).toEqual(scorecardData1)
71
- })
72
-
73
- it('should create single scorecard targeting a value', () => {
74
- const scorecard: Scorecard = ScorecardUtils.createScorecard(
75
- mockTargetScorecardDefinitionReligion as DashboardVisualisation,
76
- mockDataQualityData.flat(),
77
- )
78
-
79
- expect(scorecard).toEqual(scorecardData2)
80
- })
81
- })
82
-
83
- describe('createScorecards', () => {
84
- it('should create a scorecard group from a list - data-quality', () => {
85
- const scorecardGroup: ScorecardGroup[] = ScorecardUtils.createScorecards(
86
- mockScorecardGroupReligionByEstablishment as DashboardVisualisation,
87
- mockDataQualityData.flat(),
88
- )
89
-
90
- expect(scorecardGroup).toEqual([
91
- {
92
- title: 'Establishmnent ID: MDI',
93
- scorecards: [
94
- {
95
- title: 'With religion in Establishment: MDI',
96
- value: 680,
97
- rag: {
98
- score: 2,
99
- color: 'red',
100
- },
101
- valueFor: 'Jan 25',
102
- trend: {
103
- direction: 1,
104
- value: 104,
105
- from: 'Aug 24',
106
- },
107
- },
108
- ],
109
- },
110
- {
111
- title: 'Establishmnent ID: SLI',
112
- scorecards: [
113
- {
114
- title: 'With religion in Establishment: SLI',
115
- value: 771,
116
- rag: {
117
- score: 2,
118
- color: 'red',
119
- },
120
- valueFor: 'Jan 25',
121
- trend: {
122
- direction: 1,
123
- value: 13,
124
- from: 'Aug 24',
125
- },
126
- },
127
- ],
128
- },
129
- {
130
- title: 'Establishmnent ID: DAI',
131
- scorecards: [
132
- {
133
- title: 'With religion in Establishment: DAI',
134
- value: 648,
135
- rag: {
136
- score: 2,
137
- color: 'red',
138
- },
139
- valueFor: 'Jan 25',
140
- trend: {
141
- direction: -1,
142
- value: 86,
143
- from: 'Aug 24',
144
- },
145
- },
146
- ],
147
- },
148
- ])
149
- })
150
-
151
- it('should create a scorecard group from a list', () => {
152
- const scorecardGroup: ScorecardGroup[] = ScorecardUtils.createScorecards(
153
- dietTotals as DashboardVisualisation,
154
- mockDietData,
155
- )
156
-
157
- const expectedResult = [
158
- {
159
- title: '',
160
- scorecards: [
161
- {
162
- title: ' Vegetarian',
163
- value: '1737',
164
- valueFor: 'Feb 25',
165
- trend: {
166
- direction: 1,
167
- value: 1603,
168
- from: 'Sep 24',
169
- },
170
- },
171
- {
172
- title: ' Pescatarian',
173
- value: '1729',
174
- valueFor: 'Feb 25',
175
- trend: {
176
- direction: -1,
177
- value: 580,
178
- from: 'Sep 24',
179
- },
180
- },
181
- {
182
- title: ' Vegan',
183
- value: '294',
184
- valueFor: 'Feb 25',
185
- trend: {
186
- direction: -1,
187
- value: 1435,
188
- from: 'Sep 24',
189
- },
190
- },
191
- {
192
- title: ' Omnivore',
193
- value: '1240',
194
- valueFor: 'Feb 25',
195
- trend: {
196
- direction: 1,
197
- value: 412,
198
- from: 'Sep 24',
199
- },
200
- },
201
- ],
202
- },
203
- ]
204
-
205
- expect(scorecardGroup).toEqual(expectedResult)
206
- })
207
-
208
- it('should create a scorecard group from data columns', () => {
209
- const scorecardGroup: ScorecardGroup[] = ScorecardUtils.createScorecards(
210
- dataQualityAllCols as unknown as DashboardVisualisation,
211
- mockDataQualityData.flat(),
212
- )
213
-
214
- const expectedResult = [
215
- {
216
- title: 'Establishment ID: MDI',
217
- scorecards: [
218
- {
219
- title: 'Has ethnicity',
220
- value: 533,
221
- rag: {
222
- score: 1,
223
- color: 'yellow',
224
- },
225
- valueFor: 'Jan 25',
226
- trend: {
227
- direction: 1,
228
- value: 109,
229
- from: 'Aug 24',
230
- },
231
- },
232
- {
233
- title: 'Ethnicity is missing',
234
- value: 614,
235
- rag: {
236
- score: 2,
237
- color: 'red',
238
- },
239
- valueFor: 'Jan 25',
240
- trend: {
241
- direction: -1,
242
- value: 167,
243
- from: 'Aug 24',
244
- },
245
- },
246
- {
247
- title: 'Has nationality',
248
- value: 684,
249
- rag: {
250
- score: 2,
251
- color: 'red',
252
- },
253
- valueFor: 'Jan 25',
254
- trend: {
255
- direction: 1,
256
- value: 225,
257
- from: 'Aug 24',
258
- },
259
- },
260
- {
261
- title: 'Nationality is missing',
262
- value: 665,
263
- rag: {
264
- score: 2,
265
- color: 'red',
266
- },
267
- valueFor: 'Jan 25',
268
- trend: {
269
- direction: 1,
270
- value: 137,
271
- from: 'Aug 24',
272
- },
273
- },
274
- {
275
- title: 'Has religion',
276
- value: 680,
277
- rag: {
278
- score: 2,
279
- color: 'red',
280
- },
281
- valueFor: 'Jan 25',
282
- trend: {
283
- direction: 1,
284
- value: 104,
285
- from: 'Aug 24',
286
- },
287
- },
288
- {
289
- title: 'Religion is missing',
290
- value: 799,
291
- rag: {
292
- score: 2,
293
- color: 'red',
294
- },
295
- valueFor: 'Jan 25',
296
- trend: {
297
- direction: 1,
298
- value: 352,
299
- from: 'Aug 24',
300
- },
301
- },
302
- ],
303
- },
304
- {
305
- title: 'Establishment ID: SLI',
306
- scorecards: [
307
- {
308
- title: 'Has ethnicity',
309
- value: 484,
310
- valueFor: 'Jan 25',
311
- trend: {
312
- direction: -1,
313
- value: 277,
314
- from: 'Aug 24',
315
- },
316
- },
317
- {
318
- title: 'Ethnicity is missing',
319
- value: 713,
320
- rag: {
321
- score: 2,
322
- color: 'red',
323
- },
324
- valueFor: 'Jan 25',
325
- trend: {
326
- direction: 1,
327
- value: 103,
328
- from: 'Aug 24',
329
- },
330
- },
331
- {
332
- title: 'Has nationality',
333
- value: 700,
334
- rag: {
335
- score: 2,
336
- color: 'red',
337
- },
338
- valueFor: 'Jan 25',
339
- trend: {
340
- direction: -1,
341
- value: 34,
342
- from: 'Aug 24',
343
- },
344
- },
345
- {
346
- title: 'Nationality is missing',
347
- value: 506,
348
- rag: {
349
- score: 1,
350
- color: 'yellow',
351
- },
352
- valueFor: 'Jan 25',
353
- trend: {
354
- direction: -1,
355
- value: 279,
356
- from: 'Aug 24',
357
- },
358
- },
359
- {
360
- title: 'Has religion',
361
- value: 771,
362
- rag: {
363
- score: 2,
364
- color: 'red',
365
- },
366
- valueFor: 'Jan 25',
367
- trend: {
368
- direction: 1,
369
- value: 13,
370
- from: 'Aug 24',
371
- },
372
- },
373
- {
374
- title: 'Religion is missing',
375
- value: 457,
376
- valueFor: 'Jan 25',
377
- trend: {
378
- direction: -1,
379
- value: 237,
380
- from: 'Aug 24',
381
- },
382
- },
383
- ],
384
- },
385
- {
386
- title: 'Establishment ID: DAI',
387
- scorecards: [
388
- {
389
- title: 'Has ethnicity',
390
- value: 406,
391
- valueFor: 'Jan 25',
392
- trend: {
393
- direction: 1,
394
- value: 5,
395
- from: 'Aug 24',
396
- },
397
- },
398
- {
399
- title: 'Ethnicity is missing',
400
- value: 682,
401
- rag: {
402
- score: 2,
403
- color: 'red',
404
- },
405
- valueFor: 'Jan 25',
406
- trend: {
407
- direction: 1,
408
- value: 183,
409
- from: 'Aug 24',
410
- },
411
- },
412
- {
413
- title: 'Has nationality',
414
- value: 703,
415
- rag: {
416
- score: 2,
417
- color: 'red',
418
- },
419
- valueFor: 'Jan 25',
420
- trend: {
421
- direction: 1,
422
- value: 92,
423
- from: 'Aug 24',
424
- },
425
- },
426
- {
427
- title: 'Nationality is missing',
428
- value: 409,
429
- valueFor: 'Jan 25',
430
- trend: {
431
- direction: -1,
432
- value: 115,
433
- from: 'Aug 24',
434
- },
435
- },
436
- {
437
- title: 'Has religion',
438
- value: 648,
439
- rag: {
440
- score: 2,
441
- color: 'red',
442
- },
443
- valueFor: 'Jan 25',
444
- trend: {
445
- direction: -1,
446
- value: 86,
447
- from: 'Aug 24',
448
- },
449
- },
450
- {
451
- title: 'Religion is missing',
452
- value: 720,
453
- rag: {
454
- score: 2,
455
- color: 'red',
456
- },
457
- valueFor: 'Jan 25',
458
- trend: {
459
- direction: 1,
460
- value: 316,
461
- from: 'Aug 24',
462
- },
463
- },
464
- ],
465
- },
466
- ]
467
-
468
- expect(scorecardGroup).toEqual(expectedResult)
469
- })
470
- })
471
-
472
43
  describe('mergeScorecards', () => {
473
44
  it('should merge individual scorecards into a scorecard group', () => {
474
45
  const visualistationData: DashboardUIVisualisation[] = [
@@ -509,7 +80,7 @@ describe('ScorecardUtils', () => {
509
80
  scorecards: [
510
81
  {
511
82
  rag: {
512
- color: 'red',
83
+ colour: 'red',
513
84
  score: 2,
514
85
  },
515
86
  title: 'No of prisoners with nationality',
@@ -523,7 +94,7 @@ describe('ScorecardUtils', () => {
523
94
  },
524
95
  {
525
96
  rag: {
526
- color: 'red',
97
+ colour: 'red',
527
98
  score: 2,
528
99
  },
529
100
  title: 'No of prisoners with religion in SLI',
@@ -552,7 +123,7 @@ describe('ScorecardUtils', () => {
552
123
  scorecards: [
553
124
  {
554
125
  rag: {
555
- color: 'red',
126
+ colour: 'red',
556
127
  score: 2,
557
128
  },
558
129
  title: 'No of prisoners with nationality',
@@ -566,7 +137,7 @@ describe('ScorecardUtils', () => {
566
137
  },
567
138
  {
568
139
  rag: {
569
- color: 'red',
140
+ colour: 'red',
570
141
  score: 2,
571
142
  },
572
143
  title: 'No of prisoners with religion in SLI',