Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Spectron testing suite #1553

Merged
merged 44 commits into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9a9ae7b
Spectron iteration
evertonfraga Dec 19, 2016
fd26841
Updating spectron
evertonfraga Dec 19, 2016
4d03260
Creating switch for mist.lokidb for automated tests
evertonfraga Dec 20, 2016
43ebaf3
Adding chai-as-expected
evertonfraga Dec 22, 2016
4482a2c
Changing IPC flag
evertonfraga Dec 22, 2016
a69f944
Pairing spectron and electron versions
evertonfraga Dec 29, 2016
a13fe1a
[ESLint] Minor fixes
evertonfraga Jan 2, 2017
9e55aa6
Adding chai-string
evertonfraga Jan 4, 2017
380d6fa
Couple of tests passing
evertonfraga Jan 4, 2017
3c7a403
update .eslintrc.yml
Jan 6, 2017
e33638e
Simplifying code
evertonfraga Jan 10, 2017
0dfeef3
Removing delay in favor of better window management
evertonfraga Jan 13, 2017
8c2bb3a
Adding tests for URL bar
evertonfraga Jan 13, 2017
a6e30ad
Focusing window before each test
evertonfraga Jan 13, 2017
9fca756
Minor fixes
evertonfraga Jan 16, 2017
38e4943
Improving mist setup and teardown
evertonfraga Jan 16, 2017
de9c50e
Fixing wallet test
evertonfraga Jan 16, 2017
a14f8d0
adding html fixture
evertonfraga Jan 17, 2017
e021dcb
Improving test helpers
evertonfraga Jan 17, 2017
04510e5
Tests for ETH-01-002
evertonfraga Jan 17, 2017
155aec6
Updating tests
evertonfraga Jan 17, 2017
65b1379
Starting local HTTP server to deal with html fixtures
evertonfraga Jan 19, 2017
bf44704
Updating tests setup
evertonfraga Jan 23, 2017
58c4a63
Adding more tests
evertonfraga Jan 23, 2017
dd3f299
Updating travis file to run spectron tests
evertonfraga Jan 24, 2017
0cb40e6
Refactoring tests
evertonfraga Jan 26, 2017
8990b40
Tests for ETH-01-007
evertonfraga Jan 26, 2017
c78bc39
Downloading geth on the fly
evertonfraga Jan 30, 2017
5981ef5
Fine-tuning geth download during tests
evertonfraga Jan 30, 2017
7885ded
Merge branch 'develop' into ev_spectron
evertonfraga Jan 30, 2017
d965c42
Changing linux binary dir
evertonfraga Jan 30, 2017
18f9bf8
Fixing binary path on linux
evertonfraga Jan 30, 2017
86b45d9
Travis debug
evertonfraga Jan 30, 2017
6f49db9
Travis debug
evertonfraga Jan 30, 2017
5ad3883
Changing fixtures
evertonfraga Jan 30, 2017
5ebbe40
Fixing tests
evertonfraga Jan 30, 2017
862aee0
Fixing travis file
evertonfraga Jan 30, 2017
fc87c3d
More tests
evertonfraga Jan 30, 2017
cc20517
Adjusting timeouts
evertonfraga Jan 31, 2017
a9f96ae
Adjusting GULP_PLATFORM test env variable
evertonfraga Jan 31, 2017
73125b0
Adjusting timeouts
evertonfraga Jan 31, 2017
8eb4b9d
Disabling some tests for now
evertonfraga Jan 31, 2017
bc74c42
Merge branch 'develop' into ev_spectron
evertonfraga Jan 31, 2017
3637838
Disabling a test
evertonfraga Feb 1, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ rules:
import/no-extraneous-dependencies: ## checks if required modules are missing in packages.json
- error
- devDependencies: ## declares files, whose imports belong to devDependencies
- "**/scripts/*.js"
- "**/scripts/build-dist.js"
- "**/tests/_base.js"
- "**/*.test.js"

