From a44f2bb6ebe6979efc3c4711147b2420aa290e15 Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Thu, 28 Mar 2019 09:53:38 -0230 Subject: Use webRequest to cancel all requests to infura in e2e tests. --- test/e2e/beta/from-import-beta-ui.spec.js | 13 ++++++++++++- test/e2e/beta/metamask-beta-responsive-ui.spec.js | 13 ++++++++++++- test/e2e/beta/metamask-beta-ui.spec.js | 21 +++++++++++++++++---- 3 files changed, 41 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/e2e/beta/from-import-beta-ui.spec.js b/test/e2e/beta/from-import-beta-ui.spec.js index 8aa0fb628..962ca690a 100644 --- a/test/e2e/beta/from-import-beta-ui.spec.js +++ b/test/e2e/beta/from-import-beta-ui.spec.js @@ -76,7 +76,18 @@ describe('Using MetaMask with an existing account', function () { 'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.metametrics + '\')) }); } else if ' + '(args[0] === "https://dev.blockscale.net/api/gasexpress.json") { return ' + 'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.gasExpress + '\')) }); } ' + - 'return window.origFetch(...args); }' + 'return window.origFetch(...args); };' + + 'function cancelInfuraRequest(requestDetails) {' + + 'console.log("Canceling: " + requestDetails.url);' + + 'return {' + + 'cancel: true' + + '};' + + ' }' + + 'window.chrome && window.chrome.webRequest && window.chrome.webRequest.onBeforeRequest.addListener(' + + 'cancelInfuraRequest,' + + '{urls: ["https://*.infura.io/*"]},' + + '["blocking"]' + + ');' ) }) diff --git a/test/e2e/beta/metamask-beta-responsive-ui.spec.js b/test/e2e/beta/metamask-beta-responsive-ui.spec.js index 6df1da051..b1ed8536e 100644 --- a/test/e2e/beta/metamask-beta-responsive-ui.spec.js +++ b/test/e2e/beta/metamask-beta-responsive-ui.spec.js @@ -75,7 +75,18 @@ describe('MetaMask', function () { 'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.metametrics + '\')) }); } else if ' + '(args[0] === "https://dev.blockscale.net/api/gasexpress.json") { return ' + 'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.gasExpress + '\')) }); } ' + - 'return window.origFetch(...args); }' + 'return window.origFetch(...args); };' + + 'function cancelInfuraRequest(requestDetails) {' + + 'console.log("Canceling: " + requestDetails.url);' + + 'return {' + + 'cancel: true' + + '};' + + ' }' + + 'window.chrome && window.chrome.webRequest && window.chrome.webRequest.onBeforeRequest.addListener(' + + 'cancelInfuraRequest,' + + '{urls: ["https://*.infura.io/*"]},' + + '["blocking"]' + + ');' ) }) diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index 2700d1656..202a0052d 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -80,7 +80,18 @@ describe('MetaMask', function () { 'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.metametrics + '\')) }); } else if ' + '(args[0] === "https://dev.blockscale.net/api/gasexpress.json") { return ' + 'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.gasExpress + '\')) }); } ' + - 'return window.origFetch(...args); }' + 'return window.origFetch(...args); };' + + 'function cancelInfuraRequest(requestDetails) {' + + 'console.log("Canceling: " + requestDetails.url);' + + 'return {' + + 'cancel: true' + + '};' + + ' }' + + 'window.chrome && window.chrome.webRequest && window.chrome.webRequest.onBeforeRequest.addListener(' + + 'cancelInfuraRequest,' + + '{urls: ["https://*.infura.io/*"]},' + + '["blocking"]' + + ');' ) }) @@ -1015,11 +1026,13 @@ describe('MetaMask', function () { const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type')) const functionTypeText = await functionType.getText() - assert.equal(functionTypeText, 'Transfer') + assert.equal(functionTypeText, 'Not Found') const confirmDataDiv = await findElement(driver, By.css('.confirm-page-container-content__data-box')) const confirmDataText = await confirmDataDiv.getText() - assert.equal(confirmDataText.match(/0xa9059cbb0000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c97/)) + + await delay(regularDelayMs) + assert(confirmDataText.match(/0xa9059cbb0000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c97/)) const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`)) detailsTab.click() @@ -1191,7 +1204,7 @@ describe('MetaMask', function () { const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type')) const functionTypeText = await functionType.getText() - assert.equal(functionTypeText, 'Approve') + assert.equal(functionTypeText, 'Not Found') const confirmDataDiv = await findElement(driver, By.css('.confirm-page-container-content__data-box')) const confirmDataText = await confirmDataDiv.getText() -- cgit v1.2.3 From 10097b6a1140d87aef0d8b982115dd6dba90dbe1 Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Thu, 28 Mar 2019 13:34:31 -0230 Subject: Default to localhost network when running e2e tests --- test/e2e/beta/metamask-beta-ui.spec.js | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'test') diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index 202a0052d..0c9c59e55 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -329,16 +329,6 @@ describe('MetaMask', function () { await delay(regularDelayMs) }) - it('switches to localhost', async () => { - const networkDropdown = await findElement(driver, By.css('.network-name')) - await networkDropdown.click() - await delay(regularDelayMs) - - const [localhost] = await findElements(driver, By.xpath(`//span[contains(text(), 'Localhost')]`)) - await localhost.click() - await delay(largeDelayMs * 2) - }) - it('balance renders', async () => { const balance = await findElement(driver, By.css('.balance-display .token-amount')) await driver.wait(until.elementTextMatches(balance, /100\s*ETH/)) -- cgit v1.2.3 From 3aa76931035e9aec1e29bf523226aef94be1b6fd Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Thu, 28 Mar 2019 13:35:40 -0230 Subject: Retry transaction list item click in 'adds multiple transactions' tests first click fails. --- test/e2e/beta/metamask-beta-ui.spec.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index 0c9c59e55..40856731e 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -612,9 +612,16 @@ describe('MetaMask', function () { await driver.switchTo().window(extension) await delay(regularDelayMs) - const transactions = await findElements(driver, By.css('.transaction-list-item')) + let transactions = await findElements(driver, By.css('.transaction-list-item')) await transactions[3].click() await delay(regularDelayMs) + try { + transactions = await findElements(driver, By.css('.transaction-list-item'), 1000) + await transactions[3].click() + } catch (e) { + console.log(e) + } + await delay(regularDelayMs) }) it('navigates the transactions', async () => { -- cgit v1.2.3 From dfe8287a28c4e91e4f95adf94f62a2f6c505d3fd Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Thu, 28 Mar 2019 18:07:19 -0230 Subject: e2e: Remove Privacy mode toggle step --- test/e2e/beta/metamask-beta-ui.spec.js | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'test') diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index 40856731e..47df91d8c 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -234,26 +234,6 @@ describe('MetaMask', function () { }) }) - describe('Enable privacy mode', () => { - it('enables privacy mode', async () => { - const networkDropdown = await findElement(driver, By.css('.network-name')) - await networkDropdown.click() - await delay(regularDelayMs) - - const customRpcButton = await findElement(driver, By.xpath(`//span[contains(text(), 'Custom RPC')]`)) - await customRpcButton.click() - await delay(regularDelayMs) - - const securityTab = await findElement(driver, By.xpath(`//div[contains(text(), 'Security & Privacy')]`)) - await securityTab.click() - await delay(regularDelayMs) - - const privacyToggle = await findElement(driver, By.css('.settings-page__content-row:nth-of-type(1) .settings-page__content-item-col > div')) - await privacyToggle.click() - await delay(largeDelayMs * 2) - }) - }) - describe('Log out an log back in', () => { it('logs out of the account', async () => { await driver.findElement(By.css('.account-menu__icon')).click() -- cgit v1.2.3 From 643ddcb7d79d26e278f7edba902d928b12813309 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Thu, 28 Mar 2019 21:54:24 -0230 Subject: e2e: Skip approving token test --- test/e2e/beta/metamask-beta-ui.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index 47df91d8c..c205ef071 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -1143,7 +1143,7 @@ describe('MetaMask', function () { }) }) - describe('Approves a custom token from dapp', () => { + describe.skip('Approves a custom token from dapp', () => { let gasModal it('approves an already created token', async () => { const windowHandles = await driver.getAllWindowHandles() -- cgit v1.2.3 From 99f53f582704f8bb65b5b321ebe91c5bfd5fe952 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Thu, 28 Mar 2019 18:54:13 -0230 Subject: e2e: Update Contract Interaction wording --- test/e2e/beta/metamask-beta-ui.spec.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index c205ef071..89193046e 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -1040,8 +1040,7 @@ describe('MetaMask', function () { return confirmedTxes.length === 1 }, 10000) const txStatuses = await findElements(driver, By.css('.transaction-list-item__action')) - const tx = await driver.wait(until.elementTextMatches(txStatuses[0], /Sent\sToken|Failed/), 10000) - assert.equal(await tx.getText(), 'Sent Tokens') + await driver.wait(until.elementTextMatches(txStatuses[0], /Contract\sInteraction/i), 10000) }) }) @@ -1125,7 +1124,7 @@ describe('MetaMask', function () { const txValues = await findElements(driver, By.css('.transaction-list-item__amount--primary')) await driver.wait(until.elementTextMatches(txValues[0], /-7\s*TST/)) const txStatuses = await findElements(driver, By.css('.transaction-list-item__action')) - await driver.wait(until.elementTextMatches(txStatuses[0], /Sent\sToken/), 10000) + await driver.wait(until.elementTextMatches(txStatuses[0], /Contract\sInteraction/), 10000) const walletBalance = await findElement(driver, By.css('.wallet-balance')) await walletBalance.click() -- cgit v1.2.3 From d927a3c20a1b8d47baaf215ef88d9a1a88c3851a Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Fri, 29 Mar 2019 00:44:00 -0230 Subject: Use localhost instead of mainnent/infura for custom rpc tests in e2e tests. --- test/e2e/beta/metamask-beta-ui.spec.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index 89193046e..3b74d6fe0 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -1307,10 +1307,10 @@ describe('MetaMask', function () { describe('Stores custom RPC history', () => { const customRpcUrls = [ - 'https://mainnet.infura.io/1', - 'https://mainnet.infura.io/2', - 'https://mainnet.infura.io/3', - 'https://mainnet.infura.io/4', + 'http://127.0.0.1:8545/1', + 'http://127.0.0.1:8545/2', + 'http://127.0.0.1:8545/3', + 'http://127.0.0.1:8545/4', ] customRpcUrls.forEach(customRpcUrl => { @@ -1349,7 +1349,7 @@ describe('MetaMask', function () { await delay(regularDelayMs) // only recent 3 are found and in correct order (most recent at the top) - const customRpcs = await findElements(driver, By.xpath(`//span[contains(text(), 'https://mainnet.infura.io/')]`)) + const customRpcs = await findElements(driver, By.xpath(`//span[contains(text(), 'http://127.0.0.1:8545/')]`)) assert.equal(customRpcs.length, customRpcUrls.length) }) -- cgit v1.2.3 From 5a1545b3e49be0f5954e8e1b7bb0f2a96961eba3 Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Fri, 29 Mar 2019 02:37:30 -0230 Subject: Run from-import e2e tests with additional account, to avoid conflict with accounts in earlier test runs --- test/e2e/beta/from-import-beta-ui.spec.js | 6 +++--- test/e2e/beta/run-all.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/e2e/beta/from-import-beta-ui.spec.js b/test/e2e/beta/from-import-beta-ui.spec.js index 962ca690a..a913caa79 100644 --- a/test/e2e/beta/from-import-beta-ui.spec.js +++ b/test/e2e/beta/from-import-beta-ui.spec.js @@ -24,8 +24,8 @@ describe('Using MetaMask with an existing account', function () { let extensionId let driver - const testSeedPhrase = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent' - const testAddress = '0xE18035BF8712672935FDB4e5e431b1a0183d2DFC' + const testSeedPhrase = 'forum vessel pink push lonely enact gentle tail admit parrot grunt dress' + const testAddress = '0x0Cc5261AB8cE458dc977078A3623E2BaDD27afD3' const testPrivateKey2 = '14abe6f4aab7f9f626fe981c864d0adeb5685f289ac9270c27b8fd790b4235d6' const regularDelayMs = 1000 const largeDelayMs = regularDelayMs * 2 @@ -312,7 +312,7 @@ describe('Using MetaMask with an existing account', function () { it('should show the correct account name', async () => { const [accountName] = await findElements(driver, By.css('.account-name')) - assert.equal(await accountName.getText(), 'Account 3') + assert.equal(await accountName.getText(), 'Account 4') await delay(regularDelayMs) }) diff --git a/test/e2e/beta/run-all.sh b/test/e2e/beta/run-all.sh index f2705da4c..dace0c346 100755 --- a/test/e2e/beta/run-all.sh +++ b/test/e2e/beta/run-all.sh @@ -8,4 +8,4 @@ export PATH="$PATH:./node_modules/.bin" shell-parallel -s 'npm run ganache:start -- -b 2' -x 'sleep 5 && static-server test/e2e/beta/contract-test --port 8080' -x 'sleep 5 && mocha test/e2e/beta/metamask-beta-ui.spec' shell-parallel -s 'npm run ganache:start -- -b 2' -x 'sleep 5 && static-server test/e2e/beta/contract-test --port 8080' -x 'sleep 5 && mocha test/e2e/beta/metamask-beta-responsive-ui.spec' -shell-parallel -s 'npm run ganache:start -- -d -b 2' -x 'sleep 5 && mocha test/e2e/beta/from-import-beta-ui.spec' +shell-parallel -s 'npm run ganache:start -- -d -b 2 --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000' -x 'sleep 5 && mocha test/e2e/beta/from-import-beta-ui.spec' -- cgit v1.2.3 From 3113114d51eeb4ecc469abfbf0685183a7fd996e Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Fri, 29 Mar 2019 11:15:01 -0230 Subject: Split e2e run-all commands onto multiple lines --- test/e2e/beta/run-all.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/e2e/beta/run-all.sh b/test/e2e/beta/run-all.sh index dace0c346..685feab00 100755 --- a/test/e2e/beta/run-all.sh +++ b/test/e2e/beta/run-all.sh @@ -8,4 +8,5 @@ export PATH="$PATH:./node_modules/.bin" shell-parallel -s 'npm run ganache:start -- -b 2' -x 'sleep 5 && static-server test/e2e/beta/contract-test --port 8080' -x 'sleep 5 && mocha test/e2e/beta/metamask-beta-ui.spec' shell-parallel -s 'npm run ganache:start -- -b 2' -x 'sleep 5 && static-server test/e2e/beta/contract-test --port 8080' -x 'sleep 5 && mocha test/e2e/beta/metamask-beta-responsive-ui.spec' -shell-parallel -s 'npm run ganache:start -- -d -b 2 --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000' -x 'sleep 5 && mocha test/e2e/beta/from-import-beta-ui.spec' +shell-parallel -s 'npm run ganache:start -- -d -b 2 --account=0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9,25000000000000000000' \ + -x 'sleep 5 && mocha test/e2e/beta/from-import-beta-ui.spec' -- cgit v1.2.3