@fmidev/smartmet-alert-client 4.4.19 → 4.7.0-alpha.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 (105) hide show
  1. package/.eslintignore +2 -14
  2. package/.github/workflows/test.yaml +26 -0
  3. package/.nvmrc +1 -0
  4. package/dist/index.html +5 -0
  5. package/dist/index.js +105 -135
  6. package/dist/index.mjs +112 -135
  7. package/dist/locale-en-DCEKDw5G.js +8 -0
  8. package/dist/locale-fi-DPiOM1rB.js +8 -0
  9. package/dist/locale-sv-B0FlbgEF.js +8 -0
  10. package/dist/vendor-Cfkkvdz7.js +21 -0
  11. package/dist/vue/index.mjs +15245 -0
  12. package/dist/vue/style.css +1 -0
  13. package/dist/xml-parser-BiNO9kc-.js +13 -0
  14. package/package.json +60 -24
  15. package/src/AlertClientVue.vue +170 -0
  16. package/src/App.vue +55 -205
  17. package/src/assets/img/ui/arrow-down.svg +4 -11
  18. package/src/assets/img/ui/arrow-up.svg +4 -11
  19. package/src/assets/img/ui/clear.svg +7 -21
  20. package/src/assets/img/ui/close.svg +4 -15
  21. package/src/assets/img/ui/toggle-selected.svg +5 -6
  22. package/src/assets/img/ui/toggle-unselected.svg +5 -6
  23. package/src/assets/img/warning/cold-weather.svg +3 -6
  24. package/src/assets/img/warning/flood-level-3.svg +4 -7
  25. package/src/assets/img/warning/forest-fire-weather.svg +2 -6
  26. package/src/assets/img/warning/grass-fire-weather.svg +2 -6
  27. package/src/assets/img/warning/hot-weather.svg +3 -6
  28. package/src/assets/img/warning/pedestrian-safety.svg +3 -7
  29. package/src/assets/img/warning/rain.svg +2 -7
  30. package/src/assets/img/warning/sea-icing.svg +2 -6
  31. package/src/assets/img/warning/sea-thunder-storm.svg +2 -5
  32. package/src/assets/img/warning/sea-water-height-high-water.svg +3 -8
  33. package/src/assets/img/warning/sea-water-height-shallow-water.svg +3 -7
  34. package/src/assets/img/warning/sea-wave-height.svg +4 -7
  35. package/src/assets/img/warning/sea-wind-legend.svg +2 -5
  36. package/src/assets/img/warning/sea-wind.svg +2 -5
  37. package/src/assets/img/warning/several.svg +2 -5
  38. package/src/assets/img/warning/thunder-storm.svg +2 -5
  39. package/src/assets/img/warning/traffic-weather.svg +2 -6
  40. package/src/assets/img/warning/uv-note.svg +2 -6
  41. package/src/assets/img/warning/wind.svg +2 -5
  42. package/src/components/AlertClient.vue +41 -19
  43. package/src/components/CollapsiblePanel.vue +284 -0
  44. package/src/components/DayLarge.vue +12 -7
  45. package/src/components/DaySmall.vue +16 -6
  46. package/src/components/Days.vue +76 -51
  47. package/src/components/DescriptionWarning.vue +15 -8
  48. package/src/components/GrayScaleToggle.vue +11 -6
  49. package/src/components/Legend.vue +36 -248
  50. package/src/components/MapLarge.vue +41 -42
  51. package/src/components/MapSmall.vue +44 -28
  52. package/src/components/PopupRow.vue +6 -3
  53. package/src/components/Region.vue +30 -15
  54. package/src/components/RegionWarning.vue +6 -5
  55. package/src/components/Regions.vue +50 -19
  56. package/src/components/Warning.vue +18 -10
  57. package/src/components/Warnings.vue +36 -21
  58. package/src/main.js +1 -0
  59. package/src/mixins/alertClientCore.js +210 -0
  60. package/src/mixins/config.js +262 -256
  61. package/src/mixins/utils.js +40 -26
  62. package/src/plugins/index.js +1 -1
  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/vue.js +41 -0
  67. package/svgo.config.js +45 -0
  68. package/tests/README.md +430 -0
  69. package/tests/fixtures/mockWarningData.js +135 -0
  70. package/tests/integration/warning-flow.spec.js +452 -0
  71. package/tests/setup.js +41 -0
  72. package/tests/unit/components/AlertClient.spec.js +734 -0
  73. package/tests/unit/components/DayLarge.spec.js +281 -0
  74. package/tests/unit/components/DaySmall.spec.js +278 -0
  75. package/tests/unit/components/Days.spec.js +565 -0
  76. package/tests/unit/components/DescriptionWarning.spec.js +432 -0
  77. package/tests/unit/components/GrayScaleToggle.spec.js +311 -0
  78. package/tests/unit/components/Legend.spec.js +223 -0
  79. package/tests/unit/components/MapLarge.spec.js +276 -0
  80. package/tests/unit/components/MapSmall.spec.js +226 -0
  81. package/tests/unit/components/PopupRow.spec.js +261 -0
  82. package/tests/unit/components/Region.spec.js +430 -0
  83. package/tests/unit/components/RegionWarning.snapshot.spec.js +73 -0
  84. package/tests/unit/components/RegionWarning.spec.js +408 -0
  85. package/tests/unit/components/Regions.spec.js +335 -0
  86. package/tests/unit/components/Warning.snapshot.spec.js +107 -0
  87. package/tests/unit/components/Warning.spec.js +472 -0
  88. package/tests/unit/components/Warnings.spec.js +329 -0
  89. package/tests/unit/components/__snapshots__/RegionWarning.snapshot.spec.js.snap +21 -0
  90. package/tests/unit/components/__snapshots__/Warning.snapshot.spec.js.snap +199 -0
  91. package/tests/unit/mixins/config.spec.js +269 -0
  92. package/tests/unit/mixins/i18n.spec.js +115 -0
  93. package/tests/unit/mixins/keycodes.spec.js +37 -0
  94. package/tests/unit/mixins/utils.spec.js +624 -0
  95. package/vite.config.js +96 -26
  96. package/vitest.config.js +40 -0
  97. package/dist/index.mjs.map +0 -1
  98. package/dist/index.relative.html +0 -19
  99. package/dist/index.start.html +0 -20
  100. package/playwright.config.ts +0 -18
  101. package/public/index.relative.html +0 -19
  102. package/public/index.start.html +0 -20
  103. package/src/mixins/panzoom.js +0 -900
  104. package/test/snapshot.test.ts +0 -126
  105. package/vitest.config.ts +0 -6
@@ -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
- });