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

@@ -38,18 +38,17 @@ describe('menu_bar/dropdown', function desc() {
});
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 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);
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.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.should.equal(0);
});
@@ -68,7 +67,7 @@ describe('menu_bar/dropdown', function desc() {
});
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);
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/')));
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'));
await mainView.click('.TeamDropdownButton');
await mainWindow.click('.TeamDropdownButton');
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);

View File

@@ -31,147 +31,111 @@ describe('edit_menu', function desc() {
});
it('MM-T807 Undo in the Menu Bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') {
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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
// click on sint channel
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost');
await firstServer.click('#post_textbox');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('u');
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('Mattermos');
}
// click on sint channel
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost');
await firstServer.click('#post_textbox');
robot.keyTap('z', [env.cmdOrCtrl]);
await asyncSleep(500);
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('Mattermos');
});
it('MM-T808 Redo in the Menu Bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') {
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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
// click on sint channel
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost');
await firstServer.click('#post_textbox');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('u');
const textAfterUndo = await firstServer.inputValue('#post_textbox');
textAfterUndo.should.be.equal('Mattermos');
await firstServer.click('#post_textbox');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('r');
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('Mattermost');
}
// click on sint channel
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost');
await firstServer.click('#post_textbox');
robot.keyTap('z', [env.cmdOrCtrl]);
await asyncSleep(500);
const textAfterUndo = await firstServer.inputValue('#post_textbox');
textAfterUndo.should.be.equal('Mattermos');
await firstServer.click('#post_textbox');
robot.keyTap('z', ['shift', env.cmdOrCtrl]);
await asyncSleep(500);
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('Mattermost');
});
it('MM-T809 Cut in the Menu Bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') {
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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
// click on sint channel
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('s');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('c');
robot.keyTap('enter');
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('');
}
// click on sint channel
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost');
robot.keyTap('a', [env.cmdOrCtrl]);
await asyncSleep(500);
robot.keyTap('x', [env.cmdOrCtrl]);
await asyncSleep(500);
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('');
});
it('MM-T810 Copy in the Menu Bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') {
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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
// click on sint channel
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('s');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('c');
robot.keyTap('c');
robot.keyTap('enter');
await firstServer.click('#post_textbox');
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');
}
// click on sint channel
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost');
robot.keyTap('a', [env.cmdOrCtrl]);
await asyncSleep(500);
robot.keyTap('c', [env.cmdOrCtrl]);
await asyncSleep(500);
await firstServer.click('#post_textbox');
robot.keyTap('v', [env.cmdOrCtrl]);
await asyncSleep(500);
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('MattermostMattermost');
});
it('MM-T811 Paste in the Menu Bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') {
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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
// click on sint channel
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('s');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('c');
robot.keyTap('c');
robot.keyTap('enter');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
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');
}
// click on sint channel
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', 'Mattermost');
robot.keyTap('a', [env.cmdOrCtrl]);
await asyncSleep(500);
robot.keyTap('c', [env.cmdOrCtrl]);
await asyncSleep(500);
robot.keyTap('a', [env.cmdOrCtrl]);
await asyncSleep(500);
robot.keyTap('v', [env.cmdOrCtrl]);
await asyncSleep(500);
const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('Mattermost');
});
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'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
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('#post_textbox');
await firstServer.fill('#post_textbox', 'Mattermost');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('e');
robot.keyTap('s');
robot.keyTap('a', [env.cmdOrCtrl]);
await asyncSleep(500);
const channelHeaderText = await firstServer.evaluate('window.getSelection().toString()');
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 () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
mainWindow.should.not.be.null;
if (process.platform === 'win32' || process.platform === 'linux') {
robot.keyTap(',', ['control']);
const settingsWindow = await this.app.waitForEvent('window', {
predicate: (window) => window.url().includes('settings'),
});
settingsWindow.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;
});
it('MM-T805 Sign in to Another Server Window opens using menu item', async () => {
if (process.platform === 'win32' || process.platform === 'linux') {
// TODO: No keyboard shortcut for macOS
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'));
mainWindow.should.not.be.null;
await mainWindow.click('button.three-dot-menu');
@@ -57,19 +56,20 @@ describe('file_menu/dropdown', function desc() {
predicate: (window) => window.url().includes('newServer'),
});
signInToAnotherServerWindow.should.not.be.null;
}
});
});
}
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') {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
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']);
robot.keyTap('w', [env.cmdOrCtrl]);
//Opening the menu bar
robot.keyTap('alt');
@@ -84,20 +84,23 @@ describe('file_menu/dropdown', function desc() {
}
});
it('MM-T806 Exit in the Menu Bar', () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
mainWindow.should.not.be.null;
// TODO: Causes issues on Windows so skipping for Windows
if (process.platform !== 'win32') {
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') {
robot.keyTap('q', ['command']);
}
if (process.platform === 'darwin') {
robot.keyTap('q', ['command']);
}
if (process.platform === 'linux' || process.platform === 'win32') {
robot.keyTap('q', ['control']);
}
if (process.platform === 'linux' || process.platform === 'win32') {
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));
await asyncSleep(1000);
this.app = await env.getApp();
this.serverMap = await env.getServerMap(this.app);
});
afterEach(async () => {
@@ -31,7 +30,7 @@ describe('menu/menu', function desc() {
});
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'));
mainWindow.should.not.be.null;

View File

@@ -20,57 +20,8 @@ async function setupPromise(window, id) {
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() {
this.timeout(60000);
this.timeout(30000);
const config = env.demoMattermostConfig;
@@ -96,6 +47,7 @@ describe('menu/view', function desc() {
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#searchBox');
await asyncSleep(1000);
robot.keyTap('f', [process.platform === 'darwin' ? 'command' : 'control']);
await asyncSleep(500);
const isFocused = await firstServer.$eval('#searchBox', (el) => el === document.activeElement);
@@ -104,8 +56,9 @@ describe('menu/view', function desc() {
text.should.include('in:');
});
it.skip('MM-T816 Toggle Full Screen in the Menu Bar', async () => {
if (process.platform === 'win32' || process.platform === 'linux') {
// TODO: No keyboard shortcut for macOS
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 loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
@@ -132,54 +85,61 @@ describe('menu/view', function desc() {
currentHeight = await firstServer.evaluate('window.outerHeight');
currentWidth.should.be.lessThan(fullScreenWidth);
currentHeight.should.be.lessThan(fullScreenHeight);
}
});
});
}
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'));
mainWindow.should.not.be.null;
await mainWindow.click('button.three-dot-menu');
robot.keyTap('v');
robot.keyTap('a');
const zoomLevel = await mainWindow.evaluate('window.devicePixelRatio');
zoomLevel.should.be.equal(1);
}
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'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
await env.loginToMattermost(firstServer);
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 () => {
if (process.platform === 'win32' || process.platform === 'linux') {
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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#searchBox');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('v');
robot.keyTap('z');
robot.keyTap('enter');
const zoomLevel = await firstServer.evaluate('window.devicePixelRatio');
zoomLevel.should.be.greaterThan(1);
}
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'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#searchBox');
robot.keyTap('=', [env.cmdOrCtrl]);
await asyncSleep(1000);
const zoomLevel = await browserWindow.evaluate((window, id) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
zoomLevel.should.be.greaterThan(1);
});
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 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 env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#searchBox');
await mainWindow.click('button.three-dot-menu');
robot.keyTap('v');
robot.keyTap('z');
robot.keyTap('z');
robot.keyTap('enter');
const zoomLevel = await firstServer.evaluate('window.devicePixelRatio');
zoomLevel.should.be.lessThan(1);
}
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'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
const firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#searchBox');
robot.keyTap('-', [env.cmdOrCtrl]);
await asyncSleep(1000);
const zoomLevel = await browserWindow.evaluate((window, id) => window.getBrowserViews().find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
zoomLevel.should.be.lessThan(1);
});
describe('Reload', () => {
@@ -187,7 +147,7 @@ describe('menu/view', function desc() {
let webContentsId;
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);
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 () => {
const check = browserWindow.evaluate(setupPromise, webContentsId);
await asyncSleep(500);
robot.keyTap('r', ['control']);
robot.keyTap('r', [env.cmdOrCtrl]);
const result = await check;
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 () => {
const check = browserWindow.evaluate(setupPromise, webContentsId);
await asyncSleep(500);
robot.keyTap('r', ['control', 'shift']);
robot.keyTap('r', [env.cmdOrCtrl, 'shift']);
const result = await check;
result.should.be.true;
});
});
describe('Toggle DevTools', () => {
const CharPerMin = 600;
const DelayBetweenInputs = 500; // ms
const DevToolsLoadTime = 7000; // ms
const DevToolsLoadTimeBuffer = 10000; // ms
const MaxDialogEventWaitTime = 6000; // ms
beforeEach(async () => {
it('MM-T820 should open Developer Tools For Application Wrapper for main window', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('loadingScreen'));
const browserWindow = await this.app.browserWindow(mainWindow);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
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'));
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,
},
],
minimizeToTray: true,
alwaysMinimize: true,
};
beforeEach(async () => {
@@ -64,16 +66,16 @@ describe('Menu/window_menu', function desc() {
let dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
dropdownButtonText.should.equal('example');
robot.keyTap('2', ['control', 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
robot.keyTap('2', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("github")');
dropdownButtonText.should.equal('github');
robot.keyTap('3', ['control', 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
robot.keyTap('3', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("google")');
dropdownButtonText.should.equal('google');
robot.keyTap('1', ['control', 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
robot.keyTap('1', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("example")');
dropdownButtonText.should.equal('example');
});
@@ -83,15 +85,15 @@ describe('Menu/window_menu', function desc() {
let tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Channels');
robot.keyTap('2', [process.platform === 'darwin' ? 'command' : 'control']);
robot.keyTap('2', [env.cmdOrCtrl]);
tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Boards');
robot.keyTap('3', [process.platform === 'darwin' ? 'command' : 'control']);
robot.keyTap('3', [env.cmdOrCtrl]);
tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Playbooks');
robot.keyTap('1', [process.platform === 'darwin' ? 'command' : 'control']);
robot.keyTap('1', [env.cmdOrCtrl]);
tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Channels');
});
@@ -111,25 +113,27 @@ describe('Menu/window_menu', function desc() {
tabViewButton.should.equal('Channels');
});
it.skip('MM-T824 should be minimized when keyboard shortcuts are pressed', async () => {
const browserWindow = await this.app.browserWindow(await this.app.firstWindow());
it('MM-T824 should be minimized when keyboard shortcuts are pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
await mainWindow.click('button.three-dot-menu');
robot.keyTap('w');
robot.keyTap('m');
robot.keyTap('enter');
const browserWindow = await this.app.browserWindow(mainWindow);
if (process.platform === 'darwin') {
robot.keyTap('m', [env.cmdOrCtrl]);
} else {
await mainWindow.click('button.three-dot-menu');
robot.keyTap('w');
robot.keyTap('m');
robot.keyTap('enter');
}
await asyncSleep(2000);
const isMinimized = await browserWindow.evaluate((window) => window.isMinimized());
isMinimized.should.be.true;
});
it.skip('MM-T825 should be hidden when keyboard shortcuts are pressed', async () => {
const browserWindow = await this.app.browserWindow(await this.app.firstWindow());
it('MM-T825 should be hidden when keyboard shortcuts are pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
await mainWindow.click('button.three-dot-menu');
robot.keyTap('w');
robot.keyTap('c');
robot.keyTap('enter');
const browserWindow = await this.app.browserWindow(mainWindow);
robot.keyTap('w', [env.cmdOrCtrl]);
await asyncSleep(2000);
const isVisible = await browserWindow.evaluate((window) => window.isVisible());
isVisible.should.be.false;