From 9c6e2ec8ef4944172f6e771b216beaf00ed21575 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 21 May 2018 16:26:38 -0700 Subject: [PATCH 1/8] test - e2e - check for console errors after each test --- test/e2e/metamask.spec.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js index 707ca2560..fac560176 100644 --- a/test/e2e/metamask.spec.js +++ b/test/e2e/metamask.spec.js @@ -30,6 +30,14 @@ describe('Metamask popup page', function () { }) afterEach(async function () { + // check for console errors + const errors = await checkBrowserForConsoleErrors() + if (errors.length) { + const errorReports = errors.map(err => err.message) + const errorMessage = `Errors found in browser console:\n${errorReports.join('\n')}` + this.test.error(new Error(errorMessage)) + } + // gather extra data if test failed if (this.currentTest.state === 'failed') { await verboseReportOnFailure(this.currentTest) } @@ -300,13 +308,21 @@ describe('Metamask popup page', function () { await driver.executeScript('window.metamask.setProviderType(arguments[0])', type) } + async function checkBrowserForConsoleErrors() { + const ignoredLogTypes = ['WARNING'] + const browserLogs = await driver.manage().logs().get('browser') + const errorEntries = browserLogs.filter(entry => !ignoredLogTypes.includes(entry.level.toString())) + const errorEntryObjects = errorEntries.map(entry => entry.toJSON()) + return errorEntryObjects + } + async function verboseReportOnFailure (test) { let artifactDir if (process.env.SELENIUM_BROWSER === 'chrome') { artifactDir = `./test-artifacts/chrome/${test.title}` } else if (process.env.SELENIUM_BROWSER === 'firefox') { artifactDir = `./test-artifacts/firefox/${test.title}` - } + } const filepathBase = `${artifactDir}/test-failure` await pify(mkdirp)(artifactDir) // capture screenshot From db08d8d43eef26005c9c022445f4530caba71ac3 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 21 May 2018 17:15:05 -0700 Subject: [PATCH 2/8] test - e2e - ignore react 'unknown props dataset' warnings --- test/e2e/metamask.spec.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js index fac560176..72861adc4 100644 --- a/test/e2e/metamask.spec.js +++ b/test/e2e/metamask.spec.js @@ -310,10 +310,13 @@ describe('Metamask popup page', function () { async function checkBrowserForConsoleErrors() { const ignoredLogTypes = ['WARNING'] + const ignoredErrorMessages = ['Warning: Unknown prop `dataset` on '] const browserLogs = await driver.manage().logs().get('browser') const errorEntries = browserLogs.filter(entry => !ignoredLogTypes.includes(entry.level.toString())) - const errorEntryObjects = errorEntries.map(entry => entry.toJSON()) - return errorEntryObjects + const errorObjects = errorEntries.map(entry => entry.toJSON()) + // ignore all errors that contain a message in `ignoredErrorMessages` + const matchedErrorObjects = errorObjects.filter(entry => !ignoredErrorMessages.some(message => entry.message.includes(message))) + return matchedErrorObjects } async function verboseReportOnFailure (test) { From 5d8dd1df0e6ab603aed66a94c0f62ae36273e79c Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 21 May 2018 17:29:03 -0700 Subject: [PATCH 3/8] old-ui - ens-input - fix params passed to input --- old-ui/app/components/ens-input.js | 101 +++++++++++++++-------------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/old-ui/app/components/ens-input.js b/old-ui/app/components/ens-input.js index d09c30644..7e06fa9f1 100644 --- a/old-ui/app/components/ens-input.js +++ b/old-ui/app/components/ens-input.js @@ -1,7 +1,6 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits -const extend = require('xtend') const debounce = require('debounce') const copyToClipboard = require('copy-to-clipboard') const ENS = require('ethjs-ens') @@ -20,55 +19,61 @@ function EnsInput () { EnsInput.prototype.render = function () { const props = this.props - const opts = extend(props, { - list: 'addresses', - onChange: () => { - const network = this.props.network - const networkHasEnsSupport = getNetworkEnsSupport(network) - if (!networkHasEnsSupport) return - - const recipient = document.querySelector('input[name="address"]').value - if (recipient.match(ensRE) === null) { - return this.setState({ - loadingEns: false, - ensResolution: null, - ensFailure: null, - }) - } - this.setState({ - loadingEns: true, + function onInputChange() { + const network = this.props.network + const networkHasEnsSupport = getNetworkEnsSupport(network) + if (!networkHasEnsSupport) return + + const recipient = document.querySelector('input[name="address"]').value + if (recipient.match(ensRE) === null) { + return this.setState({ + loadingEns: false, + ensResolution: null, + ensFailure: null, }) - this.checkName() - }, - }) - return h('div', { - style: { width: '100%' }, - }, [ - h('input.large-input', opts), - // The address book functionality. - h('datalist#addresses', - [ - // Corresponds to the addresses owned. - Object.keys(props.identities).map((key) => { - const identity = props.identities[key] - return h('option', { - value: identity.address, - label: identity.name, - key: identity.address, - }) - }), - // Corresponds to previously sent-to addresses. - props.addressBook.map((identity) => { - return h('option', { - value: identity.address, - label: identity.name, - key: identity.address, - }) - }), - ]), - this.ensIcon(), - ]) + } + + this.setState({ + loadingEns: true, + }) + this.checkName() + } + + return ( + h('div', { + style: { width: '100%' }, + }, [ + h('input.large-input', { + name: props.name, + placeholder: props.placeholder, + list: 'addresses', + onChange: onInputChange.bind(this), + }), + // The address book functionality. + h('datalist#addresses', + [ + // Corresponds to the addresses owned. + Object.keys(props.identities).map((key) => { + const identity = props.identities[key] + return h('option', { + value: identity.address, + label: identity.name, + key: identity.address, + }) + }), + // Corresponds to previously sent-to addresses. + props.addressBook.map((identity) => { + return h('option', { + value: identity.address, + label: identity.name, + key: identity.address, + }) + }), + ]), + this.ensIcon(), + ]) + ) } EnsInput.prototype.componentDidMount = function () { From 0b84ceae6831638ea98584a7262287a2d6ec1a8e Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 21 May 2018 17:58:48 -0700 Subject: [PATCH 4/8] old-ui - app - use state.metamask.selectedAddress instead of currentView.context --- old-ui/app/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/old-ui/app/app.js b/old-ui/app/app.js index 2378a1a0a..abeb4f3f9 100644 --- a/old-ui/app/app.js +++ b/old-ui/app/app.js @@ -62,7 +62,7 @@ function mapStateToProps (state) { isInitialized: state.metamask.isInitialized, isUnlocked: state.metamask.isUnlocked, currentView: state.appState.currentView, - activeAddress: state.appState.activeAddress, + selectedAddress: state.metamask.selectedAddress, transForward: state.appState.transForward, isMascara: state.metamask.isMascara, isOnboarding: Boolean(!noActiveNotices || seedWords || !isInitialized), @@ -197,7 +197,7 @@ App.prototype.renderAppBar = function () { style: {}, enableAccountsSelector: true, identities: this.props.identities, - selected: this.props.currentView.context, + selected: this.props.selectedAddress, network: this.props.network, keyrings: this.props.keyrings, }, []), @@ -588,7 +588,7 @@ App.prototype.renderPrimary = function () { }, }, [ h('i.fa.fa-arrow-left.fa-lg.cursor-pointer.color-orange', { - onClick: () => props.dispatch(actions.backToAccountDetail(props.activeAddress)), + onClick: () => props.dispatch(actions.backToAccountDetail(props.selectedAddress)), style: { marginLeft: '10px', marginTop: '50px', From 81ff04ec279c5642a5e0a8dbc45724d2b8774850 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 21 May 2018 18:00:22 -0700 Subject: [PATCH 5/8] test - e2e - ignore favicon 404s --- test/e2e/metamask.spec.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js index 72861adc4..4ce51a91a 100644 --- a/test/e2e/metamask.spec.js +++ b/test/e2e/metamask.spec.js @@ -310,7 +310,12 @@ describe('Metamask popup page', function () { async function checkBrowserForConsoleErrors() { const ignoredLogTypes = ['WARNING'] - const ignoredErrorMessages = ['Warning: Unknown prop `dataset` on '] + const ignoredErrorMessages = [ + // React throws error warnings on "dataset", but still sets the data-* properties correctly + 'Warning: Unknown prop `dataset` on ', + // Third-party Favicon 404s show up as errors + 'favicon.ico - Failed to load resource: the server responded with a status of 404 (Not Found)', + ] const browserLogs = await driver.manage().logs().get('browser') const errorEntries = browserLogs.filter(entry => !ignoredLogTypes.includes(entry.level.toString())) const errorObjects = errorEntries.map(entry => entry.toJSON()) From 4856c0803fb512373107453c60781d3f0d5813b3 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 21 May 2018 19:57:13 -0700 Subject: [PATCH 6/8] test - e2e - ignore 'development build of React' warning --- test/e2e/metamask.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js index 4ce51a91a..e966517db 100644 --- a/test/e2e/metamask.spec.js +++ b/test/e2e/metamask.spec.js @@ -315,6 +315,8 @@ describe('Metamask popup page', function () { 'Warning: Unknown prop `dataset` on ', // Third-party Favicon 404s show up as errors 'favicon.ico - Failed to load resource: the server responded with a status of 404 (Not Found)', + // React Minified build - known issue blocked by test build sys + 'Warning: It looks like you\'re using a minified copy of the development build of React.', ] const browserLogs = await driver.manage().logs().get('browser') const errorEntries = browserLogs.filter(entry => !ignoredLogTypes.includes(entry.level.toString())) From a3ca64d3210077cb1da67cfd105e8e22e978ff49 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 21 May 2018 19:59:21 -0700 Subject: [PATCH 7/8] test - e2e - ignore 'development build of Redux' warning --- test/e2e/metamask.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js index e966517db..482259ee8 100644 --- a/test/e2e/metamask.spec.js +++ b/test/e2e/metamask.spec.js @@ -315,8 +315,10 @@ describe('Metamask popup page', function () { 'Warning: Unknown prop `dataset` on ', // Third-party Favicon 404s show up as errors 'favicon.ico - Failed to load resource: the server responded with a status of 404 (Not Found)', - // React Minified build - known issue blocked by test build sys + // React Development build - known issue blocked by test build sys 'Warning: It looks like you\'re using a minified copy of the development build of React.', + // Redux Development build - known issue blocked by test build sys + 'This means that you are running a slower development build of Redux.', ] const browserLogs = await driver.manage().logs().get('browser') const errorEntries = browserLogs.filter(entry => !ignoredLogTypes.includes(entry.level.toString())) From 83782421bb16f809e3679d51e598b0348f17cf3b Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 21 May 2018 20:17:46 -0700 Subject: [PATCH 8/8] test - e2e - only inspect console for errors in chrome --- test/e2e/metamask.spec.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/e2e/metamask.spec.js b/test/e2e/metamask.spec.js index 482259ee8..8ec7de16c 100644 --- a/test/e2e/metamask.spec.js +++ b/test/e2e/metamask.spec.js @@ -30,12 +30,16 @@ describe('Metamask popup page', function () { }) afterEach(async function () { - // check for console errors - const errors = await checkBrowserForConsoleErrors() - if (errors.length) { - const errorReports = errors.map(err => err.message) - const errorMessage = `Errors found in browser console:\n${errorReports.join('\n')}` - this.test.error(new Error(errorMessage)) + // logs command not supported in firefox + // https://github.com/SeleniumHQ/selenium/issues/2910 + if (process.env.SELENIUM_BROWSER === 'chrome') { + // check for console errors + const errors = await checkBrowserForConsoleErrors() + if (errors.length) { + const errorReports = errors.map(err => err.message) + const errorMessage = `Errors found in browser console:\n${errorReports.join('\n')}` + this.test.error(new Error(errorMessage)) + } } // gather extra data if test failed if (this.currentTest.state === 'failed') {