@fmidev/smartmet-alert-client 4.1.2 → 4.1.17

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": "@fmidev/smartmet-alert-client",
3
- "version": "4.1.2",
3
+ "version": "4.1.17",
4
4
  "description": "Web application for viewing weather and flood alerts",
5
5
  "author": "Finnish Meteorological Institute",
6
6
  "license": "MIT",
@@ -15,22 +15,22 @@
15
15
  "build": "vite build",
16
16
  "serve": "vite preview",
17
17
  "lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src",
18
- "test": "vitest"
18
+ "test": "vitest --reporter=verbose --disable-console-intercept"
19
19
  },
20
20
  "dependencies": {
21
21
  "@xmldom/xmldom": "0.8.10",
22
- "bootstrap": "5.3.2",
22
+ "bootstrap": "5.3.3",
23
23
  "bootstrap-vue-next": "0.14.10",
24
- "cross-fetch": "3.1.5",
25
- "dompurify": "3.0.6",
24
+ "cross-fetch": "3.1.8",
25
+ "dompurify": "3.2.3",
26
26
  "flatbush": "3.2.1",
27
- "focus-visible": "5.2.0",
27
+ "focus-visible": "5.2.1",
28
28
  "he": "1.2.0",
29
29
  "svgpath": "2.6.0",
30
30
  "url-search-params-polyfill": "8.2.5",
31
- "vue": "3.4.19",
32
- "vue-web-component-wrapper": "1.4.0",
33
- "xpath": "0.0.33"
31
+ "vue": "3.4.38",
32
+ "vue-web-component-wrapper": "1.4.4",
33
+ "xpath": "0.0.34"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@vitejs/plugin-vue": "4.5.2",
@@ -44,15 +44,15 @@
44
44
  "eslint-plugin-vue": "9.19.2",
45
45
  "fs-extra": "11.2.0",
46
46
  "playwright": "1.41.2",
47
- "postcss-prefixwrap": "1.43.0",
47
+ "postcss-prefixwrap": "1.53.0",
48
48
  "postcss-url": "10.1.3",
49
49
  "prettier": "3.1.1",
50
50
  "rollup-plugin-visualizer": "5.11.0",
51
51
  "unplugin-vue-components": "0.26.0",
52
- "vite": "5.1.7",
52
+ "vite": "5.1.8",
53
53
  "vite-plugin-banner": "0.7.1",
54
- "vite-plugin-static-copy": "1.0.2",
55
- "vitest": "0.34.4"
54
+ "vite-plugin-static-copy": "1.0.6",
55
+ "vitest": "1.6.0"
56
56
  },
57
57
  "eslintConfig": {
58
58
  "env": {
@@ -0,0 +1,18 @@
1
+ import { type PlaywrightTestConfig, devices } from '@playwright/test';
2
+
3
+ const config: PlaywrightTestConfig = {
4
+ projects: [
5
+ {
6
+ name: 'chromium',
7
+ use: {
8
+ ...devices['Desktop Chrome'],
9
+ launchOptions: {
10
+ // Put your chromium-specific args here
11
+ args: ['--disable-web-security', '--allow-file-access-from-files'],
12
+ },
13
+ },
14
+ },
15
+ ],
16
+ };
17
+ export default config;
18
+
@@ -266,11 +266,11 @@ div#fmi-warnings-date-selector.tabs {
266
266
  }
267
267
  &.dark-theme {
268
268
  div.date-selector-cell-header {
269
- border-top: 2px solid $dark-blue !important;
269
+ border-top: 2px solid $white !important;
270
270
  }
271
271
  > div {
272
- border-left: 2px solid $dark-blue !important;
273
- border-right: 2px solid $dark-blue !important;
272
+ border-left: 2px solid $white !important;
273
+ border-right: 2px solid $white !important;
274
274
  }
275
275
  }
276
276
  &.light-gray-theme {
@@ -9,10 +9,8 @@
9
9
  grayScale ? 'gray-scale-selected' : 'gray-scale-unselected',
10
10
  ]"
11
11
  tabindex="0"
12
- @touchmove="preventEvents"
13
- @touchend="preventEvents"
14
- @touchstart="toggleGrayScale"
15
- @mousedown="toggleGrayScale"
12
+ @mousedown="preventEvents"
13
+ @click="toggleGrayScale"
16
14
  @keydown.enter="toggleGrayScale"
17
15
  @keydown.space="toggleGrayScale" />
18
16
  </div>
@@ -203,7 +203,7 @@
203
203
  id="day-map-large-base-popup-closer"
204
204
  :class="['fmi-warnings-popup-closer', `shadow-${popupLevel}`]"
205
205
  href="#"
206
- @click="closeTooltip"></a>
206
+ @mousedown="closeTooltip"></a>
207
207
  <div id="day-map-large-base-popup-content">
208
208
  <div class="region-popup">
209
209
  <div :class="['region-popup-header', `${popupLevel}`]">
@@ -364,10 +364,15 @@ export default {
364
364
  const maxWarningIcons = this.maxWarningIcons
365
365
  this.regionIds.forEach((regionId) => {
366
366
  const region = this.regionData(regionId)
367
+ const geometry = this.geometries[this.geometryId][regionId]
367
368
  if (
368
369
  region != null &&
369
- this.geometries[this.geometryId][regionId].children.length === 0 &&
370
- !this.mergedRegions.has(regionId)
370
+ geometry.children.length === 0 &&
371
+ (!this.mergedRegions.has(regionId) ||
372
+ (geometry.weight > this.maxMergedWeight && region?.warnings?.filter((warning) =>
373
+ this.visibleWarnings.includes(warning.type)).length === 1) &&
374
+ !(geometry?.parent?.length && this.regionData(geometry.parent)?.warnings?.some((warning) =>
375
+ this.visibleWarnings.includes(warning.type))))
371
376
  ) {
372
377
  const iconSizes = []
373
378
  const aspectRatios = []
@@ -902,7 +907,7 @@ export default {
902
907
  }
903
908
  </script>
904
909
 
905
- <style scoped lang="scss">
910
+ <style lang="scss">
906
911
  @import '../scss/constants.scss';
907
912
  @import '../scss/warningImages.scss';
908
913
 
@@ -1107,7 +1112,7 @@ div.day-map-large
1107
1112
  box-shadow: 0 0 0 1px $dark-gray;
1108
1113
  }
1109
1114
 
1110
- :deep(.tooltip.bs-tooltip-top) {
1115
+ .tooltip.bs-tooltip-top {
1111
1116
  .arrow,
1112
1117
  .arrow::before {
1113
1118
  content: ' ';
@@ -19,10 +19,8 @@
19
19
  'd-none',
20
20
  ]"
21
21
  tabindex="0"
22
- @touchmove="preventEvents"
23
- @touchend="preventEvents"
24
- @touchstart="toggle"
25
- @mousedown="toggle"
22
+ @mousedown="preventEvents"
23
+ @click="toggle"
26
24
  @keydown.enter="toggle"
27
25
  @keydown.space="toggle" />
28
26
  </div>
@@ -10,6 +10,7 @@ export default {
10
10
  dateTimeFormatLocale: 'fi-FI',
11
11
  panLimits: { x: 175, y: 275 },
12
12
  coverageCriterion: 0.2,
13
+ maxMergedWeight: 7,
13
14
  maxUpdateDelay: {
14
15
  weather_update_time: 12 * 60 * 60 * 1000,
15
16
  flood_update_time: 12 * 60 * 60 * 1000,
@@ -179,7 +180,7 @@ export default {
179
180
  children: [],
180
181
  neighbours: [],
181
182
  weight: 24,
182
- center: [302.0, 432.0],
183
+ center: [302.0, 435.0],
183
184
  pathLarge:
184
185
  'M 290.5342 447.4933 290.7938 445.8873 293.6316 441.5318 297.1703 443.1237 297.2753 443.0853 295.6552 439.6583 293.8637 439.8821 292.3781 442.1511 290.5734 440.1121 288.0331 439.0487 287.0063 434.9678 288.938 434 288.747 432.443 291.625 430.875 290.813 429.625 292.625 429.375 291.438 422.938 289.625 423 288.688 422.063 287.75 424 285.625 422.063 287.063 419 286.25 418.813 285.7399 417.2663 289.1328 414.6089 290.0971 411.6961 292.0473 410.6481 294.8818 410.198 295.5464 412.0824 300.1694 410.5156 300.922 414.911 303.6306 416.3366 307.5181 415.8545 308.0498 419.1932 306.2513 420.252 307.5865 423.4157 307.7244 427.8533 311.041 428.798 312.6166 430.6773 314.3551 432.6717 319.0944 432.8084 319.4194 434.3236 322.2843 434.3827 323.4507 437.3547 325.4705 438.6003 323.1786 441.2268 323.1515 441.2578 323.0694 441.3518 322.2593 443.6362 316.1816 447.7442 314.1693 446.1019 312.214 447.3079 312.2111 447.3045 312.182 447.2708 308.7499 445.4473 305.1158 444.9635 303.5756 445.7331 303.5506 445.7073 303.5414 445.6685 303.5194 445.6181 303.196 444.5001 303.1818 444.5082 303.1743 444.5126 302.0771 447.8925 299.3001 448.3092 299.2651 448.2842 295.0805 450.4803 292.8157 450.292 290.5342 447.4933 Z',
185
186
  pathSmall:
@@ -192,7 +193,7 @@ export default {
192
193
  children: [],
193
194
  neighbours: [],
194
195
  weight: 33,
195
- center: [325.0, 420.0],
196
+ center: [330.0, 417.0],
196
197
  pathLarge:
197
198
  'M 325.4705 438.6003 323.4507 437.3547 322.2843 434.3827 319.4194 434.3236 319.0944 432.8084 314.3551 432.6717 312.6166 430.6773 311.041 428.798 307.7244 427.8533 307.5865 423.4157 306.2513 420.252 308.0498 419.1932 307.5181 415.8545 310.8481 415.3348 311.3885 413.4196 311.1031 412.1478 314.2393 410.8348 316.617 407.2944 319.744 408.0207 320.5649 406.4876 323.6632 406.9794 330.7848 405.5163 334.6019 401.8496 334.3914 400.5595 340.1442 401.1616 343.1474 399.564 343.0657 397.9984 346.2294 397.6513 348.3013 397.9175 352.9739 396.6449 355.9692 392.0665 359.0929 390.2909 359.2687 388.7815 371.5696 381.6216 371.8388 382.1504 369.8915 385.9354 365.6665 390.9014 363.6879 395.0447 357.2527 402.6735 354.6641 406.3472 352.8097 410.0864 349.5585 412.8912 348.2488 413.9076 348.2013 413.9497 346.7945 415.7078 343.7441 417.188 342.8661 419.1519 342.8456 419.1767 342.8444 419.1782 341.4751 420.8304 340.3233 425.193 337.2797 425.0071 328.7037 435.2032 325.4705 438.6003 Z',
198
199
  pathSmall:
@@ -231,7 +232,7 @@ export default {
231
232
  children: [],
232
233
  neighbours: [],
233
234
  weight: 5,
234
- center: [312.0, 390.0],
235
+ center: [312.0, 391.0],
235
236
  pathLarge:
236
237
  'M 307.5181 415.8545 303.6306 416.3366 300.922 414.911 300.1694 410.5156 295.5464 412.0824 294.8818 410.198 292.0473 410.6481 291.3672 408.3816 289.4862 408.3591 287.7197 406.1147 286.5734 403.5581 286.675 399.9186 287.7526 395.0718 289.0932 392.7724 292.2044 394.2692 292.554 390.8659 289.5124 383.7068 288.3098 382.1717 288.354 379.1984 290.1212 378.1879 288.3348 375.1942 285.9516 371.3663 288.0681 367.6151 293.1578 364.8715 296.0623 362.6783 298.0838 360.5193 295.9573 358.2087 296.6399 355.9347 299.2926 356.4155 300.3173 354.4307 302.2417 355.9397 305.6921 353.7965 309.1483 355.4309 311.6677 353.5552 314.7564 355.7871 317.8305 359.515 317.688 361.688 316.688 362.5 316.375 364.063 314.188 363.75 313.5 364.563 315.375 366.438 314 366.438 315 370.188 316.813 370.125 316.75 375.25 320.375 377.563 326.188 371.125 325.063 367.625 326.563 367.438 325.6217 365.8778 331.1161 365.9324 333.003 366.7062 335.5203 367.2405 338.3348 369.2624 338.6902 365.7111 340.563 366.438 342.25 367 340.688 364.625 341.313 363.063 343.438 364.625 344.75 364.563 345.125 361.938 347.875 360.688 349.75 361.063 349.5827 358.2632 352.3821 358.1307 352.7118 360.5797 355.5212 365.0156 355.0841 366.6475 356.4272 371.9172 361.0143 376.8573 360.1284 379.8485 362.0103 382.0408 361.6861 385.4695 359.2687 388.7815 359.0929 390.2909 355.9692 392.0665 352.9739 396.6449 348.3013 397.9175 346.2294 397.6513 343.0657 397.9984 343.1474 399.564 340.1442 401.1616 334.3914 400.5595 334.6019 401.8496 330.7848 405.5163 323.6632 406.9794 320.5649 406.4876 319.744 408.0207 316.617 407.2944 314.2393 410.8348 311.1031 412.1478 311.3885 413.4196 310.8481 415.3348 307.5181 415.8545 Z',
237
238
  pathSmall:
@@ -283,7 +284,7 @@ export default {
283
284
  children: [],
284
285
  neighbours: [],
285
286
  weight: 12,
286
- center: [192.5, 325.0],
287
+ center: [200.0, 320.0],
287
288
  pathLarge:
288
289
  'M 203.3818 310.6689 203.4906 312.7075 201.3391 314.9061 197.8083 313.16 198.4997 311.2477 202.9614 312.0607 203.3818 310.6689 Z M 186.58 312.3441 186.6325 316.0237 183.8247 317.7972 180.6552 316.3937 179.4855 310.951 181.9624 309.2854 183.6214 313.2534 186.58 312.3441 Z M 179.273 373.6524 178.9155 369.8916 179.5664 365.0561 181.5382 362.3104 180.0239 360.266 180.4727 357.3161 180.4595 357.3213 180.454 357.3236 180.4373 357.3402 180.3223 357.4502 181.4016 354.6862 177.5241 351.405 176.6773 345.5794 179.413 343.3479 176.1201 342.5978 177.1873 339.5483 177.184 339.525 178.7963 337.7889 178.1275 335.502 182.5129 330.4544 182.5175 330.4537 182.5713 330.4448 184.4986 330.0973 186.7646 325.3276 186.7538 325.3051 186.6592 325.258 186.355 325.0751 186.1758 324.988 186.0887 324.918 186.3842 322.9965 188.499 321.9627 189.8808 323.1945 189.8883 323.2124 190.225 323.0703 190.25 323.0378 187.8402 317.853 187.8339 317.8268 187.8218 317.7759 189.024 313.2109 191.3906 316.082 196.6707 313.3867 197.5975 314.7531 197.6225 314.7856 197.5829 314.9306 197.6571 314.9206 198.1313 316.6908 197.9533 316.6871 197.7183 316.6621 197.6396 316.6529 197.6471 316.585 197.6291 316.5375 197.6396 316.3629 197.5725 316.3575 197.4254 316.7283 198.19 316.8804 198.9247 317.2805 198.933 317.2776 198.9564 317.2696 201.0628 315.4215 205.5396 313.4922 206.666 311.0898 206.6661 311.0894 206.6705 311.0769 203.3556 305.8272 205.5046 304.3353 206.2351 301.1458 208.5966 304.1711 209.4217 302.1468 208.712 299.7557 210.3918 298.4089 210.3989 298.4051 210.4226 298.3926 212.1741 296.3278 212.6416 293.9509 212.6908 293.8859 212.7458 293.8542 212.9108 293.9642 212.9333 294.0217 212.9466 294.0584 213.0237 294.158 214.2497 294.1259 214.4401 294.1634 215.141 294.8681 215.3327 294.926 215.4286 295.1056 215.4719 295.2752 215.6928 295.3231 216.3074 295.9515 216.4074 296.0265 216.4653 296.2774 216.6404 296.3757 216.715 296.5345 216.7454 296.7012 216.742 297.2491 216.767 297.3087 218.4572 295.6161 218.4764 295.6102 218.5339 292.3299 218.5839 292.2924 218.6589 292.2665 219.1211 291.9452 219.1023 291.7027 219.1665 291.8727 220.5658 291.4756 220.9358 291.2685 225.4888 295.0297 226.6902 293.3825 230.5794 292.3803 235.7895 297.4775 231.5307 299.2002 232.0933 302.9631 233.5618 306.3172 234.1152 311.119 232.6663 310.0664 231.1728 306.9502 228.1083 305.3271 225.3601 306.4939 223.9749 309.6859 221.9718 311.8874 219.0031 310.6493 212.0586 312.7633 211.3402 314.3327 210.3801 317.4876 211.6844 321.4113 211.0998 322.6969 207.5 322.625 204.375 324.188 202.5 324.063 200.625 326.438 200.313 328.688 201.813 331.438 202.4822 336.5817 200.8074 338.2903 196.8861 336.8593 193.4404 334.6424 192.1244 332.3684 190.853 336.7338 191.8898 340.2746 188.9861 342.5486 187.3184 344.0167 187.7306 346.2436 185.797 352.3518 185.5987 355.54 188.4002 355.813 187.706 360.1514 189.7437 362.1241 187.308 363.5472 186.0746 367.5097 186.2662 371.2438 181.4199 371.2822 179.273 373.6524 Z M 218.3406 290.4842 215.6928 294.3747 212.5949 290.2326 215.2598 288.3519 218.2264 288.8941 218.3406 290.4842 Z',
289
290
  pathSmall:
@@ -397,7 +398,7 @@ export default {
397
398
  children: [],
398
399
  neighbours: ['municipality.305', 'municipality.615'],
399
400
  weight: 3,
400
- center: [327.952, 212.5446],
401
+ center: [332.0, 213.0],
401
402
  pathLarge:
402
403
  'M 345.5372 212.8642 343.7658 216.2241 340.705 216.32 334.7827 219.1736 334.1439 224.0233 325.5484 225.8464 325.0175 221.8222 321.9155 218.8002 318.8002 217.6747 317.8984 214.0339 318.6968 207.2182 317.4771 202.0788 317.3934 199.1823 324.7279 199.6369 326.2456 200.2461 331.6874 198.0309 332.7671 198.3901 334.3169 202.8631 334.5419 207.4678 336.1275 209.0763 338.4198 209.31 339.9512 207.0686 341.826 209.7426 345.5372 212.8642 Z',
403
404
  pathSmall:
@@ -410,7 +411,7 @@ export default {
410
411
  children: [],
411
412
  neighbours: ['municipality.832'],
412
413
  weight: 6,
413
- center: [345.8894, 193.365],
414
+ center: [347.0, 190.0],
414
415
  pathLarge:
415
416
  'M 356.0146 213.4284 352.0413 213.1988 351.1978 214.031 347.6004 212.675 345.5372 212.8642 341.826 209.7426 339.9512 207.0686 338.4198 209.31 336.1275 209.0763 334.5419 207.4678 334.3169 202.8631 332.7671 198.3901 331.6874 198.0309 330.0689 193.4108 330.9527 190.7326 335.9487 190.6864 335.8283 188.4028 333.5859 187.5135 336.1208 182.1692 335.6195 178.9293 332.5958 178.1783 331.7516 173.1261 333.8839 171.6272 334.3398 168.2227 344.8938 171.5072 344.838 170.37 350.707 170.1487 353.5964 177.6891 357.9023 184.0506 359.6196 190.8672 361.1593 194.6935 363.0112 205.1275 360.6276 203.9515 355.0991 206.9673 357.9861 210.4014 356.0146 213.4284 Z',
416
417
  pathSmall:
@@ -524,6 +525,7 @@ export default {
524
525
  parent: 'county.19',
525
526
  children: [],
526
527
  neighbours: [
528
+ 'municipality.845',
527
529
  'municipality.854',
528
530
  'municipality.698',
529
531
  'municipality.851',
@@ -546,6 +548,7 @@ export default {
546
548
  'municipality.751',
547
549
  'municipality.241',
548
550
  'municipality.851',
551
+ 'municipality.976',
549
552
  ],
550
553
  weight: 2,
551
554
  center: [265.3281, 185.87],
@@ -846,7 +849,7 @@ export default {
846
849
  children: [],
847
850
  neighbours: [],
848
851
  weight: 23,
849
- center: [119.0, 445.0],
852
+ center: [118.0, 444.0],
850
853
  align: 'right',
851
854
  pathLarge:
852
855
  'M 98.2747 432.8199 105.8161 433.818 105.612 437.5967 107.9942 437.1644 107.1174 433.9863 142.8844 438.1614 139.5745 468.9278 118.3066 466.5209 118.7218 464.3484 115.9273 462.3149 114.0815 456.5902 114.2548 453.2481 112.6234 453.1644 109.7262 450.9729 108.4094 451.0754 105.6402 448.7817 106.4921 447.3387 109.3599 447.1564 106.4603 441.1372 105.203 441.1795 100.1456 436.9957 98.2747 432.8199 Z',
@@ -899,7 +902,7 @@ export default {
899
902
  children: [],
900
903
  neighbours: [],
901
904
  weight: 7,
902
- center: [173.0136, 303.2831],
905
+ center: [180.0, 300.0],
903
906
  pathLarge:
904
907
  'M 178.9812 276.4819 204.2092 304.4867 205.5433 305.9199 207.6602 311.1558 207.6602 311.1558 208.1716 312.4129 206.5282 316.4975 204.0379 317.2166 198.0719 322.4695 195.5409 318.3654 191.5912 320.147 192.3052 324.7125 189.4301 328.0799 187.5368 329.4226 183.3935 334.4751 182.6431 334.6226 179.7695 335.1835 178.5202 333.7273 151.6352 301.2458 153.2131 300.4207 152.4401 297.4723 154.0171 296.8378 156.5326 293.7041 158.7818 292.5158 163.6652 292.7602 165.9977 290.7073 175.7507 283.7729 176.4291 281.6139 178.7801 278.9562 178.9812 276.4819 Z',
905
908
  pathSmall:
@@ -939,7 +942,7 @@ export default {
939
942
  children: [],
940
943
  neighbours: [],
941
944
  weight: 15,
942
- center: [345.0, 402.1622],
945
+ center: [344.0, 398.0],
943
946
  pathLarge:
944
947
  'M 344.6088 382.7259 346.1052 384.0827 346.2444 386.5113 347.4966 386.9322 351.0687 387.1468 351.8392 385.437 353.3439 383.7052 353.7998 382.4896 352.8797 380.3231 353.4027 379.7035 353.4548 377.9745 352.968 377.2749 354.1448 376.5031 355.2766 378.2058 357.5506 378.803 357.3227 377.6091 356.293 376.784 355.8417 375.0046 356.7501 374.5867 359.2491 377.2411 360.193 376.4327 359.3746 375.8139 359.4108 374.48 359.9471 373.4974 360.5009 373.5382 361.5098 375.3688 362.372 376.4644 362.1424 377.1382 362.8441 378.0616 364.0863 379.0338 362.8195 379.5076 362.7491 380.3548 360.766 380.8582 360.4734 381.7137 359.715 382.3342 360.6864 382.9734 360.0717 384.4565 357.2943 385.3887 357.9532 387.128 356.5543 386.6238 356.4317 385.387 355.5129 386.0596 356.4001 387.3631 354.9491 388.1215 355.5062 389.6587 354.7266 390.1529 353.4468 389.3937 352.7939 389.5266 353.3214 390.8114 352.9189 392.5565 351.6983 393.2979 352.0542 394.3292 349.7856 392.9912 349.4827 393.6829 348.3334 392.8912 347.2953 393.7958 348.7626 394.4684 349.3647 395.8882 348.3963 395.8161 346.504 394.2876 342.6644 390.1142 340.2292 390.015 339.97 390.4396 340.4642 392.0565 339.1699 391.091 338.589 391.8856 337.8656 390.4292 336.8667 390.5942 337.7435 394.9735 338.7227 395.0676 338.9953 396.2615 338.1006 397.6608 338.8594 397.7579 339.142 399.1214 340.1412 399.3381 339.7866 400.317 338.469 400.2865 337.8602 399.2769 337.1042 398.756 333.9322 398.8443 333.1426 399.2031 331.962 400.3178 331.7491 399.4315 333.2084 398.8585 333.4809 398.0171 335.1069 398.6818 336.4654 398.7068 337.9868 398.3167 337.7768 396.2311 336.9384 395.6573 335.0561 395.0906 334.3594 395.584 331.5182 395.506 331.7199 396.4899 330.9665 396.8224 330.1918 398.0576 329.8443 399.2773 328.7896 399.7136 328.7062 400.2345 330.5019 400.7549 331.0598 401.4942 329.0634 401.3379 329.9047 404.6058 330.7794 404.8491 331.1473 404.0874 332.0699 403.8786 332.1683 405.4859 333.1559 405.9655 334.2977 405.4834 335.1103 405.8784 334.2843 406.8043 332.8175 406.0705 331.9979 406.0234 332.5346 408.2137 330.0918 408.5441 328.8421 407.8153 328.6425 408.5737 330.0697 409.2213 331.0465 409.1588 333.7914 407.4615 335.6632 407.8049 335.6316 408.4503 337.3138 409.4467 337.1826 407.9953 335.6637 407.6144 335.6682 406.9248 338.086 406.2293 339.4878 406.4614 340.5988 406.2672 341.4097 407.544 342.1719 407.8957 343.5249 409.6376 344.4367 409.9859 344.5759 410.9981 343.6758 412.1562 342.1681 412.5508 341.393 413.7138 340.2312 413.6163 338.9799 415.1407 338.3256 414.9277 337.8822 415.9353 336.9017 415.9695 336.6588 416.6967 335.0844 417.0175 334.3089 416.7408 333.8668 417.588 332.9138 418.0493 332.5129 419.244 331.6166 419.1461 330.7119 419.8712 329.1759 419.7216 328.0687 420.7371 326.6244 419.3532 326.4981 418.2764 325.233 417.1075 324.6137 417.4717 322.8385 416.7167 322.1289 415.7949 323.0219 414.3793 324.6146 413.0633 326.7869 413.9822 327.7845 413.9605 328.1766 414.7185 328.1037 415.0523 327.947 415.4565 328.5421 416.5833 330.4594 418.8611 331.3503 419.0157 331.3111 417.6772 332.1216 416.187 331.3361 415.4928 330.6606 414.1889 330.0506 413.9064 328.1941 413.8438 327.8003 412.7212 326.4648 411.6574 326.5902 410.2426 325.3359 410.0539 324.0778 410.5693 323.1681 410.2951 321.5355 410.5922 320.9533 409.0567 320.1512 409.1396 318.3876 408.6104 318.2914 409.1346 319.7119 410.6522 318.591 410.5393 317.6996 409.9688 318.0159 408.7841 317.3509 408.4866 317.1446 407.0969 318.5556 406.501 318.6456 405.8242 317.7626 405.085 315.296 405.0129 315.1906 403.2856 313.4508 403.0268 312.9829 403.5361 311.3998 402.2747 311.7036 401.3375 312.8808 402.0976 313.52 401.7367 314.178 402.3789 315.5523 402.9372 316.5074 402.2697 318.611 403.3365 318.9181 404.4807 320.5087 404.3982 322.3651 403.8919 324.1953 404.3361 324.0016 403.4056 323.2565 402.7301 323.3473 401.8484 322.8273 400.3315 324.3424 400.3011 323.8978 398.8389 323.9053 397.8163 321.7501 398.0551 321.3154 397.295 320.1941 396.4953 319.5419 395.5898 318.1789 398.048 318.7539 398.6997 317.5225 400.4003 317.3392 401.2541 316.5228 401.0508 315.5665 400.2761 316.2311 399.1277 316.9371 399.9507 317.5113 399.4148 317.3892 398.5368 317.9401 398.0451 318.1255 396.1328 316.9362 395.676 318.2322 394.6455 319.4336 394.2046 318.9048 393.2987 319.6736 392.8816 320.7687 393.5662 321.5842 392.424 322.964 391.3035 323.3986 393.1741 322.8748 394.0892 321.8263 397.3487 322.0997 397.8538 323.1631 397.775 323.867 396.2399 324.4816 397.0437 325.5113 397.445 325.2442 398.5543 325.4496 399.7786 326.6923 400.8462 327.3419 399.7877 327.354 398.6218 328.4983 397.9955 329.3001 399.1502 330.1747 396.149 329.3434 395.6381 330.451 394.0075 330.676 390.4226 330.1843 389.0249 330.5769 387.9769 332.2362 388.2348 334.1089 388.8366 333.9039 387.954 334.5481 387.6131 334.7473 386.0975 335.5795 387.3939 336.7959 387.4243 337.3401 386.1784 339.0503 386.1542 337.6539 383.711 339.2786 384.6444 340.0566 384.3727 341.4839 384.4782 343.6016 384.2869 343.9425 382.5205 344.6088 382.7259 Z M 338.9278 389.7421 338.1102 388.9457 337.5901 389.3637 338.5177 390.2463 338.9278 389.7421 Z M 358.6407 379.0784 358.5195 377.6762 357.8131 378.11 358.6407 379.0784 Z M 343.3074 385.8254 343.96 387.0397 344.588 386.6334 343.3074 385.8254 Z M 352.8401 387.1489 353.6348 387.0272 353.3381 385.7546 352.4863 385.5566 352.8401 387.1489 Z M 326.3606 402.8893 327.2119 404.5137 327.7274 403.3481 327.2973 402.4168 326.3606 402.8893 Z M 329.5288 412.8858 330.1947 412.5183 329.7405 411.7061 328.3158 411.1686 327.8978 411.4202 329.5288 412.8858 Z M 319.834 406.691 319.0848 406.4035 317.6159 406.8981 318.2314 407.5436 319.5248 407.2727 319.834 406.691 Z M 339.3178 389.1853 339.6987 387.9615 339.0457 386.9084 338.1656 387.4881 338.4952 388.4165 339.3178 389.1853 Z M 347.6437 392.2207 347.1199 391.3118 346.0935 391.6064 346.7636 393.1424 347.6437 392.2207 Z M 341.9735 389.5804 341.5889 388.4974 340.3633 388.4982 340.4146 389.7096 341.9735 389.5804 Z M 321.6934 396.4799 322.1251 395.551 321.0392 394.4751 320.287 396.4286 321.6934 396.4799 Z M 327.9157 401.858 328.6962 402.9206 327.8107 404.077 329.3417 404.1765 329.2138 402.7172 327.9157 401.858 Z M 356.8701 381.0674 356.9597 380.1214 355.5558 379.8081 355.4179 380.9578 356.8701 381.0674 Z M 339.8962 385.0041 339.5474 385.5295 341.5993 386.2175 341.6156 385.2053 339.8962 385.0041 Z M 339.1882 412.2353 338.2352 411.3427 336.9684 411.2694 336.7409 411.8295 338.8423 413.5105 339.1882 412.2353 Z M 321.6888 406.0051 322.9273 405.9759 323.7082 405.1792 323.3244 404.3141 321.7372 405.0029 321.3184 404.5895 320.1182 404.6574 319.6786 405.3571 320.342 406.1593 321.6888 406.0051 Z M 327.629 417.1838 328.1337 416.9421 327.7486 416.0003 328.0337 415.8436 327.8428 415.2523 328.0262 415.2382 328.0399 414.656 327.3915 414.0226 326.3018 414.8852 324.8904 413.6238 324.1141 414.2718 323.2082 414.4481 323.3286 415.7978 324.7191 415.9216 325.5497 415.6149 326.6239 415.8253 326.934 416.9558 327.629 417.1838 Z M 338.9232 410.8656 339.4037 411.782 340.5892 411.7074 340.9505 410.8994 341.8406 410.228 343.4233 411.4173 344.0629 410.9139 343.1403 409.3309 341.7522 408.4916 341.2339 408.71 340.38 407.8574 340.0054 406.8806 338.334 406.3785 338.3865 407.2994 337.3922 408.9275 338.9232 410.8656 Z M 335.0853 388.7424 333.8951 389.5283 333.2776 388.7982 331.0294 388.1652 330.4831 389.0316 330.7556 390.1117 330.9715 393.9467 331.4661 394.8193 332.1983 395.0264 333.3772 394.6468 334.2756 394.8793 335.1036 394.3088 337.1176 394.0359 335.8245 390.065 335.0853 388.7424 Z M 348.883 391.356 349.2418 391.9973 350.3561 390.6422 351.1074 391.1135 352.0521 390.0904 352.3563 388.1752 351.6779 386.9947 350.2494 388.3461 349.1797 387.3939 347.4574 387.5114 346.6286 387.1551 346.1811 388.6353 346.5428 389.5975 347.9308 391.2777 348.0296 390.0071 348.8363 390.0388 348.883 391.356 Z M 324.8696 405.0396 325.413 405.9926 326.746 406.5047 328.1974 405.8234 326.1381 403.7144 325.2075 402.9618 324.8696 405.0396 Z',
945
948
  pathSmall:
@@ -179,33 +179,35 @@ export default {
179
179
  },
180
180
  msSinceStartOfDay(timestamp) {
181
181
  const moment = this.toTimeZone(timestamp)
182
- return ((moment.hour * 60 + moment.minute) * 60 + moment.second) * 1000
182
+ const ms = ((moment.hour * 60 + moment.minute) * 60 + moment.second) * 1000 + moment.millisecond
183
+ // Daylight saving time
184
+ const ref = this.toTimeZone(timestamp - ms)
185
+ if (ref.day !== moment.day) {
186
+ return ms - 60 * 60 * 1000
187
+ }
188
+ return ms + ref.hour * 60 * 60 * 1000
183
189
  },
184
190
  effectiveDays(start, end, dailyWarning) {
185
191
  const offset = this.timeOffset
186
192
  const referenceTime =
187
193
  this.startFrom === 'updated' ? this.updatedAt : this.currentTime
194
+ const day = 1000 * 60 * 60 * 24
188
195
  return [...Array(this.NUMBER_OF_DAYS).keys()].map((index) => {
189
- const date = new Date(referenceTime)
190
- date.setDate(date.getDate() + index)
191
- const day = this.toTimeZone(date)
192
- const startOfDay = new Date(day.year, day.month - 1, day.day)
196
+ const dayTime = referenceTime + index * day
197
+ const dayStartOffset = this.msSinceStartOfDay(dayTime)
198
+ let startOfDay = dayTime - dayStartOffset
199
+
200
+ const nextDayTime = referenceTime + (index + 1) * day
201
+ const nextDayStartOffset = this.msSinceStartOfDay(nextDayTime)
202
+ let startOfNextDay = nextDayTime - nextDayStartOffset
193
203
 
194
- const nextDate = new Date(referenceTime)
195
- nextDate.setDate(nextDate.getDate() + index + 1)
196
- const nextDay = this.toTimeZone(nextDate)
197
- const startOfNextDay = new Date(
198
- nextDay.year,
199
- nextDay.month - 1,
200
- nextDay.day
201
- )
202
204
  if (!dailyWarning) {
203
- startOfDay.setMilliseconds(offset)
204
- startOfNextDay.setMilliseconds(offset)
205
+ startOfDay = startOfDay + offset
206
+ startOfNextDay = startOfNextDay + offset
205
207
  }
206
208
  return (
207
- new Date(start).getTime() < startOfNextDay.getTime() &&
208
- new Date(end).getTime() > startOfDay.getTime()
209
+ new Date(start).getTime() < startOfNextDay &&
210
+ new Date(end).getTime() > startOfDay
209
211
  )
210
212
  })
211
213
  },
@@ -185,6 +185,7 @@ span.symbol-text {
185
185
  width: 100%;
186
186
  text-align: center;
187
187
  margin: 0 auto;
188
+ padding-top: 1px;
188
189
  font-family: $symbol-font-family !important;
189
190
  color: #ffffff;
190
191
  text-anchor: middle;
@@ -0,0 +1,126 @@
1
+ import { Browser, BrowserContext, chromium, Page } from 'playwright';
2
+ import { afterAll, beforeEach, describe, expect, it } from 'vitest';
3
+ import { setTimeout } from 'timers/promises';
4
+ import fs from 'fs'
5
+
6
+ const dataBaseUrl = process.env.VITE_TEST_DATA_DIRECTORY;
7
+ const htmlDir = '/html/';
8
+ const htmlExt = '-page.html'
9
+ const svgDir = '/svg/';
10
+ const svgExt = '-map.svg'
11
+ const libraryFile = 'index.js';
12
+
13
+ let years = process.env.VITE_TEST_YEARS.split(',');
14
+ let months = process.env.VITE_TEST_MONTHS.split(',').map((month) => month.padStart(2, '0'));
15
+ let days = process.env.VITE_TEST_DAYS.split(',').map((day) => day.padStart(2, '0'));
16
+
17
+ if (years.length === 0) {
18
+ years = Array.from({length: new Date().getFullYear() - 2020}, (_, i) => i + 2021);
19
+ }
20
+ if (months.length === 0) {
21
+ months = Array.from({length: 12}, (_, i) => (i + 1).toString().padStart(2, '0'));
22
+ }
23
+ if (days.length === 0) {
24
+ days = Array.from({length: 31}, (_, i) => (i + 1).toString().padStart(2, '0'));
25
+ }
26
+
27
+ let dataTimes = [];
28
+
29
+ const htmlTemplate = `<!doctype html>
30
+ <html lang="fi">
31
+ <head>
32
+ <meta charset="UTF-8" />
33
+ <meta
34
+ name="viewport"
35
+ content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
36
+ <title>SmartMet Alert Client</title>
37
+ <script type="module" crossorigin src="./index.js"></script>
38
+ </head>
39
+
40
+ <body>
41
+ <smartmet-alert-client language="fi" current-date="CURRENT_DATE" warnings='{"weather_update_time":WEATHER_UPDATE_TIME,"flood_update_time":FLOOD_UPDATE_TIME,"weather_finland_active_all":WEATHER_DATA,"flood_finland_active_all":FLOOD_DATA}'></smartmet-alert-client>
42
+ </body>
43
+ </html>`;
44
+
45
+ describe("The warnings map", () => {
46
+ let page: Page;
47
+ let browser: Browser;
48
+ let context: BrowserContext;
49
+
50
+ fs.mkdirSync(`${__dirname}${svgDir}`, { recursive: true });
51
+ const htmlPath = `${__dirname}${htmlDir}`;
52
+ fs.mkdirSync(htmlPath, { recursive: true });
53
+ fs.copyFileSync(`${__dirname}/../dist/${libraryFile}`, `${htmlPath}${libraryFile}`);
54
+
55
+ console.log(`Preparing data for regression tests, please wait.`);
56
+ for (const year of years) {
57
+ for (const month of months) {
58
+ for (const day of days) {
59
+ const subDirs = year + '/' + month + '/' + day + '/';
60
+
61
+ const dataPath = dataBaseUrl + subDirs;
62
+ try {
63
+ const dataFiles = fs.readdirSync(dataPath);
64
+ const uniqDataTimes = new Set()
65
+ for (const dataFile of dataFiles) {
66
+ const uniqDataTime = dataFile.slice(0, 14);
67
+ uniqDataTimes.add(uniqDataTime);
68
+ }
69
+ const newDataTimes = Array.from(uniqDataTimes);
70
+ newDataTimes.sort();
71
+ for (const dataTime of newDataTimes) {
72
+ const dateInput = dataTime.slice(0,4) + '-' + dataTime.slice(4,6) + '-' + dataTime.slice(6,8) + 'T'
73
+ + dataTime.slice(8,10) + ':' + dataTime.slice(10,12) + ':' + dataTime.slice(12,14) + 'Z';
74
+ const date = new Date(dateInput)
75
+ const dateOutput = date.toISOString()
76
+
77
+ let html = String(htmlTemplate);
78
+ html = html.replace('CURRENT_DATE', dateOutput);
79
+
80
+ const weatherUpdateTimeFile = dataPath + dataTime + '-weather_update_time.json';
81
+ const floodUpdateTimeFile = dataPath + dataTime + '-flood_update_time.json';
82
+ const weatherDataFile = dataPath + dataTime + '-weather_finland_active_all.json';
83
+ const floodDataFile = dataPath + dataTime + '-flood_finland_active_all.fi.json';
84
+
85
+ const weatherUpdateTime = fs.readFileSync(weatherUpdateTimeFile, "utf8");
86
+ const floodUpdateTime = fs.readFileSync(floodUpdateTimeFile, "utf8");
87
+ const weatherData = fs.readFileSync(weatherDataFile, "utf8");
88
+ const floodData = fs.readFileSync(floodDataFile, "utf8");
89
+
90
+ html = html.replace('WEATHER_UPDATE_TIME', weatherUpdateTime);
91
+ html = html.replace('FLOOD_UPDATE_TIME', floodUpdateTime);
92
+ html = html.replace('WEATHER_DATA', weatherData);
93
+ html = html.replace('FLOOD_DATA', floodData);
94
+
95
+ fs.writeFileSync(`${htmlPath}${dataTime}${htmlExt}` , html);
96
+ }
97
+ dataTimes = dataTimes.concat(newDataTimes)
98
+ } catch (error) {
99
+ console.log(error);
100
+ continue;
101
+ }
102
+ }
103
+ }
104
+ }
105
+
106
+ beforeEach(async () => {
107
+ browser = await chromium.launch({ args: ['--allow-file-access-from-files'] });
108
+ let browserContext = await browser.newContext();
109
+ page = await browserContext.newPage();
110
+ });
111
+
112
+ afterAll(async () => {
113
+ await browser.close();
114
+ });
115
+
116
+ for (const dataTime of dataTimes) {
117
+ it(`is changeless at ${dataTime}`, async () => {
118
+ await page.goto(`file:${__dirname}${htmlDir}${dataTime}${htmlExt}`);
119
+ const html = await page.content()
120
+ const result = await page.locator("svg#finland-large");
121
+ const svg = await result.evaluate((el) => el.outerHTML);
122
+ expect(svg).toMatchFileSnapshot(`${__dirname}${svgDir}${dataTime}${svgExt}`);
123
+ });
124
+ }
125
+
126
+ });
package/vitest.config.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { defineConfig } from "vite";
1
+ import { defineConfig } from 'vite';
2
2
  export default defineConfig({
3
3
  test: {
4
+ includeSource: ['test/snapshot.test.ts']
4
5
  },
5
6
  });
@@ -1,26 +0,0 @@
1
- var fs = require('fs-extra');
2
- const { chromium } = require("playwright");
3
- const timers = require("node:timers/promises");
4
-
5
- let browser = null;
6
- const url = "";
7
-
8
- (async () => {
9
- browser = await chromium.launch();
10
- let page = await browser.newPage();
11
- await page.setViewportSize({ width: 1280, height: 1000 });
12
- await page.goto(url);
13
-
14
- await timers.setTimeout(5000);
15
- await page.screenshot({ path: `./pic-${(new Date()).toISOString()}.png` });
16
-
17
- const html = await page.content()
18
- const result = await page.locator("svg#finland-large");
19
- const text = await result.evaluate((el) => el.outerHTML);
20
-
21
- await result.screenshot({ path: `./map-${(new Date()).toISOString()}.png` });
22
-
23
- console.log(text);
24
-
25
- await browser.close();
26
- })();