[MM-45448] Force electron processes to close after every test on Windows (#2207)

This commit is contained in:
Devin Binnie
2022-07-25 09:41:19 -04:00
committed by GitHub
parent 40c072981a
commit 821112c038
28 changed files with 118 additions and 339 deletions

View File

@@ -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 {

View File

@@ -27,6 +27,7 @@ describe('application', function desc() {
// eslint-disable-next-line no-empty
} catch (err) {}
}
await env.clearElectronInstances();
});
if (process.platform === 'win32') {

View File

@@ -58,6 +58,7 @@ describe('focus', function desc() {
if (this.app) {
await this.app.close();
}
await env.clearElectronInstances();
});
describe('Focus textbox tests', () => {

View File

@@ -28,6 +28,7 @@ describe('dark_mode', function desc() {
if (this.app) {
await this.app.close();
}
await env.clearElectronInstances();
});
if (process.platform === 'linux') {

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -27,6 +27,7 @@ describe('menu/menu', function desc() {
if (this.app) {
await this.app.close();
}
await env.clearElectronInstances();
});
if (process.platform !== 'darwin') {

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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

View File

@@ -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 () => {

View File

@@ -35,6 +35,7 @@ describe('Add Server Modal', function desc() {
if (this.app) {
await this.app.close();
}
await env.clearElectronInstances();
});
let newServerView;

View File

@@ -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 () => {

View File

@@ -34,6 +34,7 @@ describe('EditServerModal', function desc() {
if (this.app) {
await this.app.close();
}
await env.clearElectronInstances();
});
let editServerView;

View File

@@ -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 () => {

View File

@@ -38,6 +38,7 @@ describe('LongServerName', function desc() {
if (this.app) {
await this.app.close();
}
await env.clearElectronInstances();
});
let newServerView;

View File

@@ -37,6 +37,7 @@ describe('RemoveServerModal', function desc() {
if (this.app) {
await this.app.close();
}
await env.clearElectronInstances();
});
let removeServerView;

View File

@@ -28,6 +28,7 @@ describe('Settings', function desc() {
if (this.app) {
await this.app.close();
}
await env.clearElectronInstances();
});
describe('Options', () => {

View File

@@ -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', () => {

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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