E2E test fixups (#2045)

* Reinstall reporter and re-enable skipped tests

* Fixups for Linux

* Mac fixes

* Windows fixes

* Use keyboard shortcuts instead of menu for most menu actions

* Couple fixes

* One more fix for now

* Windows fixes

* Lint fixes

* Change up developer tools tests to be more consistent

* Fix key for mac

* Couple fixes for flaky tests/to avoid crashes on unload
This commit is contained in:
Devin Binnie
2022-04-19 09:56:41 -04:00
committed by GitHub
parent ce2ddb6a6a
commit 1c44c8527a
19 changed files with 323 additions and 491 deletions

View File

@@ -105,6 +105,8 @@ const demoMattermostConfig = {
}, githubTeam], }, githubTeam],
}; };
const cmdOrCtrl = process.platform === 'darwin' ? 'command' : 'control';
module.exports = { module.exports = {
sourceRootDir, sourceRootDir,
configFilePath, configFilePath,
@@ -114,6 +116,7 @@ module.exports = {
mattermostURL, mattermostURL,
demoConfig, demoConfig,
demoMattermostConfig, demoMattermostConfig,
cmdOrCtrl,
cleanTestConfig() { cleanTestConfig() {
[configFilePath, boundsInfoPath].forEach((file) => { [configFilePath, boundsInfoPath].forEach((file) => {

View File

@@ -33,15 +33,14 @@ describe('application', function desc() {
it('MM-T1304/MM-T1306 should open the app on the requested deep link', async () => { it('MM-T1304/MM-T1306 should open the app on the requested deep link', async () => {
this.app = await env.getApp(['mattermost://github.com/test/url']); this.app = await env.getApp(['mattermost://github.com/test/url']);
this.serverMap = await env.getServerMap(this.app); this.serverMap = await env.getServerMap(this.app);
const mainWindow = await this.app.firstWindow(); 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 webContentsId = this.serverMap[`${config.teams[1].name}___TAB_MESSAGING`].webContentsId; const webContentsId = this.serverMap[`${config.teams[1].name}___TAB_MESSAGING`].webContentsId;
const isActive = await browserWindow.evaluate((window, id) => { const isActive = await browserWindow.evaluate((window, id) => {
return window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getURL(); return window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getURL();
}, webContentsId); }, webContentsId);
isActive.should.equal('https://github.com/test/url'); isActive.should.equal('https://github.com/test/url');
const mainView = this.app.windows().find((window) => window.url().includes('index')); const dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
const dropdownButtonText = await mainView.innerText('.TeamDropdownButton');
dropdownButtonText.should.equal('github'); dropdownButtonText.should.equal('github');
await this.app.close(); await this.app.close();
}); });

View File

@@ -30,7 +30,7 @@ describe('dark_mode', function desc() {
} }
}); });
if (process.platform !== 'darwin') { if (process.platform === 'linux') {
it('MM-T2465 Linux Dark Mode Toggle', async () => { it('MM-T2465 Linux Dark Mode Toggle', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
mainWindow.should.not.be.null; mainWindow.should.not.be.null;

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('Menu/window_menu', function desc() { describe('back_button', function desc() {
this.timeout(30000); this.timeout(30000);
const config = { const config = {

View File

@@ -44,6 +44,6 @@ describe('copylink', function desc() {
const clipboardText = clipboard.readText(); const clipboardText = clipboard.readText();
await firstServer.fill('#post_textbox', clipboardText); await firstServer.fill('#post_textbox', clipboardText);
const content = await firstServer.locator('#post_textbox').textContent(); const content = await firstServer.locator('#post_textbox').textContent();
content.should.be.equal('/ad-1/channels/suscipit-4'); content.should.contain('/ad-1/channels/suscipit-4');
}); });
}); });

View File

@@ -38,18 +38,17 @@ describe('menu_bar/dropdown', function desc() {
}); });
it('MM-T4406 should only show dropdown when button is clicked', async () => { it('MM-T4406 should only show dropdown when button is clicked', async () => {
const mainWindow = await this.app.firstWindow(); 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 mainView = this.app.windows().find((window) => window.url().includes('index'));
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 mainView.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);
await mainView.click('.TabBar'); await mainWindow.click('.TabBar');
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.equal(0); dropdownHeight.should.equal(0);
}); });
@@ -68,7 +67,7 @@ describe('menu_bar/dropdown', function desc() {
}); });
it('MM-T4408 should show only the selected team', async () => { it('MM-T4408 should show only the selected team', async () => {
const mainWindow = await this.app.firstWindow(); 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);
let firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === url)), env.exampleURL); let firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === url)), env.exampleURL);
@@ -76,9 +75,8 @@ describe('menu_bar/dropdown', function desc() {
let secondViewIsAttached = await browserWindow.evaluate((window) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === 'https://github.com/'))); let 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 mainView = 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 mainView.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); firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === url)), env.exampleURL);

View File

@@ -31,147 +31,111 @@ describe('edit_menu', function desc() {
}); });
it('MM-T807 Undo in the Menu Bar', async () => { it('MM-T807 Undo in the Menu Bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') { const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); await env.loginToMattermost(firstServer);
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; await firstServer.waitForSelector('#sidebarItem_suscipit-4');
await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
// click on sint channel // click on sint channel
await firstServer.click('#sidebarItem_suscipit-4'); await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost'); await firstServer.type('#post_textbox', 'Mattermost');
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
await mainWindow.click('button.three-dot-menu'); robot.keyTap('z', [env.cmdOrCtrl]);
robot.keyTap('e'); await asyncSleep(500);
robot.keyTap('u'); const content = await firstServer.inputValue('#post_textbox');
const content = await firstServer.inputValue('#post_textbox'); content.should.be.equal('Mattermos');
content.should.be.equal('Mattermos');
}
}); });
it('MM-T808 Redo in the Menu Bar', async () => { it('MM-T808 Redo in the Menu Bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') { const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); await env.loginToMattermost(firstServer);
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; await firstServer.waitForSelector('#sidebarItem_suscipit-4');
await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
// click on sint channel // click on sint channel
await firstServer.click('#sidebarItem_suscipit-4'); await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost'); await firstServer.type('#post_textbox', 'Mattermost');
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
await mainWindow.click('button.three-dot-menu'); robot.keyTap('z', [env.cmdOrCtrl]);
robot.keyTap('e'); await asyncSleep(500);
robot.keyTap('u'); const textAfterUndo = await firstServer.inputValue('#post_textbox');
const textAfterUndo = await firstServer.inputValue('#post_textbox'); textAfterUndo.should.be.equal('Mattermos');
textAfterUndo.should.be.equal('Mattermos'); await firstServer.click('#post_textbox');
await firstServer.click('#post_textbox'); robot.keyTap('z', ['shift', env.cmdOrCtrl]);
await mainWindow.click('button.three-dot-menu'); await asyncSleep(500);
robot.keyTap('e'); const content = await firstServer.inputValue('#post_textbox');
robot.keyTap('r'); content.should.be.equal('Mattermost');
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('Mattermost');
}
}); });
it('MM-T809 Cut in the Menu Bar', async () => { it('MM-T809 Cut in the Menu Bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') { const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); await env.loginToMattermost(firstServer);
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; await firstServer.waitForSelector('#sidebarItem_suscipit-4');
await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
// click on sint channel // click on sint channel
await firstServer.click('#sidebarItem_suscipit-4'); await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost'); await firstServer.type('#post_textbox', 'Mattermost');
await mainWindow.click('button.three-dot-menu'); robot.keyTap('a', [env.cmdOrCtrl]);
robot.keyTap('e'); await asyncSleep(500);
robot.keyTap('s'); robot.keyTap('x', [env.cmdOrCtrl]);
await mainWindow.click('button.three-dot-menu'); await asyncSleep(500);
robot.keyTap('e'); const content = await firstServer.inputValue('#post_textbox');
robot.keyTap('c'); content.should.be.equal('');
robot.keyTap('enter');
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('');
}
}); });
it('MM-T810 Copy in the Menu Bar', async () => { it('MM-T810 Copy in the Menu Bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') { const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); await env.loginToMattermost(firstServer);
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; await firstServer.waitForSelector('#sidebarItem_suscipit-4');
await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
// click on sint channel // click on sint channel
await firstServer.click('#sidebarItem_suscipit-4'); await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost'); await firstServer.type('#post_textbox', 'Mattermost');
await mainWindow.click('button.three-dot-menu'); robot.keyTap('a', [env.cmdOrCtrl]);
robot.keyTap('e'); await asyncSleep(500);
robot.keyTap('s'); robot.keyTap('c', [env.cmdOrCtrl]);
await mainWindow.click('button.three-dot-menu'); await asyncSleep(500);
robot.keyTap('e'); await firstServer.click('#post_textbox');
robot.keyTap('c'); robot.keyTap('v', [env.cmdOrCtrl]);
robot.keyTap('c'); await asyncSleep(500);
robot.keyTap('enter'); const content = await firstServer.inputValue('#post_textbox');
await firstServer.click('#post_textbox'); content.should.be.equal('MattermostMattermost');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('p');
robot.keyTap('enter');
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('MattermostMattermost');
}
}); });
it('MM-T811 Paste in the Menu Bar', async () => { it('MM-T811 Paste in the Menu Bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') { const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); await env.loginToMattermost(firstServer);
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; await firstServer.waitForSelector('#sidebarItem_suscipit-4');
await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
// click on sint channel // click on sint channel
await firstServer.click('#sidebarItem_suscipit-4'); await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost'); await firstServer.type('#post_textbox', 'Mattermost');
await mainWindow.click('button.three-dot-menu'); robot.keyTap('a', [env.cmdOrCtrl]);
robot.keyTap('e'); await asyncSleep(500);
robot.keyTap('s'); robot.keyTap('c', [env.cmdOrCtrl]);
await mainWindow.click('button.three-dot-menu'); await asyncSleep(500);
robot.keyTap('e'); robot.keyTap('a', [env.cmdOrCtrl]);
robot.keyTap('c'); await asyncSleep(500);
robot.keyTap('c'); robot.keyTap('v', [env.cmdOrCtrl]);
robot.keyTap('enter'); await asyncSleep(500);
await mainWindow.click('button.three-dot-menu'); const content = await firstServer.inputValue('#post_textbox');
robot.keyTap('e'); content.should.be.equal('Mattermost');
robot.keyTap('s');
robot.keyTap('backspace');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('p');
robot.keyTap('enter');
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('Mattermost');
}
}); });
it('MM-T812 Select All in the Menu Bar', async () => { it('MM-T812 Select All in the Menu Bar', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
@@ -182,9 +146,8 @@ describe('edit_menu', function desc() {
await firstServer.click('#sidebarItem_suscipit-4'); await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
await firstServer.fill('#post_textbox', 'Mattermost'); await firstServer.fill('#post_textbox', 'Mattermost');
await mainWindow.click('button.three-dot-menu'); robot.keyTap('a', [env.cmdOrCtrl]);
robot.keyTap('e'); await asyncSleep(500);
robot.keyTap('s');
const channelHeaderText = await firstServer.evaluate('window.getSelection().toString()'); const channelHeaderText = await firstServer.evaluate('window.getSelection().toString()');
channelHeaderText.should.equal('Mattermost'); channelHeaderText.should.equal('Mattermost');
}); });

View File

@@ -35,17 +35,16 @@ describe('file_menu/dropdown', function desc() {
it('MM-T1313 Open Settings modal using keyboard shortcuts', async () => { it('MM-T1313 Open Settings modal using keyboard shortcuts', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
mainWindow.should.not.be.null; mainWindow.should.not.be.null;
if (process.platform === 'win32' || process.platform === 'linux') { robot.keyTap(',', [env.cmdOrCtrl]);
robot.keyTap(',', ['control']); const settingsWindow = await this.app.waitForEvent('window', {
const settingsWindow = await this.app.waitForEvent('window', { predicate: (window) => window.url().includes('settings'),
predicate: (window) => window.url().includes('settings'), });
}); settingsWindow.should.not.be.null;
settingsWindow.should.not.be.null;
}
}); });
it('MM-T805 Sign in to Another Server Window opens using menu item', async () => { // TODO: No keyboard shortcut for macOS
if (process.platform === 'win32' || process.platform === 'linux') { if (process.platform !== 'darwin') {
it('MM-T805 Sign in to Another Server Window opens using menu item', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
mainWindow.should.not.be.null; mainWindow.should.not.be.null;
await mainWindow.click('button.three-dot-menu'); await mainWindow.click('button.three-dot-menu');
@@ -57,19 +56,20 @@ describe('file_menu/dropdown', function desc() {
predicate: (window) => window.url().includes('newServer'), predicate: (window) => window.url().includes('newServer'),
}); });
signInToAnotherServerWindow.should.not.be.null; signInToAnotherServerWindow.should.not.be.null;
} });
}); }
it('MM-T804 Preferences in Menu Bar open the Settings page', async () => { it('MM-T804 Preferences in Menu Bar open the Settings page', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
mainWindow.should.not.be.null;
robot.keyTap(',', [env.cmdOrCtrl]);
const settingsWindow = await this.app.waitForEvent('window', {
predicate: (window) => window.url().includes('settings'),
});
settingsWindow.should.not.be.null;
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); robot.keyTap('w', [env.cmdOrCtrl]);
mainWindow.should.not.be.null;
robot.keyTap(',', ['control']);
const settingsWindow = await this.app.waitForEvent('window', {
predicate: (window) => window.url().includes('settings'),
});
settingsWindow.should.not.be.null;
robot.keyTap('w', ['control']);
//Opening the menu bar //Opening the menu bar
robot.keyTap('alt'); robot.keyTap('alt');
@@ -84,20 +84,23 @@ describe('file_menu/dropdown', function desc() {
} }
}); });
it('MM-T806 Exit in the Menu Bar', () => { // TODO: Causes issues on Windows so skipping for Windows
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); if (process.platform !== 'win32') {
mainWindow.should.not.be.null; it('MM-T806 Exit in the Menu Bar', () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
mainWindow.should.not.be.null;
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
robot.keyTap('q', ['command']); robot.keyTap('q', ['command']);
} }
if (process.platform === 'linux' || process.platform === 'win32') { if (process.platform === 'linux' || process.platform === 'win32') {
robot.keyTap('q', ['control']); robot.keyTap('q', ['control']);
} }
this.app.windows().find((window) => window.url().should.not.include('index')); this.app.windows().find((window) => window.url().should.not.include('index'));
skipAfterEach = true; // Need to skip closing in aftereach as apps execution context is destroyed above skipAfterEach = true; // Need to skip closing in aftereach as apps execution context is destroyed above
}); });
}
}); });

