feat: migrating electron e2e from spectron (deprecated) to wdio (#32)

This commit is contained in:
Amadou A. DIENE
2022-04-07 09:14:32 +02:00
committed by GitHub
parent 3534d64960
commit d7c7af13f1
18 changed files with 19223 additions and 19134 deletions

View File

@@ -1,6 +1,8 @@
import { app, BrowserWindow, shell } from 'electron';
import { Window } from './window';
declare const global: Global;
export class App {
private static _wrapper: Window;
@@ -9,10 +11,6 @@ export class App {
app.on('activate', App.start);
app.on('ready', App.start);
// Fix warning by applying electron new default value for this property
// Further details : https://github.com/electron/electron/issues/18397
app.allowRendererProcessReuse = true;
// Limit navigation and open external links in default browser
app.on('web-contents-created', App.openExternalLinksInDefaultBrowser);
}
@@ -30,7 +28,11 @@ export class App {
private static quit() {
// On MacOS it is common for applications to stay open until the user explicitly quits
if (process.platform !== 'darwin') {
// But WebDriverIO Test Runner does handle that behaviour yet
if (
process.platform !== 'darwin' ||
global.appConfig.configId === 'e2e-test'
) {
app.quit();
}
}

View File

@@ -3,6 +3,7 @@ import * as path from 'path';
import { AbstractService } from '../services/abstract-service';
import { MultiplesService } from '../services/multiples-service';
import { Logger } from '../utils/logger';
import * as remoteMain from '@electron/remote/main';
declare const global: Global;
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
@@ -25,21 +26,21 @@ export class Window {
webPreferences: {
// Default behavior in Electron since 5, that
// limits the powers granted to remote content
// except in e2e test when those powers are required by Spectron
// except in e2e test when those powers are required
nodeIntegration: global.appConfig.isNodeIntegration,
// Isolate window context to protect against prototype pollution
// except in e2e test when that access is required by Spectron
// except in e2e test when that access is required
contextIsolation: global.appConfig.isContextIsolation,
// Ensure that JS values can't unsafely cross between worlds
// when using contextIsolation
worldSafeExecuteJavaScript: global.appConfig.isContextIsolation,
// Disable the remote module to enhance security
// except in e2e test when that access is required by Spectron
enableRemoteModule: global.appConfig.isEnableRemoteModule,
// Use a preload script to enhance security
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
},
});
// Disable the remote module to enhance security
// except in e2e test when that access is required
if (global.appConfig.isEnableRemoteModule) {
remoteMain.enable(this._electronWindow.webContents);
}
}
private loadIcon(): Electron.NativeImage | undefined {