[MM-45448] Force electron processes to close after every test on Windows (#2207)
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const ps = require('ps-node');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const {_electron: electron} = require('playwright');
|
||||
@@ -119,6 +121,28 @@ module.exports = {
|
||||
demoMattermostConfig,
|
||||
cmdOrCtrl,
|
||||
|
||||
async clearElectronInstances() {
|
||||
if (process.platform !== 'win32') {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
ps.lookup({
|
||||
command: 'electron',
|
||||
}, (err, resultList) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
resultList.forEach((process) => {
|
||||
if (process && process.command === electronBinaryPath && !process.arguments.some((arg) => arg.includes('electron-mocha'))) {
|
||||
ps.kill(process.pid);
|
||||
}
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
cleanTestConfig() {
|
||||
[configFilePath, boundsInfoPath].forEach((file) => {
|
||||
try {
|
||||
|
@@ -27,6 +27,7 @@ describe('application', function desc() {
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (err) {}
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
|
@@ -58,6 +58,7 @@ describe('focus', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
describe('Focus textbox tests', () => {
|
||||
|
@@ -28,6 +28,7 @@ describe('dark_mode', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
|
@@ -53,6 +53,7 @@ describe('back_button', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('MM-T2633 Back button should behave as expected', async () => {
|
||||
|
@@ -28,6 +28,7 @@ describe('copylink', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('MM-T125 Copy Link can be used from channel LHS', async () => {
|
||||
|
@@ -24,6 +24,7 @@ describe('menu_bar/dropdown', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('MM-T4405 should set name of menu item from config file', async () => {
|
||||
|
@@ -28,6 +28,7 @@ describe('edit_menu', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('MM-T807 Undo in the Menu Bar', async () => {
|
||||
|
@@ -30,6 +30,7 @@ describe('file_menu/dropdown', function desc() {
|
||||
if (this.app && skipAfterEach === false) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('MM-T1313 Open Settings modal using keyboard shortcuts', async () => {
|
||||
|
@@ -26,6 +26,7 @@ describe('history_menu', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('Click back and forward from history', async () => {
|
||||
|
@@ -27,6 +27,7 @@ describe('menu/menu', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
|
@@ -52,6 +52,7 @@ describe('menu/view', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('MM-T813 Control+F should focus the search bar in Mattermost', async () => {
|
||||
|
@@ -57,6 +57,7 @@ describe('Menu/window_menu', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('MM-T826 should switch to servers when keyboard shortcuts are pressed', async () => {
|
||||
|
@@ -28,6 +28,7 @@ describe('popup', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
// NOTE: These tests requires that the test server have the GitHub plugin configured
|
||||
|
@@ -28,6 +28,7 @@ describe('copylink', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('MM-T1308 Check that external links dont open in the app', async () => {
|
||||
|
@@ -35,6 +35,7 @@ describe('Add Server Modal', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
let newServerView;
|
||||
|
@@ -52,6 +52,7 @@ describe('server_management/drag_and_drop', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('MM-T2634 should be able to drag and drop servers in the dropdown menu', async () => {
|
||||
|
@@ -34,6 +34,7 @@ describe('EditServerModal', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
let editServerView;
|
||||
|
@@ -23,6 +23,7 @@ describe('header', function desc() {
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (err) {}
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('MM-T2637 Double-Clicking on the header should minimize/maximize the app', async () => {
|
||||
|
@@ -38,6 +38,7 @@ describe('LongServerName', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
let newServerView;
|
||||
|
@@ -37,6 +37,7 @@ describe('RemoveServerModal', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
let removeServerView;
|
||||
|
@@ -28,6 +28,7 @@ describe('Settings', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
describe('Options', () => {
|
||||
|
@@ -28,6 +28,7 @@ describe('settings/keyboard_shortcuts', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
describe('MM-T1288 Manipulating Text', () => {
|
||||
|
@@ -21,6 +21,7 @@ describe('startup/app', function desc() {
|
||||
if (this.app) {
|
||||
await this.app.close();
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
it('MM-T4399_1 should show the new server modal when no servers exist', async () => {
|
||||
|
@@ -22,6 +22,7 @@ describe('config', function desc() {
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (err) {}
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
describe('MM-T4401 should show servers in dropdown when there is config file', async () => {
|
||||
|
@@ -22,6 +22,7 @@ describe('window', function desc() {
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (err) {}
|
||||
}
|
||||
await env.clearElectronInstances();
|
||||
});
|
||||
|
||||
// TODO: this fails on Linux right now due to the window frame for some reason
|
||||
|
Reference in New Issue
Block a user