@geode/opengeodeweb-front 12.0.0 → 12.1.0-rc.1

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.
@@ -0,0 +1,94 @@
1
+ import { waitForActionSettled } from "./wait_for_action_settled.js";
2
+ import { screenshotPath } from "./screenshot_path.js";
3
+ import path from "node:path";
4
+ import { consola } from "consola";
5
+ import { expect, test as test$1 } from "@playwright/test";
6
+ //#region tests/browser/helpers/app_test.ts
7
+ const MILLISECONDS_PER_SECOND = 1e3;
8
+ const APP_LAUNCH_TIMEOUT_MS = 18e4;
9
+ async function doNothing() {}
10
+ const test = test$1.extend({
11
+ suiteId: ["default", {
12
+ option: true,
13
+ scope: "worker"
14
+ }],
15
+ launchApp: [async ({}, use) => {
16
+ await use(() => {
17
+ throw new Error("The app must override the launchApp fixture");
18
+ });
19
+ }, { scope: "worker" }],
20
+ afterAppLaunch: [async ({}, use) => {
21
+ await use(doNothing);
22
+ }, { scope: "worker" }],
23
+ beforeAppClose: [async ({}, use) => {
24
+ await use(doNothing);
25
+ }, { scope: "worker" }],
26
+ beforeScreenshot: [async ({}, use) => {
27
+ await use(doNothing);
28
+ }, { scope: "worker" }],
29
+ appScreenshotMask: [async ({}, use) => {
30
+ await use(() => []);
31
+ }, { scope: "worker" }],
32
+ app: [async ({ launchApp, afterAppLaunch, beforeAppClose }, use) => {
33
+ let openApp = void 0;
34
+ const app = {
35
+ get window() {
36
+ if (openApp === void 0) throw new Error("The app is not open");
37
+ return openApp.window;
38
+ },
39
+ open: async () => {
40
+ if (openApp === void 0) {
41
+ openApp = await launchApp();
42
+ await afterAppLaunch(openApp.window);
43
+ }
44
+ return openApp.window;
45
+ },
46
+ close: async () => {
47
+ if (openApp !== void 0) {
48
+ const { window, cleanup } = openApp;
49
+ openApp = void 0;
50
+ await beforeAppClose(window);
51
+ await cleanup();
52
+ }
53
+ }
54
+ };
55
+ await use(app);
56
+ await app.close();
57
+ }, { scope: "worker" }],
58
+ restartApp: [async ({ app }, use) => {
59
+ await use(async () => {
60
+ await app.close();
61
+ return await app.open();
62
+ });
63
+ }, { scope: "worker" }],
64
+ window: [async ({ app }, use) => {
65
+ await use(await app.open());
66
+ }, {
67
+ scope: "test",
68
+ timeout: APP_LAUNCH_TIMEOUT_MS
69
+ }],
70
+ screenshotMask: [async ({}, use) => {
71
+ await use({ locators: [] });
72
+ }, { scope: "test" }],
73
+ logTestProgress: [async ({}, use, testInfo) => {
74
+ const name = `${path.basename(testInfo.file)} › ${testInfo.title}`;
75
+ consola.info(`\u001B[33m[START]\u001B[0m ${name}`);
76
+ const start = Date.now();
77
+ await use(void 0);
78
+ const statusColor = testInfo.status === "passed" ? "\x1B[32m" : "\x1B[31m";
79
+ const status = (testInfo.status ?? "done").toUpperCase();
80
+ const duration = ((Date.now() - start) / MILLISECONDS_PER_SECOND).toFixed(2);
81
+ consola.info(`\u001B[35m[END]\u001B[0m ${name} : ${statusColor}TEST ${status}\u001B[0m (${duration}s)`);
82
+ }, { auto: true }],
83
+ autoScreenshot: [async ({ app, beforeScreenshot, appScreenshotMask, screenshotMask }, use, testInfo) => {
84
+ await use(void 0);
85
+ const { window } = app;
86
+ if (testInfo.status === testInfo.expectedStatus) {
87
+ await beforeScreenshot(window);
88
+ await waitForActionSettled(window);
89
+ await expect(window).toHaveScreenshot(screenshotPath(testInfo), { mask: [...appScreenshotMask(window), ...screenshotMask.locators] });
90
+ }
91
+ }, { auto: true }]
92
+ });
93
+ //#endregion
94
+ export { test };
@@ -0,0 +1,15 @@
1
+ import path from "node:path";
2
+ //#region tests/browser/helpers/screenshot_path.ts
3
+ const SUITE_TEST_FILE_EXTENSION = ".test.ts";
4
+ const SUITE_FILE_REGEX = /tests[/\\]browser[/\\]suites[/\\](?<suite>.+)\.js$/u;
5
+ function sanitizeForFilePath(name) {
6
+ return name.replaceAll(/[^\dA-Za-z\u0080-￿-]+/gu, "-");
7
+ }
8
+ function screenshotPath(testInfo) {
9
+ const titles = testInfo.titlePath.slice(1);
10
+ const suite = SUITE_FILE_REGEX.exec(testInfo.file)?.groups?.suite;
11
+ if (suite !== void 0) return [...`${suite.replaceAll("\\", "/")}${SUITE_TEST_FILE_EXTENSION}`.split("/"), `${sanitizeForFilePath(titles.slice(1).join(" "))}.png`];
12
+ return [...path.relative(testInfo.project.testDir, testInfo.file).split(path.sep), `${sanitizeForFilePath(titles.join(" "))}.png`];
13
+ }
14
+ //#endregion
15
+ export { screenshotPath };
@@ -48,5 +48,19 @@ const suites = Object.fromEntries(Object.entries(/* @__PURE__ */ Object.assign({
48
48
  "./object_tree/multi_type_import.ts": multi_type_import_exports,
49
49
  "./time_series.ts": time_series_exports
50
50
  })).map(([file, { registerTests }]) => [SUITE_PATH_REGEX.exec(file)?.groups?.name ?? file, registerTests]));
51
+ function runSuites(test, loadTestDatas) {
52
+ for (const [name, registerTests] of Object.entries(suites)) test.describe(name, () => {
53
+ test.beforeAll(async ({ app }) => {
54
+ await app.open();
55
+ });
56
+ test.afterAll(async ({ app }) => {
57
+ await app.close();
58
+ });
59
+ registerTests({
60
+ test,
61
+ loadTestDatas
62
+ });
63
+ });
64
+ }
51
65
  //#endregion
52
- export { suites };
66
+ export { runSuites, suites };
@@ -0,0 +1,17 @@
1
+ <script setup lang="ts">
2
+ import { useInfraStore } from "@ogw_front/stores/infra";
3
+
4
+ const infraStore = useInfraStore();
5
+ </script>
6
+
7
+ <!-- Top-of-page progress bar shown while a microservice request is in flight: the e2e tests wait for it to hide -->
8
+ <template>
9
+ <v-progress-linear
10
+ v-if="infraStore.microservices_busy"
11
+ data-testid="microservicesBusyIndicator"
12
+ indeterminate
13
+ color="white"
14
+ class="position-fixed top-0"
15
+ style="z-index: 4"
16
+ />
17
+ </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geode/opengeodeweb-front",
3
- "version": "12.0.0",
3
+ "version": "12.1.0-rc.1",
4
4
  "description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
5
5
  "homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
6
6
  "bugs": {
@@ -82,10 +82,10 @@
82
82
  "prepublishOnly": "npm run build"
83
83
  },