View File

@@ -21,7 +21,6 @@ describe('menu/menu', function desc() {
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();
this.serverMap = await env.getServerMap(this.app);
}); });
afterEach(async () => { afterEach(async () => {
@@ -31,7 +30,7 @@ describe('menu/menu', function desc() {
}); });
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
it.skip('MM-T4404 should open the 3 dot menu with Alt', async () => { it('MM-T4404 should open the 3 dot menu with Alt', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
mainWindow.should.not.be.null; mainWindow.should.not.be.null;

View File

@@ -20,57 +20,8 @@ async function setupPromise(window, id) {
return true; return true;
} }
function robotTextInput(txt) {
for (let i = 0; i < txt.length; i++) {
robot.keyTap(txt[i]);
}
}
function robotKeyTaps(n, ...params) {
for (let i = 0; i < n; i++) {
robot.keyTap(...params);
}
}
function openDevToolsCommandPalette() {
const modifierKeys = process.platform === 'darwin' ? ['command'] : ['control'];
robotKeyTaps(1, 'p', [...modifierKeys, 'shift']);
}
async function openDevToolsConsoleTab() {
openDevToolsCommandPalette();
await asyncSleep(1500);
robotTextInput('con', 1200); // search for console command
await asyncSleep(500);
robotKeyTaps(1, 'enter');
}
async function clickThreeDotMenu(app) {
const mainWindow = app.windows().find((window) => window.url().includes('index'));
await mainWindow.click('button.three-dot-menu');
}
async function windowEventPromise(app) {
return new Promise((res) => {
app.on('window', (window) => {
res(window);
});
});
}
function windowsDialogEventPromises(app, limit) {
return app.windows().map((window) => {
return new Promise((res, rej) => {
window.on('dialog', (e) => {
res(e);
});
setTimeout(rej, limit);
});
});
}
describe('menu/view', function desc() { describe('menu/view', function desc() {
this.timeout(60000); this.timeout(30000);
const config = env.demoMattermostConfig; const config = env.demoMattermostConfig;
@@ -96,6 +47,7 @@ describe('menu/view', function desc() {
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#searchBox'); await firstServer.waitForSelector('#searchBox');
await asyncSleep(1000);
robot.keyTap('f', [process.platform === 'darwin' ? 'command' : 'control']); robot.keyTap('f', [process.platform === 'darwin' ? 'command' : 'control']);
await asyncSleep(500); await asyncSleep(500);
const isFocused = await firstServer.$eval('#searchBox', (el) => el === document.activeElement); const isFocused = await firstServer.$eval('#searchBox', (el) => el === document.activeElement);
@@ -104,8 +56,9 @@ describe('menu/view', function desc() {
text.should.include('in:'); text.should.include('in:');
}); });
it.skip('MM-T816 Toggle Full Screen in the Menu Bar', async () => { // TODO: No keyboard shortcut for macOS
if (process.platform === 'win32' || process.platform === 'linux') { if (process.platform !== 'darwin') {
it('MM-T816 Toggle Full Screen in the Menu Bar', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
@@ -132,54 +85,61 @@ describe('menu/view', function desc() {
currentHeight = await firstServer.evaluate('window.outerHeight'); currentHeight = await firstServer.evaluate('window.outerHeight');
currentWidth.should.be.lessThan(fullScreenWidth); currentWidth.should.be.lessThan(fullScreenWidth);
currentHeight.should.be.lessThan(fullScreenHeight); currentHeight.should.be.lessThan(fullScreenHeight);
} });
}); }
it('MM-T817 Actual Size Zoom in the menu bar', async () => { it('MM-T817 Actual Size Zoom in the menu bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') { 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);
mainWindow.should.not.be.null; const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await mainWindow.click('button.three-dot-menu'); await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
robot.keyTap('v'); const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
robot.keyTap('a'); const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
const zoomLevel = await mainWindow.evaluate('window.devicePixelRatio'); await env.loginToMattermost(firstServer);
zoomLevel.should.be.equal(1); await firstServer.waitForSelector('#searchBox');
}
robot.keyTap('=', [env.cmdOrCtrl]);
await asyncSleep(1000);
console.log(firstServerId);
let zoomLevel = await browserWindow.evaluate((window, id) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
zoomLevel.should.be.greaterThan(1);
robot.keyTap('0', [env.cmdOrCtrl]);
await asyncSleep(1000);
zoomLevel = await browserWindow.evaluate((window, id) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
zoomLevel.should.be.equal(1);
}); });
it('MM-T818 Zoom in from the menu bar', async () => { it('MM-T818 Zoom in from the menu bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') { 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 loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer); const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
await firstServer.waitForSelector('#searchBox'); await env.loginToMattermost(firstServer);
await mainWindow.click('button.three-dot-menu'); await firstServer.waitForSelector('#searchBox');
robot.keyTap('v');
robot.keyTap('z'); robot.keyTap('=', [env.cmdOrCtrl]);
robot.keyTap('enter'); await asyncSleep(1000);
const zoomLevel = await firstServer.evaluate('window.devicePixelRatio'); const zoomLevel = await browserWindow.evaluate((window, id) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
zoomLevel.should.be.greaterThan(1); zoomLevel.should.be.greaterThan(1);
}
}); });
it('MM-T819 Zoom out from the menu bar', async () => { it('MM-T819 Zoom out from the menu bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') { 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 loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer); const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
await firstServer.waitForSelector('#searchBox'); await env.loginToMattermost(firstServer);
await mainWindow.click('button.three-dot-menu'); await firstServer.waitForSelector('#searchBox');
robot.keyTap('v');
robot.keyTap('z'); robot.keyTap('-', [env.cmdOrCtrl]);
robot.keyTap('z'); await asyncSleep(1000);
robot.keyTap('enter'); const zoomLevel = await browserWindow.evaluate((window, id) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
const zoomLevel = await firstServer.evaluate('window.devicePixelRatio'); zoomLevel.should.be.lessThan(1);
zoomLevel.should.be.lessThan(1);
}
}); });
describe('Reload', () => { describe('Reload', () => {
@@ -187,7 +147,7 @@ describe('menu/view', function desc() {
let webContentsId; let webContentsId;
beforeEach(async () => { beforeEach(async () => {
const mainWindow = await this.app.firstWindow(); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
browserWindow = await this.app.browserWindow(mainWindow); browserWindow = await this.app.browserWindow(mainWindow);
webContentsId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId; webContentsId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
@@ -198,7 +158,7 @@ describe('menu/view', function desc() {
it('MM-T814 should reload page when pressing Ctrl+R', async () => { it('MM-T814 should reload page when pressing Ctrl+R', async () => {
const check = browserWindow.evaluate(setupPromise, webContentsId); const check = browserWindow.evaluate(setupPromise, webContentsId);
await asyncSleep(500); await asyncSleep(500);
robot.keyTap('r', ['control']); robot.keyTap('r', [env.cmdOrCtrl]);
const result = await check; const result = await check;
result.should.be.true; result.should.be.true;
}); });
@@ -206,156 +166,59 @@ describe('menu/view', function desc() {
it('MM-T815 should reload page when pressing Ctrl+Shift+R', async () => { it('MM-T815 should reload page when pressing Ctrl+Shift+R', async () => {
const check = browserWindow.evaluate(setupPromise, webContentsId); const check = browserWindow.evaluate(setupPromise, webContentsId);
await asyncSleep(500); await asyncSleep(500);
robot.keyTap('r', ['control', 'shift']); robot.keyTap('r', [env.cmdOrCtrl, 'shift']);
const result = await check; const result = await check;
result.should.be.true; result.should.be.true;
}); });
}); });
describe('Toggle DevTools', () => { it('MM-T820 should open Developer Tools For Application Wrapper for main window', async () => {
const CharPerMin = 600; const mainWindow = this.app.windows().find((window) => window.url().includes('loadingScreen'));
const DelayBetweenInputs = 500; // ms const browserWindow = await this.app.browserWindow(mainWindow);
const DevToolsLoadTime = 7000; // ms const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
const DevToolsLoadTimeBuffer = 10000; // ms await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const MaxDialogEventWaitTime = 6000; // ms
beforeEach(async () => { let isDevToolsOpen = await browserWindow.evaluate((window) => {
return window.webContents.isDevToolsOpened();
});
isDevToolsOpen.should.be.false;
robot.keyTap('i', process.platform === 'darwin' ? ['command', 'alt'] : ['control', 'shift']);
await asyncSleep(1000);
isDevToolsOpen = await browserWindow.evaluate((window) => {
return window.webContents.isDevToolsOpened();
});
isDevToolsOpen.should.be.true;
});
// TODO: Missing shortcut for macOS
if (process.platform !== 'darwin') {
it('MM-T821 should open Developer Tools For Current Server for the active tab', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('loadingScreen'));
const browserWindow = await this.app.browserWindow(mainWindow);
const webContentsId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen')); const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'}); await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
let isDevToolsOpen = await browserWindow.evaluate((window, id) => {
return window.getBrowserViews().find((view) => view.webContents.id === id).webContents.isDevToolsOpened();
}, webContentsId);
isDevToolsOpen.should.be.false;
// Open Developer Tools for Current Server
robot.keyTap('alt');
robot.keyTap('enter');
robot.keyTap('v');
robot.keyTap('d');
robot.keyTap('d');
robot.keyTap('enter');
await asyncSleep(1000);
isDevToolsOpen = await browserWindow.evaluate((window, id) => {
return window.getBrowserViews().find((view) => view.webContents.id === id).webContents.isDevToolsOpened();
}, webContentsId);
isDevToolsOpen.should.be.true;
}); });
}
it('MM-T820 should open dev tools for Application Wrapper when pressing keyboard shortcuts', async () => {
const macModifierKeys = ['command', 'alt'];
const winModifierKeys = ['shift', 'control'];
const windowLoaded = windowEventPromise(this.app);
robotKeyTaps(1, 'i', process.platform === 'darwin' ? macModifierKeys : winModifierKeys);
const window = await windowLoaded;
const windowTitle = await window.title();
const isWindowTitleDevTools = windowTitle === 'DevTools';
isWindowTitleDevTools.should.be.true;
});
it.skip('MM-T820 dev tools opened through keyboard shortcuts should point to index.html', async () => {
const macModifierKeys = ['command', 'alt'];
const winModifierKeys = ['shift', 'control'];
robotKeyTaps(1, 'i', process.platform === 'darwin' ? macModifierKeys : winModifierKeys);
// check the url
await asyncSleep(DevToolsLoadTime);
await openDevToolsConsoleTab();
const allWindowsDialogEventListener = windowsDialogEventPromises(this.app, MaxDialogEventWaitTime);
await asyncSleep(DelayBetweenInputs);
robot.typeStringDelayed('alert (window?.location?.href)', CharPerMin);
await asyncSleep(DelayBetweenInputs);
robotKeyTaps(1, 'enter');
const windowAlertDialog = await Promise.any(allWindowsDialogEventListener);
const alertMsg = windowAlertDialog?.message();
const devToolsPointsToIndexHtml = alertMsg.endsWith('index.html');
devToolsPointsToIndexHtml.should.be.true;
});
it('MM-T820 should open dev tools for Application Wrapper through menu, View > Developer Tools for Application Wrapper', async () => {
const windowLoaded = windowEventPromise(this.app);
if (process.platform === 'darwin') {
robotKeyTaps(1, 'f2', ['control']);
robotKeyTaps(3, 'right');
robotKeyTaps(1, 'enter');
robotKeyTaps(2, 'up');
robotKeyTaps(1, 'enter');
} else {
await clickThreeDotMenu(this.app);
robotKeyTaps(3, 'down');
robotKeyTaps(1, 'right');
robotKeyTaps(2, 'up');
robotKeyTaps(2, 'enter');
}
const window = await windowLoaded;
const windowTitle = await window.title();
const isWindowTitleDevTools = windowTitle === 'DevTools';
isWindowTitleDevTools.should.be.true;
});
it.skip('MM-T820 dev tools opened through menu, should point to index.html', async () => {
if (process.platform === 'darwin') {
robotKeyTaps(1, 'f2', ['control']);
robotKeyTaps(3, 'right');
robotKeyTaps(1, 'enter');
robotKeyTaps(2, 'up');
robotKeyTaps(1, 'enter');
} else {
await clickThreeDotMenu(this.app);
robotKeyTaps(3, 'down');
robotKeyTaps(1, 'right');
robotKeyTaps(2, 'up');
robotKeyTaps(2, 'enter');
}
// check the url
await asyncSleep(DevToolsLoadTime);
await openDevToolsConsoleTab();
const allWindowsDialogEventListener = windowsDialogEventPromises(this.app, MaxDialogEventWaitTime);
await asyncSleep(DelayBetweenInputs);
robot.typeStringDelayed('alert (window?.location?.href)', CharPerMin);
await asyncSleep(DelayBetweenInputs);
robotKeyTaps(1, 'enter');
const windowAlertDialog = await Promise.any(allWindowsDialogEventListener);
const alertMsg = windowAlertDialog?.message();
const devToolsPointsToIndexHtml = alertMsg.endsWith('index.html');
devToolsPointsToIndexHtml.should.be.true;
});
it('MM-T821 should open dev tools for Current Server through menu, View > Developer Tools for Current Server', async () => {
const windowLoaded = windowEventPromise(this.app);
if (process.platform === 'darwin') {
robotKeyTaps(1, 'f2', ['control']);
robotKeyTaps(3, 'right');
robotKeyTaps(1, 'enter');
robotKeyTaps(1, 'up');
robotKeyTaps(1, 'enter');
} else {
await clickThreeDotMenu(this.app);
robotKeyTaps(3, 'down');
robotKeyTaps(1, 'right');
robotKeyTaps(1, 'up');
robotKeyTaps(1, 'enter');
}
const window = await windowLoaded;
const windowTitle = await window.title();
const isWindowTitleDevTools = windowTitle === 'DevTools';
isWindowTitleDevTools.should.be.true;
});
it.skip('MM-T821 dev tools should point to localhost:8065 ', async () => {
// check the url
await asyncSleep(DevToolsLoadTimeBuffer);
await openDevToolsConsoleTab();
const allWindowsDialogEventListener = windowsDialogEventPromises(this.app, MaxDialogEventWaitTime);
await asyncSleep(DelayBetweenInputs);
robot.typeStringDelayed('alert (window?.location?.href)', CharPerMin);
await asyncSleep(DelayBetweenInputs);
robotKeyTaps(1, 'enter');
const windowAlertDialog = await Promise.any(allWindowsDialogEventListener);
const alertMsg = windowAlertDialog?.message();
const devToolsPointsToIndexHtml = alertMsg.endsWith('index.html');
devToolsPointsToIndexHtml.should.be.false;
const devToolsPointsToCurrentServer = alertMsg.includes('localhost:8065');
devToolsPointsToCurrentServer.should.be.true;
});
});
}); });

View File

@@ -40,6 +40,8 @@ describe('Menu/window_menu', function desc() {
lastActiveTab: 0, lastActiveTab: 0,
}, },
], ],
minimizeToTray: true,
alwaysMinimize: true,
}; };
beforeEach(async () => { beforeEach(async () => {
@@ -64,16 +66,16 @@ describe('Menu/window_menu', function desc() {
let dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton'); let dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
dropdownButtonText.should.equal('example'); dropdownButtonText.should.equal('example');
robot.keyTap('2', ['control', 'shift']); robot.keyTap('2', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton'); dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("github")');
dropdownButtonText.should.equal('github'); dropdownButtonText.should.equal('github');
robot.keyTap('3', ['control', 'shift']); robot.keyTap('3', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton'); dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("google")');
dropdownButtonText.should.equal('google'); dropdownButtonText.should.equal('google');
robot.keyTap('1', ['control', 'shift']); robot.keyTap('1', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton'); dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("example")');
dropdownButtonText.should.equal('example'); dropdownButtonText.should.equal('example');
}); });
@@ -83,15 +85,15 @@ describe('Menu/window_menu', function desc() {
let tabViewButton = await mainView.innerText('.active'); let tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Channels'); tabViewButton.should.equal('Channels');
robot.keyTap('2', [process.platform === 'darwin' ? 'command' : 'control']); robot.keyTap('2', [env.cmdOrCtrl]);
tabViewButton = await mainView.innerText('.active'); tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Boards'); tabViewButton.should.equal('Boards');
robot.keyTap('3', [process.platform === 'darwin' ? 'command' : 'control']); robot.keyTap('3', [env.cmdOrCtrl]);
tabViewButton = await mainView.innerText('.active'); tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Playbooks'); tabViewButton.should.equal('Playbooks');
robot.keyTap('1', [process.platform === 'darwin' ? 'command' : 'control']); robot.keyTap('1', [env.cmdOrCtrl]);
tabViewButton = await mainView.innerText('.active'); tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Channels'); tabViewButton.should.equal('Channels');
}); });
@@ -111,25 +113,27 @@ describe('Menu/window_menu', function desc() {
tabViewButton.should.equal('Channels'); tabViewButton.should.equal('Channels');
}); });
it.skip('MM-T824 should be minimized when keyboard shortcuts are pressed', async () => { it('MM-T824 should be minimized when keyboard shortcuts are pressed', async () => {
const browserWindow = await this.app.browserWindow(await this.app.firstWindow());
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
await mainWindow.click('button.three-dot-menu'); const browserWindow = await this.app.browserWindow(mainWindow);
robot.keyTap('w'); if (process.platform === 'darwin') {
robot.keyTap('m'); robot.keyTap('m', [env.cmdOrCtrl]);
robot.keyTap('enter'); } else {
await mainWindow.click('button.three-dot-menu');
robot.keyTap('w');
robot.keyTap('m');
robot.keyTap('enter');
}
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;
}); });
it.skip('MM-T825 should be hidden when keyboard shortcuts are pressed', async () => { it('MM-T825 should be hidden when keyboard shortcuts are pressed', async () => {
const browserWindow = await this.app.browserWindow(await this.app.firstWindow());
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
await mainWindow.click('button.three-dot-menu'); const browserWindow = await this.app.browserWindow(mainWindow);
robot.keyTap('w'); robot.keyTap('w', [env.cmdOrCtrl]);
robot.keyTap('c');
robot.keyTap('enter');
await asyncSleep(2000); await asyncSleep(2000);
const isVisible = await browserWindow.evaluate((window) => window.isVisible()); const isVisible = await browserWindow.evaluate((window) => window.isVisible());
isVisible.should.be.false; isVisible.should.be.false;

View File

@@ -159,7 +159,6 @@ describe('Add Server Modal', function desc() {
order: 2, order: 2,
}, },
], ],
lastActiveTab: 0,
}); });
}); });
}); });

