@fmidev/smartmet-alert-client 4.4.19 → 4.7.0-beta.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.
Files changed (123) hide show
  1. package/.eslintignore +2 -14
  2. package/.github/workflows/test.yaml +26 -0
  3. package/.nvmrc +1 -0
  4. package/AGENTS.md +26 -0
  5. package/index.html +1 -1
  6. package/package.json +80 -22
  7. package/src/AlertClientVue.vue +160 -0
  8. package/src/App.vue +154 -296
  9. package/src/assets/img/ui/arrow-down.svg +4 -11
  10. package/src/assets/img/ui/arrow-up.svg +4 -11
  11. package/src/assets/img/ui/clear.svg +7 -21
  12. package/src/assets/img/ui/close.svg +4 -15
  13. package/src/assets/img/ui/toggle-selected.svg +5 -6
  14. package/src/assets/img/ui/toggle-unselected.svg +5 -6
  15. package/src/assets/img/warning/cold-weather.svg +3 -6
  16. package/src/assets/img/warning/flood-level-3.svg +4 -7
  17. package/src/assets/img/warning/forest-fire-weather.svg +2 -6
  18. package/src/assets/img/warning/grass-fire-weather.svg +2 -6
  19. package/src/assets/img/warning/hot-weather.svg +3 -6
  20. package/src/assets/img/warning/pedestrian-safety.svg +3 -7
  21. package/src/assets/img/warning/rain.svg +2 -7
  22. package/src/assets/img/warning/sea-icing.svg +2 -6
  23. package/src/assets/img/warning/sea-thunder-storm.svg +2 -5
  24. package/src/assets/img/warning/sea-water-height-high-water.svg +3 -8
  25. package/src/assets/img/warning/sea-water-height-shallow-water.svg +3 -7
  26. package/src/assets/img/warning/sea-wave-height.svg +4 -7
  27. package/src/assets/img/warning/sea-wind-legend.svg +2 -5
  28. package/src/assets/img/warning/sea-wind.svg +2 -5
  29. package/src/assets/img/warning/several.svg +2 -5
  30. package/src/assets/img/warning/thunder-storm.svg +2 -5
  31. package/src/assets/img/warning/traffic-weather.svg +2 -6
  32. package/src/assets/img/warning/uv-note.svg +2 -6
  33. package/src/assets/img/warning/wind.svg +2 -5
  34. package/src/components/AlertClient.vue +330 -251
  35. package/src/components/CollapsiblePanel.vue +281 -0
  36. package/src/components/DayLarge.vue +146 -110
  37. package/src/components/DaySmall.vue +97 -81
  38. package/src/components/Days.vue +229 -159
  39. package/src/components/DescriptionWarning.vue +63 -38
  40. package/src/components/GrayScaleToggle.vue +58 -54
  41. package/src/components/Legend.vue +102 -325
  42. package/src/components/MapLarge.vue +574 -351
  43. package/src/components/MapSmall.vue +137 -122
  44. package/src/components/PopupRow.vue +24 -12
  45. package/src/components/Region.vue +168 -118
  46. package/src/components/RegionWarning.vue +40 -33
  47. package/src/components/Regions.vue +189 -105
  48. package/src/components/Warning.vue +70 -45
  49. package/src/components/Warnings.vue +136 -72
  50. package/src/composables/useAlertClient.ts +360 -0
  51. package/src/composables/useConfig.ts +573 -0
  52. package/src/composables/useFields.ts +66 -0
  53. package/src/composables/useI18n.ts +62 -0
  54. package/src/composables/useKeyCodes.ts +16 -0
  55. package/src/composables/useMapPaths.ts +477 -0
  56. package/src/composables/useUtils.ts +683 -0
  57. package/src/composables/useWarningsProcessor.ts +1007 -0
  58. package/src/data/geometries.json +993 -0
  59. package/src/{main.js → main.ts} +1 -0
  60. package/src/mixins/geojsonsvg.d.ts +57 -0
  61. package/src/mixins/geojsonsvg.js +5 -3
  62. package/src/plugins/index.ts +5 -0
  63. package/src/scss/_utilities.scss +193 -0
  64. package/src/scss/constants.scss +2 -1
  65. package/src/scss/warningImages.scss +8 -3
  66. package/src/types/index.ts +509 -0
  67. package/src/vite-env.d.ts +23 -0
  68. package/src/vue.ts +41 -0
  69. package/svgo.config.js +45 -0
  70. package/tests/README.md +430 -0
  71. package/tests/fixtures/mockWarningData.ts +152 -0
  72. package/tests/integration/warning-flow.spec.ts +445 -0
  73. package/tests/setup.ts +41 -0
  74. package/tests/unit/components/AlertClient.spec.ts +701 -0
  75. package/tests/unit/components/DayLarge.spec.ts +348 -0
  76. package/tests/unit/components/DaySmall.spec.ts +352 -0
  77. package/tests/unit/components/Days.spec.ts +548 -0
  78. package/tests/unit/components/DescriptionWarning.spec.ts +385 -0
  79. package/tests/unit/components/GrayScaleToggle.spec.ts +318 -0
  80. package/tests/unit/components/Legend.spec.ts +295 -0
  81. package/tests/unit/components/MapLarge.spec.ts +448 -0
  82. package/tests/unit/components/MapSmall.spec.ts +367 -0
  83. package/tests/unit/components/PopupRow.spec.ts +270 -0
  84. package/tests/unit/components/Region.spec.ts +373 -0
  85. package/tests/unit/components/RegionWarning.snapshot.spec.ts +361 -0
  86. package/tests/unit/components/RegionWarning.spec.ts +381 -0
  87. package/tests/unit/components/Regions.spec.ts +503 -0
  88. package/tests/unit/components/Warning.snapshot.spec.ts +483 -0
  89. package/tests/unit/components/Warning.spec.ts +489 -0
  90. package/tests/unit/components/Warnings.spec.ts +343 -0
  91. package/tests/unit/components/__snapshots__/RegionWarning.snapshot.spec.ts.snap +41 -0
  92. package/tests/unit/components/__snapshots__/Warning.snapshot.spec.ts.snap +433 -0
  93. package/tests/unit/composables/useConfig.spec.ts +279 -0
  94. package/tests/unit/composables/useI18n.spec.ts +116 -0
  95. package/tests/unit/composables/useKeyCodes.spec.ts +27 -0
  96. package/tests/unit/composables/useUtils.spec.ts +213 -0
  97. package/tsconfig.json +43 -0
  98. package/tsconfig.node.json +11 -0
  99. package/vite.config.js +96 -26
  100. package/vitest.config.js +40 -0
  101. package/dist/favicon.ico +0 -0
  102. package/dist/index.dark.html +0 -20
  103. package/dist/index.en.html +0 -15
  104. package/dist/index.fi.html +0 -15
  105. package/dist/index.html +0 -15
  106. package/dist/index.js +0 -281
  107. package/dist/index.mjs +0 -281
  108. package/dist/index.mjs.map +0 -1
  109. package/dist/index.relative.html +0 -19
  110. package/dist/index.start.html +0 -20
  111. package/dist/index.sv.html +0 -15
  112. package/playwright.config.ts +0 -18
  113. package/public/index.relative.html +0 -19
  114. package/public/index.start.html +0 -20
  115. package/src/mixins/config.js +0 -1378
  116. package/src/mixins/fields.js +0 -26
  117. package/src/mixins/i18n.js +0 -25
  118. package/src/mixins/keycodes.js +0 -10
  119. package/src/mixins/panzoom.js +0 -900
  120. package/src/mixins/utils.js +0 -900
  121. package/src/plugins/index.js +0 -3
  122. package/test/snapshot.test.ts +0 -126
  123. package/vitest.config.ts +0 -6
