Fixed some E2E tests that broke on v5.2 (#2453)

* Fixing some E2E tests

* Fixed a couple flaky ones

* Fixed some issues on Windows
This commit is contained in:
Devin Binnie
2022-12-06 08:40:56 -04:00
committed by GitHub
parent c37d1ba308
commit 865fd2522f
14 changed files with 64 additions and 77 deletions

View File

@@ -34,6 +34,11 @@ describe('application', function desc() {
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.serverMap = await env.getServerMap(this.app);
if (!this.app.windows().some((window) => window.url().includes('github.com'))) {
await this.app.waitForEvent('window', {
predicate: (window) => window.url().includes('github.com'),
});
}
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const browserWindow = await this.app.browserWindow(mainWindow);
const webContentsId = this.serverMap[`${config.teams[1].name}___TAB_MESSAGING`].webContentsId;

View File

@@ -2,10 +2,11 @@
// See LICENSE.txt for license information.
'use strict';
const fs = require('fs');
const robot = require('robotjs');
const env = require('../../modules/environment');
const {asyncSleep, rmDirAsync, writeFileAsync} = require('../../modules/utils');
const {asyncSleep, rmDirAsync} = require('../../modules/utils');
const config = {
...env.demoMattermostConfig,
@@ -41,12 +42,11 @@ describe('downloads/downloads_manager', function desc() {
const filename = `${Date.now().toString()}.txt`;
beforeEach(async () => {
await env.cleanDataDirAsync();
await env.cleanTestConfigAsync();
await env.createTestUserDataDirAsync();
await writeFileAsync(env.configFilePath, JSON.stringify(config));
env.cleanDataDir();
env.createTestUserDataDir();
env.cleanTestConfig();
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
await asyncSleep(1000);
this.app = await env.getApp();
this.serverMap = await env.getServerMap(this.app);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
@@ -76,9 +76,9 @@ describe('downloads/downloads_manager', function desc() {
await firstServer.locator('#file-attachment-link', {hasText: filename}).click();
await asyncSleep(1000);
await Promise.all([
firstServer.waitForEvent('download'), // It is important to call waitForEvent before click to set up waiting.
firstServer.locator(`div[role="dialog"] a[download="${filename}"]`).click(), // Triggers the download.
]);
await asyncSleep(1000);
(await env.downloadsDropdownIsOpen(this.app)).should.equal(true);
});
});

View File

@@ -56,7 +56,7 @@ describe('MM-T2633 Back button should behave as expected', function desc() {
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
firstServer = this.serverMap[`${config.teams[0].name}___TAB_MESSAGING`].win;
await firstServer.click('a:has-text("OneLogin")');
await firstServer.click('a:has-text("Okta")');
backButton = await mainWindow.waitForSelector('button:has-text("Back")');
});
@@ -67,10 +67,10 @@ describe('MM-T2633 Back button should behave as expected', function desc() {
await env.clearElectronInstances();
});
it('MM-T2633_1 after clicking OneLogin, back button should appear', async () => {
it('MM-T2633_1 after clicking Okta, back button should appear', async () => {
backButton.should.not.be.null;
const poweredByOneLogin = await firstServer.waitForSelector('a:has-text("Powered by OneLogin")');
poweredByOneLogin.should.not.be.null;
const poweredByOkta = await firstServer.waitForSelector('p:has-text("Powered by Okta")');
poweredByOkta.should.not.be.null;
});
it('MM-T2633_2 after clicking Back, should be back on the login screen', async () => {
@@ -80,26 +80,26 @@ describe('MM-T2633 Back button should behave as expected', function desc() {
await mainWindow.waitForSelector('button:has-text("Back")', {state: 'hidden'});
});
it('MM-T2633_3 on the OneLogin screen, should still allow links to be clicked and still show the Back button', async () => {
it('MM-T2633_3 on the Okta screen, should still allow links to be clicked and still show the Back button', async () => {
let isNewWindow = false;
this.app.on('window', () => {
isNewWindow = true;
});
const oneLoginUrl = firstServer.url();
await firstServer.click('a:has-text("OneLogin")');
const poweredByOneLogin = await firstServer.waitForSelector('a:has-text("Powered by OneLogin")');
poweredByOneLogin.click();
const OktaUrl = firstServer.url();
await firstServer.click('a:has-text("Okta")');
const poweredByOkta = await firstServer.waitForSelector('p:has-text("Powered by Okta") a:has-text("Okta")');
poweredByOkta.click();
backButton = await mainWindow.waitForSelector('button:has-text("Back")');
backButton.should.not.be.null;
const frameUrl = firstServer.url();
frameUrl.should.not.equal(oneLoginUrl);
frameUrl.should.not.equal(OktaUrl);
isNewWindow.should.be.false;
await firstServer.waitForSelector('a:has-text("Powered by OneLogin")', {state: 'hidden'});
await firstServer.waitForSelector('p:has-text("Powered by Okta")', {state: 'hidden'});
});
it('MM-T2633_4 after click Back twice, user should be on the main login screen again', async () => {
await backButton.click();
await firstServer.waitForURL('https://mattermost.onelogin.com/**');
await firstServer.waitForURL('https://mattermost.okta.com/**');
await backButton.click();
const loginPrompt = await firstServer.waitForSelector('#input_loginId');
loginPrompt.should.not.be.null;

View File

@@ -87,7 +87,7 @@ describe('file_menu/dropdown', function desc() {
// TODO: Causes issues on Windows so skipping for Windows
if (process.platform !== 'win32') {
it('MM-T806 Exit in the Menu Bar', () => {
it('MM-T806 Exit in the Menu Bar', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
mainWindow.should.not.be.null;
@@ -99,6 +99,7 @@ describe('file_menu/dropdown', function desc() {
robot.keyTap('q', ['control']);
}
await asyncSleep(500);
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

View File

@@ -234,7 +234,7 @@ describe('menu/view', function desc() {
});
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 mainWindow = this.app.windows().find((window) => window.url().includes('index.html'));
const browserWindow = await this.app.browserWindow(mainWindow);
const loadingScreen = this.app.windows().find((window) => window.url().includes('loadingScreen'));
await loadingScreen.waitForSelector('.LoadingScreen', {state: 'hidden'});
@@ -244,7 +244,11 @@ describe('menu/view', function desc() {
});
isDevToolsOpen.should.be.false;
robot.keyTap('i', process.platform === 'darwin' ? ['command', 'alt'] : ['control', 'shift']);
robot.keyTap('alt');
robot.keyTap('enter');
robot.keyTap('v');
robot.keyTap('d');
robot.keyTap('enter');
await asyncSleep(1000);
isDevToolsOpen = await browserWindow.evaluate((window) => {
@@ -256,7 +260,7 @@ describe('menu/view', function desc() {
// 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 mainWindow = this.app.windows().find((window) => window.url().includes('index'));
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'));

View File

@@ -38,6 +38,7 @@ describe('Menu/window_menu', function desc() {
lastActiveTab: 0,
},
],
lastActiveTeam: 2,
minimizeToTray: true,
alwaysMinimize: true,
};
@@ -72,7 +73,7 @@ describe('Menu/window_menu', function desc() {
it('MM-T826_1 should show the second server', async () => {
let dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
dropdownButtonText.should.equal('example');
dropdownButtonText.should.equal('google');
robot.keyTap('2', ['control', process.platform === 'darwin' ? 'command' : 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("github")');
@@ -92,7 +93,7 @@ describe('Menu/window_menu', function desc() {
});
});
it('MM-T4385 select tab from menu', async () => {
describe('MM-T4385 select tab from menu', async () => {
let mainView;
before(async () => {
@@ -106,18 +107,21 @@ describe('Menu/window_menu', function desc() {
tabViewButton.should.equal('Channels');
robot.keyTap('2', [env.cmdOrCtrl]);
await asyncSleep(500);
tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Boards');
});
it('MM-T4385_2 should show the third tab', async () => {
robot.keyTap('3', [env.cmdOrCtrl]);
await asyncSleep(500);
const tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Playbooks');
});
it('MM-T4385_3 should show the first tab', async () => {
robot.keyTap('1', [env.cmdOrCtrl]);
await asyncSleep(500);
const tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Channels');
});
@@ -132,10 +136,12 @@ describe('Menu/window_menu', function desc() {
tabViewButton.should.equal('Channels');
robot.keyTap('tab', ['control']);
await asyncSleep(500);
tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Boards');
robot.keyTap('tab', ['shift', 'control']);
await asyncSleep(500);
tabViewButton = await mainView.innerText('.active');
tabViewButton.should.equal('Channels');

View File

@@ -43,7 +43,7 @@ describe('popup', function desc() {
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', '/github connect');
await firstServer.type('#post_textbox', '/github connect ');
await firstServer.press('#post_textbox', 'Enter');
const githubLink = await firstServer.waitForSelector('a.theme.markdown__link:has-text("GitHub account")');
@@ -99,7 +99,7 @@ describe('popup', function desc() {
await firstServer.waitForSelector('#sidebarItem_suscipit-4');
await firstServer.click('#sidebarItem_suscipit-4');
await firstServer.click('#post_textbox');
await firstServer.type('#post_textbox', '/github connect');
await firstServer.type('#post_textbox', '/github connect ');
await firstServer.press('#post_textbox', 'Enter');
const githubLink = await firstServer.waitForSelector('a.theme.markdown__link:has-text("GitHub account")');

View File

@@ -41,7 +41,7 @@ describe('Add Server Modal', function desc() {
let newServerView;
it('MM-T1312 should focus the first text input', async () => {
const isFocused = await newServerView.$eval('#teamNameInput', (el) => el.isSameNode(document.activeElement));
const isFocused = await newServerView.$eval('#teamUrlInput', (el) => el.isSameNode(document.activeElement));
isFocused.should.be.true;
});

View File

@@ -36,6 +36,7 @@ describe('server_management/drag_and_drop', function desc() {
lastActiveTab: 0,
},
],
lastActiveTeam: 2,
};
const beforeFunc = async () => {
@@ -159,7 +160,7 @@ describe('server_management/drag_and_drop', function desc() {
it('MM-T2635_3 should update the config file', () => {
// Verify config is updated
const newConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
const firstTeam = newConfig.teams.find((team) => team.name === 'example');
const firstTeam = newConfig.teams.find((team) => team.name === 'google');
const order0 = firstTeam.tabs.find((tab) => tab.name === 'TAB_FOCALBOARD');
order0.order.should.equal(0);
const order1 = firstTeam.tabs.find((tab) => tab.name === 'TAB_MESSAGING');

View File

@@ -59,12 +59,10 @@ describe('EditServerModal', function desc() {
{
name: 'TAB_FOCALBOARD',
order: 1,
isOpen: true,
},
{
name: 'TAB_PLAYBOOKS',
order: 2,
isOpen: true,
},
],
lastActiveTab: 0,
@@ -91,12 +89,10 @@ describe('EditServerModal', function desc() {
{
name: 'TAB_FOCALBOARD',
order: 1,
isOpen: true,
},
{
name: 'TAB_PLAYBOOKS',
order: 2,
isOpen: true,
},
],
lastActiveTab: 0,
@@ -143,12 +139,10 @@ describe('EditServerModal', function desc() {
{
name: 'TAB_FOCALBOARD',
order: 1,
isOpen: true,
},
{
name: 'TAB_PLAYBOOKS',
order: 2,
isOpen: true,
},
],
lastActiveTab: 0,
@@ -166,12 +160,10 @@ describe('EditServerModal', function desc() {
{
name: 'TAB_FOCALBOARD',
order: 1,
isOpen: true,
},
{
name: 'TAB_PLAYBOOKS',
order: 2,
isOpen: true,
},
],
lastActiveTab: 0,
@@ -199,12 +191,10 @@ describe('EditServerModal', function desc() {
{
name: 'TAB_FOCALBOARD',
order: 1,
isOpen: true,
},
{
name: 'TAB_PLAYBOOKS',
order: 2,
isOpen: true,
},
],
lastActiveTab: 0,
@@ -222,12 +212,10 @@ describe('EditServerModal', function desc() {
{
name: 'TAB_FOCALBOARD',
order: 1,
isOpen: true,
},
{
name: 'TAB_PLAYBOOKS',
order: 2,
isOpen: true,
},
],
lastActiveTab: 0,
@@ -256,12 +244,10 @@ describe('EditServerModal', function desc() {
{
name: 'TAB_FOCALBOARD',
order: 1,
isOpen: true,
},
{
name: 'TAB_PLAYBOOKS',
order: 2,
isOpen: true,
},
],
lastActiveTab: 0,
@@ -279,12 +265,10 @@ describe('EditServerModal', function desc() {
{
name: 'TAB_FOCALBOARD',
order: 1,
isOpen: true,
},
{
name: 'TAB_PLAYBOOKS',
order: 2,
isOpen: true,
},
],
lastActiveTab: 0,

View File

@@ -16,11 +16,6 @@ describe('startup/app', function desc() {
env.createTestUserDataDir();
env.cleanTestConfig();
this.app = await env.getApp();
// Skip welcome screen modal
const welcomeScreenModal = this.app.windows().find((window) => window.url().includes('welcomeScreen'));
welcomeScreenModal.click('.WelcomeScreen .WelcomeScreen__button');
await asyncSleep(500);
});
afterEach(async () => {
@@ -30,29 +25,6 @@ describe('startup/app', function desc() {
await env.clearElectronInstances();
});
it('MM-T4399_1 should show the new server modal when no servers exist', async () => {
const newServerModal = this.app.windows().find((window) => window.url().includes('newServer'));
const modalTitle = await newServerModal.innerText('#newServerModal .modal-title');
modalTitle.should.equal('Add Server');
});
it('MM-T4419 should not allow the user to close the new server modal when no servers exist', async () => {
const newServerModal = this.app.windows().find((window) => window.url().includes('newServer'));
const existing = await newServerModal.isVisible('#cancelNewServerModal');
existing.should.be.false;
robot.keyTap('escape');
const existingModal = this.app.windows().find((window) => window.url().includes('newServer'));
existingModal.should.not.be.null;
});
it('MM-T4985 should show app name in title bar when no servers exist', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const titleBarText = await mainWindow.innerText('.app-title');
titleBarText.should.equal('Mattermost');
});
it('MM-T4400 should be stopped when the app instance already exists', (done) => {
const secondApp = env.getApp();
@@ -84,4 +56,12 @@ describe('startup/app', function desc() {
const modalButton = await welcomeScreenModal.innerText('.WelcomeScreen .WelcomeScreen__button');
modalButton.should.equal('Get Started');
});
if (process.platform !== 'linux') {
it('MM-T4985 should show app name in title bar when no servers exist', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
const titleBarText = await mainWindow.innerText('.app-title');
titleBarText.should.equal('Mattermost');
});
}
});