[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

@@ -7,7 +7,7 @@ const fs = require('fs');
const env = require('../../modules/environment'); const env = require('../../modules/environment');
const {asyncSleep} = require('../../modules/utils'); const {asyncSleep} = require('../../modules/utils');
describe('back_button', function desc() { describe('MM-T2633 Back button should behave as expected', function desc() {
this.timeout(30000); this.timeout(30000);
const config = { const config = {
@@ -39,7 +39,11 @@ describe('back_button', function desc() {
], ],
}; };
beforeEach(async () => { let mainWindow;
let firstServer;
let backButton;
before(async () => {
env.cleanDataDir(); env.cleanDataDir();
env.createTestUserDataDir(); env.createTestUserDataDir();
env.cleanTestConfig(); env.cleanTestConfig();
@@ -47,49 +51,57 @@ describe('back_button', function desc() {
await asyncSleep(1000); await asyncSleep(1000);
this.app = await env.getApp(); this.app = await env.getApp();
this.serverMap = await env.getServerMap(this.app); this.serverMap = await env.getServerMap(this.app);
mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await firstServer.click('a:has-text("OneLogin")');
backButton = await mainWindow.waitForSelector('button:has-text("Back")');
}); });
afterEach(async () => { after(async () => {
if (this.app) { if (this.app) {
await this.app.close(); await this.app.close();
} }
await env.clearElectronInstances(); await env.clearElectronInstances();
}); });
it('MM-T2633 Back button should behave as expected', async () => { it('MM-T2633_1 after clicking OneLogin, back button should appear', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await firstServer.click('a:has-text("OneLogin")');
let backButton = await mainWindow.waitForSelector('button:has-text("Back")');
backButton.should.not.be.null; backButton.should.not.be.null;
let poweredByOneLogin = await firstServer.waitForSelector('a:has-text("Powered by OneLogin")'); const poweredByOneLogin = await firstServer.waitForSelector('a:has-text("Powered by OneLogin")');
poweredByOneLogin.should.not.be.null; poweredByOneLogin.should.not.be.null;
});
it('MM-T2633_2 after clicking Back, should be back on the login screen', async () => {
await backButton.click(); await backButton.click();
let loginPrompt = await firstServer.waitForSelector('#input_loginId'); const loginPrompt = await firstServer.waitForSelector('#input_loginId');
loginPrompt.should.not.be.null; loginPrompt.should.not.be.null;
await mainWindow.waitForSelector('button:has-text("Back")', {state: 'hidden'}); await mainWindow.waitForSelector('button:has-text("Back")', {state: 'hidden'});
});
it('MM-T2633_3 on the OneLogin screen, should still allow links to be clicked and still show the Back button', async () => {
let isNewWindow = false; let isNewWindow = false;
this.app.on('window', () => { this.app.on('window', () => {
isNewWindow = true; isNewWindow = true;
}); });
const oneLoginUrl = firstServer.url(); const oneLoginUrl = firstServer.url();
await firstServer.click('a:has-text("OneLogin")'); await firstServer.click('a:has-text("OneLogin")');
poweredByOneLogin = await firstServer.waitForSelector('a:has-text("Powered by OneLogin")'); const poweredByOneLogin = await firstServer.waitForSelector('a:has-text("Powered by OneLogin")');
poweredByOneLogin.click(); poweredByOneLogin.click();
backButton = await mainWindow.waitForSelector('button:has-text("Back")'); backButton = await mainWindow.waitForSelector('button:has-text("Back")');
backButton.should.not.be.null; backButton.should.not.be.null;
const frameUrl = firstServer.url(); const frameUrl = firstServer.url();
frameUrl.should.not.equal(oneLoginUrl); frameUrl.should.not.equal(oneLoginUrl);
isNewWindow.should.be.false; isNewWindow.should.be.false;
await firstServer.waitForSelector('a:has-text("Powered by OneLogin")', {state: 'hidden'});
});
it('MM-T2633_4 after click Back twice, user should be on the main login screen again', async () => {
await backButton.click(); await backButton.click();
await firstServer.waitForURL('https://mattermost.onelogin.com/**');
await backButton.click(); await backButton.click();
loginPrompt = await firstServer.waitForSelector('#input_loginId'); const loginPrompt = await firstServer.waitForSelector('#input_loginId');
loginPrompt.should.not.be.null; loginPrompt.should.not.be.null;
}); });
}); });

View File

@@ -7,27 +7,29 @@ const fs = require('fs');
const env = require('../../modules/environment'); const env = require('../../modules/environment');
const {asyncSleep} = require('../../modules/utils'); const {asyncSleep} = require('../../modules/utils');
describe('menu_bar/dropdown', function desc() {
this.timeout(30000);
const config = env.demoConfig; const config = env.demoConfig;
beforeEach(async () => { describe('menu_bar/dropdown', function desc() {
const beforeFunc = async () => {
env.createTestUserDataDir(); env.createTestUserDataDir();
env.cleanTestConfig(); env.cleanTestConfig();
fs.writeFileSync(env.configFilePath, JSON.stringify(config)); fs.writeFileSync(env.configFilePath, JSON.stringify(config));
await asyncSleep(1000); await asyncSleep(1000);
this.app = await env.getApp(); this.app = await env.getApp();
}); };
afterEach(async () => { const afterFunc = async () => {
if (this.app) { if (this.app) {
await this.app.close(); await this.app.close();
} }
await env.clearElectronInstances(); await env.clearElectronInstances();
}); };
this.timeout(30000);
it('MM-T4405 should set name of menu item from config file', async () => { it('MM-T4405 should set name of menu item from config file', async () => {
await beforeFunc();
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const dropdownView = this.app.windows().find((window) => window.url().includes('dropdown')); const dropdownView = this.app.windows().find((window) => window.url().includes('dropdown'));
await mainWindow.click('.TeamDropdownButton'); await mainWindow.click('.TeamDropdownButton');
@@ -36,25 +38,40 @@ describe('menu_bar/dropdown', function desc() {
firstMenuItem.should.equal(config.teams[0].name); firstMenuItem.should.equal(config.teams[0].name);
secondMenuItem.should.equal(config.teams[1].name); secondMenuItem.should.equal(config.teams[1].name);
await afterFunc();
}); });
it('MM-T4406 should only show dropdown when button is clicked', async () => { describe('MM-T4406 should only show dropdown when button is clicked', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); let mainWindow;
const browserWindow = await this.app.browserWindow(mainWindow); let browserWindow;
before(async () => {
await beforeFunc();
mainWindow = this.app.windows().find((window) => window.url().includes('index'));
browserWindow = await this.app.browserWindow(mainWindow);
});
after(afterFunc);
it('MM-T4406_1 should show the dropdown', async () => {
let dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height); let dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
dropdownHeight.should.equal(0); dropdownHeight.should.equal(0);
await mainWindow.click('.TeamDropdownButton'); await mainWindow.click('.TeamDropdownButton');
dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height); dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
dropdownHeight.should.be.greaterThan(0); dropdownHeight.should.be.greaterThan(0);
});
it('MM-T4406_2 should hide the dropdown', async () => {
await mainWindow.click('.TabBar'); await mainWindow.click('.TabBar');
dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height); const dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
dropdownHeight.should.equal(0); dropdownHeight.should.equal(0);
}); });
});
it('MM-T4407 should open the new server prompt after clicking the add button', async () => { it('MM-T4407 should open the new server prompt after clicking the add button', async () => {
await beforeFunc();
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const dropdownView = this.app.windows().find((window) => window.url().includes('dropdown')); const dropdownView = this.app.windows().find((window) => window.url().includes('dropdown'));
await mainWindow.click('.TeamDropdownButton'); await mainWindow.click('.TeamDropdownButton');
@@ -65,24 +82,38 @@ describe('menu_bar/dropdown', function desc() {
}); });
const modalTitle = await newServerModal.innerText('#newServerModal .modal-title'); const modalTitle = await newServerModal.innerText('#newServerModal .modal-title');
modalTitle.should.equal('Add Server'); modalTitle.should.equal('Add Server');
await afterFunc();
}); });
it('MM-T4408 should show only the selected team', async () => { describe('MM-T4408 Switch Servers', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); let mainWindow;
const browserWindow = await this.app.browserWindow(mainWindow); let browserWindow;
let dropdownView;
let firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === url)), env.exampleURL); before(async () => {
await beforeFunc();
mainWindow = this.app.windows().find((window) => window.url().includes('index'));
browserWindow = await this.app.browserWindow(mainWindow);
dropdownView = this.app.windows().find((window) => window.url().includes('dropdown'));
});
after(afterFunc);
it('MM-T4408_1 should show the first view', async () => {
const firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === url)), env.exampleURL);
firstViewIsAttached.should.be.true; firstViewIsAttached.should.be.true;
let secondViewIsAttached = await browserWindow.evaluate((window) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === 'https://github.com/'))); const secondViewIsAttached = await browserWindow.evaluate((window) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === 'https://github.com/')));
secondViewIsAttached.should.be.false; secondViewIsAttached.should.be.false;
});
const dropdownView = this.app.windows().find((window) => window.url().includes('dropdown')); it('MM-T4408_2 should show the second view after clicking the menu item', async () => {
await mainWindow.click('.TeamDropdownButton'); await mainWindow.click('.TeamDropdownButton');
await dropdownView.click('.TeamDropdown button.TeamDropdown__button:nth-child(2)'); await dropdownView.click('.TeamDropdown button.TeamDropdown__button:nth-child(2)');
firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === url)), env.exampleURL); const firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === url)), env.exampleURL);
firstViewIsAttached.should.be.false; firstViewIsAttached.should.be.false;
secondViewIsAttached = await browserWindow.evaluate((window) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === 'https://github.com/'))); const secondViewIsAttached = await browserWindow.evaluate((window) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === 'https://github.com/')));
secondViewIsAttached.should.be.true; secondViewIsAttached.should.be.true;
}); });
}); });
});

