Skip to content

Commit

Permalink
Merge branch 'staging' into snyk-fix-9cxa7u
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Apr 7, 2019
2 parents 5b39f5e + 803e777 commit c6cb9d1
Show file tree
Hide file tree
Showing 5 changed files with 360 additions and 33 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -31,6 +31,7 @@ script:
- ng lint
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then yarn test-single-run; fi
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then ng e2e; fi
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then yarn test-electron; fi
- if [ ! -z "$TRAVIS_TAG" ]; then yarn build-electron; fi
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then yarn build; fi # Need to generate files for deployment
before_deploy:
Expand Down
42 changes: 19 additions & 23 deletions electron/__tests__/index.js
@@ -1,8 +1,8 @@
const Application = require('spectron').Application;
const assert = require('assert');
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const path = require('path');

console.log(__dirname);
let electronPath = path.join(__dirname, '../../node_modules', '.bin', 'electron');
const appPath = path.join(__dirname, '../main');
if (process.platform === 'win32') {
Expand All @@ -14,28 +14,24 @@ const app = new Application({
env: {
ELECTRON_ENABLE_LOGGING: true,
ELECTRON_ENABLE_STACK_DUMPING: true,
NODE_ENV: 'development'
NODE_ENV: 'test'
},
startTimeout: 20000,
requireName: 'electronRequire',
});

app.start().then(() => {
// Check if the window is visible
return app.browserWindow.isVisible();
}).then((isVisible) => {
// Verify the window is visible
assert.equal(isVisible, true);
}).then(() => {
// Get the window's title
return app.client.getTitle();
}).then((title) => {
// Verify the window's title
assert.equal(title, 'Altair');
}).then(() => {
// Stop the application
return app.stop();
}).catch((error) => {
// Log any failures
console.error('Test failed', error.message);
return app.stop();
})
global.before(function() {
chai.should();
chai.use(chaiAsPromised);
});
describe('Altair electron', () => {
beforeEach(function() {
this.timeout(20000);
return app.start();
});
afterEach(() => app.stop());

it('load window successfully', () => {
return app.browserWindow.isVisible().should.eventually.equal(true);
});
});
5 changes: 5 additions & 0 deletions electron/preload/index.js
Expand Up @@ -13,3 +13,8 @@
// window.bar = 'bar'

window.ipc = require('electron').ipcRenderer;

// Giving access to spectron to run tests successfully
if (process.env.NODE_ENV === 'test') {
window.electronRequire = require;
}
7 changes: 6 additions & 1 deletion package.json
Expand Up @@ -33,7 +33,8 @@
"package": "electron-forge package",
"make": "electron-forge make",
"dist-electron": "build",
"test-electron": "npm run build && ./electron/fix-base-path.sh && node electron/__tests__",
"test-electron": "npm run build && ./electron/fix-base-path.sh && npm run test-electron:simple",
"test-electron:simple": "./node_modules/.bin/mocha --full-trace electron/__tests__",
"postinstall": "npm run generate-settings-schema-validator && opencollective postinstall",
"lerna-publish": "lerna publish from-git --force-publish=* --yes",
"publish-packages": "npm run build && lerna bootstrap && npm run lerna-publish",
Expand Down Expand Up @@ -127,9 +128,12 @@
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"codelyzer": "^4.0.2",
"devtron": "^1.4.0",
"electron-builder": "^20.27.1",
"electron-chromedriver": "^5.0.0-beta.1",
"electron-prebuilt-compile": "^4.0.0",
"electron-reloader": "^0.2.0",
"jasmine-core": "^3.1.0",
Expand All @@ -142,6 +146,7 @@
"karma-jasmine-html-reporter": "1.3.1",
"lerna": "^3.10.7",
"mime-types": "^2.1.17",
"mocha": "6.0.0",
"ncp": "^2.0.0",
"ngrx-store-freeze": "^0.2.0",
"protractor": "^5.2.2",
Expand Down

0 comments on commit c6cb9d1

Please sign in to comment.