Commit 154a8516 authored by Tasso Evangelista's avatar Tasso Evangelista

Move e2e directory under src directory

parent b9290d4a
node_modules
app
e2e
src/public/lib/bugsnag.js
src/public/vendor/*
scripts/istanbul-reporter.js
/node_modules
/app
/src/public/lib/bugsnag.js
/src/public/vendor/*
/scripts/istanbul-reporter.js
......@@ -127,7 +127,8 @@ Using [electron-mocha](https://github.com/jprichardson/electron-mocha) test runn
yarn e2e
```
Using [mocha](https://mochajs.org/) test runner and [spectron](http://electron.atom.io/spectron/). This task searches for all files in `e2e` directory which respect pattern `*.e2e.js`.
Using [mocha](https://mochajs.org/) test runner and [spectron](http://electron.atom.io/spectron/).
This task searches for all files in `src/e2e` directory which respect pattern `*.e2e.js`.
### Code coverage
......
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 path from 'path';
import electron from 'electron';
import { Application } from 'spectron';
export let app = null;
let logFetchInterval = null;
export async function startApp () {
this.timeout(10000);
app = new Application({
path: electron,
cwd: process.cwd(),
args: [path.join(__dirname, '..')],
quitTimeout: 5000,
startTimeout: 5000,
waitTimeout: 5000,
});
await app.start();
await app.client.waitUntilWindowLoaded();
logFetchInterval = setInterval(fetchLogs, 100);
};
export async function stopApp () {
this.timeout(10000);
if (app && app.isRunning()) {
clearInterval(logFetchInterval);
fetchLogs();
await app.stop();
app = null;
}
};
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);
}
});
{
"extends": [
"@rocket.chat/eslint-config"
],
"env": {
"mocha": true
}
}
import { expect } from 'chai';
import { app, startApp, stopApp } from './utils';
import appManifest 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(appManifest.productName);
});
});
import path from 'path';
import electron from 'electron';
import { Application } from 'spectron';
export let app = null;
let logFetchInterval = null;
const fetchLogs = async() => {
const logs = await app.client.getMainProcessLogs();
logs.forEach((log) => console.log(log));
};
export async function startApp() {
this.timeout(10000);
app = new Application({
path: electron,
cwd: process.cwd(),
args: [path.join(__dirname, '..')],
quitTimeout: 5000,
startTimeout: 5000,
waitTimeout: 5000,
});
await app.start();
await app.client.waitUntilWindowLoaded();
logFetchInterval = setInterval(fetchLogs, 100);
}
export async function stopApp() {
this.timeout(10000);
if (app && app.isRunning()) {
clearInterval(logFetchInterval);
fetchLogs();
await app.stop();
app = null;
}
}
export const menuItem = (menuId) => ({
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);
},
});
......@@ -31,6 +31,6 @@ gulp.task('build-unit-tests', ['environment'], () => createEntryFile(
));
gulp.task('build-e2e-tests', ['build-app'], () => createEntryFile(
jetpack.cwd('e2e'), '*.e2e.js',
jetpack.cwd('src'), '*.e2e.js',
jetpack.cwd('app'), 'e2e.js.autogenerated'
));
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