globals: # don't warn about missing declarations
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,11 @@ It expects installer/zip files to be in the generated folders e.g. `dist_mist/re
### Code signing for production

**As of [#972](https://github.com/ethereum/mist/pull/972) we've updated the build process and thus need to redo code-signing.**


## Testing

First make sure to build Mist with:
`gulp mist --platform [mac,linux]` or `gulp wallet --platform [mac,linux]`.

Then run `gulp test-mist` or `gulp test-wallet`, accordingly.
19 changes: 12 additions & 7 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ gulp.task('build-dist', ['download-signatures', 'copy-i18n'], (cb) => {
},
dmg: {
background: '../build/dmg-background.jpg',
'icon-size': 128,
iconSize: 128,
contents: [{
x: 441,
y: 448,
Expand Down Expand Up @@ -322,11 +322,9 @@ gulp.task('release-dist', ['build-dist'], (done) => {
if (platformIsActive(osArch)) {
switch (osArch) { // eslint-disable-line default-case
case 'win-ia32':
// cp(path.join('win-ia32', `${applicationName} Setup ${version}-ia32.exe`), `${appNameHypen}-win32-${versionDashed}.exe`);
cp(`${applicationName}-${version}-ia32-win.zip`, `${appNameHypen}-win32-${versionDashed}.zip`);
break;
case 'win-x64':
// cp(path.join('win', `${applicationName} Setup ${version}.exe`), `${appNameHypen}-win64-${versionDashed}.exe`);
cp(`${applicationName}-${version}-win.zip`, `${appNameHypen}-win64-${versionDashed}.zip`);
break;
case 'mac-x64':
Expand Down Expand Up @@ -411,15 +409,22 @@ gulp.task('wallet-checksums', (cb) => {
});


gulp.task('test-wallet', () => {
const testApp = (app) => {
return gulp.src([
'./tests/wallet/*.test.js',
])
.pipe(mocha({
`./tests/${app}/*.test.js`,
]).pipe(mocha({
timeout: 60000,
ui: 'exports',
reporter: 'spec',
}));
};

gulp.task('test-wallet', () => {
testApp('wallet');
});

gulp.task('test-mist', () => {
testApp('mist');
});


Expand Down
17 changes: 16 additions & 1 deletion interface/client/lib/signatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -10015,5 +10015,20 @@ window.SIGNATURES = {
],
"0x38bbfa50": [
"__callback(bytes32,string,bytes)"
],
"0xbc08afd9": [
"WebOfTrustToken(address,uint256)"
],
"0xa5bfa9a9": [
"claimToken(bytes32)"
],
"0x5669c94f": [
"issueToken(address,string)"
],
"0xcdcd77c0": [
"baz(uint32,bool)"
],
"0x0b811cb6": [
"executeProposal(uint256,bytes32)"
]
};
};
3 changes: 1 addition & 2 deletions modules/db.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const fs = require('fs');
const path = require('path');
const Q = require('bluebird');
const Loki = require('lokijs');
const Settings = require('./settings');
Expand All @@ -10,7 +9,7 @@ let db;


exports.init = () => {
const filePath = path.join(Settings.userDataPath, 'mist.lokidb');
const filePath = Settings.dbFilePath;

return Q.try(() => {
// if db file doesn't exist then create it
Expand Down
5 changes: 5 additions & 0 deletions modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ class Settings {
return app.getPath('userData');
}

get dbFilePath() {
const dbFileName = (this.inAutoTestMode) ? 'mist.test.lokidb' : 'mist.lokidb';
return path.join(this.userDataPath, dbFileName);
}

get appDataPath() {
// Application Support/
return app.getPath('appData');
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"babel-runtime": "^6.18.0",
"bignumber.js": "^2.1.4",
"bluebird": "^3.3.5",
"chai-as-promised": "^6.0.0",
"chai-string": "^1.3.0",
"electron-squirrel-startup": "^1.0.0",
"ethereum-client-binaries": "^1.6.1",
"ethereumjs-abi": "^0.6.3",
Expand All @@ -38,6 +40,7 @@
},
"devDependencies": {
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"co-mocha": "^1.1.2",
"del": "^1.2.1",
"electron": "1.3.13",
Expand All @@ -49,13 +52,15 @@
"geth-private": "^1.3.0",
"gulp": "^3.9.0",
"gulp-flatten": "^0.3.0",
"gulp-spawn-mocha": "^2.2.2",
"gulp-spawn-mocha": "^3.1.0",
"istanbul": "^0.4.5",
"merge-stream": "^1.0.0",
"minimist": "^1.2.0",
"mocha": "^3.2.0",
"optimist": "^0.6.1",
"run-sequence": "^1.2.1",
"shelljs": "^0.7.0",
"spectron": "^3.2.2",
"spectron": "3.3.0",
"sync-request": "^3.0.1"
}
}
85 changes: 58 additions & 27 deletions tests/_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ const path = require('path');
const packageJson = require('../package.json');
const gethPrivate = require('geth-private');
const Application = require('spectron').Application;

const chai = require('chai');
// const ClientBinaryManager = require('../modules/clientBinaryManager');

chai.should();

process.env.TEST_MODE = 'true';
Expand All @@ -36,12 +37,13 @@ exports.mocha = function (_module, options) {
const logFilePath = path.join(__dirname, 'mist.log');
shell.rm('-rf', logFilePath);

const appFileName = (options.app === 'wallet') ? 'Ethereum Wallet' : 'Mist',
appVers = packageJson.version.replace(/\./ig, '-'),
platformArch = `${process.platform}-${process.arch}`;
const appFileName = (options.app === 'wallet') ? 'Ethereum Wallet' : 'Mist';
const appVers = packageJson.version.replace(/\./ig, '-');
const platformArch = `${process.platform}-${process.arch}`;

let appPath,
gethPath;
// Temporary. needs integration with ClientBinaryManager
const gethPath = '/Users/ev/Library/Application Support/Mist/binaries/Geth/unpacked/geth';
let appPath;

switch (platformArch) {
case 'darwin-x64':
Expand All @@ -68,13 +70,18 @@ exports.mocha = function (_module, options) {
throw new Error(`Cannot run tests on ${platformArch}, please run on: darwin-x64, linux-x64`);
}

// check that appPath exists
// check that appPath exists
if (!shell.test('-f', appPath)) {
throw new Error(`Cannot find binary: ${appPath}`);
}

// const clientBinaryManager = ClientBinaryManager.init();
// console.log(clientBinaryManager);


this.geth = gethPrivate({
gethPath: path.join(process.cwd(), 'nodes', 'geth', platformArch, 'geth'),
gethPath,
// gethPath: path.join(process.cwd(), 'nodes', 'geth', platformArch, 'geth'),
balance: 5,
genesisBlock: {
difficulty: '0x1',
Expand All @@ -85,49 +92,73 @@ exports.mocha = function (_module, options) {
rpcport: 58545,
},
});

console.log(this.geth);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed

yield this.geth.start();

this.web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:58545'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The port is chosen because of a custom geth one?
Why using an HTTP provider here?



this.app = new Application({
requireName: 'electronRequire',
startTimeout: 5000,
waitTimeout: 5000,
quitTimeout: 10000,
startTimeout: 10000,
waitTimeout: 10000,
quitTimeout: 3000,
path: appPath,
args: [
'--mode', options.app,
'--loglevel', 'debug',
'--logfile', logFilePath,
'--node-datadir', this.geth.dataDir,
'--ipcpath', path.join(this.geth.dataDir, 'geth.ipc'),
'--rpc', path.join(this.geth.dataDir, 'geth.ipc'),
],
});

console.log('==== App info', this.app);

yield this.app.start();

this.client = this.app.client;

yield this.client.waitUntilWindowLoaded();

// wait a small amount of time to ensure main app window is ready with data
yield Q.delay(8000);
// console.log(this.app.chromeDriver.logLines);

// console.log(this.app.chromeDriver.logLines);

/*
Utility methods
*/
/*
Utility methods
*/
for (const key in Utils) {
this[key] = genomatic.bind(Utils[key], this);
}

