vease 2.3.1-rc.2 → 2.4.0-rc.2

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.
@@ -8,6 +8,18 @@ import os from "node:os";
8
8
  //#region tests/e2e/utils/fixtures.ts
9
9
  const MILLISECONDS_PER_SECOND = 1e3;
10
10
  const BUSY_TIMEOUT_MS = 3e4;
11
+ const OGW_SUITE_TEST_FILE_EXTENSION = ".test.ts";
12
+ const OGW_SUITE_FILE_REGEX = /tests[/\\]browser[/\\]suites[/\\](?<suite>.+)\.js$/u;
13
+ const APP_LAUNCH_TIMEOUT_MS = 18e4;
14
+ function sanitizeForFilePath(name) {
15
+ return name.replaceAll(/[^\dA-Za-z\u0080-\uFFFF-]+/gu, "-");
16
+ }
17
+ function screenshotPath(testInfo) {
18
+ const titles = testInfo.titlePath.slice(1);
19
+ const suite = OGW_SUITE_FILE_REGEX.exec(testInfo.file)?.groups?.suite;
20
+ if (suite !== void 0) return [...`${suite.replaceAll("\\", "/")}${OGW_SUITE_TEST_FILE_EXTENSION}`.split("/"), `${sanitizeForFilePath(titles.slice(1).join(" "))}.png`];
21
+ return [...path.relative(testInfo.project.testDir, testInfo.file).split(path.sep), `${sanitizeForFilePath(titles.join(" "))}.png`];
22
+ }
11
23
  const test = test$1.extend({
12
24
  mode: ["DEFAULT", {
13
25
  option: true,
@@ -17,10 +29,16 @@ const test = test$1.extend({
17
29
  option: true,
18
30
  scope: "worker"
19
31
  }],
32
+ afterAppLaunch: [async ({}, use) => {
33
+ await use(async () => {});
34
+ }, { scope: "worker" }],
35
+ beforeAppClose: [async ({}, use) => {
36
+ await use(async () => {});
37
+ }, { scope: "worker" }],
20
38
  screenshotMask: [async ({}, use) => {
21
39
  await use({ locators: [] });
22
40
  }, { scope: "test" }],
23
- app: [async ({ mode, playwright, browserName, headless, channel, launchOptions }, use, workerInfo) => {
41
+ app: [async ({ mode, playwright, browserName, headless, channel, launchOptions, afterAppLaunch, beforeAppClose }, use, workerInfo) => {
24
42
  const configPath = fs.mkdtempSync(path.join(os.tmpdir(), `vease-e2e-worker${workerInfo.parallelIndex}-`));
25
43
  process.env.XDG_CONFIG_HOME = configPath;
26
44
  process.env.APPDATA = configPath;
@@ -31,30 +49,50 @@ const test = test$1.extend({
31
49
  channel
32
50
  });
33
51
  }
52
+ let openApp = void 0;
34
53
  const app = {
35
- ...await navigateToApp(mode, launchBrowser),
36
- restart: async () => {
37
- await app.cleanup();
38
- const { window, cleanup, electronApp } = await navigateToApp(mode, launchBrowser);
39
- app.window = window;
40
- app.cleanup = cleanup;
41
- app.electronApp = electronApp;
42
- return window;
54
+ get window() {
55
+ if (openApp === void 0) throw new Error("The app is not open");
56
+ return openApp.window;
57
+ },
58
+ get electronApp() {
59
+ return openApp?.electronApp;
60
+ },
61
+ open: async () => {
62
+ if (openApp === void 0) {
63
+ openApp = await navigateToApp(mode, launchBrowser);
64
+ await afterAppLaunch(openApp.window);
65
+ }
66
+ return openApp.window;
67
+ },
68
+ close: async () => {
69
+ if (openApp !== void 0) {
70
+ const { window, cleanup } = openApp;
71
+ openApp = void 0;
72
+ await beforeAppClose(window);
73
+ await cleanup();
74
+ }
43
75
  }
44
76
  };
45
77
  await use(app);
46
- await app.cleanup();
78
+ await app.close();
47
79
  fs.rmSync(configPath, {
48
80
  recursive: true,
49
81
  force: true
50
82
  });
51
83
  }, { scope: "worker" }],
52
84
  restartApp: [async ({ app }, use) => {
53
- await use(app.restart);
85
+ await use(async () => {
86
+ await app.close();
87
+ return await app.open();
88
+ });
54
89
  }, { scope: "worker" }],
55
90
  window: [async ({ app }, use) => {
56
- await use(app.window);
57
- }, { scope: "worker" }],
91
+ await use(await app.open());
92
+ }, {
93
+ scope: "test",
94
+ timeout: APP_LAUNCH_TIMEOUT_MS
95
+ }],
58
96
  logTestProgress: [async ({}, use, testInfo) => {
59
97
  const name = `${path.basename(testInfo.file)} › ${testInfo.title}`;
60
98
  consola.info(`\u001B[33m[START]\u001B[0m ${name}`);
@@ -71,7 +109,7 @@ const test = test$1.extend({
71
109
  if (testInfo.status === testInfo.expectedStatus) {
72
110
  await expect(window.getByTestId("microservicesBusyIndicator")).toBeHidden({ timeout: BUSY_TIMEOUT_MS });
73
111
  await waitForActionSettled(window);
74
- await expect(window).toHaveScreenshot({ mask: [window.getByTestId("accountNavButton"), ...screenshotMask.locators] });
112
+ await expect(window).toHaveScreenshot(screenshotPath(testInfo), { mask: [window.getByTestId("accountNavButton"), ...screenshotMask.locators] });
75
113
  }
76
114
  }, { auto: true }]
77
115
  });
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  import { waitForActionSettled } from "#ogw_e2e/wait_for_action_settled.js";
2
3
  import { expect } from "@playwright/test";
3
4
  import { consola } from "consola";
@@ -5,6 +6,7 @@ import path from "node:path";
5
6
  //#region tests/e2e/utils/load.ts
6
7
  const __dirname = import.meta.dirname;
7
8
  const loadWorkflowTimeout = 8e3;
9
+ const ogwTestDataPath = path.join(path.dirname(createRequire(import.meta.url).resolve("@geode/opengeodeweb-front/package.json")), "tests", "browser", "data");
8
10
  function getLayoutImportButton(window) {
9
11
  return window.getByTestId("layoutImportButton");
10
12
  }
@@ -26,6 +28,12 @@ async function loadVeaseTestDatas(window, inputDataFilenames, { loadTimeout = lo
26
28
  await dataImportStepper.waitFor({ state: "detached" });
27
29
  await waitForActionSettled(window, loadTimeout);
28
30
  }
31
+ async function loadOgwTestDatas(window, inputDataFilenames, { loadTimeout = loadWorkflowTimeout } = {}) {
32
+ await loadVeaseTestDatas(window, inputDataFilenames, {
33
+ loadTimeout,
34
+ inputDataPath: ogwTestDataPath
35
+ });
36
+ }
29
37
  function getDataImportStepper(window) {
30
38
  return window.getByTestId("DataImportStepper");
31
39
  }
@@ -86,4 +94,4 @@ async function applyTimeSeries(window, loadTimeout = loadWorkflowTimeout) {
86
94
  await waitForActionSettled(window, loadTimeout);
87
95
  }
88
96
  //#endregion
89
- export { applyTimeSeries, loadVeaseCsvData, loadVeaseTestDatas, selectTimeSeriesFile, selectTimeSeriesFolder, selectTimeSeriesTarget };
97
+ export { applyTimeSeries, loadOgwTestDatas, loadVeaseCsvData, loadVeaseTestDatas, selectTimeSeriesFile, selectTimeSeriesFolder, selectTimeSeriesTarget };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vease",
3
- "version": "2.3.1-rc.2",
3
+ "version": "2.4.0-rc.2",
4
4
  "description": "Desktop and cloud software for data visualization",
5
5
  "keywords": [
6
6
  "Desktop",
@@ -31,7 +31,8 @@
31
31
  "type": "module",
32
32
  "main": "dist-electron/main.js",
33
33
  "imports": {
34
- "#ogw_e2e/*": "@geode/opengeodeweb-front/tests/browser/helpers/*"
34
+ "#ogw_e2e/*": "@geode/opengeodeweb-front/tests/browser/helpers/*",
35
+ "#ogw_e2e_suites/*": "@geode/opengeodeweb-front/tests/browser/suites/*"
35
36
  },
36
37
  "exports": {
37
38
  "./vease_schemas.json": {
@@ -4,7 +4,7 @@ import os from "node:os";
4
4
  import path from "node:path";
5
5
 
6
6
  // Third party imports
7
- import type { Browser, Locator, Page } from "@playwright/test";
7
+ import type { Browser, Locator, Page, TestInfo } from "@playwright/test";
8
8
  // oxlint-disable-next-line eslint/no-duplicate-imports
9
9
  import { test as base, expect } from "@playwright/test";
10
10
  import type { ElectronApplication } from "playwright";
@@ -17,28 +17,61 @@ import { waitForActionSettled } from "#ogw_e2e/wait_for_action_settled.js";
17
17
  const MILLISECONDS_PER_SECOND = 1000;
18
18
  // Whole download deadline of a basemap build in OpenGeodeWeb-Back (FETCH_DEADLINE_SECONDS)
19
19
  const BUSY_TIMEOUT_MS = 30_000;
20
+ const OGW_SUITE_TEST_FILE_EXTENSION = ".test.ts";
21
+ // Built suite files of OpenGeodeWeb-Front, where the tests of its suites are located
22
+ const OGW_SUITE_FILE_REGEX = /tests[/\\]browser[/\\]suites[/\\](?<suite>.+)\.js$/u;
23
+ // Launching the app: browser or Electron, back and viewer, then afterAppLaunch
24
+ const APP_LAUNCH_TIMEOUT_MS = 180_000;
25
+
26
+ // Same as Playwright's {testName}: every ASCII character except letters, digits and "-" becomes "-"
27
+ function sanitizeForFilePath(name: string): string {
28
+ return name.replaceAll(/[^\dA-Za-z\u0080-\uFFFF-]+/gu, "-");
29
+ }
30
+
31
+ // Screenshots/<test file path>/<test name>.png. The OpenGeodeWeb-Front suites (run from opengeodeweb_front.test.ts,
32
+ // One describe each) keep the folders of their own test files, tests/browser/tests/<suite>.test.ts
33
+ function screenshotPath(testInfo: TestInfo): string[] {
34
+ const titles = testInfo.titlePath.slice(1);
35
+ const suite = OGW_SUITE_FILE_REGEX.exec(testInfo.file)?.groups?.suite;
36
+ if (suite !== undefined) {
37
+ return [
38
+ ...`${suite.replaceAll("\\", "/")}${OGW_SUITE_TEST_FILE_EXTENSION}`.split("/"),
39
+ `${sanitizeForFilePath(titles.slice(1).join(" "))}.png`,
40
+ ];
41
+ }
42
+ return [
43
+ ...path.relative(testInfo.project.testDir, testInfo.file).split(path.sep),
44
+ `${sanitizeForFilePath(titles.join(" "))}.png`,
45
+ ];
46
+ }
20
47
 
21
48
  interface ScreenshotMask {
22
49
  locators: Locator[];
23
50
  }
24
51
 
25
52
  interface RunningApp {
26
- window: Page;
27
- cleanup: () => Promise<void>;
28
- // Only set in DESKTOP mode
53
+ // Page of the open app (throws if the app is closed)
54
+ readonly window: Page;
55
+ // Only set in DESKTOP mode, while the app is open
29
56
  electronApp?: ElectronApplication;
30
- restart: () => Promise<Page>;
57
+ // Launches the app if it is not open
58
+ open: () => Promise<Page>;
59
+ // Closes the app if it is open
60
+ close: () => Promise<void>;
31
61
  }
32
62
 
33
63
  interface WorkerFixtures {
34
64
  mode: string;
35
65
  suiteId: string;
66
+ // Run on each launched app before its first test (Vease-Modeling loads its extension), and before closing it
67
+ afterAppLaunch: (window: Page) => Promise<void>;
68
+ beforeAppClose: (window: Page) => Promise<void>;
36
69
  app: RunningApp;
37
70
  restartApp: () => Promise<Page>;
38
- window: Page;
39
71
  }
40
72
 
41
73
  interface TestFixtures {
74
+ window: Page;
42
75
  screenshotMask: ScreenshotMask;
43
76
  logTestProgress: undefined;
44
77
  autoScreenshot: undefined;
@@ -49,6 +82,26 @@ const test = base.extend<TestFixtures, WorkerFixtures>({
49
82
 
50
83
  suiteId: ["default", { option: true, scope: "worker" }],
51
84
 
85
+ afterAppLaunch: [
86
+ // oxlint-disable-next-line no-empty-pattern
87
+ async ({}, use): Promise<void> => {
88
+ await use(async (): Promise<void> => {
89
+ // Nothing to do by default
90
+ });
91
+ },
92
+ { scope: "worker" },
93
+ ],
94
+
95
+ beforeAppClose: [
96
+ // oxlint-disable-next-line no-empty-pattern
97
+ async ({}, use): Promise<void> => {
98
+ await use(async (): Promise<void> => {
99
+ // Nothing to do by default
100
+ });
101
+ },
102
+ { scope: "worker" },
103
+ ],
104
+
52
105
  screenshotMask: [
53
106
  // oxlint-disable-next-line no-empty-pattern
54
107
  async ({}, use): Promise<void> => {
@@ -57,10 +110,20 @@ const test = base.extend<TestFixtures, WorkerFixtures>({
57
110
  { scope: "test" },
58
111
  ],
59
112
 
60
- // Mutable so restartApp can swap in a freshly launched app
113
+ // The app of the worker: opened by the first test that uses it (or a beforeAll), closed by app.close or at the end of
114
+ // The worker. A test file opens it, runs its tests and closes it; so does each suite of opengeodeweb_front.test.ts
61
115
  app: [
62
116
  async (
63
- { mode, playwright, browserName, headless, channel, launchOptions },
117
+ {
118
+ mode,
119
+ playwright,
120
+ browserName,
121
+ headless,
122
+ channel,
123
+ launchOptions,
124
+ afterAppLaunch,
125
+ beforeAppClose,
126
+ },
64
127
  use,
65
128
  workerInfo,
66
129
  ): Promise<void> => {
@@ -79,19 +142,35 @@ const test = base.extend<TestFixtures, WorkerFixtures>({
79
142
  });
80
143
  return browser;
81
144
  }
145
+ let openApp: Awaited<ReturnType<typeof navigateToApp>> | undefined = undefined;
82
146
  const app: RunningApp = {
83
- ...(await navigateToApp(mode, launchBrowser)),
84
- restart: async (): Promise<Page> => {
85
- await app.cleanup();
86
- const { window, cleanup, electronApp } = await navigateToApp(mode, launchBrowser);
87
- app.window = window;
88
- app.cleanup = cleanup;
89
- app.electronApp = electronApp;
90
- return window;
147
+ get window(): Page {
148
+ if (openApp === undefined) {
149
+ throw new Error("The app is not open");
150
+ }
151
+ return openApp.window;
152
+ },
153
+ get electronApp(): ElectronApplication | undefined {
154
+ return openApp?.electronApp;
155
+ },
156
+ open: async (): Promise<Page> => {
157
+ if (openApp === undefined) {
158
+ openApp = await navigateToApp(mode, launchBrowser);
159
+ await afterAppLaunch(openApp.window);
160
+ }
161
+ return openApp.window;
162
+ },
163
+ close: async (): Promise<void> => {
164
+ if (openApp !== undefined) {
165
+ const { window, cleanup } = openApp;
166
+ openApp = undefined;
167
+ await beforeAppClose(window);
168
+ await cleanup();
169
+ }
91
170
  },
92
171
  };
93
172
  await use(app);
94
- await app.cleanup();
173
+ await app.close();
95
174
  fs.rmSync(configPath, { recursive: true, force: true });
96
175
  },
97
176
  { scope: "worker" },
@@ -100,17 +179,21 @@ const test = base.extend<TestFixtures, WorkerFixtures>({
100
179
  // Kills the running app and launches a new one, like a user closing and reopening it
101
180
  restartApp: [
102
181
  async ({ app }, use): Promise<void> => {
103
- await use(app.restart);
182
+ await use(async (): Promise<Page> => {
183
+ await app.close();
184
+ const window = await app.open();
185
+ return window;
186
+ });
104
187
  },
105
188
  { scope: "worker" },
106
189
  ],
107
190
 
108
- // Page of the app launched with the worker: after restartApp, use the returned page or app.window
191
+ // Page of the app, opened if needed: it follows restartApp
109
192
  window: [
110
193
  async ({ app }, use): Promise<void> => {
111
- await use(app.window);
194
+ await use(await app.open());
112
195
  },
113
- { scope: "worker" },
196
+ { scope: "test", timeout: APP_LAUNCH_TIMEOUT_MS },
114
197
  ],
115
198
 
116
199
  logTestProgress: [
@@ -143,7 +226,7 @@ const test = base.extend<TestFixtures, WorkerFixtures>({
143
226
  });
144
227
  await waitForActionSettled(window);
145
228
  // The account icon depends on login state (only cloud is logged in)
146
- await expect(window).toHaveScreenshot({
229
+ await expect(window).toHaveScreenshot(screenshotPath(testInfo), {
147
230
  mask: [window.getByTestId("accountNavButton"), ...screenshotMask.locators],
148
231
  });
149
232
  }
@@ -1,4 +1,5 @@
1
1
  // Node imports
2
+ import { createRequire } from "node:module";
2
3
  import path from "node:path";
3
4
 
4
5
  // Third party imports
@@ -10,6 +11,13 @@ import { waitForActionSettled } from "#ogw_e2e/wait_for_action_settled.js";
10
11
 
11
12
  const __dirname = import.meta.dirname;
12
13
  const loadWorkflowTimeout = 8000;
14
+ // The data of the viewer tests defined in OpenGeodeWeb-Front (see #ogw_e2e_suites), published with its package
15
+ const ogwTestDataPath = path.join(
16
+ path.dirname(createRequire(import.meta.url).resolve("@geode/opengeodeweb-front/package.json")),
17
+ "tests",
18
+ "browser",
19
+ "data",
20
+ );
13
21
 
14
22
  function getLayoutImportButton(window: Page): Locator {
15
23
  return window.getByTestId("layoutImportButton");
@@ -47,6 +55,17 @@ async function loadVeaseTestDatas(
47
55
  await waitForActionSettled(window, loadTimeout);
48
56
  }
49
57
 
58
+ async function loadOgwTestDatas(
59
+ window: Page,
60
+ inputDataFilenames: string[],
61
+ { loadTimeout = loadWorkflowTimeout }: { loadTimeout?: number } = {},
62
+ ): Promise<void> {
63
+ await loadVeaseTestDatas(window, inputDataFilenames, {
64
+ loadTimeout,
65
+ inputDataPath: ogwTestDataPath,
66
+ });
67
+ }
68
+
50
69
  function getDataImportStepper(window: Page): Locator {
51
70
  return window.getByTestId("DataImportStepper");
52
71
  }
@@ -133,6 +152,7 @@ async function applyTimeSeries(window: Page, loadTimeout = loadWorkflowTimeout):
133
152
 
134
153
  export {
135
154
  applyTimeSeries,
155
+ loadOgwTestDatas,
136
156
  loadVeaseCsvData,
137
157
  loadVeaseTestDatas,
138
158
  selectTimeSeriesFile,