mirror of
https://github.com/Fabio286/antares.git
synced 2025-01-15 10:27:07 +01:00
test: basic e2e tests
This commit is contained in:
parent
e8af2d24a8
commit
37ccb6b00d
@ -18,7 +18,7 @@
|
||||
"release": "standard-version",
|
||||
"release:pre": "npm run release -- --prerelease alpha",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"test": "npm run lint",
|
||||
"test": "npm run compile && node tests/app.spec.js",
|
||||
"lint": "eslint . --ext .js,.vue && stylelint \"./src/**/*.{css,scss,sass,vue}\"",
|
||||
"lint:fix": "eslint . --ext .js,.vue --fix && stylelint \"./src/**/*.{css,scss,sass,vue}\" --fix",
|
||||
"contributors:add": "all-contributors add",
|
||||
@ -146,6 +146,7 @@
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"mini-css-extract-plugin": "^2.4.3",
|
||||
"node-loader": "^2.0.0",
|
||||
"playwright": "^1.16.3",
|
||||
"progress-webpack-plugin": "^1.0.12",
|
||||
"sass": "^1.42.1",
|
||||
"sass-loader": "^12.3.0",
|
||||
|
48
tests/app.spec.js
Normal file
48
tests/app.spec.js
Normal file
@ -0,0 +1,48 @@
|
||||
const { _electron: electron } = require('playwright');
|
||||
const { strict: assert } = require('assert');
|
||||
|
||||
(async () => {
|
||||
// Launch Electron app.
|
||||
const electronApp = await electron.launch({ args: ['dist/main.js'] });
|
||||
|
||||
/**
|
||||
* App main window state
|
||||
* @type {{isVisible: boolean; isDevToolsOpened: boolean; isCrashed: boolean}}
|
||||
*/
|
||||
const windowState = await electronApp.evaluate(({ BrowserWindow }) => {
|
||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||
|
||||
const getState = () => ({
|
||||
isVisible: mainWindow.isVisible(),
|
||||
isDevToolsOpened: mainWindow.webContents.isDevToolsOpened()
|
||||
});
|
||||
|
||||
return new Promise((resolve) => {
|
||||
if (mainWindow.isVisible())
|
||||
resolve(getState());
|
||||
else
|
||||
mainWindow.once('ready-to-show', () => setTimeout(() => resolve(getState()), 0));
|
||||
});
|
||||
});
|
||||
|
||||
// Check main window state
|
||||
assert.ok(windowState.isVisible, 'Main window not visible');
|
||||
assert.ok(!windowState.isDevToolsOpened, 'DevTools opened');
|
||||
assert.ok(!windowState.isCrashed, 'Window crashed');
|
||||
|
||||
/**
|
||||
* Rendered Main window web-page
|
||||
* @type {Page}
|
||||
*/
|
||||
const page = await electronApp.firstWindow();
|
||||
console.log(await page.title());
|
||||
|
||||
// Check web-page content
|
||||
const element = await page.$('#wrapper', { strict: true });
|
||||
|
||||
assert.notStrictEqual(element, null, 'Can\'t find root element');
|
||||
assert.notStrictEqual((await element.innerHTML()).trim(), '', 'Window content is empty');
|
||||
|
||||
// Close app
|
||||
await electronApp.close();
|
||||
})();
|
Loading…
Reference in New Issue
Block a user