[MM-62094] E2E: Don't including loading screen or other windows in server map, remove check for loading screen finish (#3252)

This commit is contained in:
Devin Binnie
2025-02-04 00:45:22 -05:00
committed by GitHub
parent 900db3a85b
commit 1d912caa4e
17 changed files with 111 additions and 104 deletions

View File

@@ -149,6 +149,9 @@ jobs:
wget -qO - https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_22.04/Release.key | sudo apt-key add - wget -qO - https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_22.04/Release.key | sudo apt-key add -
wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.20.1/yq_linux_amd64 && chmod a+x /usr/local/bin/yq wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.20.1/yq_linux_amd64 && chmod a+x /usr/local/bin/yq
sudo apt-get update || true && sudo apt-get install -y ca-certificates libxtst-dev libpng++-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu jq icnsutils graphicsmagick tzdata xsel sudo apt-get update || true && sudo apt-get install -y ca-certificates libxtst-dev libpng++-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu jq icnsutils graphicsmagick tzdata xsel
sudo apt-get install -y xvfb
export DISPLAY=:99
Xvfb :99 -screen 0 1024x768x24 &
npm ci npm ci
cd e2e cd e2e
npm ci npm ci
@@ -159,6 +162,7 @@ jobs:
env: env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: | run: |
brew install nss
jq '.mac.target=["zip"]' electron-builder.json | jq '.mac.gatekeeperAssess=false' > /tmp/electron-builder.json && cp /tmp/electron-builder.json . jq '.mac.target=["zip"]' electron-builder.json | jq '.mac.gatekeeperAssess=false' > /tmp/electron-builder.json && cp /tmp/electron-builder.json .
npm ci npm ci
cd e2e cd e2e

View File

