[MM-38875] Migrate E2E testing to Playwright, re-enable tests (#1800)
* WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * [MM-38875] Migrate E2E testing to Playwright, re-enable tests * Add functionality to map view names to Playwright windows * Added search box test * Added robot.js for automating key presses * Add test using key strokes to navigate menu * Reload test and added webcontentsid to test helper * Check Ctrl+Shift+R as well * oops * Reorganize Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
@@ -65,7 +65,7 @@ commands:
|
|||||||
default: ""
|
default: ""
|
||||||
steps:
|
steps:
|
||||||
- run: wget -qO - https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_18.04/Release.key | apt-key add -
|
- run: wget -qO - https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_18.04/Release.key | apt-key add -
|
||||||
- run: apt-get update || true && apt-get install ca-certificates && apt-get update && apt-get -y install << parameters.apt_opts >>
|
- run: apt-get update || true && apt-get install -y ca-certificates libxtst-dev libpng++-dev && apt-get update && apt-get -y install << parameters.apt_opts >>
|
||||||
|
|
||||||
update_image:
|
update_image:
|
||||||
description: "Update image"
|
description: "Update image"
|
||||||
@@ -76,7 +76,7 @@ commands:
|
|||||||
steps:
|
steps:
|
||||||
- update_base_image:
|
- update_base_image:
|
||||||
apt_opts: << parameters.apt_opts >>
|
apt_opts: << parameters.apt_opts >>
|
||||||
- run: npm ci
|
- run: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm ci
|
||||||
|
|
||||||
win_make:
|
win_make:
|
||||||
description: "Run mattermost's makefile.ps1 on ./scripts/"
|
description: "Run mattermost's makefile.ps1 on ./scripts/"
|
||||||
|
2975
package-lock.json
generated
2975
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,7 @@
|
|||||||
"build:main": "webpack-cli --bail --config webpack.config.main.js",
|
"build:main": "webpack-cli --bail --config webpack.config.main.js",
|
||||||
"build:renderer": "webpack-cli --bail --config webpack.config.renderer.js",
|
"build:renderer": "webpack-cli --bail --config webpack.config.renderer.js",
|
||||||
"build-prod": "npm-run-all build:*",
|
"build-prod": "npm-run-all build:*",
|
||||||
|
"build-robotjs": "npm rebuild --runtime=electron --target=14.1.0 --disturl=https://atom.io/download/atom-shell --abi=83",
|
||||||
"start": "electron dist/ --disable-dev-mode",
|
"start": "electron dist/ --disable-dev-mode",
|
||||||
"restart": "npm run build && npm run start",
|
"restart": "npm run build && npm run start",
|
||||||
"storybook": "start-storybook -p 9001 -c src/.storybook",
|
"storybook": "start-storybook -p 9001 -c src/.storybook",
|
||||||
@@ -38,7 +39,8 @@
|
|||||||
"watch:main": "node scripts/watch_main_and_preload.js",
|
"watch:main": "node scripts/watch_main_and_preload.js",
|
||||||
"watch:renderer": "webpack-dev-server --config webpack.config.renderer.js",
|
"watch:renderer": "webpack-dev-server --config webpack.config.renderer.js",
|
||||||
"test": "npm-run-all lint:js test:unit test:e2e",
|
"test": "npm-run-all lint:js test:unit test:e2e",
|
||||||
"test:e2e": "cross-env NODE_ENV=test npm-run-all build test:e2e:build test:e2e:run",
|
"test:e2e": "cross-env NODE_ENV=test npm-run-all build build-robotjs test:e2e:build test:e2e:run",
|
||||||
|
"test:e2e:nobuild": "cross-env NODE_ENV=test npm-run-all test:e2e:build test:e2e:run",
|
||||||
"test:e2e:build": "webpack-cli --bail --config webpack.config.test.js",
|
"test:e2e:build": "webpack-cli --bail --config webpack.config.test.js",
|
||||||
"test:e2e:run": "electron-mocha -r @babel/register --reporter mocha-circleci-reporter dist/tests/e2e_bundle.js",
|
"test:e2e:run": "electron-mocha -r @babel/register --reporter mocha-circleci-reporter dist/tests/e2e_bundle.js",
|
||||||
"test:unit": "npm-run-all test:unit:build test:unit:run",
|
"test:unit": "npm-run-all test:unit:build test:unit:run",
|
||||||
@@ -111,9 +113,10 @@
|
|||||||
"mocha": "^5.2.0",
|
"mocha": "^5.2.0",
|
||||||
"mocha-circleci-reporter": "0.0.3",
|
"mocha-circleci-reporter": "0.0.3",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
|
"playwright": "^1.15.2",
|
||||||
|
"robotjs": "^0.6.0",
|
||||||
"sass-loader": "^10.2.0",
|
"sass-loader": "^10.2.0",
|
||||||
"shebang-loader": "^0.0.1",
|
"shebang-loader": "^0.0.1",
|
||||||
"spectron": "^15.0.0",
|
|
||||||
"style-loader": "^2.0.0",
|
"style-loader": "^2.0.0",
|
||||||
"typescript": "^4.3.4",
|
"typescript": "^4.3.4",
|
||||||
"url-loader": "^1.1.2",
|
"url-loader": "^1.1.2",
|
||||||
|
@@ -100,3 +100,6 @@ export const BROWSER_HISTORY_PUSH = 'browser-history-push';
|
|||||||
export const APP_LOGGED_IN = 'app-logged-in';
|
export const APP_LOGGED_IN = 'app-logged-in';
|
||||||
|
|
||||||
export const GET_AVAILABLE_SPELL_CHECKER_LANGUAGES = 'get-available-spell-checker-languages';
|
export const GET_AVAILABLE_SPELL_CHECKER_LANGUAGES = 'get-available-spell-checker-languages';
|
||||||
|
|
||||||
|
export const GET_VIEW_NAME = 'get-view-name';
|
||||||
|
export const GET_VIEW_WEBCONTENTS_ID = 'get-view-webcontents-id';
|
||||||
|
@@ -51,6 +51,7 @@ export function displayMention(title: string, body: string, channel: {id: string
|
|||||||
});
|
});
|
||||||
|
|
||||||
mention.on('click', () => {
|
mention.on('click', () => {
|
||||||
|
log.info('notification click', serverName, mention);
|
||||||
if (serverName) {
|
if (serverName) {
|
||||||
windowManager.switchTab(serverName, TAB_MESSAGING);
|
windowManager.switchTab(serverName, TAB_MESSAGING);
|
||||||
webcontents.send('notification-clicked', {channel, teamId, url});
|
webcontents.send('notification-clicked', {channel, teamId, url});
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
/* eslint-disable no-magic-numbers */
|
/* eslint-disable no-magic-numbers */
|
||||||
|
|
||||||
import {ipcRenderer, webFrame} from 'electron';
|
import {contextBridge, ipcRenderer, webFrame} from 'electron';
|
||||||
|
|
||||||
// I've filed an issue in electron-log https://github.com/megahertz/electron-log/issues/267
|
// I've filed an issue in electron-log https://github.com/megahertz/electron-log/issues/267
|
||||||
// we'll be able to use it again if there is a workaround for the 'os' import
|
// we'll be able to use it again if there is a workaround for the 'os' import
|
||||||
@@ -23,6 +23,8 @@ import {
|
|||||||
CLOSE_TEAMS_DROPDOWN,
|
CLOSE_TEAMS_DROPDOWN,
|
||||||
BROWSER_HISTORY_PUSH,
|
BROWSER_HISTORY_PUSH,
|
||||||
APP_LOGGED_IN,
|
APP_LOGGED_IN,
|
||||||
|
GET_VIEW_NAME,
|
||||||
|
GET_VIEW_WEBCONTENTS_ID,
|
||||||
} from 'common/communication';
|
} from 'common/communication';
|
||||||
|
|
||||||
const UNREAD_COUNT_INTERVAL = 1000;
|
const UNREAD_COUNT_INTERVAL = 1000;
|
||||||
@@ -36,6 +38,13 @@ let shouldSendNotifications;
|
|||||||
|
|
||||||
console.log('Preload initialized');
|
console.log('Preload initialized');
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'test') {
|
||||||
|
contextBridge.exposeInMainWorld('testHelper', {
|
||||||
|
getViewName: () => ipcRenderer.invoke(GET_VIEW_NAME),
|
||||||
|
getWebContentsId: () => ipcRenderer.invoke(GET_VIEW_WEBCONTENTS_ID),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ipcRenderer.invoke('get-app-version').then(({name, version}) => {
|
ipcRenderer.invoke('get-app-version').then(({name, version}) => {
|
||||||
appVersion = version;
|
appVersion = version;
|
||||||
appName = name;
|
appName = name;
|
||||||
|
@@ -77,13 +77,11 @@ export class MattermostView extends EventEmitter {
|
|||||||
this.options = Object.assign({}, options);
|
this.options = Object.assign({}, options);
|
||||||
this.options.webPreferences = {
|
this.options.webPreferences = {
|
||||||
nativeWindowOpen: true,
|
nativeWindowOpen: true,
|
||||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
|
||||||
preload,
|
preload,
|
||||||
additionalArguments: [
|
additionalArguments: [
|
||||||
`version=${app.getVersion()}`,
|
`version=${app.getVersion()}`,
|
||||||
`appName=${app.name}`,
|
`appName=${app.name}`,
|
||||||
],
|
],
|
||||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
|
||||||
...options.webPreferences,
|
...options.webPreferences,
|
||||||
};
|
};
|
||||||
this.isVisible = false;
|
this.isVisible = false;
|
||||||
@@ -273,12 +271,7 @@ export class MattermostView extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getWebContents = () => {
|
getWebContents = () => {
|
||||||
if (this.status === Status.READY) {
|
return this.view.webContents;
|
||||||
return this.view.webContents;
|
|
||||||
} else if (this.window) {
|
|
||||||
return this.window.webContents; // if it's not ready you are looking at the renderer process
|
|
||||||
}
|
|
||||||
return WindowManager.getMainWindow()?.webContents;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleInputEvents = (_: Event, input: Input) => {
|
handleInputEvents = (_: Event, input: Input) => {
|
||||||
|
@@ -32,9 +32,7 @@ export class ModalView<T, T2> {
|
|||||||
log.info(`preloading with ${preload}`);
|
log.info(`preloading with ${preload}`);
|
||||||
this.view = new BrowserView({webPreferences: {
|
this.view = new BrowserView({webPreferences: {
|
||||||
nativeWindowOpen: true,
|
nativeWindowOpen: true,
|
||||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
|
||||||
preload,
|
preload,
|
||||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
|
||||||
|
|
||||||
// Workaround for this issue: https://github.com/electron/electron/issues/30993
|
// Workaround for this issue: https://github.com/electron/electron/issues/30993
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
@@ -46,9 +46,7 @@ export default class TeamDropdownView {
|
|||||||
const preload = getLocalPreload('dropdown.js');
|
const preload = getLocalPreload('dropdown.js');
|
||||||
this.view = new BrowserView({webPreferences: {
|
this.view = new BrowserView({webPreferences: {
|
||||||
nativeWindowOpen: true,
|
nativeWindowOpen: true,
|
||||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
|
||||||
preload,
|
preload,
|
||||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
|
||||||
|
|
||||||
// Workaround for this issue: https://github.com/electron/electron/issues/30993
|
// Workaround for this issue: https://github.com/electron/electron/issues/30993
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
@@ -295,8 +295,6 @@ export class ViewManager {
|
|||||||
const urlView = new BrowserView({
|
const urlView = new BrowserView({
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nativeWindowOpen: true,
|
nativeWindowOpen: true,
|
||||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
|
||||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
|
||||||
|
|
||||||
// Workaround for this issue: https://github.com/electron/electron/issues/30993
|
// Workaround for this issue: https://github.com/electron/electron/issues/30993
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
@@ -169,8 +169,6 @@ const generateNewWindowListener = (getServersFunction: () => TeamWithTabs[], spe
|
|||||||
center: true,
|
center: true,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nativeWindowOpen: true,
|
nativeWindowOpen: true,
|
||||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
|
||||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
|
||||||
spellcheck: (typeof spellcheck === 'undefined' ? true : spellcheck),
|
spellcheck: (typeof spellcheck === 'undefined' ? true : spellcheck),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@@ -80,8 +80,6 @@ function createMainWindow(config: CombinedConfig, options: {linuxAppIcon: string
|
|||||||
backgroundColor: '#fff', // prevents blurry text: https://electronjs.org/docs/faq#the-font-looks-blurry-what-is-this-and-what-can-i-do
|
backgroundColor: '#fff', // prevents blurry text: https://electronjs.org/docs/faq#the-font-looks-blurry-what-is-this-and-what-can-i-do
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nativeWindowOpen: true,
|
nativeWindowOpen: true,
|
||||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
|
||||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
|
||||||
disableBlinkFeatures: 'Auxclick',
|
disableBlinkFeatures: 'Auxclick',
|
||||||
preload,
|
preload,
|
||||||
spellcheck,
|
spellcheck,
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {app, BrowserWindow, nativeImage, systemPreferences, ipcMain, IpcMainEvent} from 'electron';
|
import {app, BrowserWindow, nativeImage, systemPreferences, ipcMain, IpcMainEvent, IpcMainInvokeEvent} from 'electron';
|
||||||
import log from 'electron-log';
|
import log from 'electron-log';
|
||||||
|
|
||||||
import {CombinedConfig} from 'types/config';
|
import {CombinedConfig} from 'types/config';
|
||||||
@@ -18,6 +18,8 @@ import {
|
|||||||
UPDATE_SHORTCUT_MENU,
|
UPDATE_SHORTCUT_MENU,
|
||||||
BROWSER_HISTORY_PUSH,
|
BROWSER_HISTORY_PUSH,
|
||||||
APP_LOGGED_IN,
|
APP_LOGGED_IN,
|
||||||
|
GET_VIEW_NAME,
|
||||||
|
GET_VIEW_WEBCONTENTS_ID,
|
||||||
} from 'common/communication';
|
} from 'common/communication';
|
||||||
import urlUtils from 'common/utils/url';
|
import urlUtils from 'common/utils/url';
|
||||||
|
|
||||||
@@ -54,6 +56,8 @@ ipcMain.on(REACT_APP_INITIALIZED, handleReactAppInitialized);
|
|||||||
ipcMain.on(LOADING_SCREEN_ANIMATION_FINISHED, handleLoadingScreenAnimationFinished);
|
ipcMain.on(LOADING_SCREEN_ANIMATION_FINISHED, handleLoadingScreenAnimationFinished);
|
||||||
ipcMain.on(BROWSER_HISTORY_PUSH, handleBrowserHistoryPush);
|
ipcMain.on(BROWSER_HISTORY_PUSH, handleBrowserHistoryPush);
|
||||||
ipcMain.on(APP_LOGGED_IN, handleAppLoggedIn);
|
ipcMain.on(APP_LOGGED_IN, handleAppLoggedIn);
|
||||||
|
ipcMain.handle(GET_VIEW_NAME, handleGetViewName);
|
||||||
|
ipcMain.handle(GET_VIEW_WEBCONTENTS_ID, handleGetWebContentsId);
|
||||||
|
|
||||||
export function setConfig(data: CombinedConfig) {
|
export function setConfig(data: CombinedConfig) {
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -585,3 +589,11 @@ export function getCurrentTeamName() {
|
|||||||
function handleAppLoggedIn(event: IpcMainEvent, viewName: string) {
|
function handleAppLoggedIn(event: IpcMainEvent, viewName: string) {
|
||||||
status.viewManager?.reloadViewIfNeeded(viewName);
|
status.viewManager?.reloadViewIfNeeded(viewName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleGetViewName(event: IpcMainInvokeEvent) {
|
||||||
|
return getViewNameByWebContentsId(event.sender.id);
|
||||||
|
}
|
||||||
|
function handleGetWebContentsId(event: IpcMainInvokeEvent) {
|
||||||
|
return event.sender.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -7,11 +7,13 @@ const fs = require('fs');
|
|||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const Application = require('spectron').Application;
|
const {_electron: electron} = require('playwright');
|
||||||
const chai = require('chai');
|
const chai = require('chai');
|
||||||
const {ipcRenderer} = require('electron');
|
const {ipcRenderer} = require('electron');
|
||||||
|
|
||||||
const {SHOW_SETTINGS_WINDOW} = require('../../src/common/communication');
|
const {SHOW_SETTINGS_WINDOW} = require('../../src/common/communication');
|
||||||
|
|
||||||
|
const {asyncSleep} = require('./utils');
|
||||||
chai.should();
|
chai.should();
|
||||||
|
|
||||||
const sourceRootDir = path.join(__dirname, '../..');
|
const sourceRootDir = path.join(__dirname, '../..');
|
||||||
@@ -47,27 +49,61 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cleanDataDir() {
|
||||||
|
try {
|
||||||
|
fs.rmdirSync(userDataDir, {recursive: true});
|
||||||
|
} catch (err) {
|
||||||
|
if (err.code !== 'ENOENT') {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
createTestUserDataDir() {
|
createTestUserDataDir() {
|
||||||
if (!fs.existsSync(userDataDir)) {
|
if (!fs.existsSync(userDataDir)) {
|
||||||
fs.mkdirSync(userDataDir);
|
fs.mkdirSync(userDataDir);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getSpectronApp() {
|
async getApp() {
|
||||||
const options = {
|
const options = {
|
||||||
path: electronBinaryPath,
|
executablePath: electronBinaryPath,
|
||||||
args: [`${path.join(sourceRootDir, 'dist')}`, `--data-dir=${userDataDir}`, '--disable-dev-mode'],
|
args: [`${path.join(sourceRootDir, 'dist')}`, `--data-dir=${userDataDir}`, '--disable-dev-mode'],
|
||||||
chromeDriverArgs: [],
|
|
||||||
};
|
};
|
||||||
if (process.env.MM_DEBUG_SETTINGS) {
|
|
||||||
options.chromeDriverLogPath = './chromedriverlog.txt';
|
// if (process.env.MM_DEBUG_SETTINGS) {
|
||||||
}
|
// options.chromeDriverLogPath = './chromedriverlog.txt';
|
||||||
if (process.platform === 'darwin' || process.platform === 'linux') {
|
// }
|
||||||
// on a mac, debbuging port might conflict with other apps
|
// if (process.platform === 'darwin' || process.platform === 'linux') {
|
||||||
// this changes the default debugging port so chromedriver can run without issues.
|
// // on a mac, debbuging port might conflict with other apps
|
||||||
options.chromeDriverArgs.push('remote-debugging-port=9222');
|
// // this changes the default debugging port so chromedriver can run without issues.
|
||||||
}
|
// options.chromeDriverArgs.push('remote-debugging-port=9222');
|
||||||
return new Application(options);
|
//}
|
||||||
|
return electron.launch(options).then(async (app) => {
|
||||||
|
// Make sure the app has time to fully load
|
||||||
|
await asyncSleep(1000);
|
||||||
|
return app;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async getServerMap(app) {
|
||||||
|
const map = {};
|
||||||
|
await Promise.all(app.windows().map(async (win) => {
|
||||||
|
return win.evaluate(async () => {
|
||||||
|
if (!window.testHelper) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const name = await window.testHelper.getViewName();
|
||||||
|
const webContentsId = await window.testHelper.getWebContentsId();
|
||||||
|
return {viewName: name, webContentsId};
|
||||||
|
}).then((result) => {
|
||||||
|
if (result) {
|
||||||
|
map[result.viewName] = {win, webContentsId: result.webContentsId};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
return map;
|
||||||
},
|
},
|
||||||
|
|
||||||
addClientCommands(client) {
|
addClientCommands(client) {
|
||||||
|
@@ -2,153 +2,50 @@
|
|||||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
// TODO: Commenting out until Spectron is upgraded for Electron v14
|
'use strict';
|
||||||
|
|
||||||
// 'use strict';
|
const env = require('../modules/environment');
|
||||||
|
|
||||||
// const fs = require('fs');
|
describe('application', function desc() {
|
||||||
|
this.timeout(30000);
|
||||||
|
|
||||||
// const env = require('../modules/environment');
|
beforeEach(async () => {
|
||||||
|
env.createTestUserDataDir();
|
||||||
|
env.cleanTestConfig();
|
||||||
|
this.app = await env.getApp();
|
||||||
|
});
|
||||||
|
|
||||||
// describe('application', function desc() {
|
afterEach(async () => {
|
||||||
// this.timeout(30000);
|
if (this.app) {
|
||||||
|
await this.app.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// beforeEach(() => {
|
it('should show the new server modal when no servers exist', async () => {
|
||||||
// env.createTestUserDataDir();
|
const newServerModal = this.app.windows().find((window) => window.url().includes('newServer'));
|
||||||
// env.cleanTestConfig();
|
const modalTitle = await newServerModal.innerText('#newServerModal .modal-title');
|
||||||
// this.app = env.getSpectronApp();
|
modalTitle.should.equal('Add Server');
|
||||||
// return this.app.start();
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
// afterEach(async () => {
|
it('should show no servers configured in dropdown when no servers exist', async () => {
|
||||||
// if (this.app && this.app.isRunning()) {
|
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
|
||||||
// await this.app.stop();
|
const dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
|
||||||
// }
|
dropdownButtonText.should.equal('No servers configured');
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // it('should show two windows if there is no config file', async () => {
|
it('should be stopped when the app instance already exists', (done) => {
|
||||||
// // await this.app.client.waitUntilWindowLoaded();
|
const secondApp = env.getApp();
|
||||||
// // const count = await this.app.client.getWindowCount();
|
|
||||||
// // count.should.equal(2);
|
|
||||||
// // const opened = await this.app.browserWindow.isDevToolsOpened();
|
|
||||||
// // opened.should.be.false;
|
|
||||||
|
|
||||||
// // const visible = await this.app.browserWindow.isVisible();
|
// In the correct case, 'start().then' is not called.
|
||||||
// // visible.should.be.true;
|
// So need to use setTimeout in order to finish this test.
|
||||||
// // });
|
const timer = setTimeout(() => {
|
||||||
|
done();
|
||||||
// if (process.platform === 'darwin') {
|
}, 3000);
|
||||||
// it.skip('should show closed window with cmd+tab', async () => {
|
secondApp.then(() => {
|
||||||
// // Unable to utilize Command key press due to: https://bugs.chromium.org/p/chromedriver/issues/detail?id=3023#c2
|
clearTimeout(timer);
|
||||||
// await this.app.client.waitUntilWindowLoaded();
|
return secondApp.close();
|
||||||
// await this.app.client.keys(['Meta', 'w']);
|
}).then(() => {
|
||||||
// let visible = await this.app.browserWindow.isVisible();
|
done(new Error('Second app instance exists'));
|
||||||
// visible.should.be.false;
|
});
|
||||||
|
});
|
||||||
// this.app.client.keys(['Meta', 'Tab']);
|
});
|
||||||
// visible = await this.app.browserWindow.isVisible();
|
|
||||||
// visible.should.be.true;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// it.skip('should restore window bounds', async () => {
|
|
||||||
// // bounds seems to be incorrectly calculated in some environments
|
|
||||||
// // - Windows 10: OK
|
|
||||||
// // - CircleCI: NG
|
|
||||||
// const expectedBounds = {x: 100, y: 200, width: 300, height: 400};
|
|
||||||
// fs.writeFileSync(env.boundsInfoPath, JSON.stringify(expectedBounds));
|
|
||||||
// await this.app.restart();
|
|
||||||
// const bounds = await this.app.browserWindow.getBounds();
|
|
||||||
// bounds.should.deep.equal(expectedBounds);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should NOT restore window bounds if the origin 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: 300, height: 400}));
|
|
||||||
// await this.app.restart();
|
|
||||||
// let bounds = await this.app.browserWindow.getBounds();
|
|
||||||
// bounds.x.should.satisfy((x) => (x > -10000));
|
|
||||||
|
|
||||||
// fs.writeFileSync(env.boundsInfoPath, JSON.stringify({x: 100, y: 200000, width: 300, height: 400}));
|
|
||||||
// await this.app.restart();
|
|
||||||
// bounds = await this.app.browserWindow.getBounds();
|
|
||||||
// bounds.y.should.satisfy((y) => (y < 10000));
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // it('should show settings.html when there is no config file', async () => {
|
|
||||||
// // await this.app.client.waitUntilWindowLoaded();
|
|
||||||
// // await this.app.client.pause(1000);
|
|
||||||
// // const url = await this.app.client.getUrl();
|
|
||||||
// // url.should.match(/\/settings.html$/);
|
|
||||||
|
|
||||||
// // const existing = await this.app.client.isExisting('#newServerModal');
|
|
||||||
// // existing.should.equal(true);
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // it('should show index.html when there is config file', async () => {
|
|
||||||
// // const config = {
|
|
||||||
// // version: 2,
|
|
||||||
// // teams: [{
|
|
||||||
// // name: 'example',
|
|
||||||
// // url: env.mattermostURL,
|
|
||||||
// // order: 0,
|
|
||||||
// // }, {
|
|
||||||
// // name: 'github',
|
|
||||||
// // url: 'https://github.com/',
|
|
||||||
// // order: 1,
|
|
||||||
// // }],
|
|
||||||
// // showTrayIcon: false,
|
|
||||||
// // trayIconTheme: 'light',
|
|
||||||
// // minimizeToTray: false,
|
|
||||||
// // notifications: {
|
|
||||||
// // flashWindow: 0,
|
|
||||||
// // bounceIcon: false,
|
|
||||||
// // bounceIconType: 'informational',
|
|
||||||
// // },
|
|
||||||
// // showUnreadBadge: true,
|
|
||||||
// // useSpellChecker: true,
|
|
||||||
// // enableHardwareAcceleration: true,
|
|
||||||
// // autostart: true,
|
|
||||||
// // darkMode: false,
|
|
||||||
// // };
|
|
||||||
// // fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
|
||||||
// // await this.app.restart();
|
|
||||||
|
|
||||||
// // const url = await this.app.client.getUrl();
|
|
||||||
// // url.should.match(/\/index.html$/);
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // it('should upgrade v0 config file', async () => {
|
|
||||||
// // const Config = require('../../src/common/config').default;
|
|
||||||
// // const newConfig = new Config(env.configFilePath);
|
|
||||||
// // const oldConfig = {
|
|
||||||
// // url: env.mattermostURL,
|
|
||||||
// // };
|
|
||||||
// // fs.writeFileSync(env.configFilePath, JSON.stringify(oldConfig));
|
|
||||||
// // await this.app.restart();
|
|
||||||
|
|
||||||
// // const url = await this.app.client.getUrl();
|
|
||||||
// // url.should.match(/\/index.html$/);
|
|
||||||
|
|
||||||
// // const str = fs.readFileSync(env.configFilePath, 'utf8');
|
|
||||||
// // const upgradedConfig = JSON.parse(str);
|
|
||||||
// // upgradedConfig.version.should.equal(newConfig.defaultData.version);
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // it.skip('should be stopped when the app instance already exists', (done) => {
|
|
||||||
// // const secondApp = env.getSpectronApp();
|
|
||||||
|
|
||||||
// // // In the correct case, 'start().then' is not called.
|
|
||||||
// // // So need to use setTimeout in order to finish this test.
|
|
||||||
// // const timer = setTimeout(() => {
|
|
||||||
// // done();
|
|
||||||
// // }, 3000);
|
|
||||||
// // secondApp.start().then(() => {
|
|
||||||
// // clearTimeout(timer);
|
|
||||||
// // return secondApp.stop();
|
|
||||||
// // }).then(() => {
|
|
||||||
// // done(new Error('Second app instance exists'));
|
|
||||||
// // });
|
|
||||||
// });
|
|
||||||
|
@@ -5,8 +5,10 @@
|
|||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const http = require('http');
|
const robot = require('robotjs');
|
||||||
const path = require('path');
|
|
||||||
|
// const http = require('http');
|
||||||
|
// const path = require('path');
|
||||||
|
|
||||||
const env = require('../../modules/environment');
|
const env = require('../../modules/environment');
|
||||||
const {asyncSleep} = require('../../modules/utils');
|
const {asyncSleep} = require('../../modules/utils');
|
||||||
@@ -15,15 +17,51 @@ describe('renderer/index.html', function desc() {
|
|||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
version: 2,
|
version: 3,
|
||||||
teams: [{
|
teams: [{
|
||||||
name: 'example',
|
name: 'example',
|
||||||
url: env.mattermostURL,
|
url: env.mattermostURL,
|
||||||
order: 0,
|
order: 0,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
|
order: 0,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_PLAYBOOKS',
|
||||||
|
order: 2,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
}, {
|
}, {
|
||||||
name: 'github',
|
name: 'github',
|
||||||
url: 'https://github.com/',
|
url: 'https://github.com/',
|
||||||
order: 1,
|
order: 1,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
|
order: 0,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_PLAYBOOKS',
|
||||||
|
order: 2,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
}],
|
}],
|
||||||
showTrayIcon: false,
|
showTrayIcon: false,
|
||||||
trayIconTheme: 'light',
|
trayIconTheme: 'light',
|
||||||
@@ -38,178 +76,123 @@ describe('renderer/index.html', function desc() {
|
|||||||
enableHardwareAcceleration: true,
|
enableHardwareAcceleration: true,
|
||||||
autostart: true,
|
autostart: true,
|
||||||
darkMode: false,
|
darkMode: false,
|
||||||
|
lastActiveTeam: 0,
|
||||||
|
spellCheckerLocales: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const serverPort = 8181;
|
|
||||||
|
|
||||||
before(() => {
|
|
||||||
function serverCallback(req, res) {
|
|
||||||
res.writeHead(200, {
|
|
||||||
'Content-Type': 'text/html',
|
|
||||||
});
|
|
||||||
res.end(fs.readFileSync(path.resolve(env.sourceRootDir, 'test/modules/test.html'), 'utf-8'));
|
|
||||||
}
|
|
||||||
this.server = http.createServer(serverCallback).listen(serverPort, '127.0.0.1');
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
|
env.createTestUserDataDir();
|
||||||
|
env.cleanTestConfig();
|
||||||
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
||||||
await asyncSleep(1000);
|
await asyncSleep(1000);
|
||||||
this.app = env.getSpectronApp();
|
this.app = await env.getApp();
|
||||||
await this.app.start();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
if (this.app && this.app.isRunning()) {
|
if (this.app) {
|
||||||
await this.app.stop();
|
await this.app.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
after((done) => {
|
it('should set src of browser view from config file', async () => {
|
||||||
this.server.close(done);
|
const firstServer = this.app.windows().find((window) => window.url() === config.teams[0].url);
|
||||||
|
const secondServer = this.app.windows().find((window) => window.url() === config.teams[1].url);
|
||||||
|
|
||||||
|
firstServer.should.not.be.null;
|
||||||
|
secondServer.should.not.be.null;
|
||||||
});
|
});
|
||||||
|
|
||||||
// it('should set src of webview from config file', async () => {
|
it('should set name of menu item from config file', async () => {
|
||||||
// const src0 = await this.app.client.getAttribute('#mattermostView0', 'src');
|
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
|
||||||
// src0.should.equal(config.teams[0].url);
|
const dropdownView = this.app.windows().find((window) => window.url().includes('dropdown'));
|
||||||
|
await mainWindow.click('.TeamDropdownButton');
|
||||||
|
const firstMenuItem = await dropdownView.innerText('.TeamDropdown button.TeamDropdown__button:nth-child(1) span');
|
||||||
|
const secondMenuItem = await dropdownView.innerText('.TeamDropdown button.TeamDropdown__button:nth-child(2) span');
|
||||||
|
|
||||||
// const src1 = await this.app.client.getAttribute('#mattermostView1', 'src');
|
firstMenuItem.should.equal(config.teams[0].name);
|
||||||
// src1.should.equal(config.teams[1].url);
|
secondMenuItem.should.equal(config.teams[1].name);
|
||||||
|
});
|
||||||
|
|
||||||
// const existing = await this.app.client.isExisting('#mattermostView2');
|
it('should only show dropdown when button is clicked', async () => {
|
||||||
// existing.should.be.false;
|
const mainWindow = await this.app.firstWindow();
|
||||||
// });
|
const browserWindow = await this.app.browserWindow(mainWindow);
|
||||||
|
const mainView = this.app.windows().find((window) => window.url().includes('index'));
|
||||||
|
|
||||||
// it('should set name of tab from config file', async () => {
|
let dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
|
||||||
// const tabName0 = await this.app.client.getText('#teamTabItem0');
|
dropdownHeight.should.equal(0);
|
||||||
// tabName0.should.equal(config.teams[0].name);
|
|
||||||
|
|
||||||
// const tabName1 = await this.app.client.getText('#teamTabItem1');
|
await mainView.click('.TeamDropdownButton');
|
||||||
// tabName1.should.equal(config.teams[1].name);
|
dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
|
||||||
// });
|
dropdownHeight.should.be.greaterThan(0);
|
||||||
|
|
||||||
// it('should show only the selected team', () => {
|
await mainView.click('.TabBar');
|
||||||
// return this.app.client.
|
dropdownHeight = await browserWindow.evaluate((window) => window.getBrowserViews().find((view) => view.webContents.getURL().includes('dropdown')).getBounds().height);
|
||||||
// waitForVisible('#mattermostView0', 2000).
|
dropdownHeight.should.equal(0);
|
||||||
// waitForVisible('#mattermostView1', 2000, true).
|
});
|
||||||
// click('#teamTabItem1').
|
|
||||||
// waitForVisible('#mattermostView1', 2000).
|
|
||||||
// waitForVisible('#mattermostView0', 2000, true);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// validation now prevents incorrect url's from being used
|
it('should show only the selected team', async () => {
|
||||||
// it.skip('should show error when using incorrect URL', async () => {
|
const mainWindow = await this.app.firstWindow();
|
||||||
// this.timeout(30000);
|
const browserWindow = await this.app.browserWindow(mainWindow);
|
||||||
// fs.writeFileSync(env.configFilePath, JSON.stringify({
|
|
||||||
// version: 2,
|
|
||||||
// teams: [{
|
|
||||||
// name: 'error_1',
|
|
||||||
// url: 'http://false',
|
|
||||||
// order: 0,
|
|
||||||
// }],
|
|
||||||
// }));
|
|
||||||
// await this.app.restart();
|
|
||||||
// return this.app.client.
|
|
||||||
// waitForVisible('#mattermostView0-fail', 20000);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('shouldn\'t set window title by using webview\'s one', async () => {
|
let firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === url)), env.mattermostURL);
|
||||||
// fs.writeFileSync(env.configFilePath, JSON.stringify({
|
firstViewIsAttached.should.be.true;
|
||||||
// version: 2,
|
let secondViewIsAttached = await browserWindow.evaluate((window) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === 'https://github.com/')));
|
||||||
// teams: [{
|
secondViewIsAttached.should.be.false;
|
||||||
// name: 'title_test',
|
|
||||||
// url: `http://localhost:${serverPort}`,
|
|
||||||
// order: 0,
|
|
||||||
// }],
|
|
||||||
// }));
|
|
||||||
// await this.app.restart();
|
|
||||||
// await this.app.client.pause(2000);
|
|
||||||
// const windowTitle = await this.app.browserWindow.getTitle();
|
|
||||||
// windowTitle.should.equal('Mattermost Desktop App');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Skip because it's very unstable in CI
|
const mainView = this.app.windows().find((window) => window.url().includes('index'));
|
||||||
// it.skip('should update window title when the activated tab\'s title is updated', async () => {
|
const dropdownView = this.app.windows().find((window) => window.url().includes('dropdown'));
|
||||||
// fs.writeFileSync(env.configFilePath, JSON.stringify({
|
await mainView.click('.TeamDropdownButton');
|
||||||
// version: 2,
|
await dropdownView.click('.TeamDropdown button.TeamDropdown__button:nth-child(2)');
|
||||||
// teams: [{
|
|
||||||
// name: 'title_test_0',
|
|
||||||
// url: `http://localhost:${serverPort}`,
|
|
||||||
// order: 0,
|
|
||||||
// }, {
|
|
||||||
// name: 'title_test_1',
|
|
||||||
// url: `http://localhost:${serverPort}`,
|
|
||||||
// order: 1,
|
|
||||||
// }],
|
|
||||||
// }));
|
|
||||||
// await this.app.restart();
|
|
||||||
// await this.app.client.pause(500);
|
|
||||||
|
|
||||||
// // Note: Indices of webview are correct.
|
firstViewIsAttached = await browserWindow.evaluate((window, url) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === url)), env.mattermostURL);
|
||||||
// // Somehow they are swapped.
|
firstViewIsAttached.should.be.false;
|
||||||
// await this.app.client.
|
secondViewIsAttached = await browserWindow.evaluate((window) => Boolean(window.getBrowserViews().find((view) => view.webContents.getURL() === 'https://github.com/')));
|
||||||
// windowByIndex(2).
|
secondViewIsAttached.should.be.true;
|
||||||
// execute(() => {
|
});
|
||||||
// document.title = 'Title 0';
|
|
||||||
// });
|
|
||||||
// await this.app.client.windowByIndex(0).pause(500);
|
|
||||||
// let windowTitle = await this.app.browserWindow.getTitle();
|
|
||||||
// windowTitle.should.equal('Title 0');
|
|
||||||
|
|
||||||
// await this.app.client.
|
it('should open the new server prompt after clicking the add button', async () => {
|
||||||
// windowByIndex(1).
|
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
|
||||||
// execute(() => {
|
const dropdownView = this.app.windows().find((window) => window.url().includes('dropdown'));
|
||||||
// document.title = 'Title 1';
|
await mainWindow.click('.TeamDropdownButton');
|
||||||
// });
|
await dropdownView.click('.TeamDropdown__button.addServer');
|
||||||
// await this.app.client.windowByIndex(0).pause(500);
|
|
||||||
// windowTitle = await this.app.browserWindow.getTitle();
|
|
||||||
// windowTitle.should.equal('Title 0');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Skip because it's very unstable in CI
|
const newServerModal = await this.app.waitForEvent('window', {
|
||||||
// it.skip('should update window title when a tab is selected', async () => {
|
predicate: (window) => window.url().includes('newServer'),
|
||||||
// fs.writeFileSync(env.configFilePath, JSON.stringify({
|
});
|
||||||
// version: 2,
|
const modalTitle = await newServerModal.innerText('#newServerModal .modal-title');
|
||||||
// teams: [{
|
modalTitle.should.equal('Add Server');
|
||||||
// name: 'title_test_0',
|
});
|
||||||
// url: `http://localhost:${serverPort}`,
|
|
||||||
// order: 0,
|
|
||||||
// }, {
|
|
||||||
// name: 'title_test_1',
|
|
||||||
// url: `http://localhost:${serverPort}`,
|
|
||||||
// order: 1,
|
|
||||||
// }],
|
|
||||||
// }));
|
|
||||||
// await this.app.restart();
|
|
||||||
|
|
||||||
// // Note: Indices of webview are correct.
|
it('should switch to servers when keyboard shortcuts are pressed', async () => {
|
||||||
// // Somehow they are swapped.
|
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
|
||||||
// await this.app.client.pause(500);
|
|
||||||
|
|
||||||
// await this.app.client.
|
let dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
|
||||||
// windowByIndex(2).
|
dropdownButtonText.should.equal('example');
|
||||||
// execute(() => {
|
|
||||||
// document.title = 'Title 0';
|
|
||||||
// });
|
|
||||||
// await this.app.client.
|
|
||||||
// windowByIndex(1).
|
|
||||||
// execute(() => {
|
|
||||||
// document.title = 'Title 1';
|
|
||||||
// });
|
|
||||||
// await this.app.client.windowByIndex(0).pause(500);
|
|
||||||
|
|
||||||
// let windowTitle = await this.app.browserWindow.getTitle();
|
robot.keyTap('2', ['control', 'shift']);
|
||||||
// windowTitle.should.equal('Title 0');
|
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
|
||||||
|
dropdownButtonText.should.equal('github');
|
||||||
|
|
||||||
// await this.app.client.click('#teamTabItem1').pause(500);
|
robot.keyTap('1', ['control', 'shift']);
|
||||||
// windowTitle = await this.app.browserWindow.getTitle();
|
dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
|
||||||
// windowTitle.should.equal('Title 1');
|
dropdownButtonText.should.equal('example');
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it('should open the new server prompt after clicking the add button', async () => {
|
if (process.platform !== 'darwin') {
|
||||||
// // See settings_test for specs that cover the actual prompt
|
it('should open the 3 dot menu with Alt', async () => {
|
||||||
// await this.app.client.click('#addServerButton').pause(500);
|
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
|
||||||
// const isModalExisting = await this.app.client.isExisting('#newServerModal');
|
mainWindow.should.not.be.null;
|
||||||
// isModalExisting.should.be.true;
|
|
||||||
// });
|
// Settings window should open if Alt works
|
||||||
|
robot.keyTap('alt');
|
||||||
|
robot.keyTap('enter');
|
||||||
|
robot.keyTap('f');
|
||||||
|
robot.keyTap('s');
|
||||||
|
robot.keyTap('enter');
|
||||||
|
const settingsWindow = await this.app.waitForEvent('window', {
|
||||||
|
predicate: (window) => window.url().includes('settings'),
|
||||||
|
});
|
||||||
|
settingsWindow.should.not.be.null;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
266
test/specs/browser/modal_test.js
Normal file
266
test/specs/browser/modal_test.js
Normal file
@@ -0,0 +1,266 @@
|
|||||||
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const env = require('../../modules/environment');
|
||||||
|
const {asyncSleep} = require('../../modules/utils');
|
||||||
|
|
||||||
|
describe('modals', function desc() {
|
||||||
|
this.timeout(30000);
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
version: 3,
|
||||||
|
teams: [{
|
||||||
|
name: 'example',
|
||||||
|
url: env.mattermostURL,
|
||||||
|
order: 0,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
|
order: 0,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_PLAYBOOKS',
|
||||||
|
order: 2,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
|
}, {
|
||||||
|
name: 'github',
|
||||||
|
url: 'https://github.com/',
|
||||||
|
order: 1,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
|
order: 0,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_PLAYBOOKS',
|
||||||
|
order: 2,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
|
}],
|
||||||
|
showTrayIcon: false,
|
||||||
|
trayIconTheme: 'light',
|
||||||
|
minimizeToTray: false,
|
||||||
|
notifications: {
|
||||||
|
flashWindow: 0,
|
||||||
|
bounceIcon: false,
|
||||||
|
bounceIconType: 'informational',
|
||||||
|
},
|
||||||
|
showUnreadBadge: true,
|
||||||
|
useSpellChecker: true,
|
||||||
|
enableHardwareAcceleration: true,
|
||||||
|
autostart: true,
|
||||||
|
darkMode: false,
|
||||||
|
lastActiveTeam: 0,
|
||||||
|
spellCheckerLocales: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
env.createTestUserDataDir();
|
||||||
|
env.cleanTestConfig();
|
||||||
|
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
||||||
|
await asyncSleep(1000);
|
||||||
|
this.app = await env.getApp();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
if (this.app) {
|
||||||
|
await this.app.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('RemoveServerModal', () => {
|
||||||
|
let removeServerView;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
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 dropdownView.hover('.TeamDropdown .TeamDropdown__button:nth-child(1)');
|
||||||
|
await dropdownView.click('.TeamDropdown .TeamDropdown__button:nth-child(1) button.TeamDropdown__button-remove');
|
||||||
|
|
||||||
|
removeServerView = await this.app.waitForEvent('window', {
|
||||||
|
predicate: (window) => window.url().includes('removeServer'),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should remove existing team on click Remove', async () => {
|
||||||
|
await removeServerView.click('button:has-text("Remove")');
|
||||||
|
await asyncSleep(1000);
|
||||||
|
|
||||||
|
const expectedConfig = JSON.parse(JSON.stringify(config.teams.slice(1)));
|
||||||
|
expectedConfig.forEach((value) => {
|
||||||
|
value.order--;
|
||||||
|
});
|
||||||
|
|
||||||
|
const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
||||||
|
savedConfig.teams.should.deep.equal(expectedConfig);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should NOT remove existing team on click Cancel', async () => {
|
||||||
|
await removeServerView.click('button:has-text("Cancel")');
|
||||||
|
await asyncSleep(1000);
|
||||||
|
|
||||||
|
const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
||||||
|
savedConfig.teams.should.deep.equal(config.teams);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should disappear on click Close', async () => {
|
||||||
|
await removeServerView.click('button.close');
|
||||||
|
await asyncSleep(1000);
|
||||||
|
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('removeServer')));
|
||||||
|
existing.should.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should disappear on click background', async () => {
|
||||||
|
await removeServerView.click('.modal', {position: {x: 20, y: 20}});
|
||||||
|
await asyncSleep(1000);
|
||||||
|
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('removeServer')));
|
||||||
|
existing.should.be.false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('NewTeamModal', () => {
|
||||||
|
let newServerView;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
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 dropdownView.click('.TeamDropdown .TeamDropdown__button.addServer');
|
||||||
|
newServerView = await this.app.waitForEvent('window', {
|
||||||
|
predicate: (window) => window.url().includes('newServer'),
|
||||||
|
});
|
||||||
|
|
||||||
|
// wait for autofocus to finish
|
||||||
|
await asyncSleep(500);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should open the new server modal', async () => {
|
||||||
|
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('newServer')));
|
||||||
|
existing.should.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should close the window after clicking cancel', async () => {
|
||||||
|
await newServerView.click('#cancelNewServerModal');
|
||||||
|
await asyncSleep(1000);
|
||||||
|
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('newServer')));
|
||||||
|
existing.should.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not be valid if no team name has been set', async () => {
|
||||||
|
await newServerView.click('#saveNewServerModal');
|
||||||
|
const existing = await newServerView.isVisible('#teamNameInput.is-invalid');
|
||||||
|
existing.should.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not be valid if no server address has been set', async () => {
|
||||||
|
await newServerView.click('#saveNewServerModal');
|
||||||
|
const existing = await newServerView.isVisible('#teamUrlInput.is-invalid');
|
||||||
|
existing.should.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Valid server name', async () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await newServerView.type('#teamNameInput', 'TestTeam');
|
||||||
|
await newServerView.click('#saveNewServerModal');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not be marked invalid', async () => {
|
||||||
|
const existing = await newServerView.isVisible('#teamNameInput.is-invalid');
|
||||||
|
existing.should.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not be possible to click save', async () => {
|
||||||
|
const disabled = await newServerView.getAttribute('#saveNewServerModal', 'disabled');
|
||||||
|
(disabled === '').should.be.true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Valid server url', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await newServerView.type('#teamUrlInput', 'http://example.org');
|
||||||
|
await newServerView.click('#saveNewServerModal');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be valid', async () => {
|
||||||
|
const existing = await newServerView.isVisible('#teamUrlInput.is-invalid');
|
||||||
|
existing.should.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not be possible to click save', async () => {
|
||||||
|
const disabled = await newServerView.getAttribute('#saveNewServerModal', 'disabled');
|
||||||
|
(disabled === '').should.be.true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not be valid if an invalid server address has been set', async () => {
|
||||||
|
await newServerView.type('#teamUrlInput', 'superInvalid url');
|
||||||
|
await newServerView.click('#saveNewServerModal');
|
||||||
|
const existing = await newServerView.isVisible('#teamUrlInput.is-invalid');
|
||||||
|
existing.should.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Valid Team Settings', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await newServerView.type('#teamUrlInput', 'http://example.org');
|
||||||
|
await newServerView.type('#teamNameInput', 'TestTeam');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be possible to click add', async () => {
|
||||||
|
const disabled = await newServerView.getAttribute('#saveNewServerModal', 'disabled');
|
||||||
|
(disabled === null).should.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add the team to the config file', async () => {
|
||||||
|
await newServerView.click('#saveNewServerModal');
|
||||||
|
await asyncSleep(1000);
|
||||||
|
const existing = Boolean(await this.app.windows().find((window) => window.url().includes('newServer')));
|
||||||
|
existing.should.be.false;
|
||||||
|
|
||||||
|
const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
||||||
|
savedConfig.teams.should.deep.contain({
|
||||||
|
name: 'TestTeam',
|
||||||
|
url: 'http://example.org',
|
||||||
|
order: 2,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
|
order: 0,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_PLAYBOOKS',
|
||||||
|
order: 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -4,529 +4,265 @@
|
|||||||
|
|
||||||
// TODO: fix test with new settings window
|
// TODO: fix test with new settings window
|
||||||
|
|
||||||
// 'use strict';
|
'use strict';
|
||||||
|
|
||||||
// const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
// const env = require('../../modules/environment');
|
const {SHOW_SETTINGS_WINDOW} = require('../../../src/common/communication');
|
||||||
// const {asyncSleep} = require('../../modules/utils');
|
|
||||||
|
const env = require('../../modules/environment');
|
||||||
// describe('renderer/settings.html', function desc() {
|
const {asyncSleep} = require('../../modules/utils');
|
||||||
// this.timeout(30000);
|
|
||||||
|
describe('renderer/settings.html', function desc() {
|
||||||
// const config = {
|
this.timeout(30000);
|
||||||
// version: 2,
|
|
||||||
// teams: [{
|
const config = {
|
||||||
// name: 'example',
|
version: 3,
|
||||||
// url: env.mattermostURL,
|
teams: [{
|
||||||
// order: 0,
|
name: 'example',
|
||||||
// }, {
|
url: env.mattermostURL,
|
||||||
// name: 'github',
|
order: 0,
|
||||||
// url: 'https://github.com/',
|
tabs: [
|
||||||
// order: 1,
|
{
|
||||||
// }],
|
name: 'TAB_MESSAGING',
|
||||||
// showTrayIcon: false,
|
order: 0,
|
||||||
// trayIconTheme: 'light',
|
isOpen: true,
|
||||||
// minimizeToTray: false,
|
},
|
||||||
// notifications: {
|
{
|
||||||
// flashWindow: 0,
|
name: 'TAB_FOCALBOARD',
|
||||||
// bounceIcon: false,
|
order: 1,
|
||||||
// bounceIconType: 'informational',
|
isOpen: true,
|
||||||
// },
|
},
|
||||||
// showUnreadBadge: true,
|
{
|
||||||
// useSpellChecker: true,
|
name: 'TAB_PLAYBOOKS',
|
||||||
// enableHardwareAcceleration: true,
|
order: 2,
|
||||||
// autostart: true,
|
isOpen: true,
|
||||||
// darkMode: false,
|
},
|
||||||
// };
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
// beforeEach(async () => {
|
}, {
|
||||||
// fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
name: 'github',
|
||||||
// await asyncSleep(1000);
|
url: 'https://github.com/',
|
||||||
// this.app = env.getSpectronApp();
|
order: 1,
|
||||||
// await this.app.start();
|
tabs: [
|
||||||
// });
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
// afterEach(async () => {
|
order: 0,
|
||||||
// if (this.app && this.app.isRunning()) {
|
isOpen: true,
|
||||||
// await this.app.stop();
|
},
|
||||||
// }
|
{
|
||||||
// });
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
// describe('Close button', async () => {
|
isOpen: true,
|
||||||
// // it.skip('should show index.html when it\'s clicked', async () => {
|
},
|
||||||
// // env.addClientCommands(this.app.client);
|
{
|
||||||
// // await this.app.client.
|
name: 'TAB_PLAYBOOKS',
|
||||||
// // loadSettingsPage().
|
order: 2,
|
||||||
// // click('#btnClose').
|
isOpen: true,
|
||||||
// // pause(1000);
|
},
|
||||||
// // const url = await this.app.client.getUrl();
|
],
|
||||||
// // url.should.match(/\/index.html(\?.+)?$/);
|
lastActiveTab: 0,
|
||||||
// // });
|
}],
|
||||||
|
showTrayIcon: false,
|
||||||
// it('should be disabled when the number of servers is zero', async () => {
|
trayIconTheme: 'light',
|
||||||
// await this.app.stop();
|
minimizeToTray: false,
|
||||||
// env.cleanTestConfig();
|
notifications: {
|
||||||
// await this.app.start();
|
flashWindow: 0,
|
||||||
|
bounceIcon: false,
|
||||||
// await this.app.client.waitUntilWindowLoaded().
|
bounceIconType: 'informational',
|
||||||
// waitForVisible('#newServerModal', 10000).
|
},
|
||||||
// click('#cancelNewServerModal');
|
showUnreadBadge: true,
|
||||||
// let isCloseButtonEnabled = await this.app.client.isEnabled('#btnClose');
|
useSpellChecker: true,
|
||||||
// isCloseButtonEnabled.should.equal(false);
|
enableHardwareAcceleration: true,
|
||||||
|
autostart: true,
|
||||||
// await this.app.client.
|
darkMode: false,
|
||||||
// waitForVisible('#newServerModal', true).
|
lastActiveTeam: 0,
|
||||||
// pause(250).
|
spellCheckerLocales: [],
|
||||||
// click('#addNewServer').
|
};
|
||||||
// waitForVisible('#newServerModal').
|
|
||||||
// setValue('#teamNameInput', 'TestTeam').
|
beforeEach(async () => {
|
||||||
// pause(100).
|
env.createTestUserDataDir();
|
||||||
// setValue('#teamUrlInput', 'http://example.org').
|
env.cleanTestConfig();
|
||||||
// click('#saveNewServerModal').
|
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
||||||
// waitForVisible('#newServerModal', true).
|
await asyncSleep(1000);
|
||||||
// waitForVisible('#serversSaveIndicator').
|
this.app = await env.getApp();
|
||||||
// waitForVisible('#serversSaveIndicator', 10000, true); // at least 2500 ms to disappear
|
});
|
||||||
// isCloseButtonEnabled = await this.app.client.isEnabled('#btnClose');
|
|
||||||
// isCloseButtonEnabled.should.equal(true);
|
afterEach(async () => {
|
||||||
// });
|
if (this.app) {
|
||||||
// });
|
await this.app.close();
|
||||||
|
}
|
||||||
// it('should show NewServerModal after all servers are removed', async () => {
|
});
|
||||||
// const modalTitleSelector = '.modal-title=Remove Server';
|
|
||||||
// env.addClientCommands(this.app.client);
|
describe('Options', () => {
|
||||||
// await this.app.client.
|
describe('Start app on login', () => {
|
||||||
// loadSettingsPage().
|
it('should appear on win32 or linux', async () => {
|
||||||
// click('=Remove').
|
const expected = (process.platform === 'win32' || process.platform === 'linux');
|
||||||
// waitForVisible(modalTitleSelector).
|
this.app.evaluate(({ipcMain}, showWindow) => {
|
||||||
// element('.modal-dialog').click('.btn=Remove').
|
ipcMain.emit(showWindow);
|
||||||
// pause(500).
|
}, SHOW_SETTINGS_WINDOW);
|
||||||
// click('=Remove').
|
const settingsWindow = await this.app.waitForEvent('window', {
|
||||||
// waitForVisible(modalTitleSelector).
|
predicate: (window) => window.url().includes('settings'),
|
||||||
// element('.modal-dialog').click('.btn=Remove').
|
});
|
||||||
// pause(500);
|
await settingsWindow.waitForSelector('.settingsPage.container');
|
||||||
// const isModalExisting = await this.app.client.isExisting('#newServerModal');
|
const existing = await settingsWindow.isVisible('#inputAutoStart');
|
||||||
// isModalExisting.should.be.true;
|
existing.should.equal(expected);
|
||||||
// });
|
});
|
||||||
|
});
|
||||||
// // describe('Server list', () => {
|
|
||||||
// // it.skip('should open the corresponding tab when a server list item is clicked', async () => {
|
describe('Show icon in menu bar / notification area', () => {
|
||||||
// // env.addClientCommands(this.app.client);
|
it('should appear on darwin or linux', async () => {
|
||||||
// // await this.app.client.
|
const expected = (process.platform === 'darwin' || process.platform === 'linux');
|
||||||
// // loadSettingsPage().
|
this.app.evaluate(({ipcMain}, showWindow) => {
|
||||||
// // click('h4=example').
|
ipcMain.emit(showWindow);
|
||||||
// // pause(1000).
|
}, SHOW_SETTINGS_WINDOW);
|
||||||
// // waitUntilWindowLoaded();
|
const settingsWindow = await this.app.waitForEvent('window', {
|
||||||
// // let indexURL = await this.app.client.getUrl();
|
predicate: (window) => window.url().includes('settings'),
|
||||||
// // indexURL.should.match(/\/index.html(\?.+)?$/);
|
});
|
||||||
|
await settingsWindow.waitForSelector('.settingsPage.container');
|
||||||
// // let isView0Visible = await this.app.client.isVisible('#mattermostView0');
|
const existing = await settingsWindow.isVisible('#inputShowTrayIcon');
|
||||||
// // isView0Visible.should.be.true;
|
existing.should.equal(expected);
|
||||||
|
});
|
||||||
// // let isView1Visible = await this.app.client.isVisible('#mattermostView1');
|
|
||||||
// // isView1Visible.should.be.false;
|
describe('Save tray icon setting on mac', () => {
|
||||||
|
env.shouldTest(it, env.isOneOf(['darwin', 'linux']))('should be saved when it\'s selected', async () => {
|
||||||
// // await this.app.client.
|
this.app.evaluate(({ipcMain}, showWindow) => {
|
||||||
// // loadSettingsPage().
|
ipcMain.emit(showWindow);
|
||||||
// // click('h4=github').
|
}, SHOW_SETTINGS_WINDOW);
|
||||||
// // pause(1000).
|
const settingsWindow = await this.app.waitForEvent('window', {
|
||||||
// // waitUntilWindowLoaded();
|
predicate: (window) => window.url().includes('settings'),
|
||||||
// // indexURL = await this.app.client.getUrl();
|
});
|
||||||
// // indexURL.should.match(/\/index.html(\?.+)?$/);
|
await settingsWindow.waitForSelector('.settingsPage.container');
|
||||||
|
await settingsWindow.click('#inputShowTrayIcon');
|
||||||
// // isView0Visible = await this.app.client.isVisible('#mattermostView0');
|
await settingsWindow.waitForSelector('.IndicatorContainer :text("Saved")');
|
||||||
// // isView0Visible.should.be.false;
|
|
||||||
|
let config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
||||||
// // isView1Visible = await this.app.client.isVisible('#mattermostView1');
|
config0.showTrayIcon.should.true;
|
||||||
// // isView1Visible.should.be.true;
|
|
||||||
// // });
|
await settingsWindow.click('#inputShowTrayIcon');
|
||||||
// // });
|
await settingsWindow.waitForSelector('.IndicatorContainer :text("Saved")');
|
||||||
|
|
||||||
// describe('Options', () => {
|
config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
||||||
// // describe.skip('Hide Menu Bar', () => {
|
config0.showTrayIcon.should.false;
|
||||||
// // it('should appear on win32 or linux', async () => {
|
});
|
||||||
// // const expected = (process.platform === 'win32' || process.platform === 'linux');
|
});
|
||||||
// // env.addClientCommands(this.app.client);
|
|
||||||
// // await this.app.client.loadSettingsPage();
|
describe('Save tray icon theme on linux', () => {
|
||||||
// // const existing = await this.app.client.isExisting('#inputHideMenuBar');
|
env.shouldTest(it, process.platform === 'linux')('should be saved when it\'s selected', async () => {
|
||||||
// // existing.should.equal(expected);
|
this.app.evaluate(({ipcMain}, showWindow) => {
|
||||||
// // });
|
ipcMain.emit(showWindow);
|
||||||
|
}, SHOW_SETTINGS_WINDOW);
|
||||||
// // [true, false].forEach((v) => {
|
const settingsWindow = await this.app.waitForEvent('window', {
|
||||||
// // env.shouldTest(it, env.isOneOf(['win32', 'linux']))(`should be saved and loaded: ${v}`, async () => {
|
predicate: (window) => window.url().includes('settings'),
|
||||||
// // env.addClientCommands(this.app.client);
|
});
|
||||||
// // await this.app.client.
|
await settingsWindow.waitForSelector('.settingsPage.container');
|
||||||
// // loadSettingsPage().
|
await settingsWindow.click('#inputShowTrayIcon');
|
||||||
// // scroll('#inputHideMenuBar');
|
await settingsWindow.click('input[value="dark"]');
|
||||||
// // const isSelected = await this.app.client.isSelected('#inputHideMenuBar');
|
await settingsWindow.waitForSelector('.IndicatorContainer :text("Saved")');
|
||||||
// // if (isSelected !== v) {
|
|
||||||
// // await this.app.client.click('#inputHideMenuBar');
|
const config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
||||||
// // }
|
config0.trayIconTheme.should.equal('dark');
|
||||||
|
|
||||||
// // await this.app.client.
|
await settingsWindow.click('input[value="light"]');
|
||||||
// // pause(600).
|
await settingsWindow.waitForSelector('.IndicatorContainer :text("Saved")');
|
||||||
// // click('#btnClose').
|
|
||||||
// // pause(1000);
|
const config1 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
||||||
|
config1.trayIconTheme.should.equal('light');
|
||||||
// // const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
});
|
||||||
// // savedConfig.hideMenuBar.should.equal(v);
|
});
|
||||||
|
});
|
||||||
// // let autoHide = await this.app.browserWindow.isMenuBarAutoHide();
|
|
||||||
// // autoHide.should.equal(v);
|
describe('Leave app running in notification area when application window is closed', () => {
|
||||||
|
it('should appear on linux', async () => {
|
||||||
// // // confirm actual behavior
|
const expected = (process.platform === 'linux');
|
||||||
// // await this.app.restart();
|
this.app.evaluate(({ipcMain}, showWindow) => {
|
||||||
// // env.addClientCommands(this.app.client);
|
ipcMain.emit(showWindow);
|
||||||
|
}, SHOW_SETTINGS_WINDOW);
|
||||||
// // autoHide = await this.app.browserWindow.isMenuBarAutoHide();
|
const settingsWindow = await this.app.waitForEvent('window', {
|
||||||
// // autoHide.should.equal(v);
|
predicate: (window) => window.url().includes('settings'),
|
||||||
|
});
|
||||||
// // await this.app.loadSettingsPage();
|
await settingsWindow.waitForSelector('.settingsPage.container');
|
||||||
// // autoHide = await this.app.client.isSelected('#inputHideMenuBar');
|
const existing = await settingsWindow.isVisible('#inputMinimizeToTray');
|
||||||
// // autoHide.should.equal(v);
|
existing.should.equal(expected);
|
||||||
// // });
|
});
|
||||||
// // });
|
});
|
||||||
// // });
|
|
||||||
|
describe('Flash app window and taskbar icon when a new message is received', () => {
|
||||||
// describe('Start app on login', () => {
|
it('should appear on win32 and linux', async () => {
|
||||||
// it('should appear on win32 or linux', async () => {
|
const expected = (process.platform === 'win32' || process.platform === 'linux');
|
||||||
// const expected = (process.platform === 'win32' || process.platform === 'linux');
|
this.app.evaluate(({ipcMain}, showWindow) => {
|
||||||
// env.addClientCommands(this.app.client);
|
ipcMain.emit(showWindow);
|
||||||
// await this.app.client.loadSettingsPage();
|
}, SHOW_SETTINGS_WINDOW);
|
||||||
// const existing = await this.app.client.isExisting('#inputAutoStart');
|
const settingsWindow = await this.app.waitForEvent('window', {
|
||||||
// existing.should.equal(expected);
|
predicate: (window) => window.url().includes('settings'),
|
||||||
// });
|
});
|
||||||
// });
|
await settingsWindow.waitForSelector('.settingsPage.container');
|
||||||
|
const existing = await settingsWindow.isVisible('#inputflashWindow');
|
||||||
// describe('Show icon in menu bar / notification area', () => {
|
existing.should.equal(expected);
|
||||||
// it('should appear on darwin or linux', async () => {
|
});
|
||||||
// const expected = (process.platform === 'darwin' || process.platform === 'linux');
|
});
|
||||||
// env.addClientCommands(this.app.client);
|
|
||||||
// await this.app.client.loadSettingsPage();
|
describe('Show red badge on taskbar icon to indicate unread messages', () => {
|
||||||
// const existing = await this.app.client.isExisting('#inputShowTrayIcon');
|
it('should appear on darwin or win32', async () => {
|
||||||
// existing.should.equal(expected);
|
const expected = (process.platform === 'darwin' || process.platform === 'win32');
|
||||||
// });
|
this.app.evaluate(({ipcMain}, showWindow) => {
|
||||||
|
ipcMain.emit(showWindow);
|
||||||
// describe('Save tray icon setting on mac', () => {
|
}, SHOW_SETTINGS_WINDOW);
|
||||||
// env.shouldTest(it, env.isOneOf(['darwin', 'linux']))('should be saved when it\'s selected', async () => {
|
const settingsWindow = await this.app.waitForEvent('window', {
|
||||||
// env.addClientCommands(this.app.client);
|
predicate: (window) => window.url().includes('settings'),
|
||||||
// await this.app.browserWindow.setSize(1024, 768); // Resize the window to click the element
|
});
|
||||||
// await this.app.client.
|
await settingsWindow.waitForSelector('.settingsPage.container');
|
||||||
// loadSettingsPage().
|
const existing = await settingsWindow.isVisible('#inputShowUnreadBadge');
|
||||||
// click('#inputShowTrayIcon').
|
existing.should.equal(expected);
|
||||||
// waitForAppOptionsAutoSaved();
|
});
|
||||||
|
});
|
||||||
// let config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
|
||||||
// config0.showTrayIcon.should.true;
|
describe('Check spelling', () => {
|
||||||
|
it('should appear and be selectable', async () => {
|
||||||
// await this.app.client.
|
this.app.evaluate(({ipcMain}, showWindow) => {
|
||||||
// click('#inputShowTrayIcon').
|
ipcMain.emit(showWindow);
|
||||||
// waitForAppOptionsAutoSaved();
|
}, SHOW_SETTINGS_WINDOW);
|
||||||
|
const settingsWindow = await this.app.waitForEvent('window', {
|
||||||
// config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
predicate: (window) => window.url().includes('settings'),
|
||||||
// config0.showTrayIcon.should.false;
|
});
|
||||||
// });
|
await settingsWindow.waitForSelector('.settingsPage.container');
|
||||||
// });
|
const existing = await settingsWindow.isVisible('#inputSpellChecker');
|
||||||
|
existing.should.equal(true);
|
||||||
// describe('Save tray icon theme on linux', () => {
|
|
||||||
// env.shouldTest(it, process.platform === 'linux')('should be saved when it\'s selected', async () => {
|
const selected = await settingsWindow.isChecked('#inputSpellChecker');
|
||||||
// env.addClientCommands(this.app.client);
|
selected.should.equal(true);
|
||||||
// await this.app.browserWindow.setSize(1024, 768); // Resize the window to click the element
|
|
||||||
// await this.app.client.
|
await settingsWindow.click('#inputSpellChecker');
|
||||||
// loadSettingsPage().
|
await settingsWindow.waitForSelector('.IndicatorContainer :text("Saved")');
|
||||||
// click('#inputShowTrayIcon').
|
|
||||||
// click('input[value="dark"]').
|
const config1 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
||||||
// pause(700); // wait auto-save
|
config1.useSpellChecker.should.equal(false);
|
||||||
|
});
|
||||||
// const config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
});
|
||||||
// config0.trayIconTheme.should.equal('dark');
|
|
||||||
|
describe('Enable GPU hardware acceleration', () => {
|
||||||
// await this.app.client.
|
it('should save selected option', async () => {
|
||||||
// click('input[value="light"]').
|
const ID_INPUT_ENABLE_HARDWARE_ACCELERATION = '#inputEnableHardwareAcceleration';
|
||||||
// pause(700); // wait auto-save
|
this.app.evaluate(({ipcMain}, showWindow) => {
|
||||||
|
ipcMain.emit(showWindow);
|
||||||
// const config1 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
}, SHOW_SETTINGS_WINDOW);
|
||||||
// config1.trayIconTheme.should.equal('light');
|
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_HARDWARE_ACCELERATION);
|
||||||
// describe('Leave app running in notification area when application window is closed', () => {
|
selected.should.equal(true); // default is true
|
||||||
// it('should appear on linux', async () => {
|
|
||||||
// const expected = (process.platform === 'linux');
|
await settingsWindow.click(ID_INPUT_ENABLE_HARDWARE_ACCELERATION);
|
||||||
// env.addClientCommands(this.app.client);
|
await settingsWindow.waitForSelector('.IndicatorContainer :text("Saved")');
|
||||||
// await this.app.client.loadSettingsPage();
|
const config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
||||||
// const existing = await this.app.client.isExisting('#inputMinimizeToTray');
|
config0.enableHardwareAcceleration.should.equal(false);
|
||||||
// existing.should.equal(expected);
|
|
||||||
// });
|
await settingsWindow.click(ID_INPUT_ENABLE_HARDWARE_ACCELERATION);
|
||||||
// });
|
await settingsWindow.waitForSelector('.IndicatorContainer :text("Saved")');
|
||||||
|
const config1 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
||||||
// // describe.skip('Toggle window visibility when clicking on the tray icon', () => {
|
config1.enableHardwareAcceleration.should.equal(true);
|
||||||
// // it('should appear on win32', async () => {
|
});
|
||||||
// // const expected = (process.platform === 'win32');
|
});
|
||||||
// // env.addClientCommands(this.app.client);
|
});
|
||||||
// // await this.app.client.loadSettingsPage();
|
});
|
||||||
// // const existing = await this.app.client.isExisting('#inputToggleWindowOnTrayIconClick');
|
|
||||||
// // existing.should.equal(expected);
|
|
||||||
// // });
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// describe('Flash app window and taskbar icon when a new message is received', () => {
|
|
||||||
// it('should appear on win32 and linux', async () => {
|
|
||||||
// const expected = (process.platform === 'win32' || process.platform === 'linux');
|
|
||||||
// env.addClientCommands(this.app.client);
|
|
||||||
// await this.app.client.loadSettingsPage();
|
|
||||||
// const existing = await this.app.client.isExisting('#inputflashWindow');
|
|
||||||
// existing.should.equal(expected);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('Show red badge on taskbar icon to indicate unread messages', () => {
|
|
||||||
// it('should appear on darwin or win32', async () => {
|
|
||||||
// const expected = (process.platform === 'darwin' || process.platform === 'win32');
|
|
||||||
// env.addClientCommands(this.app.client);
|
|
||||||
// await this.app.client.loadSettingsPage();
|
|
||||||
// const existing = await this.app.client.isExisting('#inputShowUnreadBadge');
|
|
||||||
// existing.should.equal(expected);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('Check spelling', () => {
|
|
||||||
// it('should appear and be selectable', async () => {
|
|
||||||
// env.addClientCommands(this.app.client);
|
|
||||||
// await this.app.client.loadSettingsPage();
|
|
||||||
// const existing = await this.app.client.isExisting('#inputSpellChecker');
|
|
||||||
// existing.should.equal(true);
|
|
||||||
|
|
||||||
// const selected = await this.app.client.isSelected('#inputSpellChecker');
|
|
||||||
// selected.should.equal(true);
|
|
||||||
|
|
||||||
// const windowBounds = await this.app.browserWindow.getBounds();
|
|
||||||
// const inputLocation = await this.app.client.getLocation('#inputSpellChecker');
|
|
||||||
// const offset = (inputLocation.y - windowBounds.height) + 100;
|
|
||||||
|
|
||||||
// await this.app.client.
|
|
||||||
// scroll(0, offset).
|
|
||||||
// click('#inputSpellChecker').
|
|
||||||
// pause(5000);
|
|
||||||
// const config1 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
|
||||||
// config1.useSpellChecker.should.equal(false);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('Enable GPU hardware acceleration', () => {
|
|
||||||
// it('should save selected option', async () => {
|
|
||||||
// const ID_INPUT_ENABLE_HARDWARE_ACCELERATION = '#inputEnableHardwareAcceleration';
|
|
||||||
// env.addClientCommands(this.app.client);
|
|
||||||
// await this.app.client.
|
|
||||||
// loadSettingsPage().
|
|
||||||
// waitForExist(ID_INPUT_ENABLE_HARDWARE_ACCELERATION, 5000).
|
|
||||||
// scroll(ID_INPUT_ENABLE_HARDWARE_ACCELERATION);
|
|
||||||
// const selected = await this.app.client.isSelected(ID_INPUT_ENABLE_HARDWARE_ACCELERATION);
|
|
||||||
// selected.should.equal(true); // default is true
|
|
||||||
|
|
||||||
// await this.app.client.click(ID_INPUT_ENABLE_HARDWARE_ACCELERATION).
|
|
||||||
// waitForVisible('#appOptionsSaveIndicator', 5000).
|
|
||||||
// waitForVisible('#appOptionsSaveIndicator', 5000, true); // at least 2500 ms to disappear
|
|
||||||
// const config0 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
|
||||||
// config0.enableHardwareAcceleration.should.equal(false);
|
|
||||||
|
|
||||||
// await this.app.client.click(ID_INPUT_ENABLE_HARDWARE_ACCELERATION).
|
|
||||||
// waitForVisible('#appOptionsSaveIndicator', 5000).
|
|
||||||
// waitForVisible('#appOptionsSaveIndicator', 5000, true); // at least 2500 ms to disappear
|
|
||||||
// const config1 = JSON.parse(fs.readFileSync(env.configFilePath, 'utf-8'));
|
|
||||||
// config1.enableHardwareAcceleration.should.equal(true);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('RemoveServerModal', () => {
|
|
||||||
// const modalTitleSelector = '.modal-title=Remove Server';
|
|
||||||
|
|
||||||
// beforeEach(async () => {
|
|
||||||
// env.addClientCommands(this.app.client);
|
|
||||||
// await this.app.client.loadSettingsPage();
|
|
||||||
// const existing = await this.app.client.isExisting(modalTitleSelector);
|
|
||||||
// existing.should.be.false;
|
|
||||||
|
|
||||||
// const visible = await this.app.client.isVisible(modalTitleSelector);
|
|
||||||
// visible.should.be.false;
|
|
||||||
|
|
||||||
// await this.app.client.
|
|
||||||
// click('=Remove').
|
|
||||||
// waitForVisible(modalTitleSelector);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should remove existing team on click Remove', async () => {
|
|
||||||
// await this.app.client.
|
|
||||||
// element('.modal-dialog').click('.btn=Remove').
|
|
||||||
// waitForExist(modalTitleSelector, 5000, true);
|
|
||||||
|
|
||||||
// await this.app.client.waitForVisible('#serversSaveIndicator', 10000, true);
|
|
||||||
|
|
||||||
// const expectedConfig = JSON.parse(JSON.stringify(config.teams.slice(1)));
|
|
||||||
// expectedConfig.forEach((value) => {
|
|
||||||
// value.order--;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
|
||||||
// savedConfig.teams.should.deep.equal(expectedConfig);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should NOT remove existing team on click Cancel', async () => {
|
|
||||||
// await this.app.client.
|
|
||||||
// element('.modal-dialog').click('.btn=Cancel').
|
|
||||||
// waitForExist(modalTitleSelector, 5000, true);
|
|
||||||
|
|
||||||
// await this.app.client.waitForVisible('#serversSaveIndicator', 10000, true);
|
|
||||||
|
|
||||||
// const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
|
||||||
// savedConfig.teams.should.deep.equal(config.teams);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should disappear on click Close', async () => {
|
|
||||||
// await this.app.client.
|
|
||||||
// element('.modal-dialog').click('button.close').
|
|
||||||
// waitForVisible(modalTitleSelector, 10000, true);
|
|
||||||
// const existing = await this.app.client.isExisting(modalTitleSelector);
|
|
||||||
// existing.should.be.false;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should disappear on click background', async () => {
|
|
||||||
// await this.app.browserWindow.setSize(1024, 768); // Resize the window to click the center of <body>
|
|
||||||
// await this.app.client.
|
|
||||||
// click('body').
|
|
||||||
// waitForVisible(modalTitleSelector, 10000, true);
|
|
||||||
// const existing = await this.app.client.isExisting(modalTitleSelector);
|
|
||||||
// existing.should.be.false;
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('NewTeamModal', () => {
|
|
||||||
// beforeEach(() => {
|
|
||||||
// env.addClientCommands(this.app.client);
|
|
||||||
// return this.app.client.
|
|
||||||
// loadSettingsPage().
|
|
||||||
// click('#addNewServer').
|
|
||||||
// pause(1000);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should open the new server modal', () => {
|
|
||||||
// return this.app.client.isExisting('#newServerModal').then((existing) => {
|
|
||||||
// existing.should.be.true;
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should close the window after clicking cancel', () => {
|
|
||||||
// return this.app.client.
|
|
||||||
// click('#cancelNewServerModal').
|
|
||||||
// waitForExist('#newServerModal', 10000, true).
|
|
||||||
// isExisting('#newServerModal').then((existing) => {
|
|
||||||
// existing.should.be.false;
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should not be valid if no team name has been set', () => {
|
|
||||||
// return this.app.client.
|
|
||||||
// click('#saveNewServerModal').
|
|
||||||
// waitForExist('.has-error #teamNameInput', 10000).
|
|
||||||
// isExisting('.has-error #teamNameInput').then((existing) => {
|
|
||||||
// existing.should.be.true;
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should not be valid if no server address has been set', () => {
|
|
||||||
// return this.app.client.
|
|
||||||
// click('#saveNewServerModal').
|
|
||||||
// waitForExist('.has-error #teamUrlInput', 10000).
|
|
||||||
// isExisting('.has-error #teamUrlInput').then((existing) => {
|
|
||||||
// existing.should.be.true;
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('Valid server name', () => {
|
|
||||||
// beforeEach(() => {
|
|
||||||
// return this.app.client.
|
|
||||||
// setValue('#teamNameInput', 'TestTeam').
|
|
||||||
// click('#saveNewServerModal');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should not be marked invalid', () => {
|
|
||||||
// return this.app.client.
|
|
||||||
// isExisting('.has-error #teamNameInput').then((existing) => {
|
|
||||||
// existing.should.be.false;
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should not be possible to click save', () => {
|
|
||||||
// return this.app.client.
|
|
||||||
// getAttribute('#saveNewServerModal', 'disabled').then((disabled) => {
|
|
||||||
// disabled.should.equal('true');
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('Valid server url', () => {
|
|
||||||
// beforeEach(() => {
|
|
||||||
// return this.app.client.
|
|
||||||
// setValue('#teamUrlInput', 'http://example.org').
|
|
||||||
// click('#saveNewServerModal');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should be valid', () => {
|
|
||||||
// return this.app.client.
|
|
||||||
// isExisting('.has-error #teamUrlInput').then((existing) => {
|
|
||||||
// existing.should.be.false;
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should not be possible to click save', () => {
|
|
||||||
// return this.app.client.
|
|
||||||
// getAttribute('#saveNewServerModal', 'disabled').then((disabled) => {
|
|
||||||
// disabled.should.equal('true');
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should not be valid if an invalid server address has been set', () => {
|
|
||||||
// return this.app.client.
|
|
||||||
// setValue('#teamUrlInput', 'superInvalid url').
|
|
||||||
// click('#saveNewServerModal').
|
|
||||||
// pause(500).
|
|
||||||
// isExisting('.has-error #teamUrlInput').then((existing) => {
|
|
||||||
// existing.should.be.true;
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('Valid Team Settings', () => {
|
|
||||||
// beforeEach(() => {
|
|
||||||
// return this.app.client.
|
|
||||||
// setValue('#teamUrlInput', 'http://example.org').
|
|
||||||
// setValue('#teamNameInput', 'TestTeam');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should be possible to click add', () => {
|
|
||||||
// return this.app.client.
|
|
||||||
// getAttribute('#saveNewServerModal', 'disabled').then((disabled) => {
|
|
||||||
// (disabled === null).should.be.true;
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should add the team to the config file', async () => {
|
|
||||||
// await this.app.client.
|
|
||||||
// click('#saveNewServerModal').
|
|
||||||
// waitForVisible('#newServerModal', 10000, true).
|
|
||||||
// waitForVisible('#serversSaveIndicator', 10000).
|
|
||||||
// waitForVisible('#serversSaveIndicator', 10000, true). // at least 2500 ms to disappear
|
|
||||||
// waitUntilWindowLoaded();
|
|
||||||
|
|
||||||
// const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8'));
|
|
||||||
// savedConfig.teams.should.deep.contain({
|
|
||||||
// name: 'TestTeam',
|
|
||||||
// url: 'http://example.org',
|
|
||||||
// order: 2,
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
116
test/specs/config_test.js
Normal file
116
test/specs/config_test.js
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const env = require('../modules/environment');
|
||||||
|
|
||||||
|
describe('config', function desc() {
|
||||||
|
this.timeout(30000);
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
env.createTestUserDataDir();
|
||||||
|
env.cleanTestConfig();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
if (this.app) {
|
||||||
|
try {
|
||||||
|
await this.app.close();
|
||||||
|
// eslint-disable-next-line no-empty
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show servers in dropdown when there is config file', async () => {
|
||||||
|
const config = {
|
||||||
|
version: 3,
|
||||||
|
teams: [{
|
||||||
|
name: 'example',
|
||||||
|
url: env.mattermostURL,
|
||||||
|
order: 0,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
|
order: 0,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_PLAYBOOKS',
|
||||||
|
order: 2,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
|
}, {
|
||||||
|
name: 'github',
|
||||||
|
url: 'https://github.com/',
|
||||||
|
order: 1,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
|
order: 0,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_PLAYBOOKS',
|
||||||
|
order: 2,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
|
}],
|
||||||
|
showTrayIcon: false,
|
||||||
|
trayIconTheme: 'light',
|
||||||
|
minimizeToTray: false,
|
||||||
|
notifications: {
|
||||||
|
flashWindow: 0,
|
||||||
|
bounceIcon: false,
|
||||||
|
bounceIconType: 'informational',
|
||||||
|
},
|
||||||
|
showUnreadBadge: true,
|
||||||
|
useSpellChecker: true,
|
||||||
|
enableHardwareAcceleration: true,
|
||||||
|
autostart: true,
|
||||||
|
darkMode: false,
|
||||||
|
lastActiveTeam: 0,
|
||||||
|
spellCheckerLocales: [],
|
||||||
|
};
|
||||||
|
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
||||||
|
this.app = await env.getApp();
|
||||||
|
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
|
||||||
|
const dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton');
|
||||||
|
dropdownButtonText.should.equal('example');
|
||||||
|
await this.app.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should upgrade v0 config file', async () => {
|
||||||
|
const Config = require('../../src/common/config').default;
|
||||||
|
const newConfig = new Config(env.configFilePath);
|
||||||
|
const oldConfig = {
|
||||||
|
url: env.mattermostURL,
|
||||||
|
};
|
||||||
|
fs.writeFileSync(env.configFilePath, JSON.stringify(oldConfig));
|
||||||
|
this.app = await env.getApp();
|
||||||
|
const mainWindow = this.app.windows().find((window) => window.url().includes('index'));
|
||||||
|
const dropdownButtonText = await mainWindow.innerText('.TeamDropdownButton:has-text("Primary team")');
|
||||||
|
dropdownButtonText.should.equal('Primary team');
|
||||||
|
|
||||||
|
const str = fs.readFileSync(env.configFilePath, 'utf8');
|
||||||
|
const upgradedConfig = JSON.parse(str);
|
||||||
|
upgradedConfig.version.should.equal(newConfig.defaultData.version);
|
||||||
|
await this.app.close();
|
||||||
|
});
|
||||||
|
});
|
@@ -2,9 +2,13 @@
|
|||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import './app_test.js';
|
import './app_test.js';
|
||||||
import './security_test.js';
|
import './config_test.js';
|
||||||
import './spellchecker_test.js';
|
import './mattermost_test.js';
|
||||||
|
import './window_test.js';
|
||||||
|
|
||||||
import './browser/index_test.js';
|
import './browser/index_test.js';
|
||||||
|
import './browser/modal_test.js';
|
||||||
import './browser/settings_test.js';
|
import './browser/settings_test.js';
|
||||||
|
|
||||||
import './main/user_activity_monitor_test.js';
|
import './main/user_activity_monitor_test.js';
|
||||||
import './utils/util_test.js';
|
import './utils/util_test.js';
|
||||||
|
106
test/specs/mattermost_test.js
Normal file
106
test/specs/mattermost_test.js
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See LICENSE.txt for license information.
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const env = require('../modules/environment');
|
||||||
|
const {asyncSleep} = require('../modules/utils');
|
||||||
|
|
||||||
|
describe('mattermost', function desc() {
|
||||||
|
this.timeout(30000);
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
version: 3,
|
||||||
|
teams: [{
|
||||||
|
name: 'example',
|
||||||
|
url: env.mattermostURL,
|
||||||
|
order: 0,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
|
order: 0,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
|
isOpen: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_PLAYBOOKS',
|
||||||
|
order: 2,
|
||||||
|
isOpen: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
|
}, {
|
||||||
|
name: 'github',
|
||||||
|
url: 'https://github.com/',
|
||||||
|
order: 1,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
|
order: 0,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
|
isOpen: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_PLAYBOOKS',
|
||||||
|
order: 2,
|
||||||
|
isOpen: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
|
}],
|
||||||
|
showTrayIcon: false,
|
||||||
|
trayIconTheme: 'light',
|
||||||
|
minimizeToTray: false,
|
||||||
|
notifications: {
|
||||||
|
flashWindow: 0,
|
||||||
|
bounceIcon: false,
|
||||||
|
bounceIconType: 'informational',
|
||||||
|
},
|
||||||
|
showUnreadBadge: true,
|
||||||
|
useSpellChecker: true,
|
||||||
|
enableHardwareAcceleration: true,
|
||||||
|
autostart: true,
|
||||||
|
darkMode: false,
|
||||||
|
lastActiveTeam: 0,
|
||||||
|
spellCheckerLocales: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: enable when we have a server to test against
|
||||||
|
it.skip('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;
|
||||||
|
await env.loginToMattermost(firstServer);
|
||||||
|
await firstServer.waitForSelector('#searchBox');
|
||||||
|
await firstServer.press('body', process.platform === 'darwin' ? 'Meta+F' : 'Control+F');
|
||||||
|
const isFocused = await firstServer.$eval('#searchBox', (el) => el === document.activeElement);
|
||||||
|
isFocused.should.be.true;
|
||||||
|
const text = await firstServer.inputValue('#searchBox');
|
||||||
|
text.should.include('in:');
|
||||||
|
});
|
||||||
|
});
|
143
test/specs/menu_test.js
Normal file
143
test/specs/menu_test.js
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See LICENSE.txt for license information.
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
// const http = require('http');
|
||||||
|
// const path = require('path');
|
||||||
|
|
||||||
|
const robot = require('robotjs');
|
||||||
|
|
||||||
|
const env = require('../modules/environment');
|
||||||
|
const {asyncSleep} = require('../modules/utils');
|
||||||
|
|
||||||
|
describe('mattermost', function desc() {
|
||||||
|
this.timeout(30000);
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
version: 3,
|
||||||
|
teams: [{
|
||||||
|
name: 'example',
|
||||||
|
url: env.mattermostURL,
|
||||||
|
order: 0,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
|
order: 0,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
|
isOpen: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_PLAYBOOKS',
|
||||||
|
order: 2,
|
||||||
|
isOpen: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
|
}, {
|
||||||
|
name: 'github',
|
||||||
|
url: 'https://github.com/',
|
||||||
|
order: 1,
|
||||||
|
tabs: [
|
||||||
|
{
|
||||||
|
name: 'TAB_MESSAGING',
|
||||||
|
order: 0,
|
||||||
|
isOpen: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_FOCALBOARD',
|
||||||
|
order: 1,
|
||||||
|
isOpen: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'TAB_PLAYBOOKS',
|
||||||
|
order: 2,
|
||||||
|
isOpen: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
lastActiveTab: 0,
|
||||||
|
}],
|
||||||
|
showTrayIcon: false,
|
||||||
|
trayIconTheme: 'light',
|
||||||
|
minimizeToTray: false,
|
||||||
|
notifications: {
|
||||||
|
flashWindow: 0,
|
||||||
|
bounceIcon: false,
|
||||||
|
bounceIconType: 'informational',
|
||||||
|
},
|
||||||
|
showUnreadBadge: true,
|
||||||
|
useSpellChecker: true,
|
||||||
|
enableHardwareAcceleration: true,
|
||||||
|
autostart: true,
|
||||||
|
darkMode: false,
|
||||||
|
lastActiveTeam: 0,
|
||||||
|
spellCheckerLocales: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
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('should reload page when pressing Ctrl+R', async () => {
|
||||||
|
const mainWindow = await this.app.firstWindow();
|
||||||
|
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'});
|
||||||
|
const check = browserWindow.evaluate(async (window, id) => {
|
||||||
|
const promise = new Promise((resolve) => {
|
||||||
|
const browserView = window.getBrowserViews().find((view) => view.webContents.id === id);
|
||||||
|
browserView.webContents.on('did-finish-load', () => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
await promise;
|
||||||
|
return true;
|
||||||
|
}, webContentsId);
|
||||||
|
await asyncSleep(500);
|
||||||
|
robot.keyTap('r', ['control']);
|
||||||
|
const result = await check;
|
||||||
|
result.should.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reload page when pressing Ctrl+Shift+R', async () => {
|
||||||
|
const mainWindow = await this.app.firstWindow();
|
||||||
|
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'});
|
||||||
|
const check = browserWindow.evaluate(async (window, id) => {
|
||||||
|
const promise = new Promise((resolve) => {
|
||||||
|
const browserView = window.getBrowserViews().find((view) => view.webContents.id === id);
|
||||||
|
browserView.webContents.on('did-finish-load', () => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
await promise;
|
||||||
|
return true;
|
||||||
|
}, webContentsId);
|
||||||
|
await asyncSleep(500);
|
||||||
|
robot.keyTap('r', ['control', 'shift']);
|
||||||
|
const result = await check;
|
||||||
|
result.should.be.true;
|
||||||
|
});
|
||||||
|
});
|
@@ -1,126 +0,0 @@
|
|||||||
// Copyright (c) 2015-2016 Yuya Ochiai
|
|
||||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
||||||
// See LICENSE.txt for license information.
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// const fs = require('fs');
|
|
||||||
|
|
||||||
// const path = require('path');
|
|
||||||
// const http = require('http');
|
|
||||||
|
|
||||||
// const env = require('../modules/environment');
|
|
||||||
|
|
||||||
// describe.skip('security', function desc() {
|
|
||||||
// this.timeout(30000);
|
|
||||||
|
|
||||||
// const serverPort = 8181;
|
|
||||||
// const testURL = `http://localhost:${serverPort}`;
|
|
||||||
|
|
||||||
// const config = {
|
|
||||||
// version: 2,
|
|
||||||
// teams: [{
|
|
||||||
// name: 'example_1',
|
|
||||||
// url: testURL,
|
|
||||||
// order: 0,
|
|
||||||
// }, {
|
|
||||||
// name: 'example_2',
|
|
||||||
// url: testURL,
|
|
||||||
// order: 1,
|
|
||||||
// }],
|
|
||||||
// };
|
|
||||||
|
|
||||||
// before(() => {
|
|
||||||
// this.server = http.createServer((req, res) => {
|
|
||||||
// res.writeHead(200, {
|
|
||||||
// 'Content-Type': 'text/html',
|
|
||||||
// });
|
|
||||||
// res.end(fs.readFileSync(path.resolve(env.sourceRootDir, 'test/modules/test.html'), 'utf-8'));
|
|
||||||
// }).listen(serverPort, '127.0.0.1');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// beforeEach(() => {
|
|
||||||
// fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
|
||||||
// this.app = env.getSpectronApp();
|
|
||||||
// return this.app.start();
|
|
||||||
// });
|
|
||||||
|
|
||||||
// afterEach(() => {
|
|
||||||
// if (this.app && this.app.isRunning()) {
|
|
||||||
// return this.app.stop();
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// after((done) => {
|
|
||||||
// this.server.close(done);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should NOT be able to call Node.js API in webview', () => {
|
|
||||||
// env.addClientCommands(this.app.client);
|
|
||||||
|
|
||||||
// // webview is handled as a window by chromedriver.
|
|
||||||
// return this.app.client.
|
|
||||||
// windowByIndex(1).isNodeEnabled().then((enabled) => {
|
|
||||||
// enabled.should.be.false;
|
|
||||||
// }).
|
|
||||||
// windowByIndex(2).isNodeEnabled().then((enabled) => {
|
|
||||||
// enabled.should.be.false;
|
|
||||||
// }).
|
|
||||||
// windowByIndex(0).
|
|
||||||
// getAttribute('webview', 'nodeintegration').then((nodeintegration) => {
|
|
||||||
// // nodeintegration is an array of string
|
|
||||||
// nodeintegration.forEach((n) => {
|
|
||||||
// n.should.equal('false');
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should NOT be able to call Node.js API in a new window', () => {
|
|
||||||
// env.addClientCommands(this.app.client);
|
|
||||||
// const client = this.app.client;
|
|
||||||
// return this.app.client.
|
|
||||||
// windowByIndex(1). // in the first webview
|
|
||||||
// execute(() => {
|
|
||||||
// open_window();
|
|
||||||
// }).
|
|
||||||
// waitUntil(() => {
|
|
||||||
// return client.windowHandles().then((handles) => {
|
|
||||||
// return handles.value.length === 4;
|
|
||||||
// });
|
|
||||||
// }, 5000, 'expected a new window').
|
|
||||||
// windowByIndex(3).isNodeEnabled().then((enabled) => {
|
|
||||||
// enabled.should.be.false;
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should NOT be able to call eval() in any window', () => {
|
|
||||||
// env.addClientCommands(this.app.client);
|
|
||||||
// const tryEval = (index) => {
|
|
||||||
// return this.app.client.
|
|
||||||
// windowByIndex(index).
|
|
||||||
// execute(() => {
|
|
||||||
// return eval('1 + 1');
|
|
||||||
// }).then((result) => {
|
|
||||||
// throw new Error(`Promise was unexpectedly fulfilled (result: ${result})`);
|
|
||||||
// }, (error) => {
|
|
||||||
// (error !== null).should.be.true;
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
// const tryEvalInSettingsPage = () => {
|
|
||||||
// return this.app.client.
|
|
||||||
// windowByIndex(0).
|
|
||||||
// loadSettingsPage().
|
|
||||||
// execute(() => {
|
|
||||||
// return eval('1 + 1');
|
|
||||||
// }).then((result) => {
|
|
||||||
// throw new Error(`Promise was unexpectedly fulfilled (result: ${result})`);
|
|
||||||
// }, (error) => {
|
|
||||||
// (error !== null).should.be.true;
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
// return Promise.all([
|
|
||||||
// tryEval(0),
|
|
||||||
// tryEvalInSettingsPage(),
|
|
||||||
// ]);
|
|
||||||
// });
|
|
||||||
// });
|
|
@@ -1,152 +0,0 @@
|
|||||||
// Copyright (c) 2015-2016 Yuya Ochiai
|
|
||||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
||||||
// See LICENSE.txt for license information.
|
|
||||||
//import path from 'path';
|
|
||||||
|
|
||||||
// TODO: reenable with the new spellchecker
|
|
||||||
|
|
||||||
// describe('main/Spellchecker.js', function() {
|
|
||||||
// describe('getSpellCheckerLocale()', () => {
|
|
||||||
// it('should return recognized locale', () => {
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('en').should.equal('en-US');
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('en-US').should.equal('en-US');
|
|
||||||
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('fr').should.equal('fr-FR');
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('fr-FR').should.equal('fr-FR');
|
|
||||||
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('de').should.equal('de-DE');
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('de-DE').should.equal('de-DE');
|
|
||||||
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('es').should.equal('es-ES');
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('es-ES').should.equal('es-ES');
|
|
||||||
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('nl').should.equal('nl-NL');
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('nl-NL').should.equal('nl-NL');
|
|
||||||
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('pl').should.equal('pl-PL');
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('pl-PL').should.equal('pl-PL');
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('pt').should.equal('pt-BR');
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('pt-BR').should.equal('pt-BR');
|
|
||||||
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('ja').should.equal('en-US');
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('ja-JP').should.equal('en-US');
|
|
||||||
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('it').should.equal('it-IT');
|
|
||||||
// // SpellChecker.getSpellCheckerLocale('it-IT').should.equal('it-IT');
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('en-US', function() {
|
|
||||||
// const spellchecker = null;
|
|
||||||
|
|
||||||
// // before(function(done) {
|
|
||||||
// // // spellchecker = new SpellChecker(
|
|
||||||
// // // 'en-US',
|
|
||||||
// // // path.resolve(__dirname, '../../src/node_modules/simple-spellchecker/dict'),
|
|
||||||
// // // done
|
|
||||||
// // // );
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// it('should spellcheck', function() {
|
|
||||||
// // https://github.com/jfmdev/simple-spellchecker/issues/3
|
|
||||||
// spellchecker.spellCheck('spell').should.equal(true);
|
|
||||||
// spellchecker.spellCheck('spel').should.equal(false);
|
|
||||||
// spellchecker.spellCheck('December').should.equal(true);
|
|
||||||
// spellchecker.spellCheck('december').should.equal(true);
|
|
||||||
// spellchecker.spellCheck('English').should.equal(true);
|
|
||||||
// spellchecker.spellCheck('Japan').should.equal(true);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should allow contractions', function() {
|
|
||||||
// spellchecker.spellCheck("shouldn't").should.equal(true);
|
|
||||||
// spellchecker.spellCheck('shouldn').should.equal(true);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should allow numerals', function() {
|
|
||||||
// spellchecker.spellCheck('1').should.equal(true);
|
|
||||||
// spellchecker.spellCheck('-100').should.equal(true);
|
|
||||||
// spellchecker.spellCheck('3.14').should.equal(true);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should allow "Mattermost"', function() {
|
|
||||||
// spellchecker.spellCheck('Mattermost').should.equal(true);
|
|
||||||
// spellchecker.spellCheck('mattermost').should.equal(true);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should give at most the requested number of suggestions', function() {
|
|
||||||
// // helllo known to give at least 4 suggestions
|
|
||||||
// spellchecker.getSuggestions('helllo', 4).length.should.be.equal(4);
|
|
||||||
// spellchecker.getSuggestions('helllo', 1).length.should.be.equal(1);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should give suggestions which preserve case of first letter', function() {
|
|
||||||
// let suggestions = spellchecker.getSuggestions('carr', 4);
|
|
||||||
// suggestions.length.should.not.be.equal(0);
|
|
||||||
// let i;
|
|
||||||
// for (i = 0; i < suggestions.length; i++) {
|
|
||||||
// suggestions[i].charAt(0).should.be.equal('c');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// suggestions = spellchecker.getSuggestions('Carr', 4);
|
|
||||||
// suggestions.length.should.not.be.equal(0);
|
|
||||||
// for (i = 0; i < suggestions.length; i++) {
|
|
||||||
// suggestions[i].charAt(0).should.be.equal('C');
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('en-GB', function() {
|
|
||||||
// const spellchecker = null;
|
|
||||||
|
|
||||||
// // before(function(done) {
|
|
||||||
// // spellchecker = new SpellChecker(
|
|
||||||
// // 'en-GB',
|
|
||||||
// // path.resolve(__dirname, '../../src/node_modules/simple-spellchecker/dict'),
|
|
||||||
// // done
|
|
||||||
// // );
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// it('should allow contractions', function() {
|
|
||||||
// spellchecker.spellCheck("shouldn't").should.equal(true);
|
|
||||||
// spellchecker.spellCheck('shouldn').should.equal(true);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('de-DE', function() {
|
|
||||||
// const spellchecker = null;
|
|
||||||
|
|
||||||
// // before(function(done) {
|
|
||||||
// // spellchecker = new SpellChecker(
|
|
||||||
// // 'de-DE',
|
|
||||||
// // path.resolve(__dirname, '../../src/node_modules/simple-spellchecker/dict'),
|
|
||||||
// // done
|
|
||||||
// // );
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// it('should spellcheck', function() {
|
|
||||||
// spellchecker.spellCheck('Guten').should.equal(true);
|
|
||||||
// spellchecker.spellCheck('tag').should.equal(true);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should allow numerals', function() {
|
|
||||||
// spellchecker.spellCheck('1').should.equal(true);
|
|
||||||
// spellchecker.spellCheck('-100').should.equal(true);
|
|
||||||
// spellchecker.spellCheck('3.14').should.equal(true);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should give suggestions which preserve case of first letter', function() {
|
|
||||||
// let suggestions = spellchecker.getSuggestions('gutenn', 4);
|
|
||||||
// suggestions.length.should.not.be.equal(0);
|
|
||||||
// let i;
|
|
||||||
// for (i = 0; i < suggestions.length; i++) {
|
|
||||||
// suggestions[i].charAt(0).should.be.equal('g');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// suggestions = spellchecker.getSuggestions('Gutenn', 4);
|
|
||||||
// suggestions.length.should.not.be.equal(0);
|
|
||||||
// for (i = 0; i < suggestions.length; i++) {
|
|
||||||
// suggestions[i].charAt(0).should.be.equal('G');
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
67
test/specs/window_test.js
Normal file
67
test/specs/window_test.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const env = require('../modules/environment');
|
||||||
|
|
||||||
|
describe('window', function desc() {
|
||||||
|
this.timeout(30000);
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
env.createTestUserDataDir();
|
||||||
|
env.cleanTestConfig();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
if (this.app) {
|
||||||
|
try {
|
||||||
|
await this.app.close();
|
||||||
|
// eslint-disable-next-line no-empty
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it.skip('should restore window bounds', async () => {
|
||||||
|
// TODO: Still fails in CircleCI
|
||||||
|
// bounds seems to be incorrectly calculated in some environments
|
||||||
|
// - Windows 10: OK
|
||||||
|
// - CircleCI: NG
|
||||||
|
const expectedBounds = {x: 100, y: 200, width: 800, height: 400};
|
||||||
|
fs.writeFileSync(env.boundsInfoPath, JSON.stringify(expectedBounds));
|
||||||
|
this.app = await env.getApp();
|
||||||
|
const mainWindow = await this.app.firstWindow();
|
||||||
|
const browserWindow = await this.app.browserWindow(mainWindow);
|
||||||
|
const bounds = await browserWindow.evaluate((window) => window.getContentBounds());
|
||||||
|
bounds.should.deep.equal(expectedBounds);
|
||||||
|
await this.app.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('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}));
|
||||||
|
this.app = await env.getApp();
|
||||||
|
const mainWindow = await this.app.firstWindow();
|
||||||
|
const browserWindow = await this.app.browserWindow(mainWindow);
|
||||||
|
const bounds = await browserWindow.evaluate((window) => window.getContentBounds());
|
||||||
|
bounds.x.should.satisfy((x) => (x > -100000));
|
||||||
|
await this.app.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('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}));
|
||||||
|
this.app = await env.getApp();
|
||||||
|
const mainWindow = await this.app.firstWindow();
|
||||||
|
const browserWindow = await this.app.browserWindow(mainWindow);
|
||||||
|
const bounds = await browserWindow.evaluate((window) => window.getContentBounds());
|
||||||
|
bounds.y.should.satisfy((y) => (y < 200000));
|
||||||
|
await this.app.close();
|
||||||
|
});
|
||||||
|
});
|
@@ -38,7 +38,8 @@ module.exports = merge(base, {
|
|||||||
net: 'require("net")',
|
net: 'require("net")',
|
||||||
repl: 'require("repl")',
|
repl: 'require("repl")',
|
||||||
tls: 'require("tls")',
|
tls: 'require("tls")',
|
||||||
spectron: 'require("spectron")',
|
playwright: 'require("playwright")',
|
||||||
|
robotjs: 'require("robotjs")',
|
||||||
},
|
},
|
||||||
node: {
|
node: {
|
||||||
__filename: false,
|
__filename: false,
|
||||||
|
Reference in New Issue
Block a user