View File

@@ -233,8 +233,7 @@ describe('EditServerModal', function desc() {
}); });
}); });
// TODO: disabling flaky test it('MM-T4391_4 should edit team when Save is pressed and both edited', async () => {
it.skip('MM-T4391_4 should edit team when Save is pressed and both edited', async () => {
await editServerView.fill('#teamNameInput', 'NewTestTeam'); await editServerView.fill('#teamNameInput', 'NewTestTeam');
await editServerView.fill('#teamUrlInput', 'http://google.com'); await editServerView.fill('#teamUrlInput', 'http://google.com');
await editServerView.click('#saveNewServerModal'); await editServerView.click('#saveNewServerModal');

View File

@@ -29,7 +29,7 @@ describe('header', function desc() {
const initialBounds = {x: 0, y: 0, width: 800, height: 400, maximized: false}; const initialBounds = {x: 0, y: 0, width: 800, height: 400, maximized: false};
fs.writeFileSync(env.boundsInfoPath, JSON.stringify(initialBounds)); fs.writeFileSync(env.boundsInfoPath, JSON.stringify(initialBounds));
this.app = await env.getApp(); this.app = await env.getApp();
const mainWindow = await this.app.firstWindow(); const mainWindow = await this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const header = await mainWindow.locator('div.topBar'); const header = await mainWindow.locator('div.topBar');
const headerBounds = await header.boundingBox(); const headerBounds = await header.boundingBox();

View File

@@ -41,7 +41,7 @@ describe('Settings', function desc() {
predicate: (window) => window.url().includes('settings'), predicate: (window) => window.url().includes('settings'),
}); });
await settingsWindow.waitForSelector('.settingsPage.container'); await settingsWindow.waitForSelector('.settingsPage.container');
await settingsWindow.waitForSelector('#inputAutoStart'); await settingsWindow.waitForSelector('#inputAutoStart', {state: expected ? 'attached' : 'detached'});
const existing = await settingsWindow.isVisible('#inputAutoStart'); const existing = await settingsWindow.isVisible('#inputAutoStart');
existing.should.equal(expected); existing.should.equal(expected);
}); });
@@ -57,7 +57,7 @@ describe('Settings', function desc() {
predicate: (window) => window.url().includes('settings'), predicate: (window) => window.url().includes('settings'),
}); });
await settingsWindow.waitForSelector('.settingsPage.container'); await settingsWindow.waitForSelector('.settingsPage.container');
await settingsWindow.waitForSelector('#inputShowTrayIcon'); await settingsWindow.waitForSelector('#inputShowTrayIcon', {state: expected ? 'attached' : 'detached'});
const existing = await settingsWindow.isVisible('#inputShowTrayIcon'); const existing = await settingsWindow.isVisible('#inputShowTrayIcon');
existing.should.equal(expected); existing.should.equal(expected);
}); });
@@ -115,8 +115,8 @@ describe('Settings', function desc() {
}); });
describe('Leave app running in notification area when application window is closed', () => { describe('Leave app running in notification area when application window is closed', () => {
it('MM-T4394 should appear on linux', async () => { it('MM-T4394 should appear on linux and win32', async () => {
const expected = (process.platform === 'linux'); const expected = (process.platform === 'linux' || process.platform === 'win32');
this.app.evaluate(({ipcMain}, showWindow) => { this.app.evaluate(({ipcMain}, showWindow) => {
ipcMain.emit(showWindow); ipcMain.emit(showWindow);
}, SHOW_SETTINGS_WINDOW); }, SHOW_SETTINGS_WINDOW);
@@ -210,31 +210,33 @@ describe('Settings', function desc() {
}); });
}); });
describe('Enable automatic check for updates', () => { if (process.platform !== 'darwin') {
it('MM-T4549 should save selected option', async () => { describe('Enable automatic check for updates', () => {
const ID_INPUT_ENABLE_AUTO_UPDATES = '#inputAutoCheckForUpdates'; it('MM-T4549 should save selected option', async () => {
this.app.evaluate(({ipcMain}, showWindow) => { const ID_INPUT_ENABLE_AUTO_UPDATES = '#inputAutoCheckForUpdates';
ipcMain.emit(showWindow); this.app.evaluate(({ipcMain}, showWindow) => {
}, SHOW_SETTINGS_WINDOW); ipcMain.emit(showWindow);
const settingsWindow = await this.app.waitForEvent('window', { }, SHOW_SETTINGS_WINDOW);
predicate: (window) => window.url().includes('settings'), const settingsWindow = await this.app.waitForEvent('window', {
predicate: (window) => window.url().includes('settings'),
});
await settingsWindow.waitForSelector('.settingsPage.container');
const selected = await settingsWindow.isChecked(ID_INPUT_ENABLE_AUTO_UPDATES);
selected.should.equal(true); // default is true
await settingsWindow.click(ID_INPUT_ENABLE_AUTO_UPDATES);
await settingsWindow.waitForSelector('.updatesSaveIndicator :text("Saving...")');
await settingsWindow.waitForSelector('.updatesSaveIndicator :text("Saved")');
const config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
config0.autoCheckForUpdates.should.equal(false);
await settingsWindow.click(ID_INPUT_ENABLE_AUTO_UPDATES);
await settingsWindow.waitForSelector('.updatesSaveIndicator :text("Saving...")');
await settingsWindow.waitForSelector('.updatesSaveIndicator :text("Saved")');
const config1 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
config1.autoCheckForUpdates.should.equal(true);
}); });
await settingsWindow.waitForSelector('.settingsPage.container');
const selected = await settingsWindow.isChecked(ID_INPUT_ENABLE_AUTO_UPDATES);
selected.should.equal(true); // default is true
await settingsWindow.click(ID_INPUT_ENABLE_AUTO_UPDATES);
await settingsWindow.waitForSelector('.updatesSaveIndicator :text("Saving...")');
await settingsWindow.waitForSelector('.updatesSaveIndicator :text("Saved")');
const config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
config0.autoCheckForUpdates.should.equal(false);
await settingsWindow.click(ID_INPUT_ENABLE_AUTO_UPDATES);
await settingsWindow.waitForSelector('.updatesSaveIndicator :text("Saving...")');
await settingsWindow.waitForSelector('.updatesSaveIndicator :text("Saved")');
const config1 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
config1.autoCheckForUpdates.should.equal(true);
}); });
}); }
}); });
}); });

View File

@@ -24,28 +24,24 @@ describe('window', function desc() {
} }
}); });
it.skip('MM-T4403_1 should restore window bounds', async () => { // TODO: this fails on Linux right now due to the window frame for some reason
// TODO: Still fails in CircleCI if (process.platform !== 'linux') {
// bounds seems to be incorrectly calculated in some environments it('MM-T4403_1 should restore window bounds', async () => {
// - Windows 10: OK const expectedBounds = {x: 100, y: 200, width: 800, height: 400};
// - CircleCI: NG fs.writeFileSync(env.boundsInfoPath, JSON.stringify(expectedBounds));
const expectedBounds = {x: 100, y: 200, width: 800, height: 400}; this.app = await env.getApp();
fs.writeFileSync(env.boundsInfoPath, JSON.stringify(expectedBounds)); const mainWindow = await this.app.windows().find((window) => window.url().includes('index'));
this.app = await env.getApp(); const browserWindow = await this.app.browserWindow(mainWindow);
const mainWindow = await this.app.firstWindow(); const bounds = await browserWindow.evaluate((window) => window.getContentBounds());
const browserWindow = await this.app.browserWindow(mainWindow); bounds.should.deep.equal(expectedBounds);
const bounds = await browserWindow.evaluate((window) => window.getContentBounds()); await this.app.close();
bounds.should.deep.equal(expectedBounds); });
await this.app.close(); }
});
it('MM-T4403_2 should NOT restore window bounds if x is located on outside of viewarea', async () => { it('MM-T4403_2 should NOT restore window bounds if x is located on outside of viewarea', async () => {
// bounds seems to be incorrectly calculated in some environments (e.g. CircleCI)
// - Windows 10: OK
// - CircleCI: NG
fs.writeFileSync(env.boundsInfoPath, JSON.stringify({x: -100000, y: 200, width: 800, height: 400})); fs.writeFileSync(env.boundsInfoPath, JSON.stringify({x: -100000, y: 200, width: 800, height: 400}));
this.app = await env.getApp(); this.app = await env.getApp();
const mainWindow = await this.app.firstWindow(); const mainWindow = await this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const bounds = await browserWindow.evaluate((window) => window.getContentBounds()); const bounds = await browserWindow.evaluate((window) => window.getContentBounds());
bounds.x.should.satisfy((x) => (x > -100000)); bounds.x.should.satisfy((x) => (x > -100000));
@@ -53,12 +49,9 @@ describe('window', function desc() {
}); });
it('MM-T4403_3 should NOT restore window bounds if y is located on outside of viewarea', async () => { it('MM-T4403_3 should NOT restore window bounds if y is located on outside of viewarea', async () => {
// bounds seems to be incorrectly calculated in some environments (e.g. CircleCI)
// - Windows 10: OK
// - CircleCI: NG
fs.writeFileSync(env.boundsInfoPath, JSON.stringify({x: 100, y: 200000, width: 800, height: 400})); fs.writeFileSync(env.boundsInfoPath, JSON.stringify({x: 100, y: 200000, width: 800, height: 400}));
this.app = await env.getApp(); this.app = await env.getApp();
const mainWindow = await this.app.firstWindow(); const mainWindow = await this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const bounds = await browserWindow.evaluate((window) => window.getContentBounds()); const bounds = await browserWindow.evaluate((window) => window.getContentBounds());
bounds.y.should.satisfy((y) => (y < 200000)); bounds.y.should.satisfy((y) => (y < 200000));

View File

@@ -107,6 +107,10 @@ export function setupTray(icontheme: string) {
} }
function setTray(status: string, message: string) { function setTray(status: string, message: string) {
if (trayIcon.isDestroyed()) {
return;
}
lastStatus = status; lastStatus = status;
lastMessage = message; lastMessage = message;
trayIcon.setImage(trayImages[status]); trayIcon.setImage(trayImages[status]);

View File

@@ -105,6 +105,10 @@ export class MattermostView extends EventEmitter {
// wait for screen to truly finish loading before sending the message down // wait for screen to truly finish loading before sending the message down
const timeout = setInterval(() => { const timeout = setInterval(() => {
if (!this.view.webContents) {
return;
}
if (!this.view.webContents.isLoading()) { if (!this.view.webContents.isLoading()) {
try { try {
this.view.webContents.send(SET_VIEW_OPTIONS, this.tab.name, this.tab.shouldNotify); this.view.webContents.send(SET_VIEW_OPTIONS, this.tab.name, this.tab.shouldNotify);

View File

@@ -129,7 +129,7 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
getConfig = () => { getConfig = () => {
window.ipcRenderer.invoke(GET_LOCAL_CONFIGURATION).then((config) => { window.ipcRenderer.invoke(GET_LOCAL_CONFIGURATION).then((config) => {
this.setState({ready: true, maximized: false, ...this.convertConfigDataToState(config) as Omit<State, 'ready'>}); this.setState({ready: true, maximized: false, ...this.convertConfigDataToState(config, this.state) as Omit<State, 'ready'>});
}); });
} }
@@ -161,8 +161,8 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
this.savingIsDebounced = true; this.savingIsDebounced = true;
setTimeout(() => { setTimeout(() => {
this.savingIsDebounced = false; this.savingIsDebounced = false;
window.ipcRenderer.send(UPDATE_CONFIGURATION, this.saveQueue.splice(0, this.saveQueue.length));
}, 500); }, 500);
window.ipcRenderer.send(UPDATE_CONFIGURATION, this.saveQueue.splice(0, this.saveQueue.length));
} }
updateSaveState = () => { updateSaveState = () => {
@@ -197,13 +197,12 @@ export default class SettingsPage extends React.PureComponent<Record<string, nev
this.resetSaveStateIsDebounced = true; this.resetSaveStateIsDebounced = true;
setTimeout(() => { setTimeout(() => {
this.resetSaveStateIsDebounced = false; this.resetSaveStateIsDebounced = false;
if (this.state.savingState[configType] !== SavingState.SAVING_STATE_SAVING) {
const savingState = Object.assign({}, this.state.savingState);
savingState[configType] = SavingState.SAVING_STATE_DONE;
this.setState({savingState});
}
}, 2000); }, 2000);
if (this.state.savingState[configType] !== SavingState.SAVING_STATE_SAVING) {
const savingState = Object.assign({}, this.state.savingState);
savingState[configType] = SavingState.SAVING_STATE_DONE;
this.setState({savingState});
}
} }
handleChangeShowTrayIcon = () => { handleChangeShowTrayIcon = () => {