E2E omnibus fixes (#2249)

* Add environment variable for E2E test server

* Fix auto updater test

* Kill macOS processes after test as well

* No dot

* Just do it for all of them

* Force focus of main window on tests

* Fix a focus issue, try win.show() instead

* Another windows hack

* Oops can't spell

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Devin Binnie
2022-09-12 10:43:19 -04:00
committed by GitHub
parent 7e414bdf5a
commit 2837b764bd
4 changed files with 28 additions and 9 deletions

View File

@@ -29,8 +29,14 @@ const electronBinaryPath = (() => {
const userDataDir = path.join(sourceRootDir, 'e2e/testUserData/');
const configFilePath = path.join(userDataDir, 'config.json');
const boundsInfoPath = path.join(userDataDir, 'bounds-info.json');
const appUpdatePath = path.join(userDataDir, 'app-update.yml');
const exampleURL = 'http://example.com/';
const mattermostURL = 'http://localhost:8065/';
const mattermostURL = process.env.MM_TEST_SERVER_URL || 'http://localhost:8065/';
if (process.platform === 'win32') {
const robot = require('robotjs');
robot.mouseClick();
}
const exampleTeam = {
name: 'example',
@@ -115,6 +121,7 @@ module.exports = {
configFilePath,
userDataDir,
boundsInfoPath,
appUpdatePath,
exampleURL,
mattermostURL,
demoConfig,
@@ -122,13 +129,9 @@ module.exports = {
cmdOrCtrl,
async clearElectronInstances() {
if (process.platform !== 'win32') {
return Promise.resolve();
}
return new Promise((resolve, reject) => {
ps.lookup({
command: 'electron',
command: process.platform === 'darwin' ? 'Electron' : 'electron',
}, (err, resultList) => {
if (err) {
reject(err);
@@ -175,6 +178,10 @@ module.exports = {
async getApp(args = []) {
const options = {
env: {
...process.env,
RESOURCES_PATH: userDataDir,
},
executablePath: electronBinaryPath,
args: [`${path.join(sourceRootDir, 'dist')}`, `--data-dir=${userDataDir}`, '--disable-dev-mode', ...args],
};
@@ -188,8 +195,14 @@ module.exports = {
// options.chromeDriverArgs.push('remote-debugging-port=9222');
//}
return electron.launch(options).then(async (app) => {
// Make sure the app has time to fully load
// Make sure the app has time to fully load and that the window is focused
await asyncSleep(1000);
const mainWindow = app.windows().find((window) => window.url().includes('index'));
const browserWindow = await app.browserWindow(mainWindow);
await browserWindow.evaluate((win) => {
win.show();
return true;
});
return app;
});
},