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:
parent
7e414bdf5a
commit
2837b764bd
|
@ -29,8 +29,14 @@ const electronBinaryPath = (() => {
|
||||||
const userDataDir = path.join(sourceRootDir, 'e2e/testUserData/');
|
const userDataDir = path.join(sourceRootDir, 'e2e/testUserData/');
|
||||||
const configFilePath = path.join(userDataDir, 'config.json');
|
const configFilePath = path.join(userDataDir, 'config.json');
|
||||||
const boundsInfoPath = path.join(userDataDir, 'bounds-info.json');
|
const boundsInfoPath = path.join(userDataDir, 'bounds-info.json');
|
||||||
|
const appUpdatePath = path.join(userDataDir, 'app-update.yml');
|
||||||
const exampleURL = 'http://example.com/';
|
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 = {
|
const exampleTeam = {
|
||||||
name: 'example',
|
name: 'example',
|
||||||
|
@ -115,6 +121,7 @@ module.exports = {
|
||||||
configFilePath,
|
configFilePath,
|
||||||
userDataDir,
|
userDataDir,
|
||||||
boundsInfoPath,
|
boundsInfoPath,
|
||||||
|
appUpdatePath,
|
||||||
exampleURL,
|
exampleURL,
|
||||||
mattermostURL,
|
mattermostURL,
|
||||||
demoConfig,
|
demoConfig,
|
||||||
|
@ -122,13 +129,9 @@ module.exports = {
|
||||||
cmdOrCtrl,
|
cmdOrCtrl,
|
||||||
|
|
||||||
async clearElectronInstances() {
|
async clearElectronInstances() {
|
||||||
if (process.platform !== 'win32') {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ps.lookup({
|
ps.lookup({
|
||||||
command: 'electron',
|
command: process.platform === 'darwin' ? 'Electron' : 'electron',
|
||||||
}, (err, resultList) => {
|
}, (err, resultList) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
@ -175,6 +178,10 @@ module.exports = {
|
||||||
|
|
||||||
async getApp(args = []) {
|
async getApp(args = []) {
|
||||||
const options = {
|
const options = {
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
RESOURCES_PATH: userDataDir,
|
||||||
|
},
|
||||||
executablePath: electronBinaryPath,
|
executablePath: electronBinaryPath,
|
||||||
args: [`${path.join(sourceRootDir, 'dist')}`, `--data-dir=${userDataDir}`, '--disable-dev-mode', ...args],
|
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');
|
// options.chromeDriverArgs.push('remote-debugging-port=9222');
|
||||||
//}
|
//}
|
||||||
return electron.launch(options).then(async (app) => {
|
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);
|
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;
|
return app;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -105,7 +105,7 @@ describe('popup', function desc() {
|
||||||
const githubLink = await firstServer.waitForSelector('a.theme.markdown__link:has-text("GitHub account")');
|
const githubLink = await firstServer.waitForSelector('a.theme.markdown__link:has-text("GitHub account")');
|
||||||
githubLink.click();
|
githubLink.click();
|
||||||
const popupWindow = await this.app.waitForEvent('window');
|
const popupWindow = await this.app.waitForEvent('window');
|
||||||
popupWindow.focus();
|
await popupWindow.bringToFront();
|
||||||
const currentURL = popupWindow.url();
|
const currentURL = popupWindow.url();
|
||||||
|
|
||||||
// Try and go back
|
// Try and go back
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
const {SHOW_SETTINGS_WINDOW} = require('../../src/common/communication');
|
const {SHOW_SETTINGS_WINDOW} = require('../../src/common/communication');
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ describe('Settings', function desc() {
|
||||||
env.createTestUserDataDir();
|
env.createTestUserDataDir();
|
||||||
env.cleanTestConfig();
|
env.cleanTestConfig();
|
||||||
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
||||||
|
fs.writeFileSync(env.appUpdatePath, '');
|
||||||
await asyncSleep(1000);
|
await asyncSleep(1000);
|
||||||
this.app = await env.getApp();
|
this.app = await env.getApp();
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,17 +13,21 @@ const webpack = require('webpack');
|
||||||
|
|
||||||
const VERSION = childProcess.execSync('git rev-parse --short HEAD').toString();
|
const VERSION = childProcess.execSync('git rev-parse --short HEAD').toString();
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
|
const isTest = process.env.NODE_ENV === 'test';
|
||||||
const isRelease = process.env.CIRCLE_BRANCH && process.env.CIRCLE_BRANCH.startsWith('release-');
|
const isRelease = process.env.CIRCLE_BRANCH && process.env.CIRCLE_BRANCH.startsWith('release-');
|
||||||
|
|
||||||
const codeDefinitions = {
|
const codeDefinitions = {
|
||||||
__HASH_VERSION__: !isRelease && JSON.stringify(VERSION),
|
__HASH_VERSION__: !isRelease && JSON.stringify(VERSION),
|
||||||
__CAN_UPGRADE__: JSON.stringify(process.env.CAN_UPGRADE === 'true'),
|
__CAN_UPGRADE__: isTest || JSON.stringify(process.env.CAN_UPGRADE === 'true'),
|
||||||
__IS_NIGHTLY_BUILD__: JSON.stringify(process.env.CIRCLE_BRANCH === 'nightly'),
|
__IS_NIGHTLY_BUILD__: JSON.stringify(process.env.CIRCLE_BRANCH === 'nightly'),
|
||||||
__IS_MAC_APP_STORE__: JSON.stringify(process.env.IS_MAC_APP_STORE === 'true'),
|
__IS_MAC_APP_STORE__: JSON.stringify(process.env.IS_MAC_APP_STORE === 'true'),
|
||||||
__SKIP_ONBOARDING_SCREENS__: JSON.stringify(process.env.MM_DESKTOP_BUILD_SKIPONBOARDINGSCREENS === 'true'),
|
__SKIP_ONBOARDING_SCREENS__: JSON.stringify(process.env.MM_DESKTOP_BUILD_SKIPONBOARDINGSCREENS === 'true'),
|
||||||
__DISABLE_GPU__: JSON.stringify(process.env.MM_DESKTOP_BUILD_DISABLEGPU === 'true'),
|
__DISABLE_GPU__: JSON.stringify(process.env.MM_DESKTOP_BUILD_DISABLEGPU === 'true'),
|
||||||
};
|
};
|
||||||
codeDefinitions['process.env.NODE_ENV'] = JSON.stringify(process.env.NODE_ENV);
|
codeDefinitions['process.env.NODE_ENV'] = JSON.stringify(process.env.NODE_ENV);
|
||||||
|
if (isTest) {
|
||||||
|
codeDefinitions['process.resourcesPath'] = 'process.env.RESOURCES_PATH';
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue