diff --git a/.circleci/config.yml b/.circleci/config.yml index 1e9d7f87..124f044b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/test/base.test.ts b/test/base.test.ts new file mode 100644 index 00000000..3a1b4ddf --- /dev/null +++ b/test/base.test.ts @@ -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(); +}); diff --git a/test/intro.png b/test/intro.png new file mode 100644 index 00000000..fa50249f Binary files /dev/null and b/test/intro.png differ