@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
@@ -1,3 +0,0 @@
1
- export const pluginsWrapper = {
2
- install(GivenVue) {},
3
- }
@@ -1,126 +0,0 @@
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 DELETED
@@ -1,6 +0,0 @@
1
- import { defineConfig } from 'vite';
2
- export default defineConfig({
3
- test: {
4
- includeSource: ['test/snapshot.test.ts']
5
- },
6
- });