// Loop over windows trying to select Main Window
let app = this;
let selectMainWindow = function* (mainWindowSearch) {
let windowHandles = (yield app.client.windowHandles()).value;

for (let handle in windowHandles) {
yield app.client.window(windowHandles[handle]);
const windowUrl = yield app.client.getUrl();
const isMainWindow = mainWindowSearch.test(windowUrl);
if (isMainWindow) return true;
}

// not main window. try again after 1 second.
yield Q.delay(1000);
yield selectMainWindow(mainWindowSearch);
}

const mainWindowSearch = (options.app === 'wallet') ? /^file:\/\/\/$/ : /interface\/index\.html$/;
yield selectMainWindow(mainWindowSearch);

this.mainWindowHandle = (yield this.client.windowHandle()).value;
},

* after() {
* beforeEach () {
yield this.app.client.window(this.mainWindowHandle);
},

* afterEach () {
},

* after () {
if (this.app && this.app.isRunning()) {
yield this.app.stop();
}
Expand Down Expand Up @@ -214,7 +245,7 @@ const Utils = {
);

accounts = accounts.map(a => a.toLowerCase());
balances = balances.map(b => parseInt(b));
balances = balances.map(b => parseInt(b, 10));

return _.object(accounts, balances);
},
Expand All @@ -224,7 +255,7 @@ const Utils = {
let _balances = yield this.execElemsMethod('elementIdText', '.wallet-box .account-balance');

_accounts = _accounts.map(a => a.toLowerCase());
_balances = _balances.map(b => parseInt(b));
_balances = _balances.map(b => parseInt(b, 10));

return _.object(_accounts, _balances);
},
Expand All @@ -233,10 +264,10 @@ const Utils = {

let idx = -1;

accId = accId.toLowerCase();
const accountId = accId.toLowerCase();

for (const i in _accounts) {
if (_accounts[i].toLowerCase() === accId) {
if (_accounts[i].toLowerCase() === accountId) {
idx = i;
}
}
Expand Down
Loading