diff options
author | Dan J Miller <danjm.com@gmail.com> | 2018-08-15 22:40:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-15 22:40:04 +0800 |
commit | a41afebd66ada032f12167668940da96ed9199d6 (patch) | |
tree | 0c85f96aad042cb42d50cb97a1baa80ec4f904cf /test | |
parent | d7aa1bf5c0ed4439526612cdf175db2d79e360cc (diff) | |
parent | 3c8a4162a489a8e3477553b163a73bf0a2b7ea71 (diff) | |
download | tangerine-wallet-browser-a41afebd66ada032f12167668940da96ed9199d6.tar tangerine-wallet-browser-a41afebd66ada032f12167668940da96ed9199d6.tar.gz tangerine-wallet-browser-a41afebd66ada032f12167668940da96ed9199d6.tar.bz2 tangerine-wallet-browser-a41afebd66ada032f12167668940da96ed9199d6.tar.lz tangerine-wallet-browser-a41afebd66ada032f12167668940da96ed9199d6.tar.xz tangerine-wallet-browser-a41afebd66ada032f12167668940da96ed9199d6.tar.zst tangerine-wallet-browser-a41afebd66ada032f12167668940da96ed9199d6.zip |
Merge pull request #5059 from MetaMask/e2e-tests-more-reliable
Another e2e beta test fix
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/beta/contract-test/contract.js | 8 | ||||
-rw-r--r-- | test/e2e/beta/contract-test/index.html | 2 | ||||
-rw-r--r-- | test/e2e/beta/from-import-beta-ui.spec.js | 9 | ||||
-rw-r--r-- | test/e2e/beta/helpers.js | 12 | ||||
-rw-r--r-- | test/e2e/beta/metamask-beta-ui.spec.js | 34 |
5 files changed, 45 insertions, 20 deletions
diff --git a/test/e2e/beta/contract-test/contract.js b/test/e2e/beta/contract-test/contract.js index 51891ea21..39e7238ae 100644 --- a/test/e2e/beta/contract-test/contract.js +++ b/test/e2e/beta/contract-test/contract.js @@ -38,18 +38,20 @@ const transferTokens = document.getElementById('transferTokens') const approveTokens = document.getElementById('approveTokens') deployButton.addEventListener('click', async function (event) { + document.getElementById('contractStatus').innerHTML = 'Deploying' + var piggybank = await piggybankContract.new( { from: web3.eth.accounts[0], data: '0x608060405234801561001057600080fd5b5033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000808190555061023b806100686000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632e1a7d4d1461005c5780638da5cb5b1461009d578063d0e30db0146100f4575b600080fd5b34801561006857600080fd5b5061008760048036038101908080359060200190929190505050610112565b6040518082815260200191505060405180910390f35b3480156100a957600080fd5b506100b26101d0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100fc6101f6565b6040518082815260200191505060405180910390f35b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017057600080fd5b8160008082825403925050819055503373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101c5573d6000803e3d6000fd5b506000549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60003460008082825401925050819055506000549050905600a165627a7a72305820f237db3ec816a52589d82512117bc85bc08d3537683ffeff9059108caf3e5d400029', gas: '4700000', }, function (e, contract) { - console.log(e, contract) + if (e) { + throw e + } if (typeof contract.address !== 'undefined') { console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash) - console.log(`contract`, contract) - document.getElementById('contractStatus').innerHTML = 'Deployed' depositButton.addEventListener('click', function (event) { diff --git a/test/e2e/beta/contract-test/index.html b/test/e2e/beta/contract-test/index.html index f6e6f44c7..0d422ef20 100644 --- a/test/e2e/beta/contract-test/index.html +++ b/test/e2e/beta/contract-test/index.html @@ -11,7 +11,7 @@ <button id="withdrawButton">Withdraw</button> </div> <div id="contractStatus" style="display: flex; font-size: 1rem;"> - Not yet deployed + Not clicked </div> </div> <div style="display: flex; flex-flow: column;"> diff --git a/test/e2e/beta/from-import-beta-ui.spec.js b/test/e2e/beta/from-import-beta-ui.spec.js index 5582d4697..e14ee2361 100644 --- a/test/e2e/beta/from-import-beta-ui.spec.js +++ b/test/e2e/beta/from-import-beta-ui.spec.js @@ -89,7 +89,14 @@ describe('Using MetaMask with an existing account', function () { await driver.wait(until.stalenessOf(overlay)) } catch (e) {} - const button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) + let button + try { + button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) + } catch (e) { + await loadExtension(driver, extensionId) + await delay(largeDelayMs) + button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) + } await button.click() await delay(regularDelayMs) diff --git a/test/e2e/beta/helpers.js b/test/e2e/beta/helpers.js index 828f87db7..d90cd5d66 100644 --- a/test/e2e/beta/helpers.js +++ b/test/e2e/beta/helpers.js @@ -122,12 +122,14 @@ async function closeAllWindowHandlesExcept (driver, exceptions, windowHandles) { } async function assertElementNotPresent (webdriver, driver, by) { + let dataTab try { - const dataTab = await findElement(driver, by, 4000) - if (dataTab) { - assert(false, 'Data tab should not be present') - } + dataTab = await findElement(driver, by, 4000) } catch (err) { - assert(err instanceof webdriver.error.NoSuchElementError) + console.log(err) + assert(err instanceof webdriver.error.NoSuchElementError || err instanceof webdriver.error.TimeoutError) + } + if (dataTab) { + assert(false, 'Data tab should not be present') } } diff --git a/test/e2e/beta/metamask-beta-ui.spec.js b/test/e2e/beta/metamask-beta-ui.spec.js index 3ad5c2d61..43300bda6 100644 --- a/test/e2e/beta/metamask-beta-ui.spec.js +++ b/test/e2e/beta/metamask-beta-ui.spec.js @@ -88,7 +88,14 @@ describe('MetaMask', function () { await driver.wait(until.stalenessOf(overlay)) } catch (e) {} - const button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) + let button + try { + button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) + } catch (e) { + await loadExtension(driver, extensionId) + await delay(largeDelayMs) + button = await findElement(driver, By.xpath("//button[contains(text(), 'Try it now')]")) + } await button.click() await delay(regularDelayMs) @@ -345,8 +352,8 @@ describe('MetaMask', function () { const passwordInputs = await driver.findElements(By.css('input')) await delay(regularDelayMs) - passwordInputs[0].sendKeys('correct horse battery staple') - passwordInputs[1].sendKeys('correct horse battery staple') + await passwordInputs[0].sendKeys('correct horse battery staple') + await passwordInputs[1].sendKeys('correct horse battery staple') await driver.findElement(By.css('.first-time-flow__button')).click() await delay(regularDelayMs) }) @@ -438,7 +445,7 @@ describe('MetaMask', function () { await driver.switchTo().window(windowHandles[2]) await delay(regularDelayMs) - assertElementNotPresent(webdriver, driver, By.xpath(`//li[contains(text(), 'Data')]`)) + await assertElementNotPresent(webdriver, driver, By.xpath(`//li[contains(text(), 'Data')]`)) const confirmButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Confirm')]`), 10000) await confirmButton.click() @@ -453,6 +460,11 @@ describe('MetaMask', function () { const transactions = await findElements(driver, By.css('.tx-list-item')) assert.equal(transactions.length, 2) + await findElement(driver, By.xpath(`//span[contains(text(), 'Submitted')]`)) + + const txStatuses = await findElements(driver, By.css('.tx-list-status')) + await driver.wait(until.elementTextMatches(txStatuses[0], /Confirmed/)) + const txValues = await findElement(driver, By.css('.tx-list-value')) await driver.wait(until.elementTextMatches(txValues, /3\sETH/), 10000) }) @@ -503,6 +515,8 @@ describe('MetaMask', function () { await confirmButton.click() await delay(regularDelayMs) + await findElement(driver, By.xpath(`//span[contains(text(), 'Submitted')]`)) + const txStatuses = await findElements(driver, By.css('.tx-list-status')) await driver.wait(until.elementTextMatches(txStatuses[0], /Confirmed/)) @@ -515,15 +529,15 @@ describe('MetaMask', function () { await driver.switchTo().window(dapp) await delay(regularDelayMs) - let contractStatus = await driver.findElement(By.css('#contractStatus')) - await driver.wait(until.elementTextMatches(contractStatus, /Deployed/)) + let contractStatus = await findElement(driver, By.css('#contractStatus')) + await driver.wait(until.elementTextMatches(contractStatus, /Deployed/), 15000) const depositButton = await findElement(driver, By.css('#depositButton')) await depositButton.click() await delay(largeDelayMs) - contractStatus = await driver.findElement(By.css('#contractStatus')) - await driver.wait(until.elementTextMatches(contractStatus, /Deposit\sinitiated/)) + contractStatus = await findElement(driver, By.css('#contractStatus')) + await driver.wait(until.elementTextMatches(contractStatus, /Deposit\sinitiated/), 10000) await driver.switchTo().window(extension) await delay(largeDelayMs) @@ -539,8 +553,8 @@ describe('MetaMask', function () { await configureGas.click() await delay(regularDelayMs) - const gasModal = await driver.findElement(By.css('span .modal')) - await driver.wait(until.elementLocated(By.css('.customize-gas__title'))) + const gasModal = await findElement(driver, By.css('span .modal')) + await driver.wait(until.elementLocated(By.css('.customize-gas__title')), 10000) const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.customize-gas-input')) await gasPriceInput.clear() |