This commit is contained in:
Core 2022-02-01 08:34:33 +00:00
parent 4811675149
commit bfd7141864
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
3 changed files with 49 additions and 0 deletions

View file

@ -30,6 +30,11 @@ jobs:
sudo dpkg --add-architecture i386
sudo apt-get update -y
sudo apt-get install -y wine32
- store_test_results:
path: test-results
- run:
name: Base Functionality Test
command: yarn playwright test
- run:
name: Generate Builds (Linux)
command: yarn dist -l -p never

44
test/base.test.ts Normal file
View file

@ -0,0 +1,44 @@
import { _electron as electron } from "playwright";
import { test, expect } from "@playwright/test";
test("Launch electron app", async () => {
const electronApp = await electron.launch({ args: ["./index.js"], cwd: "../build" });
const appPath = await electronApp.evaluate(async ({ app }) => {
// This runs in the main Electron process, parameter here is always
// the result of the require('electron') in the main app script.
return app.getAppPath();
});
console.log(appPath);
const windowState: { isVisible: boolean, isDevToolsOpened: boolean, isCrashed: boolean } = await electronApp.evaluate(async ({ BrowserWindow, app }) => {
const win = BrowserWindow.getAllWindows()[0];
console.log(win)
const getState = (win: Electron.BrowserWindow) => ({
isVisible: win.isVisible(),
isDevToolsOpened: win.webContents.isDevToolsOpened(),
isCrashed: win.webContents.isCrashed()
})
return new Promise((resolve) => {
if (win && win.isVisible()) {
resolve(getState(win))
} else if (win) {
win.once("ready-to-show", () => setTimeout(() => resolve(getState(win))));
} else {
app.once("browser-window-created", (_e: Event, window: Electron.BrowserWindow) => setTimeout(() => resolve(getState(window))));
}
})
})
expect(windowState.isVisible).toBeTruthy();
expect(windowState.isDevToolsOpened).toBeFalsy();
expect(windowState.isCrashed).toBeFalsy();
await electronApp.close();
});

BIN
test/intro.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB