[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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 {asyncSleep} = require('../../modules/utils');
describe('back_button', function desc() {
describe('MM-T2633 Back button should behave as expected', function desc() {
this.timeout(30000);
const config = {
@ -39,7 +39,11 @@ describe('back_button', function desc() {
],
};
beforeEach(async () => {
let mainWindow;
let firstServer;
let backButton;
before(async () => {
env.cleanDataDir();
env.createTestUserDataDir();
env.cleanTestConfig();
@ -47,49 +51,57 @@ describe('back_button', function desc() {
await asyncSleep(1000);
this.app = await env.getApp();
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) {
await this.app.close();
}
await env.clearElectronInstances();
});
it('MM-T2633 Back button should behave as expected', 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")');
it('MM-T2633_1 after clicking OneLogin, back button should appear', async () => {
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;
});
it('MM-T2633_2 after clicking Back, should be back on the login screen', async () => {
await backButton.click();
let loginPrompt = await firstServer.waitForSelector('#input_loginId');
const loginPrompt = await firstServer.waitForSelector('#input_loginId');
loginPrompt.should.not.be.null;
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;
this.app.on('window', () => {
isNewWindow = true;
});
const oneLoginUrl = firstServer.url();
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();
backButton = await mainWindow.waitForSelector('button:has-text("Back")');
backButton.should.not.be.null;
const frameUrl = firstServer.url();
frameUrl.should.not.equal(oneLoginUrl);
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 firstServer.waitForURL('https://mattermost.onelogin.com/**');
await backButton.click();
loginPrompt = await firstServer.waitForSelector('#input_loginId');
const loginPrompt = await firstServer.waitForSelector('#input_loginId');
loginPrompt.should.not.be.null;
});
});

View file

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

View file

@ -124,7 +124,7 @@ describe('menu/view', function desc() {
});
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 browserWindow = await this.app.browserWindow(mainWindow);
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);
});
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 browserWindow = await this.app.browserWindow(mainWindow);
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', () => {
it('MM-T819 Zoom out when CmdOrCtrl+Minus is pressed', async () => {
describe('MM-T819 Zoom out from the menu bar', () => {
it('MM-T819_1 Zoom out when CmdOrCtrl+Minus is pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow);
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);
});
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 browserWindow = await this.app.browserWindow(mainWindow);
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');
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();
});
});

View file

@ -53,16 +53,12 @@ describe('Add Server Modal', function desc() {
});
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');
const existing = await newServerView.isVisible('#teamNameInput.is-invalid');
existing.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;
const existingName = await newServerView.isVisible('#teamNameInput.is-invalid');
const existingUrl = await newServerView.isVisible('#teamUrlInput.is-invalid');
existingName.should.be.true;
existingUrl.should.be.true;
});
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');
});
it('MM-T4389_3 should not be marked invalid', async () => {
const existing = await newServerView.isVisible('#teamNameInput.is-invalid');
existing.should.be.false;
});
it('MM-T4389_4 should not be possible to click save', async () => {
it('MM-T4389_2 Name should not be marked invalid, URL should be marked invalid', async () => {
const existingName = await newServerView.isVisible('#teamNameInput.is-invalid');
const existingUrl = await newServerView.isVisible('#teamUrlInput.is-invalid');
const disabled = await newServerView.getAttribute('#saveNewServerModal', 'disabled');
existingName.should.be.false;
existingUrl.should.be.true;
(disabled === '').should.be.true;
});
});
@ -104,13 +99,12 @@ describe('Add Server Modal', function desc() {
await newServerView.click('#saveNewServerModal');
});
it('MM-T4389_5 should be valid', async () => {
const existing = await newServerView.isVisible('#teamUrlInput.is-invalid');
existing.should.be.false;
});
it('MM-T4389_6 should not be possible to click save', async () => {
it('MM-T4389_3 URL should not be marked invalid, name should be marked invalid', async () => {
const existingName = await newServerView.isVisible('#teamNameInput.is-invalid');
const existingUrl = await newServerView.isVisible('#teamUrlInput.is-invalid');
const disabled = await newServerView.getAttribute('#saveNewServerModal', 'disabled');
existingName.should.be.true;
existingUrl.should.be.false;
(disabled === '').should.be.true;
});
});

View file

@ -8,8 +8,6 @@ const env = require('../../modules/environment');
const {asyncSleep} = require('../../modules/utils');
describe('server_management/drag_and_drop', function desc() {
this.timeout(30000);
const config = {
...env.demoConfig,
teams: [
@ -40,107 +38,134 @@ describe('server_management/drag_and_drop', function desc() {
],
};
beforeEach(async () => {
const beforeFunc = async () => {
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();
};
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_2 after dragging the server down, should appear in the new order', async () => {
// Move the first server down, then re-open the dropdown
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('ArrowDown');
await dropdownView.keyboard.down(' ');
await asyncSleep(1000);
await mainWindow.keyboard.press('Escape');
await mainWindow.click('.TeamDropdownButton');
// Verify that the new order persists
const firstMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(1) .TeamDropdown__draggable-handle');
const firstMenuItemText = await firstMenuItem.innerText();
firstMenuItemText.should.equal('github');
const secondMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(2) .TeamDropdown__draggable-handle');
const secondMenuItemText = await secondMenuItem.innerText();
secondMenuItemText.should.equal('example');
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_3 should update the config file', () => {
// Verify config is updated
const newConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
const order0 = newConfig.teams.find((team) => team.name === 'github');
order0.order.should.equal(0);
const order1 = newConfig.teams.find((team) => team.name === 'example');
order1.order.should.equal(1);
const order2 = newConfig.teams.find((team) => team.name === 'google');
order2.order.should.equal(2);
});
});
it('MM-T2634 should be able to drag and drop servers in the dropdown menu', 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');
describe('MM-T2635 should be able to drag and drop tabs', async () => {
let mainWindow;
before(async () => {
await beforeFunc();
mainWindow = this.app.windows().find((window) => window.url().includes('index'));
});
after(afterFunc);
// 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');
it('MM-T2635_1 should be in the original order', async () => {
// Verify the original order
const firstTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(1)');
const firstTabText = await firstTab.innerText();
firstTabText.should.equal('Channels');
const secondTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(2)');
const secondTabText = await secondTab.innerText();
secondTabText.should.equal('Boards');
const thirdTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(3)');
const thirdTabText = await thirdTab.innerText();
thirdTabText.should.equal('Playbooks');
});
// Move the first server down, then re-open the dropdown
await firstMenuItem.focus();
await dropdownView.keyboard.down(' ');
await dropdownView.keyboard.down('ArrowDown');
await dropdownView.keyboard.down(' ');
await asyncSleep(1000);
await mainWindow.keyboard.press('Escape');
await mainWindow.click('.TeamDropdownButton');
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
let firstTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(1)');
await firstTab.focus();
await mainWindow.keyboard.down(' ');
await mainWindow.keyboard.down('ArrowRight');
await mainWindow.keyboard.down(' ');
await asyncSleep(1000);
// Verify that the new order persists
firstMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(1) .TeamDropdown__draggable-handle');
firstMenuItemText = await firstMenuItem.innerText();
firstMenuItemText.should.equal('github');
secondMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(2) .TeamDropdown__draggable-handle');
secondMenuItemText = await secondMenuItem.innerText();
secondMenuItemText.should.equal('example');
thirdMenuItem = await dropdownView.waitForSelector('.TeamDropdown button.TeamDropdown__button:nth-child(3) .TeamDropdown__draggable-handle');
thirdMenuItemText = await thirdMenuItem.innerText();
thirdMenuItemText.should.equal('google');
// Verify that the new order is visible
firstTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(1)');
const firstTabText = await firstTab.innerText();
firstTabText.should.equal('Boards');
const secondTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(2)');
const secondTabText = await secondTab.innerText();
secondTabText.should.equal('Channels');
const thirdTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(3)');
const thirdTabText = await thirdTab.innerText();
thirdTabText.should.equal('Playbooks');
});
// Verify config is updated
const newConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
const order0 = newConfig.teams.find((team) => team.name === 'github');
order0.order.should.equal(0);
const order1 = newConfig.teams.find((team) => team.name === 'example');
order1.order.should.equal(1);
const order2 = newConfig.teams.find((team) => team.name === 'google');
order2.order.should.equal(2);
});
it('MM-T2635 should be able to drag and drop tabs', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
// Verify the original order
let firstTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(1)');
let firstTabText = await firstTab.innerText();
firstTabText.should.equal('Channels');
let secondTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(2)');
let secondTabText = await secondTab.innerText();
secondTabText.should.equal('Boards');
let thirdTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(3)');
let thirdTabText = await thirdTab.innerText();
thirdTabText.should.equal('Playbooks');
// Move the first tab to the right
await firstTab.focus();
await mainWindow.keyboard.down(' ');
await mainWindow.keyboard.down('ArrowRight');
await mainWindow.keyboard.down(' ');
await asyncSleep(1000);
// Verify that the new order is visible
firstTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(1)');
firstTabText = await firstTab.innerText();
firstTabText.should.equal('Boards');
secondTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(2)');
secondTabText = await secondTab.innerText();
secondTabText.should.equal('Channels');
thirdTab = await mainWindow.waitForSelector('.TabBar li.teamTabItem:nth-child(3)');
thirdTabText = await thirdTab.innerText();
thirdTabText.should.equal('Playbooks');
// Verify config is updated
const newConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
const firstTeam = newConfig.teams.find((team) => team.name === 'example');
const order0 = firstTeam.tabs.find((tab) => tab.name === 'TAB_FOCALBOARD');
order0.order.should.equal(0);
const order1 = firstTeam.tabs.find((tab) => tab.name === 'TAB_MESSAGING');
order1.order.should.equal(1);
const order2 = firstTeam.tabs.find((tab) => tab.name === 'TAB_PLAYBOOKS');
order2.order.should.equal(2);
it('MM-T2635_3 should update the config file', () => {
// Verify config is updated
const newConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
const firstTeam = newConfig.teams.find((team) => team.name === 'example');
const order0 = firstTeam.tabs.find((tab) => tab.name === 'TAB_FOCALBOARD');
order0.order.should.equal(0);
const order1 = firstTeam.tabs.find((tab) => tab.name === 'TAB_MESSAGING');
order1.order.should.equal(1);
const order2 = firstTeam.tabs.find((tab) => tab.name === 'TAB_PLAYBOOKS');
order2.order.should.equal(2);
});
});
});

