[MM-46535] Fix E2E tests for reporting purposes (#2236)

This commit is contained in:
Devin Binnie
2022-08-25 09:11:23 -04:00
committed by GitHub
parent 16dccd373e
commit 86d35669be
9 changed files with 362 additions and 278 deletions

View File

@@ -10,8 +10,6 @@ const env = require('../../modules/environment');
const {asyncSleep} = require('../../modules/utils');
describe('Menu/window_menu', function desc() {
this.timeout(30000);
const config = {
...env.demoConfig,
teams: [
@@ -44,62 +42,90 @@ describe('Menu/window_menu', function desc() {
alwaysMinimize: true,
};
beforeEach(async () => {
const beforeFunc = async () => {
env.cleanDataDir();
env.createTestUserDataDir();
env.cleanTestConfig();
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
await asyncSleep(1000);
this.app = await env.getApp();
});
};
afterEach(async () => {
const afterFunc = async () => {
if (this.app) {
await this.app.close();
}
await env.clearElectronInstances();
});
};
it('MM-T826 should switch to servers when keyboard shortcuts are pressed', async () => {
await env.getServerMap(this.app);
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
this.timeout(30000);
let dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
dropdownButtonText.should.equal('example');
describe('MM-T826 should switch to servers when keyboard shortcuts are pressed', async () => {
let mainWindow;
robot.keyTap('2', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("github")');
dropdownButtonText.should.equal('github');
before(async () => {
await beforeFunc();
await env.getServerMap(this.app);
mainWindow = this.app.windows().find((window) => window.url().includes('index'));
});
after(afterFunc);
robot.keyTap('3', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("google")');
dropdownButtonText.should.equal('google');
it('MM-T826_1 should show the second server', async () => {
let dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
dropdownButtonText.should.equal('example');
robot.keyTap('1', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("example")');
dropdownButtonText.should.equal('example');
robot.keyTap('2', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("github")');
dropdownButtonText.should.equal('github');
});
it('MM-T826_2 should show the third server', async () => {
robot.keyTap('3', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
const dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("google")');
dropdownButtonText.should.equal('google');
});
it('MM-T826_3 should show the first server', async () => {
robot.keyTap('1', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
const dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("example")');
dropdownButtonText.should.equal('example');
});
});
it('MM-T4385 select tab from menu', async () => {
const mainView = this.app.windows().find((window) => window.url().includes('index'));
let mainView;
let tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Channels');
before(async () => {
await beforeFunc();
mainView = this.app.windows().find((window) => window.url().includes('index'));
});
after(afterFunc);
robot.keyTap('2', [env.cmdOrCtrl]);
tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Boards');
it('MM-T4385_1 should show the second tab', async () => {
let tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Channels');
robot.keyTap('3', [env.cmdOrCtrl]);
tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Playbooks');
robot.keyTap('2', [env.cmdOrCtrl]);
tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Boards');
});
robot.keyTap('1', [env.cmdOrCtrl]);
tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Channels');
it('MM-T4385_2 should show the third tab', async () => {
robot.keyTap('3', [env.cmdOrCtrl]);
const tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Playbooks');
});
it('MM-T4385_3 should show the first tab', async () => {
robot.keyTap('1', [env.cmdOrCtrl]);
const tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Channels');
});
});
it('MM-T827 select next/previous tab', async () => {
await beforeFunc();
const mainView = this.app.windows().find((window) => window.url().includes('index'));
let tabViewButton = await mainView.innerText('.active');
@@ -112,9 +138,13 @@ describe('Menu/window_menu', function desc() {
robot.keyTap('tab', ['shift', 'control']);
tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Channels');
await afterFunc();
});
it('MM-T824 should be minimized when keyboard shortcuts are pressed', async () => {
await beforeFunc();
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow);
if (process.platform === 'darwin') {
@@ -129,9 +159,13 @@ describe('Menu/window_menu', function desc() {
await asyncSleep(2000);
const isMinimized = await browserWindow.evaluate((window) => window.isMinimized());
isMinimized.should.be.true;
await afterFunc();
});
it('MM-T825 should be hidden when keyboard shortcuts are pressed', async () => {
await beforeFunc();
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow);
robot.keyTap('w', [env.cmdOrCtrl]);
@@ -140,5 +174,7 @@ describe('Menu/window_menu', function desc() {
isVisible.should.be.false;
const isDestroyed = await browserWindow.evaluate((window) => window.isDestroyed());
isDestroyed.should.be.false;
await afterFunc();
});
});