84
84
  "dependencies": {
85
- "@geode/cloud-api": "latest",
86
- "@geode/opengeodeweb-back": "latest",
87
- "@geode/opengeodeweb-microservice": "latest",
88
- "@geode/opengeodeweb-viewer": "latest",
85
+ "@geode/cloud-api": "next",
86
+ "@geode/opengeodeweb-back": "next",
87
+ "@geode/opengeodeweb-microservice": "next",
88
+ "@geode/opengeodeweb-viewer": "next",
89
89
  "@kitware/vtk.js": "33.3.0",
90
90
  "@msgpack/msgpack": "2.8.0",
91
91
  "@phosphor-icons/web": "2.1.2",
@@ -0,0 +1,214 @@
1
+ // The Playwright test of the apps built on this layer, which run its shared suites (see ../suites/index.ts) against
2
+ // Their own UI. Each app gives how it is launched (launchApp); the app of a worker is opened by the first test that
3
+ // Uses it (or a beforeAll) and closed by app.close or at the end of the worker. A screenshot is taken at the end of
4
+ // Each passing test
5
+
6
+ // Node imports
7
+ import path from "node:path";
8
+
9
+ // Third party imports
10
+ import type { Locator, Page } from "@playwright/test";
11
+ // oxlint-disable-next-line eslint/no-duplicate-imports
12
+ import { test as base, expect } from "@playwright/test";
13
+ import { consola } from "consola";
14
+
15
+ // Local imports
16
+ import { screenshotPath } from "./screenshot_path";
17
+ import { waitForActionSettled } from "./wait_for_action_settled";
18
+
19
+ const MILLISECONDS_PER_SECOND = 1000;
20
+ // Launching the app (browser, back and viewer), then afterAppLaunch
21
+ const APP_LAUNCH_TIMEOUT_MS = 180_000;
22
+
23
+ interface LaunchedApp {
24
+ window: Page;
25
+ // Closes the page and stops everything launchApp started
26
+ cleanup: () => Promise<void>;
27
+ }
28
+
29
+ interface ScreenshotMask {
30
+ locators: Locator[];
31
+ }
32
+
33
+ interface RunningApp {
34
+ // Page of the open app (throws if the app is closed)
35
+ readonly window: Page;
36
+ // Launches the app if it is not open
37
+ open: () => Promise<Page>;
38
+ // Closes the app if it is open
39
+ close: () => Promise<void>;
40
+ }
41
+
42
+ interface AppWorkerFixtures {
43
+ // One worker per test file: set to import.meta.url by each test file
44
+ suiteId: string;
45
+ // Given by each app
46
+ launchApp: () => Promise<LaunchedApp>;
47
+ // Run on each launched app before its first test, and before closing it
48
+ afterAppLaunch: (window: Page) => Promise<void>;
49
+ beforeAppClose: (window: Page) => Promise<void>;
50
+ // Run before each screenshot, before waiting for the actions to settle (e.g. a busy indicator of the app)
51
+ beforeScreenshot: (window: Page) => Promise<void>;
52
+ // Parts of the app masked in every screenshot (e.g. depending on the login state)
53
+ appScreenshotMask: (window: Page) => Locator[];
54
+ app: RunningApp;
55
+ // Kills the running app and launches a new one, like a user closing and reopening it
56
+ restartApp: () => Promise<Page>;
57
+ }
58
+
59
+ interface AppTestFixtures {
60
+ // Page of the app, opened if needed: it follows restartApp
61
+ window: Page;
62
+ // Parts of the app masked in the screenshot of the test
63
+ screenshotMask: ScreenshotMask;
64
+ logTestProgress: undefined;
65
+ autoScreenshot: undefined;
66
+ }
67
+
68
+ async function doNothing(): Promise<void> {
69
+ // Default of the app hooks
70
+ }
71
+
72
+ const test = base.extend<AppTestFixtures, AppWorkerFixtures>({
73
+ suiteId: ["default", { option: true, scope: "worker" }],
74
+
75
+ launchApp: [
76
+ // oxlint-disable-next-line no-empty-pattern
77
+ async ({}, use): Promise<void> => {
78
+ await use(() => {
79
+ throw new Error("The app must override the launchApp fixture");
80
+ });
81
+ },
82
+ { scope: "worker" },
83
+ ],
84
+
85
+ afterAppLaunch: [
86
+ // oxlint-disable-next-line no-empty-pattern
87
+ async ({}, use): Promise<void> => {
88
+ await use(doNothing);
89
+ },
90
+ { scope: "worker" },
91
+ ],
92
+
93
+ beforeAppClose: [
94
+ // oxlint-disable-next-line no-empty-pattern
95
+ async ({}, use): Promise<void> => {
96
+ await use(doNothing);
97
+ },
98
+ { scope: "worker" },
99
+ ],
100
+
101
+ beforeScreenshot: [
102
+ // oxlint-disable-next-line no-empty-pattern
103
+ async ({}, use): Promise<void> => {
104
+ await use(doNothing);
105
+ },
106
+ { scope: "worker" },
107
+ ],
108
+
109
+ appScreenshotMask: [
110
+ // oxlint-disable-next-line no-empty-pattern
111
+ async ({}, use): Promise<void> => {
112
+ await use(() => []);
113
+ },
114
+ { scope: "worker" },
115
+ ],
116
+
117
+ app: [
118
+ async ({ launchApp, afterAppLaunch, beforeAppClose }, use): Promise<void> => {
119
+ let openApp: LaunchedApp | undefined = undefined;
120
+ const app: RunningApp = {
121
+ get window(): Page {
122
+ if (openApp === undefined) {
123
+ throw new Error("The app is not open");
124
+ }
125
+ return openApp.window;
126
+ },
127
+ open: async (): Promise<Page> => {
128
+ if (openApp === undefined) {
129
+ openApp = await launchApp();
130
+ await afterAppLaunch(openApp.window);
131
+ }
132
+ return openApp.window;
133
+ },
134
+ close: async (): Promise<void> => {
135
+ if (openApp !== undefined) {
136
+ const { window, cleanup } = openApp;
137
+ openApp = undefined;
138
+ await beforeAppClose(window);
139
+ await cleanup();
140
+ }
141
+ },
142
+ };
143
+ await use(app);
144
+ await app.close();
145
+ },
146
+ { scope: "worker" },
147
+ ],
148
+
149
+ restartApp: [
150
+ async ({ app }, use): Promise<void> => {
151
+ await use(async (): Promise<Page> => {
152
+ await app.close();
153
+ const window = await app.open();
154
+ return window;
155
+ });
156
+ },
157
+ { scope: "worker" },
158
+ ],
159
+
160
+ window: [
161
+ async ({ app }, use): Promise<void> => {
162
+ await use(await app.open());
163
+ },
164
+ { scope: "test", timeout: APP_LAUNCH_TIMEOUT_MS },
165
+ ],
166
+
167
+ screenshotMask: [
168
+ // oxlint-disable-next-line no-empty-pattern
169
+ async ({}, use): Promise<void> => {
170
+ await use({ locators: [] });
171
+ },
172
+ { scope: "test" },
173
+ ],
174
+
175
+ logTestProgress: [
176
+ // oxlint-disable-next-line no-empty-pattern
177
+ async ({}, use, testInfo): Promise<void> => {
178
+ const name = `${path.basename(testInfo.file)} › ${testInfo.title}`;
179
+ consola.info(`\u001B[33m[START]\u001B[0m ${name}`);
180
+ const start = Date.now();
181
+ await use(undefined);
182
+ const statusColor = testInfo.status === "passed" ? "\u001B[32m" : "\u001B[31m";
183
+ const status = (testInfo.status ?? "done").toUpperCase();
184
+ const duration = ((Date.now() - start) / MILLISECONDS_PER_SECOND).toFixed(2);
185
+ consola.info(
186
+ `\u001B[35m[END]\u001B[0m ${name} : ${statusColor}TEST ${status}\u001B[0m (${duration}s)`,
187
+ );
188
+ },
189
+ { auto: true },
190
+ ],
191
+
192
+ autoScreenshot: [
193
+ async (
194
+ { app, beforeScreenshot, appScreenshotMask, screenshotMask },
195
+ use,
196
+ testInfo,
197
+ ): Promise<void> => {
198
+ await use(undefined);
199
+ // Read at teardown: the test may have restarted the app
200
+ const { window } = app;
201
+ if (testInfo.status === testInfo.expectedStatus) {
202
+ await beforeScreenshot(window);
203
+ await waitForActionSettled(window);
204
+ await expect(window).toHaveScreenshot(screenshotPath(testInfo), {
205
+ mask: [...appScreenshotMask(window), ...screenshotMask.locators],
206
+ });
207
+ }
208
+ },
209
+ { auto: true },
210
+ ],
211
+ });
212
+
213
+ export { test };
214
+ export type { AppTestFixtures, AppWorkerFixtures, LaunchedApp, RunningApp };
@@ -0,0 +1,36 @@
1
+ // Where the apps built on this layer store the screenshot taken at the end of each test (see ./app_test.ts):
2
+ // Screenshots/<test file path>/<test name>.png, relative to the pathTemplate of their Playwright config
3
+
4
+ // Node imports
5
+ import path from "node:path";
6
+
7
+ // Third party imports
8
+ import type { TestInfo } from "@playwright/test";
9
+
10
+ const SUITE_TEST_FILE_EXTENSION = ".test.ts";
11
+ // Built suite files of this layer, where the tests of its suites are located
12
+ const SUITE_FILE_REGEX = /tests[/\\]browser[/\\]suites[/\\](?<suite>.+)\.js$/u;
13
+
14
+ // Same as Playwright's {testName}: every ASCII character except letters, digits and "-" becomes "-"
15
+ function sanitizeForFilePath(name: string): string {
16
+ return name.replaceAll(/[^\dA-Za-z\u0080-￿-]+/gu, "-");
17
+ }
18
+
19
+ // The shared suites (one describe each, see ../suites/index.ts) keep the folders of their test files here,
20
+ // Tests/browser/tests/<suite>.test.ts; the other tests keep their path in the test folder of the app
21
+ function screenshotPath(testInfo: TestInfo): string[] {
22
+ const titles = testInfo.titlePath.slice(1);
23
+ const suite = SUITE_FILE_REGEX.exec(testInfo.file)?.groups?.suite;
24
+ if (suite !== undefined) {
25
+ return [
26
+ ...`${suite.replaceAll("\\", "/")}${SUITE_TEST_FILE_EXTENSION}`.split("/"),
27
+ `${sanitizeForFilePath(titles.slice(1).join(" "))}.png`,
28
+ ];
29
+ }
30
+ return [
31
+ ...path.relative(testInfo.project.testDir, testInfo.file).split(path.sep),
32
+ `${sanitizeForFilePath(titles.join(" "))}.png`,
33
+ ];
34
+ }
35
+
36
+ export { screenshotPath };
@@ -2,6 +2,7 @@
2
2
  // Layer run them all from one test file, each suite in its own describe. Collected from the folder, a new suite file is
3
3
  // Run by these apps without any change on their side
4
4
 
5
+ import type { test as AppTest } from "#browser_helpers/app_test";
5
6
  import type { SuiteRuntime } from "#browser_helpers/suite_runtime";
6
7
 
7
8
  interface SuiteModule {
@@ -19,4 +20,21 @@ const suites: Record<string, SuiteModule["registerTests"]> = Object.fromEntries(
19
20
  ]),
20
21
  );
21
22
 
22
- export { suites };
23
+ // Runs every suite from the test file of an app (its test extends ../helpers/app_test.ts): each suite is a describe
24
+ // Named by its path, which opens the app, runs its tests and closes the app
25
+ function runSuites(test: typeof AppTest, loadTestDatas: SuiteRuntime["loadTestDatas"]): void {
26
+ // oxlint-disable-next-line vitest/prefer-each -- Playwright's test has no each for describes
27
+ for (const [name, registerTests] of Object.entries(suites)) {
28
+ test.describe(name, () => {
29
+ test.beforeAll(async ({ app }) => {
30
+ await app.open();
31
+ });
32
+ test.afterAll(async ({ app }) => {
33
+ await app.close();
34
+ });
35
+ registerTests({ test, loadTestDatas });
36
+ });
37
+ }
38
+ }
39
+
40
+ export { runSuites, suites };