@@ -0,0 +1,483 @@
1
+ import { describe, it, expect, afterEach } from 'vitest'
2
+ import { mount, VueWrapper } from '@vue/test-utils'
3
+ import Warning from '@/components/Warning.vue'
4
+ import type { LegendItem, Theme, Language } from '@/types'
5
+
6
+ describe('Warning.vue Snapshots', () => {
7
+ let wrapper: VueWrapper | null = null
8
+
9
+ afterEach(() => {
10
+ if (wrapper) {
11
+ wrapper.unmount()
12
+ wrapper = null
13
+ }
14
+ })
15
+
16
+ describe('Warning type snapshots', () => {
17
+ it('should render wind warning correctly', () => {
18
+ const warning: LegendItem = {
19
+ type: 'wind',
20
+ severity: 3,
21
+ visible: true,
22
+ }
23
+
24
+ wrapper = mount(Warning, {
25
+ props: {
26
+ input: warning,
27
+ hideable: true,
28
+ language: 'fi' as Language,
29
+ theme: 'light-theme' as Theme,
30
+ },
31
+ })
32
+
33
+ expect(wrapper.html()).toMatchSnapshot()
34
+ })
35
+
36
+ it('should render thunderstorm warning correctly', () => {
37
+ const warning: LegendItem = {
38
+ type: 'thunderStorm',
39
+ severity: 4,
40
+ visible: true,
41
+ }
42
+
43
+ wrapper = mount(Warning, {
44
+ props: {
45
+ input: warning,
46
+ hideable: true,
47
+ language: 'fi' as Language,
48
+ theme: 'light-theme' as Theme,
49
+ },
50
+ })
51
+
52
+ expect(wrapper.html()).toMatchSnapshot()
53
+ })
54
+
55
+ it('should render rain warning correctly', () => {
56
+ const warning: LegendItem = {
57
+ type: 'rain',
58
+ severity: 2,
59
+ visible: true,
60
+ }
61
+
62
+ wrapper = mount(Warning, {
63
+ props: {
64
+ input: warning,
65
+ hideable: true,
66
+ language: 'fi' as Language,
67
+ theme: 'light-theme' as Theme,
68
+ },
69
+ })
70
+
71
+ expect(wrapper.html()).toMatchSnapshot()
72
+ })
73
+
74
+ it('should render sea wind warning correctly', () => {
75
+ const warning: LegendItem = {
76
+ type: 'seaWind',
77
+ severity: 3,
78
+ visible: true,
79
+ }
80
+
81
+ wrapper = mount(Warning, {
82
+ props: {
83
+ input: warning,
84
+ hideable: true,
85
+ language: 'fi' as Language,
86
+ theme: 'light-theme' as Theme,
87
+ },
88
+ })
89
+
90
+ expect(wrapper.html()).toMatchSnapshot()
91
+ })
92
+
93
+ it('should render traffic weather warning correctly', () => {
94
+ const warning: LegendItem = {
95
+ type: 'trafficWeather',
96
+ severity: 2,
97
+ visible: true,
98
+ }
99
+
100
+ wrapper = mount(Warning, {
101
+ props: {
102
+ input: warning,
103
+ hideable: true,
104
+ language: 'fi' as Language,
105
+ theme: 'light-theme' as Theme,
106
+ },
107
+ })
108
+
109
+ expect(wrapper.html()).toMatchSnapshot()
110
+ })
111
+
112
+ it('should render pedestrian safety warning correctly', () => {
113
+ const warning: LegendItem = {
114
+ type: 'pedestrianSafety',
115
+ severity: 2,
116
+ visible: true,
117
+ }
118
+
119
+ wrapper = mount(Warning, {
120
+ props: {
121
+ input: warning,
122
+ hideable: true,
123
+ language: 'fi' as Language,
124
+ theme: 'light-theme' as Theme,
125
+ },
126
+ })
127
+
128
+ expect(wrapper.html()).toMatchSnapshot()
129
+ })
130
+
131
+ it('should render forest fire weather warning correctly', () => {
132
+ const warning: LegendItem = {
133
+ type: 'forestFireWeather',
134
+ severity: 3,
135
+ visible: true,
136
+ }
137
+
138
+ wrapper = mount(Warning, {
139
+ props: {
140
+ input: warning,
141
+ hideable: true,
142
+ language: 'fi' as Language,
143
+ theme: 'light-theme' as Theme,
144
+ },
145
+ })
146
+
147
+ expect(wrapper.html()).toMatchSnapshot()
148
+ })
149
+
150
+ it('should render hot weather warning correctly', () => {
151
+ const warning: LegendItem = {
152
+ type: 'hotWeather',
153
+ severity: 2,
154
+ visible: true,
155
+ }
156
+
157
+ wrapper = mount(Warning, {
158
+ props: {
159
+ input: warning,
160
+ hideable: true,
161
+ language: 'fi' as Language,
162
+ theme: 'light-theme' as Theme,
163
+ },
164
+ })
165
+
166
+ expect(wrapper.html()).toMatchSnapshot()
167
+ })
168
+
169
+ it('should render cold weather warning correctly', () => {
170
+ const warning: LegendItem = {
171
+ type: 'coldWeather',
172
+ severity: 3,
173
+ visible: true,
174
+ }
175
+
176
+ wrapper = mount(Warning, {
177
+ props: {
178
+ input: warning,
179
+ hideable: true,
180
+ language: 'fi' as Language,
181
+ theme: 'light-theme' as Theme,
182
+ },
183
+ })
184
+
185
+ expect(wrapper.html()).toMatchSnapshot()
186
+ })
187
+
188
+ it('should render flood level warning correctly', () => {
189
+ const warning: LegendItem = {
190
+ type: 'floodLevel',
191
+ severity: 3,
192
+ visible: true,
193
+ }
194
+
195
+ wrapper = mount(Warning, {
196
+ props: {
197
+ input: warning,
198
+ hideable: true,
199
+ language: 'fi' as Language,
200
+ theme: 'light-theme' as Theme,
201
+ },
202
+ })
203
+
204
+ expect(wrapper.html()).toMatchSnapshot()
205
+ })
206
+ })
207
+
208
+ describe('Visibility state snapshots', () => {
209
+ it('should render visible warning correctly', () => {
210
+ const warning: LegendItem = {
211
+ type: 'wind',
212
+ severity: 3,
213
+ visible: true,
214
+ }
215
+
216
+ wrapper = mount(Warning, {
217
+ props: {
218
+ input: warning,
219
+ hideable: true,
220
+ language: 'fi' as Language,
221
+ theme: 'light-theme' as Theme,
222
+ },
223
+ })
224
+
225
+ expect(wrapper.html()).toMatchSnapshot()
226
+ })
227
+
228
+ it('should render hidden warning correctly', () => {
229
+ const warning: LegendItem = {
230
+ type: 'wind',
231
+ severity: 3,
232
+ visible: false,
233
+ }
234
+
235
+ wrapper = mount(Warning, {
236
+ props: {
237
+ input: warning,
238
+ hideable: true,
239
+ language: 'fi' as Language,
240
+ theme: 'light-theme' as Theme,
241
+ },
242
+ })
243
+
244
+ expect(wrapper.html()).toMatchSnapshot()
245
+ })
246
+ })
247
+
248
+ describe('Theme snapshots', () => {
249
+ it('should render with light theme correctly', () => {
250
+ const warning: LegendItem = {
251
+ type: 'wind',
252
+ severity: 3,
253
+ visible: true,
254
+ }
255
+
256
+ wrapper = mount(Warning, {
257
+ props: {
258
+ input: warning,
259
+ hideable: true,
260
+ language: 'fi' as Language,
261
+ theme: 'light-theme' as Theme,
262
+ },
263
+ })
264
+
265
+ expect(wrapper.html()).toMatchSnapshot()
266
+ })
267
+
268
+ it('should render with dark theme correctly', () => {
269
+ const warning: LegendItem = {
270
+ type: 'wind',
271
+ severity: 3,
272
+ visible: true,
273
+ }
274
+
275
+ wrapper = mount(Warning, {
276
+ props: {
277
+ input: warning,
278
+ hideable: true,
279
+ language: 'fi' as Language,
280
+ theme: 'dark-theme' as Theme,
281
+ },
282
+ })
283
+
284
+ expect(wrapper.html()).toMatchSnapshot()
285
+ })
286
+
287
+ it('should render with light-gray theme correctly', () => {
288
+ const warning: LegendItem = {
289
+ type: 'wind',
290
+ severity: 3,
291
+ visible: true,
292
+ }
293
+
294
+ wrapper = mount(Warning, {
295
+ props: {
296
+ input: warning,
297
+ hideable: true,
298
+ language: 'fi' as Language,
299
+ theme: 'light-gray-theme' as Theme,
300
+ },
301
+ })
302
+
303
+ expect(wrapper.html()).toMatchSnapshot()
304
+ })
305
+
306
+ it('should render with dark-gray theme correctly', () => {
307
+ const warning: LegendItem = {
308
+ type: 'wind',
309
+ severity: 3,
310
+ visible: true,
311
+ }
312
+
313
+ wrapper = mount(Warning, {
314
+ props: {
315
+ input: warning,
316
+ hideable: true,
317
+ language: 'fi' as Language,
318
+ theme: 'dark-gray-theme' as Theme,
319
+ },
320
+ })
321
+
322
+ expect(wrapper.html()).toMatchSnapshot()
323
+ })
324
+ })
325
+
326
+ describe('Language snapshots', () => {
327
+ it('should render in Finnish correctly', () => {
328
+ const warning: LegendItem = {
329
+ type: 'wind',
330
+ severity: 3,
331
+ visible: true,
332
+ }
333
+
334
+ wrapper = mount(Warning, {
335
+ props: {
336
+ input: warning,
337
+ hideable: true,
338
+ language: 'fi' as Language,
339
+ theme: 'light-theme' as Theme,
340
+ },
341
+ })
342
+
343
+ expect(wrapper.html()).toMatchSnapshot()
344
+ })
345
+
346
+ it('should render in Swedish correctly', () => {
347
+ const warning: LegendItem = {
348
+ type: 'wind',
349
+ severity: 3,
350
+ visible: true,
351
+ }
352
+
353
+ wrapper = mount(Warning, {
354
+ props: {
355
+ input: warning,
356
+ hideable: true,
357
+ language: 'sv' as Language,
358
+ theme: 'light-theme' as Theme,
359
+ },
360
+ })
361
+
362
+ expect(wrapper.html()).toMatchSnapshot()
363
+ })
364
+
365
+ it('should render in English correctly', () => {
366
+ const warning: LegendItem = {
367
+ type: 'wind',
368
+ severity: 3,
369
+ visible: true,
370
+ }
371
+
372
+ wrapper = mount(Warning, {
373
+ props: {
374
+ input: warning,
375
+ hideable: true,
376
+ language: 'en' as Language,
377
+ theme: 'light-theme' as Theme,
378
+ },
379
+ })
380
+
381
+ expect(wrapper.html()).toMatchSnapshot()
382
+ })
383
+ })
384
+
385
+ describe('Severity level snapshots', () => {
386
+ it('should render severity level 2 correctly', () => {
387
+ const warning: LegendItem = {
388
+ type: 'wind',
389
+ severity: 2,
390
+ visible: true,
391
+ }
392
+
393
+ wrapper = mount(Warning, {
394
+ props: {
395
+ input: warning,
396
+ hideable: true,
397
+ language: 'fi' as Language,
398
+ theme: 'light-theme' as Theme,
399
+ },
400
+ })
401
+
402
+ expect(wrapper.html()).toMatchSnapshot()
403
+ })
404
+
405
+ it('should render severity level 3 correctly', () => {
406
+ const warning: LegendItem = {
407
+ type: 'wind',
408
+ severity: 3,
409
+ visible: true,
410
+ }
411
+
412
+ wrapper = mount(Warning, {
413
+ props: {
414
+ input: warning,
415
+ hideable: true,
416
+ language: 'fi' as Language,
417
+ theme: 'light-theme' as Theme,
418
+ },
419
+ })
420
+
421
+ expect(wrapper.html()).toMatchSnapshot()
422
+ })
423
+
424
+ it('should render severity level 4 correctly', () => {
425
+ const warning: LegendItem = {
426
+ type: 'wind',
427
+ severity: 4,
428
+ visible: true,
429
+ }
430
+
431
+ wrapper = mount(Warning, {
432
+ props: {
433
+ input: warning,
434
+ hideable: true,
435
+ language: 'fi' as Language,
436
+ theme: 'light-theme' as Theme,
437
+ },
438
+ })
439
+
440
+ expect(wrapper.html()).toMatchSnapshot()
441
+ })
442
+ })
443
+
444
+ describe('Hideable prop snapshots', () => {
445
+ it('should render with hideable true correctly', () => {
446
+ const warning: LegendItem = {
447
+ type: 'wind',
448
+ severity: 3,
449
+ visible: true,
450
+ }
451
+
452
+ wrapper = mount(Warning, {
453
+ props: {
454
+ input: warning,
455
+ hideable: true,
456
+ language: 'fi' as Language,
457
+ theme: 'light-theme' as Theme,
458
+ },
459
+ })
460
+
461
+ expect(wrapper.html()).toMatchSnapshot()
462
+ })
463
+
464
+ it('should render with hideable false correctly', () => {
465
+ const warning: LegendItem = {
466
+ type: 'wind',
467
+ severity: 3,
468
+ visible: true,
469
+ }
470
+
471
+ wrapper = mount(Warning, {
472
+ props: {
473
+ input: warning,
474
+ hideable: false,
475
+ language: 'fi' as Language,
476
+ theme: 'light-theme' as Theme,
477
+ },
478
+ })
479
+
480
+ expect(wrapper.html()).toMatchSnapshot()
481
+ })
482
+ })
483
+ })