This repository has been archived by the owner on Sep 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Spectron testing suite #1553
Merged
Merged
Spectron testing suite #1553
Changes from 14 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
9a9ae7b
Spectron iteration
evertonfraga fd26841
Updating spectron
evertonfraga 4d03260
Creating switch for mist.lokidb for automated tests
evertonfraga 43ebaf3
Adding chai-as-expected
evertonfraga 4482a2c
Changing IPC flag
evertonfraga a69f944
Pairing spectron and electron versions
evertonfraga a13fe1a
[ESLint] Minor fixes
evertonfraga 9e55aa6
Adding chai-string
evertonfraga 380d6fa
Couple of tests passing
evertonfraga 3c7a403
update .eslintrc.yml
e33638e
Simplifying code
evertonfraga 0dfeef3
Removing delay in favor of better window management
evertonfraga 8c2bb3a
Adding tests for URL bar
evertonfraga a6e30ad
Focusing window before each test
evertonfraga 9fca756
Minor fixes
evertonfraga 38e4943
Improving mist setup and teardown
evertonfraga de9c50e
Fixing wallet test
evertonfraga a14f8d0
adding html fixture
evertonfraga e021dcb
Improving test helpers
evertonfraga 04510e5
Tests for ETH-01-002
evertonfraga 155aec6
Updating tests
evertonfraga 65b1379
Starting local HTTP server to deal with html fixtures
evertonfraga bf44704
Updating tests setup
evertonfraga 58c4a63
Adding more tests
evertonfraga dd3f299
Updating travis file to run spectron tests
evertonfraga 0cb40e6
Refactoring tests
evertonfraga 8990b40
Tests for ETH-01-007
evertonfraga c78bc39
Downloading geth on the fly
evertonfraga 5981ef5
Fine-tuning geth download during tests
evertonfraga 7885ded
Merge branch 'develop' into ev_spectron
evertonfraga d965c42
Changing linux binary dir
evertonfraga 18f9bf8
Fixing binary path on linux
evertonfraga 86b45d9
Travis debug
evertonfraga 6f49db9
Travis debug
evertonfraga 5ad3883
Changing fixtures
evertonfraga 5ebbe40
Fixing tests
evertonfraga 862aee0
Fixing travis file
evertonfraga fc87c3d
More tests
evertonfraga cc20517
Adjusting timeouts
evertonfraga a9f96ae
Adjusting GULP_PLATFORM test env variable
evertonfraga 73125b0
Adjusting timeouts
evertonfraga 8eb4b9d
Disabling some tests for now
evertonfraga bc74c42
Merge branch 'develop' into ev_spectron
evertonfraga 3637838
Disabling a test
evertonfraga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -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': | ||
|
@@ -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', | ||
|
@@ -85,49 +92,73 @@ exports.mocha = function (_module, options) { | |
rpcport: 58545, | ||
}, | ||
}); | ||
|
||
console.log(this.geth); | ||
yield this.geth.start(); | ||
|
||
this.web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:58545')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The port is chosen because of a custom geth one? |
||
|
||
|
||
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(); | ||
} | ||
|
@@ -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); | ||
}, | ||
|
@@ -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); | ||
}, | ||
|
@@ -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; | ||
} | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed