mattermost-desktop/e2e/specs/menu_bar/window_menu.test.js
Devin Binnie 4fa89a5fce
[MM-40144] Restructure tests, add test case numbers, some cleanup (#1864)
* [MM-40144] Restructure tests, add test case numbers, some cleanup

* Fix a test
2021-11-19 10:21:34 -05:00

80 lines
2.4 KiB
JavaScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
'use strict';
const fs = require('fs');
const robot = require('robotjs');
const env = require('../../modules/environment');
const {asyncSleep} = require('../../modules/utils');
describe('mattermost', function desc() {
this.timeout(30000);
const config = {
...env.demoConfig,
teams: [
...env.demoConfig.teams,
{
name: 'google',
url: 'https://google.com/',
order: 2,
tabs: [
{
name: 'TAB_MESSAGING',
order: 0,
isOpen: true,
},
{
name: 'TAB_FOCALBOARD',
order: 1,
isOpen: false,
},
{
name: 'TAB_PLAYBOOKS',
order: 2,
isOpen: false,
},
],
lastActiveTab: 0,
},
],
};
beforeEach(async () => {
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);
});
afterEach(async () => {
if (this.app) {
await this.app.close();
}
});
it('MM-T826 should switch to servers when keyboard shortcuts are pressed', async () => {
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
let dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
dropdownButtonText.should.equal('example');
robot.keyTap('2', ['control', 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
dropdownButtonText.should.equal('github');
robot.keyTap('3', ['control', 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
dropdownButtonText.should.equal('google');
robot.keyTap('1', ['control', 'shift']);
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
dropdownButtonText.should.equal('example');
});
});