mirror of
https://github.com/netzbegruenung/Rocket.Chat.Electron.git
synced 2024-05-05 15:33:40 +02:00
Move e2e directory under src directory
This commit is contained in:
parent
b9290d4a8b
commit
154a8516db
|
@ -1,6 +1,5 @@
|
|||
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
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
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);
|
||||
});
|
||||
});
|
87
e2e/utils.js
87
e2e/utils.js
|
@ -1,87 +0,0 @@
|
|||
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);
|
||||
}
|
||||
});
|
8
src/e2e/.eslintrc
Normal file
8
src/e2e/.eslintrc
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"extends": [
|
||||
"@rocket.chat/eslint-config"
|
||||
],
|
||||
"env": {
|
||||
"mocha": true
|
||||
}
|
||||
}
|
14
src/e2e/app.e2e.js
Normal file
14
src/e2e/app.e2e.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
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);
|
||||
});
|
||||
});
|
87
src/e2e/utils.js
Normal file
87
src/e2e/utils.js
Normal file
|
@ -0,0 +1,87 @@
|
|||
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'
|
||||
));
|
||||
|
|
Loading…
Reference in a new issue