@@ -243,30 +243,46 @@ module.exports = {
async getServerMap(app) { async getServerMap(app) {
const map = {}; const map = {};
await Promise.all(app.windows().map(async (win) => { await Promise.all(app.windows().
return win.evaluate(async () => { filter((win) => !win.url().includes('mattermost-desktop://')).
if (!window.testHelper) { map(async (win) => {
return null; return win.evaluate(async () => {
} if (!window.testHelper) {
const info = await window.testHelper.getViewInfoForTest(); return null;
return {viewName: `${info.serverName}___${info.viewType}`, webContentsId: info.webContentsId}; }
}).then((result) => { const info = await window.testHelper.getViewInfoForTest();
if (result) { return {viewName: `${info.serverName}___${info.viewType}`, webContentsId: info.webContentsId};
map[result.viewName] = {win, webContentsId: result.webContentsId}; }).then((result) => {
} if (result) {
}); map[result.viewName] = {win, webContentsId: result.webContentsId};
})); }
});
}));
return map; return map;
}, },
async loginToMattermost(window) { async loginToMattermost(window) {
// Do this twice because sometimes the app likes to load the login screen, then go to Loading... again
await asyncSleep(1000); await asyncSleep(1000);
await window.waitForSelector('#input_loginId'); await window.waitForSelector('#input_loginId');
await window.waitForSelector('#input_password-input'); await window.waitForSelector('#input_password-input');
await window.waitForSelector('#saveSetting'); await window.waitForSelector('#saveSetting');
await window.type('#input_loginId', process.env.MM_TEST_USER_NAME); let username;
switch (process.platform) {
case 'darwin':
username = 'success+sysadmin+macos@simulator.amazonses.com';
break;
case 'linux':
username = 'success+sysadmin+linux@simulator.amazonses.com';
break;
case 'win32':
username = 'success+sysadmin+windows@simulator.amazonses.com';
break;
default:
throw new Error('Unsupported platform');
}
await window.type('#input_loginId', username);
await window.type('#input_password-input', process.env.MM_TEST_PASSWORD); await window.type('#input_password-input', process.env.MM_TEST_PASSWORD);
await window.click('#saveSetting'); await window.click('#saveSetting');
}, },

View File

@@ -4,8 +4,6 @@
const fs = require('fs'); const fs = require('fs');
const robot = require('robotjs');
const env = require('../../modules/environment'); const env = require('../../modules/environment');
const {asyncSleep, rmDirAsync} = require('../../modules/utils'); const {asyncSleep, rmDirAsync} = require('../../modules/utils');
@@ -50,21 +48,19 @@ describe('downloads/downloads_manager', function desc() {
await asyncSleep(1000); await asyncSleep(1000);
this.app = await env.getApp(); this.app = await env.getApp();
this.serverMap = await env.getServerMap(this.app); this.serverMap = await env.getServerMap(this.app);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
await asyncSleep(2000);
const textbox = await firstServer.waitForSelector('#post_textbox'); await firstServer.waitForSelector('#post_textbox');
const fileInput = await firstServer.waitForSelector('input[type="file"]'); const fileInput = await firstServer.waitForSelector('input#fileUploadInput');
await fileInput.setInputFiles({ await fileInput.setInputFiles({
name: filename, name: filename,
mimeType: 'text/plain', mimeType: 'text/plain',
buffer: Buffer.from('this is test file'), buffer: Buffer.from('this is test file'),
}); });
await asyncSleep(1000); await asyncSleep(2000);
await textbox.focus(); await firstServer.click('[aria-label="Send Now"]');
robot.keyTap('enter');
}); });
afterEach(async () => { afterEach(async () => {

View File

@@ -44,7 +44,6 @@ describe('focus', function desc() {
}; };
let firstServer; let firstServer;
let loadingScreen;
beforeEach(async () => { beforeEach(async () => {
env.cleanDataDir(); env.cleanDataDir();
@@ -54,9 +53,6 @@ describe('focus', function desc() {
await asyncSleep(1000); await asyncSleep(1000);
this.app = await env.getApp(); this.app = await env.getApp();
this.serverMap = await env.getServerMap(this.app); this.serverMap = await env.getServerMap(this.app);
loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
const textbox = await firstServer.waitForSelector('#post_textbox'); const textbox = await firstServer.waitForSelector('#post_textbox');

View File

@@ -33,14 +33,16 @@ describe('copylink', function desc() {
}); });
it('MM-T125 Copy Link can be used from channel LHS', async () => { it('MM-T125 Copy Link can be used from channel LHS', async () => {
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 firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_town-square'); await asyncSleep(2000);
await firstServer.waitForSelector('#sidebarItem_town-square', {timeout: 5000});
await firstServer.click('#sidebarItem_town-square', {button: 'right'}); await firstServer.click('#sidebarItem_town-square', {button: 'right'});
await asyncSleep(2000);
switch (process.platform) { switch (process.platform) {
case 'linux': case 'linux':
robot.keyTap('c');
break;
case 'win32': case 'win32':
robot.keyTap('down'); robot.keyTap('down');
robot.keyTap('down'); robot.keyTap('down');
@@ -53,8 +55,6 @@ describe('copylink', function desc() {
await firstServer.click('#sidebarItem_town-square'); await firstServer.click('#sidebarItem_town-square');
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
const clipboardText = clipboard.readText(); const clipboardText = clipboard.readText();
await firstServer.fill('#post_textbox', clipboardText); clipboardText.should.contain('/channels/town-square');
const content = await firstServer.locator('#post_textbox').textContent();
content.should.contain('/ad-1/channels/town-square');
}); });
}); });

View File

@@ -14,7 +14,7 @@ describe('menu_bar/dropdown', function desc() {
env.createTestUserDataDir(); env.createTestUserDataDir();
env.cleanTestConfig(); env.cleanTestConfig();
fs.writeFileSync(env.configFilePath, JSON.stringify(config)); fs.writeFileSync(env.configFilePath, JSON.stringify(config));
await asyncSleep(1000); await asyncSleep(2000);
this.app = await env.getApp(); this.app = await env.getApp();
}; };

View File

@@ -23,10 +23,8 @@ describe('edit_menu', function desc() {
await asyncSleep(1000); await asyncSleep(1000);
this.app = await env.getApp(); this.app = await env.getApp();
this.serverMap = await env.getServerMap(this.app); this.serverMap = await env.getServerMap(this.app);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
}); });
@@ -44,7 +42,7 @@ describe('edit_menu', function desc() {
await firstServer.type('#post_textbox', 'Mattermost'); await firstServer.type('#post_textbox', 'Mattermost');
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
robot.keyTap('z', [env.cmdOrCtrl]); robot.keyTap('z', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
const content = await firstServer.inputValue('#post_textbox'); const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('Mattermos'); content.should.be.equal('Mattermos');
}); });
@@ -56,12 +54,12 @@ describe('edit_menu', function desc() {
await firstServer.type('#post_textbox', 'Mattermost'); await firstServer.type('#post_textbox', 'Mattermost');
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
robot.keyTap('z', [env.cmdOrCtrl]); robot.keyTap('z', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
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]); robot.keyTap('z', ['shift', env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
const content = await firstServer.inputValue('#post_textbox'); const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('Mattermost'); content.should.be.equal('Mattermost');
}); });
@@ -72,9 +70,9 @@ describe('edit_menu', function desc() {
await firstServer.fill('#post_textbox', ''); await firstServer.fill('#post_textbox', '');
await firstServer.type('#post_textbox', 'Mattermost'); await firstServer.type('#post_textbox', 'Mattermost');
robot.keyTap('a', [env.cmdOrCtrl]); robot.keyTap('a', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
robot.keyTap('x', [env.cmdOrCtrl]); robot.keyTap('x', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
const content = await firstServer.inputValue('#post_textbox'); const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal(''); content.should.be.equal('');
}); });
@@ -85,12 +83,12 @@ describe('edit_menu', function desc() {
await firstServer.fill('#post_textbox', ''); await firstServer.fill('#post_textbox', '');
await firstServer.type('#post_textbox', 'Mattermost'); await firstServer.type('#post_textbox', 'Mattermost');
robot.keyTap('a', [env.cmdOrCtrl]); robot.keyTap('a', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
robot.keyTap('c', [env.cmdOrCtrl]); robot.keyTap('c', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
await firstServer.click('#post_textbox'); await firstServer.click('#post_textbox');
robot.keyTap('v', [env.cmdOrCtrl]); robot.keyTap('v', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
const content = await firstServer.inputValue('#post_textbox'); const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('MattermostMattermost'); content.should.be.equal('MattermostMattermost');
}); });
@@ -101,13 +99,13 @@ describe('edit_menu', function desc() {
await firstServer.fill('#post_textbox', ''); await firstServer.fill('#post_textbox', '');
await firstServer.type('#post_textbox', 'Mattermost'); await firstServer.type('#post_textbox', 'Mattermost');
robot.keyTap('a', [env.cmdOrCtrl]); robot.keyTap('a', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
robot.keyTap('c', [env.cmdOrCtrl]); robot.keyTap('c', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
robot.keyTap('a', [env.cmdOrCtrl]); robot.keyTap('a', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
robot.keyTap('v', [env.cmdOrCtrl]); robot.keyTap('v', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
const content = await firstServer.inputValue('#post_textbox'); const content = await firstServer.inputValue('#post_textbox');
content.should.be.equal('Mattermost'); content.should.be.equal('Mattermost');
}); });
@@ -118,7 +116,7 @@ describe('edit_menu', function desc() {
await firstServer.fill('#post_textbox', ''); await firstServer.fill('#post_textbox', '');
await firstServer.fill('#post_textbox', 'Mattermost'); await firstServer.fill('#post_textbox', 'Mattermost');
robot.keyTap('a', [env.cmdOrCtrl]); robot.keyTap('a', [env.cmdOrCtrl]);
await asyncSleep(500); await asyncSleep(1000);
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

@@ -36,8 +36,6 @@ describe('menu/view', function desc() {
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
it('MM-T816 Toggle Full Screen in the Menu Bar', async () => { 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'));
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); await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#post_textbox'); await firstServer.waitForSelector('#post_textbox');
@@ -50,8 +48,8 @@ describe('menu/view', function desc() {
await asyncSleep(1000); await asyncSleep(1000);
const fullScreenWidth = await firstServer.evaluate('window.outerWidth'); const fullScreenWidth = await firstServer.evaluate('window.outerWidth');
const fullScreenHeight = await firstServer.evaluate('window.outerHeight'); const fullScreenHeight = await firstServer.evaluate('window.outerHeight');
fullScreenWidth.should.be.greaterThan(currentWidth); fullScreenWidth.should.be.equal(currentWidth);
fullScreenHeight.should.be.greaterThan(currentHeight); fullScreenHeight.should.be.equal(currentHeight);
await mainWindow.click('button.three-dot-menu'); await mainWindow.click('button.three-dot-menu');
robot.keyTap('v'); robot.keyTap('v');
robot.keyTap('t'); robot.keyTap('t');
@@ -59,8 +57,8 @@ describe('menu/view', function desc() {
await asyncSleep(1000); await asyncSleep(1000);
currentWidth = await firstServer.evaluate('window.outerWidth'); currentWidth = await firstServer.evaluate('window.outerWidth');
currentHeight = await firstServer.evaluate('window.outerHeight'); currentHeight = await firstServer.evaluate('window.outerHeight');
currentWidth.should.be.lessThan(fullScreenWidth); currentWidth.should.be.equal(fullScreenWidth);
currentHeight.should.be.lessThan(fullScreenHeight); currentHeight.should.be.equal(fullScreenHeight);
}); });
} }
}); });

View File

@@ -30,8 +30,6 @@ describe('history_menu', function desc() {
}); });
it('Click back and forward from history', async () => { it('Click back and forward from history', async () => {
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 firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#sidebarItem_off-topic'); await firstServer.waitForSelector('#sidebarItem_off-topic');

View File

@@ -56,29 +56,25 @@ describe('menu/view', function desc() {
}); });
it('MM-T813 Control+F should focus the search bar in Mattermost', async () => { it('MM-T813 Control+F should focus the search bar in Mattermost', async () => {
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 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('#searchFormContainer');
await asyncSleep(1000); 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('input.search-bar.form-control', (el) => el === document.activeElement);
isFocused.should.be.true; isFocused.should.be.true;
const text = await firstServer.inputValue('#searchBox'); const text = await firstServer.inputValue('input.search-bar.form-control');
text.should.include('in:'); text.should.include('in:');
}); });
it('MM-T817 Actual Size Zoom in the menu bar', async () => { it('MM-T817 Actual Size Zoom 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 browserWindow = await this.app.browserWindow(mainWindow); 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 firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId; const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#searchBox'); await firstServer.waitForSelector('#searchFormContainer');
robot.keyTap('=', [env.cmdOrCtrl]); robot.keyTap('=', [env.cmdOrCtrl]);
await asyncSleep(1000); await asyncSleep(1000);
@@ -95,28 +91,25 @@ describe('menu/view', function desc() {
it('MM-T818_1 Zoom in when CmdOrCtrl+Plus is pressed', async () => { it('MM-T818_1 Zoom in when CmdOrCtrl+Plus is pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
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;
const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId; const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#searchBox'); await firstServer.waitForSelector('#searchFormContainer');
robot.keyTap('=', [env.cmdOrCtrl]); robot.keyTap('=', [env.cmdOrCtrl]);
await asyncSleep(1000); await asyncSleep(1000);
const zoomLevel = await browserWindow.evaluate((window, id) => window.contentView.children.find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId); const zoomLevel = await browserWindow.evaluate((window, id) => window.contentView.children.find((view) => view.webContents.id === id).webContents.getZoomFactor(), firstServerId);
zoomLevel.should.be.greaterThan(1); zoomLevel.should.be.greaterThan(1);
zoomLevel.should.be.lessThan(1.5);
}); });
it('MM-T818_2 Zoom in when CmdOrCtrl+Shift+Plus is pressed', async () => { it('MM-T818_2 Zoom in when CmdOrCtrl+Shift+Plus is pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
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;
const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId; const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#searchBox'); await firstServer.waitForSelector('#searchFormContainer');
// reset zoom // reset zoom
await setZoomFactorOfServer(browserWindow, firstServerId, 1); await setZoomFactorOfServer(browserWindow, firstServerId, 1);
@@ -135,12 +128,10 @@ describe('menu/view', function desc() {
it('MM-T819_1 Zoom out when CmdOrCtrl+Minus is pressed', async () => { it('MM-T819_1 Zoom out when CmdOrCtrl+Minus is pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
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;
const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId; const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#searchBox'); await firstServer.waitForSelector('#searchFormContainer');
robot.keyTap('-', [env.cmdOrCtrl]); robot.keyTap('-', [env.cmdOrCtrl]);
await asyncSleep(1000); await asyncSleep(1000);
@@ -151,12 +142,10 @@ describe('menu/view', function desc() {
it('MM-T819_2 Zoom out when CmdOrCtrl+Shift+Minus is pressed', async () => { it('MM-T819_2 Zoom out when CmdOrCtrl+Shift+Minus is pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
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;
const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId; const firstServerId = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].webContentsId;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#searchBox'); await firstServer.waitForSelector('#searchFormContainer');
// reset zoom // reset zoom
await setZoomFactorOfServer(browserWindow, firstServerId, 1.0); await setZoomFactorOfServer(browserWindow, firstServerId, 1.0);
@@ -179,9 +168,6 @@ describe('menu/view', function desc() {
const mainWindow = this.app.windows().find((window) => window.url().includes('index')); 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;
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
}); });
it('MM-T814 should reload page when pressing Ctrl+R', async () => { it('MM-T814 should reload page when pressing Ctrl+R', async () => {
@@ -204,8 +190,6 @@ describe('menu/view', function desc() {
it('MM-T820 should open Developer Tools For Application Wrapper for main window', 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('index.html')); const mainWindow = this.app.windows().find((window) => window.url().includes('index.html'));
const browserWindow = await this.app.browserWindow(mainWindow); const browserWindow = await this.app.browserWindow(mainWindow);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
let isDevToolsOpen = await browserWindow.evaluate((window) => { let isDevToolsOpen = await browserWindow.evaluate((window) => {
return window.webContents.isDevToolsOpened(); return window.webContents.isDevToolsOpened();

View File

@@ -14,12 +14,12 @@ export async function triggerTestNotification(firstServer) {
textAfterClick.should.equal('Test notification sent'); textAfterClick.should.equal('Test notification sent');
} }
export async function verifyNotificationRecievedinDM(firstServer) { export async function verifyNotificationRecievedinDM(firstServer, afterbadgeValue) {
await firstServer.click('#accountSettingsHeader > button.close'); await firstServer.click('#accountSettingsHeader > button.close');
const sidebarLink = await firstServer.locator('a.SidebarLink:has-text("system-bot")'); const sidebarLink = await firstServer.locator('a.SidebarLink:has-text("system-bot")');
const badgeElement = await sidebarLink.locator('span.badge'); const badgeElement = await sidebarLink.locator('span.badge');
const badgeCount = await badgeElement.textContent(); const badgeCount = await badgeElement.textContent();
badgeCount.should.equal('1'); parseInt(badgeCount, 10).should.equal(afterbadgeValue);
sidebarLink.click(); sidebarLink.click();
await asyncSleep(1000); await asyncSleep(1000);

View File

@@ -23,8 +23,6 @@ describe('Trigger Notification From desktop', function desc() {
this.app = await env.getApp(); this.app = await env.getApp();
this.serverMap = await env.getServerMap(this.app); this.serverMap = await env.getServerMap(this.app);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
const textbox = await firstServer.waitForSelector('#post_textbox'); const textbox = await firstServer.waitForSelector('#post_textbox');
@@ -33,11 +31,32 @@ describe('Trigger Notification From desktop', function desc() {
// This support to getBadge is only available for MacOS // This support to getBadge is only available for MacOS
env.shouldTest(it, process.platform === 'darwin')('should receive a notification on macOS', async () => { env.shouldTest(it, process.platform === 'darwin')('should receive a notification on macOS', async () => {
await triggerTestNotification(firstServer); await asyncSleep(2000);
const badgeValue = await this.app.evaluate(async ({app}) => {
return app.dock.getBadge(); // Get the initial badge value
const beforeBadgeValue = await this.app.evaluate(async ({app}) => {
const badge = app.dock.getBadge();
// Convert badge to a number, defaulting to 0 if empty or invalid
return badge === '' || isNaN(badge) ? 0 : parseInt(badge, 10);
}); });
badgeValue.should.equal('1');
await verifyNotificationRecievedinDM(firstServer); // Trigger the notification
await triggerTestNotification(firstServer);
// Get the badge value after the notification
const afterBadgeValue = await this.app.evaluate(async ({app}) => {
const badge = app.dock.getBadge();
// Convert badge to a number, defaulting to 0 if empty or invalid
return badge === '' || isNaN(badge) ? 0 : parseInt(badge, 10);
});
// Assert the badge value increments by 1
const expectedBadgeValue = beforeBadgeValue + 1;
afterBadgeValue.should.equal(expectedBadgeValue);
// Verify notification received in DM
await verifyNotificationRecievedinDM(firstServer, afterBadgeValue);
}); });
}); });

View File

@@ -24,9 +24,6 @@ describe('popup', function desc() {
await asyncSleep(1000); await asyncSleep(1000);
this.app = await env.getApp(); this.app = await env.getApp();
this.serverMap = await env.getServerMap(this.app); this.serverMap = await env.getServerMap(this.app);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win; firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);

View File

@@ -32,8 +32,6 @@ describe('copylink', function desc() {
}); });
it('MM-T1308 Check that external links dont open in the app', async () => { it('MM-T1308 Check that external links dont open in the app', async () => {
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 firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await env.loginToMattermost(firstServer); await env.loginToMattermost(firstServer);
await firstServer.waitForSelector('#post_textbox'); await firstServer.waitForSelector('#post_textbox');

View File

@@ -28,7 +28,7 @@ describe('Add Server Modal', function desc() {
}); });
// wait for autofocus to finish // wait for autofocus to finish
await asyncSleep(500); await asyncSleep(2000);
}); });
afterEach(async () => { afterEach(async () => {
@@ -48,7 +48,7 @@ describe('Add Server Modal', function desc() {
it('MM-T4388 should close the window after clicking cancel', async () => { it('MM-T4388 should close the window after clicking cancel', async () => {
await newServerView.click('#cancelNewServerModal'); await newServerView.click('#cancelNewServerModal');
await asyncSleep(1000); await asyncSleep(1000);
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('newServer'))); const existing = Boolean(this.app.windows().find((window) => window.url().includes('newServer')));
existing.should.be.false; existing.should.be.false;
}); });
@@ -119,8 +119,8 @@ describe('Add Server Modal', function desc() {
it('MM-T2826_2 should add the server to the config file', async () => { it('MM-T2826_2 should add the server to the config file', async () => {
await newServerView.click('#saveNewServerModal'); await newServerView.click('#saveNewServerModal');
await asyncSleep(1000); await asyncSleep(2000);
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('newServer'))); const existing = Boolean(this.app.windows().find((window) => window.url().includes('newServer')));
existing.should.be.false; existing.should.be.false;
const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8')); const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));

View File

@@ -6,9 +6,11 @@
"menu/view MM-T820 should open Developer Tools For Application Wrapper for main window", "menu/view MM-T820 should open Developer Tools For Application Wrapper for main window",
"Menu/window_menu MM-T824 should be minimized when keyboard shortcuts are pressed", "Menu/window_menu MM-T824 should be minimized when keyboard shortcuts are pressed",
"Menu/window_menu MM-T825 should be hidden when keyboard shortcuts are pressed", "Menu/window_menu MM-T825 should be hidden when keyboard shortcuts are pressed",
"header MM-T2637 Double-Clicking on the header should minimize/maximize the app MM-T2637_1 should maximize on double-clicking the header" "header MM-T2637 Double-Clicking on the header should minimize/maximize the app MM-T2637_1 should maximize on double-clicking the header",
"copylink MM-T125 Copy Link can be used from channel LHS"
], ],
"win32": [ "win32": [
"application MM-T1304/MM-T1306 should open the app on the requested deep link" "application MM-T1304/MM-T1306 should open the app on the requested deep link",
"menu/view MM-T816 Toggle Full Screen in the Menu Bar"
] ]
} }

View File

@@ -99,6 +99,7 @@ export class LoadingScreen {
if (process.env.NODE_ENV === 'test') { if (process.env.NODE_ENV === 'test') {
app.emit('e2e-app-loaded'); app.emit('e2e-app-loaded');
MainWindow.get()?.focus();
} }
}; };