View File

@@ -124,7 +124,7 @@ describe('menu/view', function desc() {
}); });
describe('MM-T818 Zoom in from the menu bar', () => { describe('MM-T818 Zoom in from the menu bar', () => {
it('MM-T818 Zoom in when CmdOrCtrl+Plus is pressed', async () => { it('MM-T818_1 Zoom in when CmdOrCtrl+Plus is pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
@@ -140,7 +140,7 @@ describe('menu/view', function desc() {
zoomLevel.should.be.greaterThan(1); zoomLevel.should.be.greaterThan(1);
}); });
it('MM-T818_1 Zoom in when CmdOrCtrl+Shift+Plus is pressed', async () => { it('MM-T818_2 Zoom in when CmdOrCtrl+Shift+Plus is pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
@@ -163,8 +163,8 @@ describe('menu/view', function desc() {
}); });
}); });
describe('MM-T818 Zoom out from the menu bar', () => { describe('MM-T819 Zoom out from the menu bar', () => {
it('MM-T819 Zoom out when CmdOrCtrl+Minus is pressed', async () => { it('MM-T819_1 Zoom out when CmdOrCtrl+Minus is pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
@@ -180,7 +180,7 @@ describe('menu/view', function desc() {
zoomLevel.should.be.lessThan(1); zoomLevel.should.be.lessThan(1);
}); });
it('MM-T819_1 Zoom out when CmdOrCtrl+Shift+Minus is pressed', async () => { it('MM-T819_2 Zoom out when CmdOrCtrl+Shift+Minus is pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));

View File

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

View File

@@ -53,16 +53,12 @@ describe('Add Server Modal', function desc() {
}); });
describe('MM-T4389 Invalid messages', () => { describe('MM-T4389 Invalid messages', () => {
it('MM-T4389_1 should not be valid if no team name has been set', async () => { it('MM-T4389_1 should not be valid if no team name or URL has been set', async () => {
await newServerView.click('#saveNewServerModal'); await newServerView.click('#saveNewServerModal');
const existing = await newServerView.isVisible('#teamNameInput.is-invalid'); const existingName = await newServerView.isVisible('#teamNameInput.is-invalid');
existing.should.be.true; const existingUrl = await newServerView.isVisible('#teamUrlInput.is-invalid');
}); existingName.should.be.true;
existingUrl.should.be.true;
it('MM-T4389_2 should not be valid if no server address has been set', async () => {
await newServerView.click('#saveNewServerModal');
const existing = await newServerView.isVisible('#teamUrlInput.is-invalid');
existing.should.be.true;
}); });
it('should not be valid if a server with the same name exists', async () => { it('should not be valid if a server with the same name exists', async () => {
@@ -87,13 +83,12 @@ describe('Add Server Modal', function desc() {
await newServerView.click('#saveNewServerModal'); await newServerView.click('#saveNewServerModal');
}); });
it('MM-T4389_3 should not be marked invalid', async () => { it('MM-T4389_2 Name should not be marked invalid, URL should be marked invalid', async () => {
const existing = await newServerView.isVisible('#teamNameInput.is-invalid'); const existingName = await newServerView.isVisible('#teamNameInput.is-invalid');
existing.should.be.false; const existingUrl = await newServerView.isVisible('#teamUrlInput.is-invalid');
});
it('MM-T4389_4 should not be possible to click save', async () => {
const disabled = await newServerView.getAttribute('#saveNewServerModal', 'disabled'); const disabled = await newServerView.getAttribute('#saveNewServerModal', 'disabled');
existingName.should.be.false;
existingUrl.should.be.true;
(disabled === '').should.be.true; (disabled === '').should.be.true;
}); });
}); });
@@ -104,13 +99,12 @@ describe('Add Server Modal', function desc() {
await newServerView.click('#saveNewServerModal'); await newServerView.click('#saveNewServerModal');
}); });
it('MM-T4389_5 should be valid', async () => { it('MM-T4389_3 URL should not be marked invalid, name should be marked invalid', async () => {
const existing = await newServerView.isVisible('#teamUrlInput.is-invalid'); const existingName = await newServerView.isVisible('#teamNameInput.is-invalid');
existing.should.be.false; const existingUrl = await newServerView.isVisible('#teamUrlInput.is-invalid');
});
it('MM-T4389_6 should not be possible to click save', async () => {
const disabled = await newServerView.getAttribute('#saveNewServerModal', 'disabled'); const disabled = await newServerView.getAttribute('#saveNewServerModal', 'disabled');
existingName.should.be.true;
existingUrl.should.be.false;
(disabled === '').should.be.true; (disabled === '').should.be.true;
}); });
}); });

View File

@@ -8,8 +8,6 @@ const env = require('../../modules/environment');
const {asyncSleep} = require('../../modules/utils'); const {asyncSleep} = require('../../modules/utils');
describe('server_management/drag_and_drop', function desc() { describe('server_management/drag_and_drop', function desc() {
this.timeout(30000);
const config = { const config = {
...env.demoConfig, ...env.demoConfig,
teams: [ teams: [
@@ -40,39 +38,51 @@ describe('server_management/drag_and_drop', function desc() {
], ],
}; };
beforeEach(async () => { const beforeFunc = async () => {
env.createTestUserDataDir(); env.createTestUserDataDir();
env.cleanTestConfig(); env.cleanTestConfig();
fs.writeFileSync(env.configFilePath, JSON.stringify(config)); fs.writeFileSync(env.configFilePath, JSON.stringify(config));
await asyncSleep(1000); await asyncSleep(1000);
this.app = await env.getApp(); this.app = await env.getApp();
}); };
afterEach(async () => { const afterFunc = async () => {
if (this.app) { if (this.app) {
await this.app.close(); await this.app.close();
} }
await env.clearElectronInstances(); await env.clearElectronInstances();
};
this.timeout(30000);
describe('MM-T2634 should be able to drag and drop servers in the dropdown menu', async () => {
let mainWindow;
let dropdownView;
before(async () => {
await beforeFunc();
mainWindow = this.app.windows().find((window) => window.url().includes('index'));
dropdownView = this.app.windows().find((window) => window.url().includes('dropdown'));
await mainWindow.click('.TeamDropdownButton');
});
after(afterFunc);
it('MM-T2634_1 should appear the original order', async () => {
const firstMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(1) .TeamDropdown__draggable-handle');
const firstMenuItemText = await firstMenuItem.innerText();
firstMenuItemText.should.equal('example');
const secondMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(2) .TeamDropdown__draggable-handle');
const secondMenuItemText = await secondMenuItem.innerText();
secondMenuItemText.should.equal('github');
const thirdMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(3) .TeamDropdown__draggable-handle');
const thirdMenuItemText = await thirdMenuItem.innerText();
thirdMenuItemText.should.equal('google');
}); });
it('MM-T2634 should be able to drag and drop servers in the dropdown menu', async () => { it('MM-T2634_2 after dragging the server down, should appear in the new order', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const dropdownView = this.app.windows().find((window) => window.url().includes('dropdown'));
await mainWindow.click('.TeamDropdownButton');
// Verify the original order
let firstMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(1) .TeamDropdown__draggable-handle');
let firstMenuItemText = await firstMenuItem.innerText();
firstMenuItemText.should.equal('example');
let secondMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(2) .TeamDropdown__draggable-handle');
let secondMenuItemText = await secondMenuItem.innerText();
secondMenuItemText.should.equal('github');
let thirdMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(3) .TeamDropdown__draggable-handle');
let thirdMenuItemText = await thirdMenuItem.innerText();
thirdMenuItemText.should.equal('google');
// Move the first server down, then re-open the dropdown // Move the first server down, then re-open the dropdown
await firstMenuItem.focus(); const initialMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(1) .TeamDropdown__draggable-handle');
await initialMenuItem.focus();
await dropdownView.keyboard.down(' '); await dropdownView.keyboard.down(' ');
await dropdownView.keyboard.down('ArrowDown'); await dropdownView.keyboard.down('ArrowDown');
await dropdownView.keyboard.down(' '); await dropdownView.keyboard.down(' ');
@@ -81,16 +91,18 @@ describe('server_management/drag_and_drop', function desc() {
await mainWindow.click('.TeamDropdownButton'); await mainWindow.click('.TeamDropdownButton');
// Verify that the new order persists // Verify that the new order persists
firstMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(1) .TeamDropdown__draggable-handle'); const firstMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(1) .TeamDropdown__draggable-handle');
firstMenuItemText = await firstMenuItem.innerText(); const firstMenuItemText = await firstMenuItem.innerText();
firstMenuItemText.should.equal('github'); firstMenuItemText.should.equal('github');
secondMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(2) .TeamDropdown__draggable-handle'); const secondMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(2) .TeamDropdown__draggable-handle');
secondMenuItemText = await secondMenuItem.innerText(); const secondMenuItemText = await secondMenuItem.innerText();
secondMenuItemText.should.equal('example'); secondMenuItemText.should.equal('example');
thirdMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(3) .TeamDropdown__draggable-handle'); const thirdMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(3) .TeamDropdown__draggable-handle');
thirdMenuItemText = await thirdMenuItem.innerText(); const thirdMenuItemText = await thirdMenuItem.innerText();
thirdMenuItemText.should.equal('google'); thirdMenuItemText.should.equal('google');
});
it('MM-T2634_3 should update the config file', () => {
// Verify config is updated // Verify config is updated
const newConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8')); const newConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
const order0 = newConfig.teams.find((team) => team.name === 'github'); const order0 = newConfig.teams.find((team) => team.name === 'github');
@@ -100,22 +112,32 @@ describe('server_management/drag_and_drop', function desc() {
const order2 = newConfig.teams.find((team) => team.name === 'google'); const order2 = newConfig.teams.find((team) => team.name === 'google');
order2.order.should.equal(2); order2.order.should.equal(2);
}); });
});
it('MM-T2635 should be able to drag and drop tabs', async () => { describe('MM-T2635 should be able to drag and drop tabs', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); let mainWindow;
before(async () => {
await beforeFunc();
mainWindow = this.app.windows().find((window) => window.url().includes('index'));
});
after(afterFunc);
it('MM-T2635_1 should be in the original order', async () => {
// Verify the original order // Verify the original order
let firstTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(1)'); const firstTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(1)');
let firstTabText = await firstTab.innerText(); const firstTabText = await firstTab.innerText();
firstTabText.should.equal('Channels'); firstTabText.should.equal('Channels');
let secondTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(2)'); const secondTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(2)');
let secondTabText = await secondTab.innerText(); const secondTabText = await secondTab.innerText();
secondTabText.should.equal('Boards'); secondTabText.should.equal('Boards');
let thirdTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(3)'); const thirdTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(3)');
let thirdTabText = await thirdTab.innerText(); const thirdTabText = await thirdTab.innerText();
thirdTabText.should.equal('Playbooks'); thirdTabText.should.equal('Playbooks');
});
it('MM-T2635_2 after moving the tab to the right, the tab should be in the new order', async () => {
// Move the first tab to the right // Move the first tab to the right
let firstTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(1)');
await firstTab.focus(); await firstTab.focus();
await mainWindow.keyboard.down(' '); await mainWindow.keyboard.down(' ');
await mainWindow.keyboard.down('ArrowRight'); await mainWindow.keyboard.down('ArrowRight');
@@ -124,15 +146,17 @@ describe('server_management/drag_and_drop', function desc() {
// Verify that the new order is visible // Verify that the new order is visible
firstTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(1)'); firstTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(1)');
firstTabText = await firstTab.innerText(); const firstTabText = await firstTab.innerText();
firstTabText.should.equal('Boards'); firstTabText.should.equal('Boards');
secondTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(2)'); const secondTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(2)');
secondTabText = await secondTab.innerText(); const secondTabText = await secondTab.innerText();
secondTabText.should.equal('Channels'); secondTabText.should.equal('Channels');
thirdTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(3)'); const thirdTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(3)');
thirdTabText = await thirdTab.innerText(); const thirdTabText = await thirdTab.innerText();
thirdTabText.should.equal('Playbooks'); thirdTabText.should.equal('Playbooks');
});
it('MM-T2635_3 should update the config file', () => {
// Verify config is updated // Verify config is updated
const newConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8')); const newConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
const firstTeam = newConfig.teams.find((team) => team.name === 'example'); const firstTeam = newConfig.teams.find((team) => team.name === 'example');
@@ -144,3 +168,4 @@ describe('server_management/drag_and_drop', function desc() {
order2.order.should.equal(2); order2.order.should.equal(2);
}); });
}); });
});

View File

@@ -11,12 +11,23 @@ const {asyncSleep} = require('../../modules/utils');
describe('header', function desc() { describe('header', function desc() {
this.timeout(30000); this.timeout(30000);
beforeEach(async () => { describe('MM-T2637 Double-Clicking on the header should minimize/maximize the app', async () => {
let header;
let browserWindow;
let initialBounds;
before(async () => {
env.createTestUserDataDir(); env.createTestUserDataDir();
env.cleanTestConfig(); env.cleanTestConfig();
initialBounds = {x: 0, y: 0, width: 800, height: 400, maximized: false};
fs.writeFileSync(env.boundsInfoPath, JSON.stringify(initialBounds));
this.app = await env.getApp();
const mainWindow = await this.app.windows().find((window) => window.url().includes('index'));
browserWindow = await this.app.browserWindow(mainWindow);
header = await mainWindow.locator('div.topBar');
}); });
afterEach(async () => { after(async () => {
if (this.app) { if (this.app) {
try { try {
await this.app.close(); await this.app.close();
@@ -26,18 +37,15 @@ describe('header', function desc() {
await env.clearElectronInstances(); await env.clearElectronInstances();
}); });
it('MM-T2637 Double-Clicking on the header should minimize/maximize the app', async () => { it('MM-T2637_1 should maximize on double-clicking the header', async () => {
const initialBounds = {x: 0, y: 0, width: 800, height: 400, maximized: false};
fs.writeFileSync(env.boundsInfoPath, JSON.stringify(initialBounds));
this.app = await env.getApp();
const mainWindow = await this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow);
const header = await mainWindow.locator('div.topBar');
const headerBounds = await header.boundingBox(); const headerBounds = await header.boundingBox();
await header.dblclick({position: {x: headerBounds.width / 2, y: headerBounds.y / 2}}); await header.dblclick({position: {x: headerBounds.width / 2, y: headerBounds.y / 2}});
await asyncSleep(1000); await asyncSleep(1000);
const isMaximized = await browserWindow.evaluate((window) => window.isMaximized()); const isMaximized = await browserWindow.evaluate((window) => window.isMaximized());
isMaximized.should.be.equal(true); isMaximized.should.be.equal(true);
});
it('MM-T2637_2 should restore on double-clicking the header when maximized', async () => {
const maximizedHeaderBounds = await header.boundingBox(); const maximizedHeaderBounds = await header.boundingBox();
await header.dblclick({position: {x: maximizedHeaderBounds.width / 2, y: maximizedHeaderBounds.y / 2}}); await header.dblclick({position: {x: maximizedHeaderBounds.width / 2, y: maximizedHeaderBounds.y / 2}});
await asyncSleep(1000); await asyncSleep(1000);
@@ -46,3 +54,4 @@ describe('header', function desc() {
revertedBounds.width.should.be.equal(initialBounds.width); revertedBounds.width.should.be.equal(initialBounds.width);
}); });
}); });
});

View File

@@ -43,14 +43,11 @@ describe('LongServerName', function desc() {
let newServerView; let newServerView;
describe('MM-T4050 Long server name', () => { it('MM-T4050 Long server name', async () => {
beforeEach(async () => {
await newServerView.type('#teamNameInput', longServerName); await newServerView.type('#teamNameInput', longServerName);
await newServerView.type('#teamUrlInput', longServerUrl); await newServerView.type('#teamUrlInput', longServerUrl);
await newServerView.click('#saveNewServerModal'); await newServerView.click('#saveNewServerModal');
});
it('MM-T4050_1 should add new server tab', async () => {
await asyncSleep(1000); await asyncSleep(1000);
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('newServer'))); const existing = Boolean(await this.app.windows().find((window) => window.url().includes('newServer')));
existing.should.be.false; existing.should.be.false;
@@ -60,41 +57,21 @@ describe('LongServerName', function desc() {
const isServerTabExists = Boolean(await mainView.locator(`text=${longServerName}`)); const isServerTabExists = Boolean(await mainView.locator(`text=${longServerName}`));
const isServerAddedDropdown = Boolean(await dropdownView.locator(`text=${longServerName}`)); const isServerAddedDropdown = Boolean(await dropdownView.locator(`text=${longServerName}`));
isServerTabExists.should.be.true; isServerTabExists.should.be.true;
isServerAddedDropdown.should.be.true; isServerAddedDropdown.should.be.true;
});
it('MM-T4050_2 should truncate server name', async () => {
await asyncSleep(1000);
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('newServer')));
existing.should.be.false;
const mainView = this.app.windows().find((window) => window.url().includes('index'));
const serverNameLocator = await mainView.locator(`text=${longServerName}`); const serverNameLocator = await mainView.locator(`text=${longServerName}`);
const isTruncated = await serverNameLocator.evaluate((element) => { const isTruncated = await serverNameLocator.evaluate((element) => {
return element.offsetWidth < element.scrollWidth; return element.offsetWidth < element.scrollWidth;
}); });
isTruncated.should.be.true; isTruncated.should.be.true;
});
it('MM-T4050_3 should display server tab with max width of 400px', async () => {
await asyncSleep(1000);
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('newServer')));
existing.should.be.false;
const mainView = this.app.windows().find((window) => window.url().includes('index'));
const serverNameLocator = await mainView.locator('.TeamDropdownButton');
const isWithinMaxWidth = await serverNameLocator.evaluate((element) => { const isWithinMaxWidth = await serverNameLocator.evaluate((element) => {
const width = parseFloat(window.getComputedStyle(element).getPropertyValue('width')); const width = parseFloat(window.getComputedStyle(element).getPropertyValue('width'));
return width <= 400; return width <= 400;
}); });
isWithinMaxWidth.should.be.true; isWithinMaxWidth.should.be.true;
}); });
}); });
});

View File

@@ -63,8 +63,8 @@ describe('Settings', function desc() {
existing.should.equal(expected); existing.should.equal(expected);
}); });
describe('MM-T4393_2 Save tray icon setting on mac', () => { describe('Save tray icon setting on mac', () => {
env.shouldTest(it, env.isOneOf(['darwin', 'linux']))('should be saved when it\'s selected', async () => { env.shouldTest(it, env.isOneOf(['darwin', 'linux']))('MM-T4393_2 should be saved when it\'s selected', async () => {
this.app.evaluate(({ipcMain}, showWindow) => { this.app.evaluate(({ipcMain}, showWindow) => {
ipcMain.emit(showWindow); ipcMain.emit(showWindow);
}, SHOW_SETTINGS_WINDOW); }, SHOW_SETTINGS_WINDOW);
@@ -88,8 +88,8 @@ describe('Settings', function desc() {
}); });
}); });
describe('MM-T4393_3 Save tray icon theme on linux', () => { describe('Save tray icon theme on linux', () => {
env.shouldTest(it, process.platform === 'linux')('should be saved when it\'s selected', async () => { env.shouldTest(it, process.platform === 'linux')('MM-T4393_3 should be saved when it\'s selected', async () => {
this.app.evaluate(({ipcMain}, showWindow) => { this.app.evaluate(({ipcMain}, showWindow) => {
ipcMain.emit(showWindow); ipcMain.emit(showWindow);
}, SHOW_SETTINGS_WINDOW); }, SHOW_SETTINGS_WINDOW);