Unverified Commit 2306eb2c authored by Tasso Evangelista's avatar Tasso Evangelista Committed by GitHub

Merge pull request #881 from RocketChat/improve/e2e

[IMPROVE] End-to-end tests
parents 3a07d6d3 0f044167
......@@ -41,4 +41,12 @@ install:
script:
- if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then export CSC_IDENTITY_AUTO_DISCOVERY=false; fi
# e2e tests should be performed only on Linux
- |
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sleep 3
yarn e2e
fi
- yarn release
import { expect } from 'chai';
import { app, startApp, stopApp } from './utils';
import packageJson from '../package.json';
describe('application', function () {
before(startApp);
after(stopApp);
it('shows the main window', async function () {
expect(await app.browserWindow.isVisible()).to.be.true;
expect(await app.browserWindow.getTitle()).to.be.equal(packageJson.productName);
});
});
import { expect } from 'chai';
import testUtils from './utils';
describe('application launch', function () {
beforeEach(testUtils.beforeEach);
afterEach(testUtils.afterEach);
it.skip('shows hello world text on screen after launch', function () {
return this.app.client.getText('#greet').then(function (text) {
expect(text).to.equal('Hello World!');
});
});
});
import path from 'path';
import electron from 'electron';
import { Application } from 'spectron';
var beforeEach = function () {
export let app = null;
let logFetchInterval = null;
export async function startApp () {
this.timeout(10000);
this.app = new Application({
app = new Application({
path: electron,
args: ['.'],
startTimeout: 10000,
waitTimeout: 10000,
cwd: process.cwd(),
args: [path.join(__dirname, '..')],
quitTimeout: 5000,
startTimeout: 5000,
waitTimeout: 5000,
});
return this.app.start();
await app.start();
await app.client.waitUntilWindowLoaded();
logFetchInterval = setInterval(fetchLogs, 100);
};
var afterEach = function () {
export async function stopApp () {
this.timeout(10000);
if (this.app && this.app.isRunning()) {
return this.app.stop();
if (app && app.isRunning()) {
clearInterval(logFetchInterval);
fetchLogs();
await app.stop();
app = null;
}
};
export default {
beforeEach: beforeEach,
afterEach: afterEach,
const fetchLogs = async () => {
const logs = await app.client.getMainProcessLogs();
logs.forEach(log => console.log(log));
};
export const menuItem = (menuId, cb) => ({
get exists() {
return app.client.execute((menuId) => {
const { Menu } = require('electron').remote;
const appMenu = Menu.getApplicationMenu();
const menuItem = appMenu.getMenuItemById(menuId);
return !!menuItem;
}, menuId).then(({ value }) => value);
},
get enabled() {
return app.client.execute((menuId) => {
const { Menu } = require('electron').remote;
const appMenu = Menu.getApplicationMenu();
const menuItem = appMenu.getMenuItemById(menuId);
return menuItem.enabled;
}, menuId).then(({ value }) => value);
},
get visible() {
return app.client.execute((menuId) => {
const { Menu } = require('electron').remote;
const appMenu = Menu.getApplicationMenu();
const menuItem = appMenu.getMenuItemById(menuId);
return menuItem.visible;
}, menuId).then(({ value }) => value);
},
get label() {
return app.client.execute((menuId) => {
const { Menu } = require('electron').remote;
const appMenu = Menu.getApplicationMenu();
const menuItem = appMenu.getMenuItemById(menuId);
return menuItem.label;
}, menuId).then(({ value }) => value);
},
click() {
return app.client.execute((menuId) => {
const { Menu } = require('electron').remote;
const appMenu = Menu.getApplicationMenu();
const menuItem = appMenu.getMenuItemById(menuId);
menuItem.click();
}, menuId);
}
});
......@@ -3,6 +3,7 @@
const path = require('path');
const jetpack = require('fs-jetpack');
const rollup = require('rollup').rollup;
const rollupJson = require('rollup-plugin-json');
const nodeBuiltInModules = ['assert', 'buffer', 'child_process', 'cluster',
'console', 'constants', 'crypto', 'dgram', 'dns', 'domain', 'events',
......@@ -31,7 +32,10 @@ module.exports = function (src, dest, opts) {
input: src,
external: generateExternalModulesList(),
cache: cached[src],
plugins: opts.rollupPlugins,
plugins: [].concat(
opts.rollupPlugins,
rollupJson()
),
})
.then(function (bundle) {
cached[src] = bundle;
......
......@@ -5377,7 +5377,13 @@ rollup-plugin-istanbul@^2.0.1:
istanbul-lib-instrument "^1.9.1"
rollup-pluginutils "^2.0.1"
rollup-pluginutils@^2.0.1:
rollup-plugin-json@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-json/-/rollup-plugin-json-3.1.0.tgz#7c1daf60c46bc21021ea016bd00863561a03321b"
dependencies:
rollup-pluginutils "^2.3.1"
rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.3.1.tgz#760d185ccc237dedc12d7ae48c6bcd127b4892d0"
dependencies:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment