@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.
- package/.eslintignore +2 -14
- package/.github/workflows/test.yaml +26 -0
- package/.nvmrc +1 -0
- package/AGENTS.md +26 -0
- package/index.html +1 -1
- package/package.json +80 -22
- package/src/AlertClientVue.vue +160 -0
- package/src/App.vue +154 -296
- package/src/assets/img/ui/arrow-down.svg +4 -11
- package/src/assets/img/ui/arrow-up.svg +4 -11
- package/src/assets/img/ui/clear.svg +7 -21
- package/src/assets/img/ui/close.svg +4 -15
- package/src/assets/img/ui/toggle-selected.svg +5 -6
- package/src/assets/img/ui/toggle-unselected.svg +5 -6
- package/src/assets/img/warning/cold-weather.svg +3 -6
- package/src/assets/img/warning/flood-level-3.svg +4 -7
- package/src/assets/img/warning/forest-fire-weather.svg +2 -6
- package/src/assets/img/warning/grass-fire-weather.svg +2 -6
- package/src/assets/img/warning/hot-weather.svg +3 -6
- package/src/assets/img/warning/pedestrian-safety.svg +3 -7
- package/src/assets/img/warning/rain.svg +2 -7
- package/src/assets/img/warning/sea-icing.svg +2 -6
- package/src/assets/img/warning/sea-thunder-storm.svg +2 -5
- package/src/assets/img/warning/sea-water-height-high-water.svg +3 -8
- package/src/assets/img/warning/sea-water-height-shallow-water.svg +3 -7
- package/src/assets/img/warning/sea-wave-height.svg +4 -7
- package/src/assets/img/warning/sea-wind-legend.svg +2 -5
- package/src/assets/img/warning/sea-wind.svg +2 -5
- package/src/assets/img/warning/several.svg +2 -5
- package/src/assets/img/warning/thunder-storm.svg +2 -5
- package/src/assets/img/warning/traffic-weather.svg +2 -6
- package/src/assets/img/warning/uv-note.svg +2 -6
- package/src/assets/img/warning/wind.svg +2 -5
- package/src/components/AlertClient.vue +330 -251
- package/src/components/CollapsiblePanel.vue +281 -0
- package/src/components/DayLarge.vue +146 -110
- package/src/components/DaySmall.vue +97 -81
- package/src/components/Days.vue +229 -159
- package/src/components/DescriptionWarning.vue +63 -38
- package/src/components/GrayScaleToggle.vue +58 -54
- package/src/components/Legend.vue +102 -325
- package/src/components/MapLarge.vue +574 -351
- package/src/components/MapSmall.vue +137 -122
- package/src/components/PopupRow.vue +24 -12
- package/src/components/Region.vue +168 -118
- package/src/components/RegionWarning.vue +40 -33
- package/src/components/Regions.vue +189 -105
- package/src/components/Warning.vue +70 -45
- package/src/components/Warnings.vue +136 -72
- package/src/composables/useAlertClient.ts +360 -0
- package/src/composables/useConfig.ts +573 -0
- package/src/composables/useFields.ts +66 -0
- package/src/composables/useI18n.ts +62 -0
- package/src/composables/useKeyCodes.ts +16 -0
- package/src/composables/useMapPaths.ts +477 -0
- package/src/composables/useUtils.ts +683 -0
- package/src/composables/useWarningsProcessor.ts +1007 -0
- package/src/data/geometries.json +993 -0
- package/src/{main.js → main.ts} +1 -0
- package/src/mixins/geojsonsvg.d.ts +57 -0
- package/src/mixins/geojsonsvg.js +5 -3
- package/src/plugins/index.ts +5 -0
- package/src/scss/_utilities.scss +193 -0
- package/src/scss/constants.scss +2 -1
- package/src/scss/warningImages.scss +8 -3
- package/src/types/index.ts +509 -0
- package/src/vite-env.d.ts +23 -0
- package/src/vue.ts +41 -0
- package/svgo.config.js +45 -0
- package/tests/README.md +430 -0
- package/tests/fixtures/mockWarningData.ts +152 -0
- package/tests/integration/warning-flow.spec.ts +445 -0
- package/tests/setup.ts +41 -0
- package/tests/unit/components/AlertClient.spec.ts +701 -0
- package/tests/unit/components/DayLarge.spec.ts +348 -0
- package/tests/unit/components/DaySmall.spec.ts +352 -0
- package/tests/unit/components/Days.spec.ts +548 -0
- package/tests/unit/components/DescriptionWarning.spec.ts +385 -0
- package/tests/unit/components/GrayScaleToggle.spec.ts +318 -0
- package/tests/unit/components/Legend.spec.ts +295 -0
- package/tests/unit/components/MapLarge.spec.ts +448 -0
- package/tests/unit/components/MapSmall.spec.ts +367 -0
- package/tests/unit/components/PopupRow.spec.ts +270 -0
- package/tests/unit/components/Region.spec.ts +373 -0
- package/tests/unit/components/RegionWarning.snapshot.spec.ts +361 -0
- package/tests/unit/components/RegionWarning.spec.ts +381 -0
- package/tests/unit/components/Regions.spec.ts +503 -0
- package/tests/unit/components/Warning.snapshot.spec.ts +483 -0
- package/tests/unit/components/Warning.spec.ts +489 -0
- package/tests/unit/components/Warnings.spec.ts +343 -0
- package/tests/unit/components/__snapshots__/RegionWarning.snapshot.spec.ts.snap +41 -0
- package/tests/unit/components/__snapshots__/Warning.snapshot.spec.ts.snap +433 -0
- package/tests/unit/composables/useConfig.spec.ts +279 -0
- package/tests/unit/composables/useI18n.spec.ts +116 -0
- package/tests/unit/composables/useKeyCodes.spec.ts +27 -0
- package/tests/unit/composables/useUtils.spec.ts +213 -0
- package/tsconfig.json +43 -0
- package/tsconfig.node.json +11 -0
- package/vite.config.js +96 -26
- package/vitest.config.js +40 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.dark.html +0 -20
- package/dist/index.en.html +0 -15
- package/dist/index.fi.html +0 -15
- package/dist/index.html +0 -15
- package/dist/index.js +0 -281
- package/dist/index.mjs +0 -281
- package/dist/index.mjs.map +0 -1
- package/dist/index.relative.html +0 -19
- package/dist/index.start.html +0 -20
- package/dist/index.sv.html +0 -15
- package/playwright.config.ts +0 -18
- package/public/index.relative.html +0 -19
- package/public/index.start.html +0 -20
- package/src/mixins/config.js +0 -1378
- package/src/mixins/fields.js +0 -26
- package/src/mixins/i18n.js +0 -25
- package/src/mixins/keycodes.js +0 -10
- package/src/mixins/panzoom.js +0 -900
- package/src/mixins/utils.js +0 -900
- package/src/plugins/index.js +0 -3
- package/test/snapshot.test.ts +0 -126
- package/vitest.config.ts +0 -6
package/src/plugins/index.js
DELETED
package/test/snapshot.test.ts
DELETED
|
@@ -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
|
-
});
|