View file

@ -11,38 +11,47 @@ const {asyncSleep} = require('../../modules/utils');
describe('header', function desc() {
this.timeout(30000);
beforeEach(async () => {
env.createTestUserDataDir();
env.cleanTestConfig();
});
describe('MM-T2637 Double-Clicking on the header should minimize/maximize the app', async () => {
let header;
let browserWindow;
let initialBounds;
afterEach(async () => {
if (this.app) {
try {
await this.app.close();
// eslint-disable-next-line no-empty
} catch (err) {}
}
await env.clearElectronInstances();
});
before(async () => {
env.createTestUserDataDir();
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');
});
it('MM-T2637 Double-Clicking on the header should minimize/maximize the app', 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();
await header.dblclick({position: {x: headerBounds.width / 2, y: headerBounds.y / 2}});
await asyncSleep(1000);
const isMaximized = await browserWindow.evaluate((window) => window.isMaximized());
isMaximized.should.be.equal(true);
const maximizedHeaderBounds = await header.boundingBox();
await header.dblclick({position: {x: maximizedHeaderBounds.width / 2, y: maximizedHeaderBounds.y / 2}});
await asyncSleep(1000);
const revertedBounds = await browserWindow.evaluate((window) => window.getContentBounds());
revertedBounds.height.should.be.equal(initialBounds.height);
revertedBounds.width.should.be.equal(initialBounds.width);
after(async () => {
if (this.app) {
try {
await this.app.close();
// eslint-disable-next-line no-empty
} catch (err) {}
}
await env.clearElectronInstances();
});
it('MM-T2637_1 should maximize on double-clicking the header', async () => {
const headerBounds = await header.boundingBox();
await header.dblclick({position: {x: headerBounds.width / 2, y: headerBounds.y / 2}});
await asyncSleep(1000);
const isMaximized = await browserWindow.evaluate((window) => window.isMaximized());
isMaximized.should.be.equal(true);
});
it('MM-T2637_2 should restore on double-clicking the header when maximized', async () => {
const maximizedHeaderBounds = await header.boundingBox();
await header.dblclick({position: {x: maximizedHeaderBounds.width / 2, y: maximizedHeaderBounds.y / 2}});
await asyncSleep(1000);
const revertedBounds = await browserWindow.evaluate((window) => window.getContentBounds());
revertedBounds.height.should.be.equal(initialBounds.height);
revertedBounds.width.should.be.equal(initialBounds.width);
});
});
});

View file

@ -43,58 +43,35 @@ describe('LongServerName', function desc() {
let newServerView;
describe('MM-T4050 Long server name', () => {
beforeEach(async () => {
await newServerView.type('#teamNameInput', longServerName);
await newServerView.type('#teamUrlInput', longServerUrl);
await newServerView.click('#saveNewServerModal');
it('MM-T4050 Long server name', async () => {
await newServerView.type('#teamNameInput', longServerName);
await newServerView.type('#teamUrlInput', longServerUrl);
await newServerView.click('#saveNewServerModal');
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 dropdownView = this.app.windows().find((window) => window.url().includes('dropdown'));
const isServerTabExists = Boolean(await mainView.locator(`text=${longServerName}`));
const isServerAddedDropdown = Boolean(await dropdownView.locator(`text=${longServerName}`));
isServerTabExists.should.be.true;
isServerAddedDropdown.should.be.true;
const serverNameLocator = await mainView.locator(`text=${longServerName}`);
const isTruncated = await serverNameLocator.evaluate((element) => {
return element.offsetWidth < element.scrollWidth;
});
isTruncated.should.be.true;
it('MM-T4050_1 should add new server tab', async () => {
await asyncSleep(1000);
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('newServer')));
existing.should.be.false;
const isWithinMaxWidth = await serverNameLocator.evaluate((element) => {
const width = parseFloat(window.getComputedStyle(element).getPropertyValue('width'));
const mainView = this.app.windows().find((window) => window.url().includes('index'));
const dropdownView = this.app.windows().find((window) => window.url().includes('dropdown'));
const isServerTabExists = Boolean(await mainView.locator(`text=${longServerName}`));
const isServerAddedDropdown = Boolean(await dropdownView.locator(`text=${longServerName}`));
isServerTabExists.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 isTruncated = await serverNameLocator.evaluate((element) => {
return element.offsetWidth < element.scrollWidth;
});
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 width = parseFloat(window.getComputedStyle(element).getPropertyValue('width'));
return width <= 400;
});
isWithinMaxWidth.should.be.true;
return width <= 400;
});
isWithinMaxWidth.should.be.true;
});
});

View file

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