2018-05-25 03:17:26 +02:00
|
|
|
const assert = require('assert')
|
|
|
|
const webdriver = require('selenium-webdriver')
|
2020-01-09 04:34:58 +01:00
|
|
|
|
2018-06-06 04:21:55 +02:00
|
|
|
const { By, Key, until } = webdriver
|
2020-08-18 21:18:25 +02:00
|
|
|
const enLocaleMessages = require('../../app/_locales/en/messages.json')
|
2018-05-25 03:17:26 +02:00
|
|
|
const {
|
2020-01-13 16:07:32 +01:00
|
|
|
tinyDelayMs,
|
|
|
|
regularDelayMs,
|
|
|
|
largeDelayMs,
|
2018-05-25 03:17:26 +02:00
|
|
|
} = require('./helpers')
|
2020-01-14 18:34:38 +01:00
|
|
|
const { buildWebDriver } = require('./webdriver')
|
2019-12-09 15:40:43 +01:00
|
|
|
const Ganache = require('./ganache')
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2019-12-09 15:40:43 +01:00
|
|
|
const ganacheServer = new Ganache()
|
|
|
|
|
2018-05-25 03:17:26 +02:00
|
|
|
describe('MetaMask', function () {
|
|
|
|
let driver
|
|
|
|
let tokenAddress
|
|
|
|
|
|
|
|
const testSeedPhrase = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'
|
|
|
|
|
|
|
|
this.timeout(0)
|
2019-09-10 17:45:43 +02:00
|
|
|
this.bail(true)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
|
|
|
before(async function () {
|
2019-12-09 15:40:43 +01:00
|
|
|
await ganacheServer.start()
|
2020-01-14 18:34:38 +01:00
|
|
|
const result = await buildWebDriver()
|
2019-09-07 09:13:58 +02:00
|
|
|
driver = result.driver
|
2018-11-05 17:50:06 +01:00
|
|
|
})
|
|
|
|
|
2018-05-25 03:17:26 +02:00
|
|
|
afterEach(async function () {
|
|
|
|
if (process.env.SELENIUM_BROWSER === 'chrome') {
|
2020-01-13 16:07:32 +01:00
|
|
|
const errors = await driver.checkBrowserForConsoleErrors(driver)
|
2018-05-25 03:17:26 +02:00
|
|
|
if (errors.length) {
|
2020-02-15 21:34:12 +01:00
|
|
|
const errorReports = errors.map((err) => err.message)
|
2018-05-25 03:17:26 +02:00
|
|
|
const errorMessage = `Errors found in browser console:\n${errorReports.join('\n')}`
|
|
|
|
console.error(new Error(errorMessage))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this.currentTest.state === 'failed') {
|
2020-07-09 17:01:14 +02:00
|
|
|
await driver.verboseReportOnFailure(this.currentTest.title)
|
2018-05-25 03:17:26 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
after(async function () {
|
2019-12-09 15:40:43 +01:00
|
|
|
await ganacheServer.quit()
|
2018-05-25 03:17:26 +02:00
|
|
|
await driver.quit()
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Going through the first time flow', function () {
|
|
|
|
it('clicks the continue button on the welcome screen', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.findElement(By.css('.welcome-page__header'))
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.getStarted.message}')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('clicks the "Create New Wallet" option', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create a Wallet')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2019-02-27 15:46:41 +01:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('clicks the "No thanks" option on the metametrics opt-in screen', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.btn-default'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2019-03-05 16:45:01 +01:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('accepts a secure password', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
const passwordBox = await driver.findElement(By.css('.first-time-flow__form #create-password'))
|
|
|
|
const passwordBoxConfirm = await driver.findElement(By.css('.first-time-flow__form #confirm-password'))
|
2018-05-25 03:17:26 +02:00
|
|
|
|
|
|
|
await passwordBox.sendKeys('correct horse battery staple')
|
|
|
|
await passwordBoxConfirm.sendKeys('correct horse battery staple')
|
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.first-time-flow__checkbox'))
|
2018-06-14 08:52:51 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.first-time-flow__form button'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-14 09:36:14 +02:00
|
|
|
})
|
2018-06-14 08:52:51 +02:00
|
|
|
|
2018-05-25 03:17:26 +02:00
|
|
|
let seedPhrase
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('reveals the seed phrase', async function () {
|
2019-01-23 16:25:34 +01:00
|
|
|
const byRevealButton = By.css('.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button')
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.findElement(byRevealButton)
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(byRevealButton)
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const revealedSeedPhrase = await driver.findElement(By.css('.reveal-seed-phrase__secret-words'))
|
|
|
|
seedPhrase = await revealedSeedPhrase.getText()
|
2018-05-25 03:17:26 +02:00
|
|
|
assert.equal(seedPhrase.split(' ').length, 12)
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.next.message}')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2018-08-06 16:11:40 +02:00
|
|
|
async function clickWordAndWait (word) {
|
2020-01-29 20:42:46 +01:00
|
|
|
await driver.clickElement(By.css(`[data-testid="seed-phrase-sorted"] [data-testid="draggable-seed-${word}"]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(tinyDelayMs)
|
2018-08-06 16:11:40 +02:00
|
|
|
}
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('can retype the seed phrase', async function () {
|
2018-06-22 21:36:22 +02:00
|
|
|
const words = seedPhrase.split(' ')
|
|
|
|
|
2019-10-23 19:00:16 +02:00
|
|
|
for (const word of words) {
|
|
|
|
await clickWordAndWait(word)
|
|
|
|
}
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('clicks through the success screen', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Show account information', function () {
|
|
|
|
it('shows the QR code for the account', async function () {
|
2020-05-27 22:28:33 +02:00
|
|
|
await driver.clickElement(By.css('[data-testid="account-options-menu-button"]'))
|
|
|
|
await driver.clickElement(By.css('[data-testid="account-options-menu__account-details"]'))
|
2020-08-07 17:58:48 +02:00
|
|
|
await driver.findVisibleElement(By.css('.qr-code__wrapper'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2018-07-03 00:49:33 +02:00
|
|
|
const accountModal = await driver.findElement(By.css('span .modal'))
|
2020-08-11 18:07:47 +02:00
|
|
|
await driver.clickElement(By.css('.account-modal__close'))
|
2018-06-11 15:06:15 +02:00
|
|
|
|
|
|
|
await driver.wait(until.stalenessOf(accountModal))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Lock an unlock', function () {
|
|
|
|
it('logs out of the account', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.account-menu__icon'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-21 23:09:53 +01:00
|
|
|
const lockButton = await driver.findClickableElement(By.css('.account-menu__lock-button'))
|
|
|
|
assert.equal(await lockButton.getText(), 'Lock')
|
|
|
|
await lockButton.click()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('accepts the account password after lock', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
const passwordField = await driver.findElement(By.id('password'))
|
|
|
|
await passwordField.sendKeys('correct horse battery staple')
|
|
|
|
await passwordField.sendKeys(Key.ENTER)
|
|
|
|
await driver.delay(largeDelayMs * 4)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Add account', function () {
|
|
|
|
it('choose Create Account from the account menu', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.account-menu__icon'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'Create Account')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('set account name', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
const accountName = await driver.findElement(By.css('.new-account-create-form input'))
|
2018-05-25 03:17:26 +02:00
|
|
|
await accountName.sendKeys('2nd account')
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('should display correct account name', async function () {
|
2020-05-27 22:28:33 +02:00
|
|
|
const accountName = await driver.findElement(By.css('.selected-account__name'))
|
2018-05-25 03:17:26 +02:00
|
|
|
assert.equal(await accountName.getText(), '2nd account')
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Import seed phrase', function () {
|
|
|
|
it('logs out of the vault', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.account-menu__icon'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-21 23:09:53 +01:00
|
|
|
const lockButton = await driver.findClickableElement(By.css('.account-menu__lock-button'))
|
|
|
|
assert.equal(await lockButton.getText(), 'Lock')
|
|
|
|
await lockButton.click()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('imports seed phrase', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
const restoreSeedLink = await driver.findClickableElement(By.css('.unlock-page__link--import'))
|
2018-05-25 03:17:26 +02:00
|
|
|
assert.equal(await restoreSeedLink.getText(), 'Import using account seed phrase')
|
|
|
|
await restoreSeedLink.click()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-09-02 17:45:09 +02:00
|
|
|
await driver.clickElement(By.css('.import-account__checkbox-container'))
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const seedTextArea = await driver.findElement(By.css('textarea'))
|
2018-05-25 03:17:26 +02:00
|
|
|
await seedTextArea.sendKeys(testSeedPhrase)
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2018-06-22 19:11:18 +02:00
|
|
|
const passwordInputs = await driver.findElements(By.css('input'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-22 19:11:18 +02:00
|
|
|
|
2018-08-14 17:08:25 +02:00
|
|
|
await passwordInputs[0].sendKeys('correct horse battery staple')
|
|
|
|
await passwordInputs[1].sendKeys('correct horse battery staple')
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.restore.message}')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('balance renders', async function () {
|
2020-06-03 19:50:12 +02:00
|
|
|
const balance = await driver.findElement(By.css('[data-testid="wallet-balance"] .list-item__heading'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(balance, /100\s*ETH/u))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Send ETH from inside MetaMask using default gas', function () {
|
2019-02-08 15:22:19 +01:00
|
|
|
it('starts a send transaction', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-02-08 15:22:19 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const inputAddress = await driver.findElement(By.css('input[placeholder="Search, public address (0x), or ENS"]'))
|
2019-02-08 15:22:19 +01:00
|
|
|
await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970')
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const inputAmount = await driver.findElement(By.css('.unit-input__input'))
|
2019-07-31 21:56:44 +02:00
|
|
|
await inputAmount.sendKeys('1000')
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const errorAmount = await driver.findElement(By.css('.send-v2__error-amount'))
|
2019-07-31 21:56:44 +02:00
|
|
|
assert.equal(await errorAmount.getText(), 'Insufficient funds.', 'send screen should render an insufficient fund error message')
|
|
|
|
|
|
|
|
await inputAmount.sendKeys(Key.BACK_SPACE)
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2019-07-31 21:56:44 +02:00
|
|
|
await inputAmount.sendKeys(Key.BACK_SPACE)
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2019-07-31 21:56:44 +02:00
|
|
|
await inputAmount.sendKeys(Key.BACK_SPACE)
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(tinyDelayMs)
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.assertElementNotPresent(By.css('.send-v2__error-amount'))
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
const amountMax = await driver.findClickableElement(By.css('.send-v2__amount-max'))
|
2019-07-31 21:56:44 +02:00
|
|
|
await amountMax.click()
|
|
|
|
|
|
|
|
assert.equal(await inputAmount.isEnabled(), false)
|
|
|
|
|
|
|
|
let inputValue = await inputAmount.getAttribute('value')
|
|
|
|
|
|
|
|
assert(Number(inputValue) > 99)
|
|
|
|
|
|
|
|
await amountMax.click()
|
|
|
|
|
|
|
|
assert.equal(await inputAmount.isEnabled(), true)
|
|
|
|
|
2019-02-08 15:22:19 +01:00
|
|
|
await inputAmount.sendKeys('1')
|
|
|
|
|
2019-07-31 21:56:44 +02:00
|
|
|
inputValue = await inputAmount.getAttribute('value')
|
2019-02-08 15:22:19 +01:00
|
|
|
assert.equal(inputValue, '1')
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-02-08 15:22:19 +01:00
|
|
|
|
|
|
|
// Continue to next screen
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Next')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-02-08 15:22:19 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('confirms the transaction', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs * 2)
|
2019-02-08 15:22:19 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2020-06-11 22:14:07 +02:00
|
|
|
await driver.clickElement(By.css('[data-testid="home__activity-tab"]'))
|
2019-10-31 17:27:22 +01:00
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2019-10-31 17:27:22 +01:00
|
|
|
return confirmedTxes.length === 1
|
|
|
|
}, 10000)
|
2019-02-08 15:22:19 +01:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txValues = await driver.findElement(By.css('.transaction-list-item__primary-currency'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/u), 10000)
|
2019-02-08 15:22:19 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Send ETH from inside MetaMask using fast gas option', function () {
|
2019-02-08 15:22:19 +01:00
|
|
|
it('starts a send transaction', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-02-08 15:22:19 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const inputAddress = await driver.findElement(By.css('input[placeholder="Search, public address (0x), or ENS"]'))
|
2019-02-08 15:22:19 +01:00
|
|
|
await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970')
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const inputAmount = await driver.findElement(By.css('.unit-input__input'))
|
2019-02-08 15:22:19 +01:00
|
|
|
await inputAmount.sendKeys('1')
|
|
|
|
|
|
|
|
const inputValue = await inputAmount.getAttribute('value')
|
|
|
|
assert.equal(inputValue, '1')
|
|
|
|
|
|
|
|
// Set the gas price
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button/div/div[contains(text(), "Fast")]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-02-08 15:22:19 +01:00
|
|
|
|
|
|
|
// Continue to next screen
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Next')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-02-08 15:22:19 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('confirms the transaction', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2019-02-08 15:22:19 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2019-10-31 17:27:22 +01:00
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2019-10-31 17:27:22 +01:00
|
|
|
return confirmedTxes.length === 2
|
|
|
|
}, 10000)
|
2019-02-08 15:22:19 +01:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txValues = await driver.findElement(By.css('.transaction-list-item__primary-currency'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/u), 10000)
|
2019-02-08 15:22:19 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Send ETH from inside MetaMask using advanced gas modal', function () {
|
2018-11-05 17:50:06 +01:00
|
|
|
it('starts a send transaction', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const inputAddress = await driver.findElement(By.css('input[placeholder="Search, public address (0x), or ENS"]'))
|
2018-05-25 03:17:26 +02:00
|
|
|
await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970')
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const inputAmount = await driver.findElement(By.css('.unit-input__input'))
|
2018-05-25 03:17:26 +02:00
|
|
|
await inputAmount.sendKeys('1')
|
|
|
|
|
2018-07-09 18:08:05 +02:00
|
|
|
const inputValue = await inputAmount.getAttribute('value')
|
|
|
|
assert.equal(inputValue, '1')
|
|
|
|
|
2018-05-25 03:17:26 +02:00
|
|
|
// Set the gas limit
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.advanced-gas-options-btn'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2018-06-07 14:37:41 +02:00
|
|
|
const gasModal = await driver.findElement(By.css('span .modal'))
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Save')]`))
|
2018-06-07 14:37:41 +02:00
|
|
|
await driver.wait(until.stalenessOf(gasModal))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
|
|
|
// Continue to next screen
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Next')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('confirms the transaction', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
const transactionAmounts = await driver.findElements(By.css('.currency-display-component__text'))
|
2019-07-03 22:33:44 +02:00
|
|
|
const transactionAmount = transactionAmounts[0]
|
|
|
|
assert.equal(await transactionAmount.getText(), '1')
|
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2019-10-31 17:27:22 +01:00
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2019-10-31 17:27:22 +01:00
|
|
|
return confirmedTxes.length === 3
|
|
|
|
}, 10000)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txValues = await driver.findElement(By.css('.transaction-list-item__primary-currency'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txValues, /-1\s*ETH/u), 10000)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Send ETH from dapp using advanced gas controls', function () {
|
2018-09-27 20:19:09 +02:00
|
|
|
let windowHandles
|
|
|
|
let extension
|
|
|
|
let popup
|
|
|
|
let dapp
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('goes to the settings screen', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.account-menu__icon'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-02-13 15:03:14 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'Settings')]`))
|
2019-02-13 15:03:14 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
// await driver.findElement(By.css('.tab-bar'))
|
2019-03-25 17:13:23 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//div[contains(text(), 'Advanced')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-02-13 15:03:14 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('[data-testid="advanced-setting-show-testnet-conversion"] .settings-page__content-item-col > div > div'))
|
2019-02-26 19:30:41 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const advancedGasTitle = await driver.findElement(By.xpath(`//span[contains(text(), 'Advanced gas controls')]`))
|
|
|
|
await driver.scrollToElement(advancedGasTitle)
|
2019-02-13 15:03:14 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('[data-testid="advanced-setting-advanced-gas-inline"] .settings-page__content-item-col > div > div'))
|
2019-02-13 15:03:14 +01:00
|
|
|
windowHandles = await driver.getAllWindowHandles()
|
|
|
|
extension = windowHandles[0]
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.closeAllWindowHandlesExcept([extension])
|
2019-02-13 15:03:14 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.app-header__logo-container'))
|
2019-02-13 15:03:14 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2019-02-13 15:03:14 +01:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('connects the dapp', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.openNewPage('http://127.0.0.1:8080/')
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Connect')]`))
|
2019-11-22 18:03:51 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-11-22 18:03:51 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.waitUntilXWindowHandles(3)
|
2018-09-27 20:19:09 +02:00
|
|
|
windowHandles = await driver.getAllWindowHandles()
|
|
|
|
|
|
|
|
extension = windowHandles[0]
|
2020-01-13 16:07:32 +01:00
|
|
|
dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
2020-02-15 21:34:12 +01:00
|
|
|
popup = windowHandles.find((handle) => handle !== extension && handle !== dapp)
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(popup)
|
2018-06-21 14:19:27 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-09-27 20:19:09 +02:00
|
|
|
|
2020-04-02 11:09:53 +02:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Next')]`))
|
2020-05-04 22:40:09 +02:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Connect')]`))
|
Connect distinct accounts per site (#7004)
* add PermissionsController
remove provider approval controller
integrate rpc-cap
create PermissionsController
move provider approval functionality to permissions controller
add permissions approval ui, settings page
add permissions activity and history
move some functionality to metamask-inpage-provider
rename siteMetadata -> domainMetadata
add accountsChange notification to inpage provider
move functionality to inpage provider
update inpage provider
Remove 'Connections' settings page (#7369)
add hooks for exposing accounts in settings
rename unused messages in non-English locales
Add external extension id to metadata (#7396)
update inpage provider, rpc-cap
add eth_requestAccounts handling to background
prevent notifying connections if extension is locked
update inpage provider
Fix lint errors
add migration
review fixes
transaction controller review updates
removed unused messages
* Login Per Site UI (#7368)
* LoginPerSite original UI changes to keep
* First commit
* Get necessary connected tab info for redirect and icon display for permissioned sites
* Fix up designs and add missing features
* Some lint fixes
* More lint fixes
* Ensures the tx controller + tx-state-manager orders transactions in the order they are received
* Code cleanup for LoginPerSite-ui
* Update e2e tests to use new connection flow
* Fix display of connect screen and app header after login when connect request present
* Update metamask-responsive-ui.spec for new item in accounts dropdown
* Fix approve container by replacing approvedOrigins with domainMetaData
* Adds test/e2e/permissions.spec.js
* Correctly handle cancellation of a permissions request
* Redirect to home after disconnecting all sites / cancelling all permissions
* Fix display of site icons in menu
* Fix height of permissions page container
* Remove unused locale messages
* Set default values for openExternalTabs and tabIdOrigins in account-menu.container
* More code cleanup for LoginPerSite-ui
* Use extensions api to close tab in permissions-connect
* Remove unnecessary change in domIsReady() in contentscript
* Remove unnecessary private function markers and class methods (for background tab info) in metamask-controller.
* Adds getOriginOfCurrentTab selector
* Adds IconWithFallback component and substitutes for appropriate cases
* Add and utilize font mixins
* Remove unused method in disconnect-all.container.js
* Simplify buttonSizeLarge code in page-container-footer.component.js
* Add and utilize getAccountsWithLabels selector
* Remove console.log in ui/app/store/actions.js
* Change last connected time format to yyyy-M-d
* Fix css associated with IconWithFallback change
* Ensure tracked openNonMetamaskTabsIDs are correctly set to inactive on tab changes
* Code cleanup for LoginPerSite-ui
* Use reusable function for modifying openNonMetamaskTabsIDs in background.js
* Enables automatic switching to connected account when connected domain is open
* Prevent exploit of tabIdOriginMap in background.js
* Remove unneeded code from contentscript.js
* Simplify current tab origin and window opener logic using remotePort listener tabs.queryTabs
* Design and styling fixes for LoginPerSite-ui
* Fix permissionHistory and permission logging for eth_requestAccounts and eth_accounts
* Front end changes to support display of lastConnected time in connected and permissions screens
* Fix lint errors
* Refactor structure of permissionsHistory
* Fix default values and object modifications for domain and permissionsHistory related data
* Fix connecting to new accounts from modal
* Replace retweet.svg with connect-white.svg
* Fix signature-request.spec
* Update metamask-inpage-provider version
* Fix permissions e2e tests
* Remove unneeded delay from test/e2e/signature-request.spec.js
* Add delay before attempting to retrieve network id in dapp in ethereum-on=.spec
* Use requestAccountTabIds strategy for determining tab id that opened a given window
* Improve default values for permissions requests
* Add some message descriptions to app/_locales/en/messages.json
* Code clean up in permission controller
* Stopped deep cloning object in mapObjectValues
* Bump metamask-inpage-provider version
* Add missing description in app/_locales/en/messages.json
* Return promises from queryTabs and switchToTab of extension.js
* Remove unused getAllPermissions function
* Use default props in icon-with-fallback.component.js
* Stop passing to permissions controller
* Delete no longer used clear-approved-origins modal code
* Remove duplicate imports in ui/app/components/app/index.scss
* Use URL instead of regex in getOriginFromUrl()
* Add runtime error checking to platform, promise based extension.tab methods
* Support permission requests from external extensions
* Improve font size and colour of the domain origin on the permission confirmation screen
* Add support for toggling permissions
* Ensure getRenderablePermissionsDomains only returns domains with exposedAccount caveat permissions
* Remove unused code from LoginPerSite-ui branch
* Ensure modal closes on Enter press for new-account-modal.component.js
* Lint fix
* fixup! Login Per Site UI (#7368)
* Some code cleanup for LoginPerSite
* Adds UX for connecting to dapps via the connected sites screen (#7593)
* Adds UX for connecting to dapps via the connected sites screen
* Use openMetaMaskTabIds from background.js to determine if current active tab is MetaMask
* Delete unused permissions controller methods
* Fixes two small bugs in the LoginPerSite ui (#7595)
* Restore `providerRequest` message translations (#7600)
This message was removed, but it was replaced with a very similar
message called `likeToConnect`. The only difference is that the new
message has "MetaMask" in it. Preserving these messages without
"MetaMask" is probably better than deleting them, so these messages
have all been restored and renamed to `likeToConnect`.
* Login per site no sitemetadata fix (#7610)
* Support connected sites for which we have no site metadata.
* Change property containing subtitle info often populated by origin to a more accurate of purpose name
* Lint fix
* Improve disconnection modal messages (#7612)
* Improve disconnectAccountModalDescription and disconnectAllModalDescription messages
* Update disconnectAccountModalDescription app/_locales/en/messages.json
Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
* Improve disconnectAccount modal message clarity
* Adds cancel button to the account selection screen of the permissions request flow (#7613)
* Fix eth_accounts permission language & selectability (#7614)
* fix eth_accounts language & selectability
* fix MetaMask capitalization in all messages
* Close sidebar when opening connected sites (#7611)
The 'Connected Sites' button in the accounts details now closes the
sidebar, if it is open. This was accomplished by pulling the click
handler for that button up to the wallet view component, where another
button already followed a similar pattern of closing the sidebar.
It seemed confusing to me that one handler was in the `AccountsDetails`
container component, and one was handed down from above, so I added
PropTypes to the container component.
I'm not sure that the WalletView component is the best place for this
logic, but I've put it there for now to be consistent with the add
token button.
* Reject permissions request upon tab close (#7618)
Permissions requests are now rejected when the page is closed. This
only applies to the full-screen view, as that is the view permission
requests should be handled in. The case where the user deals with the
request through a different view is handled in #7617
* Handle tab update failure (#7619)
`extension.tabs.update` can sometimes fail if the user interacts with
the tabs directly around the same time. The redirect flow has been
updated to ensure that the permissions tab is still closed in that
case. The user is on their own to find the dapp tab again in that case.
* Login per site tab popup fixes (#7617)
* Handle redirect in response to state update in permissions-connect
* Ensure origin is available to permissions-connect subcomponents during redirect
* Hide app bar whenever on redirect route
* Improvements to handling of redirects in permissions-connect
* Ensure permission request id change handling only happens when page is not null
* Lint fix
* Decouple confirm transaction screen from the selected address (#7622)
* Avoid race condtion that could prevent contextual account switching (#7623)
There was a race condition in the logic responsible for switching the
selected account based upon the active tab. It was asynchronously
querying the active tab, then assuming it had been retrieved later.
The active tab info itself was already in the redux store in another
spot, one that is guaranteed to be set before the UI renders. The
race condition was avoided by deleting the duplicate state, and using
the other active tab state.
* Only redirect back to dapp if current tab is active (#7621)
The "redirect back to dapp" behaviour can be disruptive when the
permissions connect tab is not active. The purpose of the redirect was
to maintain context between the dapp and the permissions request, but
if the user has already moved to another tab, that no longer applies.
* Fix JSX style lint errors
* Remove unused state
2019-12-03 18:35:56 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.waitUntilXWindowHandles(2)
|
|
|
|
await driver.switchToWindow(dapp)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-11-05 17:50:06 +01:00
|
|
|
})
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('initiates a send from the dapp', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`), 10000)
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(2000)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2018-07-07 00:55:30 +02:00
|
|
|
windowHandles = await driver.getAllWindowHandles()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindowWithTitle('MetaMask Notification', windowHandles)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.assertElementNotPresent(By.xpath(`//li[contains(text(), 'Data')]`))
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input'))
|
2019-02-13 15:03:14 +01:00
|
|
|
|
2020-04-30 05:48:36 +02:00
|
|
|
await gasPriceInput.clear()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2019-02-13 15:03:14 +01:00
|
|
|
await gasPriceInput.sendKeys('10')
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
|
|
|
await driver.delay(tinyDelayMs)
|
|
|
|
await driver.delay(50)
|
2020-04-30 05:48:36 +02:00
|
|
|
|
|
|
|
await gasLimitInput.clear()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2019-03-29 15:48:08 +01:00
|
|
|
await gasLimitInput.sendKeys('25000')
|
Use `AdvancedGasInputs` in `AdvancedTabContent` (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`
The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.
The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.
Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.
The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.
Closes #6872
* Cleanup send components
Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 14:23:15 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(1000)
|
2019-02-13 15:03:14 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`), 10000)
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.waitUntilXWindowHandles(2)
|
|
|
|
await driver.switchToWindow(extension)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-07 00:55:30 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2019-03-29 15:48:08 +01:00
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2019-03-29 15:48:08 +01:00
|
|
|
return confirmedTxes.length === 4
|
|
|
|
}, 10000)
|
2018-07-07 00:55:30 +02:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txValue = await driver.findClickableElement(By.css('.transaction-list-item__primary-currency'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txValue, /-3\s*ETH/u), 10000)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
2019-02-13 15:03:14 +01:00
|
|
|
|
|
|
|
it('the transaction has the expected gas price', async function () {
|
2020-05-26 22:49:11 +02:00
|
|
|
const txValue = await driver.findClickableElement(By.css('.transaction-list-item__primary-currency'))
|
2020-01-15 20:34:15 +01:00
|
|
|
await txValue.click()
|
2020-05-26 22:49:11 +02:00
|
|
|
const popoverCloseButton = await driver.findClickableElement(By.css('.popover-header__button'))
|
2020-06-03 15:54:55 +02:00
|
|
|
const txGasPrice = await driver.findElement(By.css('[data-testid="transaction-breakdown__gas-price"]'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txGasPrice, /^10$/u), 10000)
|
2020-05-26 22:49:11 +02:00
|
|
|
await popoverCloseButton.click()
|
2019-02-13 15:03:14 +01:00
|
|
|
})
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Navigate transactions', function () {
|
|
|
|
it('adds multiple transactions', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.waitUntilXWindowHandles(2)
|
2018-11-13 18:19:12 +01:00
|
|
|
const windowHandles = await driver.getAllWindowHandles()
|
|
|
|
const extension = windowHandles[0]
|
|
|
|
const dapp = windowHandles[1]
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(dapp)
|
|
|
|
await driver.delay(largeDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
const send3eth = await driver.findClickableElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
2018-11-13 18:19:12 +01:00
|
|
|
await send3eth.click()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
const contractDeployment = await driver.findClickableElement(By.xpath(`//button[contains(text(), 'Deploy Contract')]`))
|
2018-11-13 18:19:12 +01:00
|
|
|
await contractDeployment.click()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
|
|
|
await send3eth.click()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
await contractDeployment.click()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(extension)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.transaction-list-item'))
|
|
|
|
await driver.delay(largeDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('navigates the transactions', async function () {
|
2020-01-14 19:53:02 +01:00
|
|
|
await driver.clickElement(By.css('[data-testid="next-page"]'))
|
2020-01-13 16:07:32 +01:00
|
|
|
let navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
2018-11-13 18:19:12 +01:00
|
|
|
let navigationText = await navigationElement.getText()
|
|
|
|
assert.equal(navigationText.includes('2'), true, 'changed transaction right')
|
|
|
|
|
2020-01-14 19:53:02 +01:00
|
|
|
await driver.clickElement(By.css('[data-testid="next-page"]'))
|
2020-01-13 16:07:32 +01:00
|
|
|
navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
2018-11-13 18:19:12 +01:00
|
|
|
navigationText = await navigationElement.getText()
|
|
|
|
assert.equal(navigationText.includes('3'), true, 'changed transaction right')
|
|
|
|
|
2020-01-14 19:53:02 +01:00
|
|
|
await driver.clickElement(By.css('[data-testid="next-page"]'))
|
2020-01-13 16:07:32 +01:00
|
|
|
navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
2018-11-13 18:19:12 +01:00
|
|
|
navigationText = await navigationElement.getText()
|
|
|
|
assert.equal(navigationText.includes('4'), true, 'changed transaction right')
|
|
|
|
|
2020-01-14 19:53:02 +01:00
|
|
|
await driver.clickElement(By.css('[data-testid="first-page"]'))
|
2020-01-13 16:07:32 +01:00
|
|
|
navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
2018-11-13 18:19:12 +01:00
|
|
|
navigationText = await navigationElement.getText()
|
|
|
|
assert.equal(navigationText.includes('1'), true, 'navigate to first transaction')
|
|
|
|
|
2020-01-14 19:53:02 +01:00
|
|
|
await driver.clickElement(By.css('[data-testid="last-page"]'))
|
2020-01-13 16:07:32 +01:00
|
|
|
navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
2018-11-13 18:19:12 +01:00
|
|
|
navigationText = await navigationElement.getText()
|
|
|
|
assert.equal(navigationText.split('4').length, 3, 'navigate to last transaction')
|
|
|
|
|
2020-01-14 19:53:02 +01:00
|
|
|
await driver.clickElement(By.css('[data-testid="previous-page"]'))
|
2020-01-13 16:07:32 +01:00
|
|
|
navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
2018-11-13 18:19:12 +01:00
|
|
|
navigationText = await navigationElement.getText()
|
|
|
|
assert.equal(navigationText.includes('3'), true, 'changed transaction left')
|
|
|
|
|
2020-01-14 19:53:02 +01:00
|
|
|
await driver.clickElement(By.css('[data-testid="previous-page"]'))
|
2020-01-13 16:07:32 +01:00
|
|
|
navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
2018-11-13 18:19:12 +01:00
|
|
|
navigationText = await navigationElement.getText()
|
|
|
|
assert.equal(navigationText.includes('2'), true, 'changed transaction left')
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('adds a transaction while confirm screen is in focus', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
let navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
2018-11-13 18:19:12 +01:00
|
|
|
let navigationText = await navigationElement.getText()
|
|
|
|
assert.equal(navigationText.includes('2'), true, 'second transaction in focus')
|
|
|
|
|
|
|
|
const windowHandles = await driver.getAllWindowHandles()
|
|
|
|
const extension = windowHandles[0]
|
|
|
|
const dapp = windowHandles[1]
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(dapp)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(extension)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
2018-11-13 18:19:12 +01:00
|
|
|
navigationText = await navigationElement.getText()
|
2020-01-10 15:34:02 +01:00
|
|
|
assert.equal(navigationText.includes('2'), true, 'correct (same) transaction in focus')
|
2018-11-13 18:19:12 +01:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('rejects a transaction', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(tinyDelayMs)
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Reject')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs * 2)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
|
|
|
await driver.delay(tinyDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
const navigationText = await navigationElement.getText()
|
2020-01-10 20:32:57 +01:00
|
|
|
assert.equal(navigationText.includes('4'), true, 'transaction rejected')
|
2018-11-13 18:19:12 +01:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('confirms a transaction', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(tinyDelayMs / 2)
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const navigationElement = await driver.findElement(By.css('.confirm-page-container-navigation'))
|
|
|
|
await driver.delay(tinyDelayMs / 2)
|
2018-11-13 18:19:12 +01:00
|
|
|
const navigationText = await navigationElement.getText()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(tinyDelayMs / 2)
|
2020-01-10 20:32:57 +01:00
|
|
|
assert.equal(navigationText.includes('3'), true, 'transaction confirmed')
|
2018-11-13 18:19:12 +01:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('rejects the rest of the transactions', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//a[contains(text(), 'Reject 3')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Reject All')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs * 2)
|
2018-11-13 18:19:12 +01:00
|
|
|
|
2020-04-30 16:39:42 +02:00
|
|
|
await driver.wait(async () => {
|
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
|
|
|
return confirmedTxes.length === 5
|
|
|
|
}, 10000)
|
2018-11-13 18:19:12 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Deploy contract and call contract methods', function () {
|
2018-06-22 14:13:01 +02:00
|
|
|
let extension
|
2018-07-07 00:55:30 +02:00
|
|
|
let dapp
|
2020-02-11 17:51:13 +01:00
|
|
|
it('creates a deploy contract transaction', async function () {
|
2018-07-07 00:55:30 +02:00
|
|
|
const windowHandles = await driver.getAllWindowHandles()
|
|
|
|
extension = windowHandles[0]
|
|
|
|
dapp = windowHandles[1]
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(tinyDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(dapp)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('#deployButton'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(extension)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
await driver.clickElement(By.xpath(`//h2[contains(text(), 'Contract Deployment')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('displays the contract creation data', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//li[contains(text(), 'Data')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.findElement(By.xpath(`//div[contains(text(), '127.0.0.1')]`))
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmDataDiv = await driver.findElement(By.css('.confirm-page-container-content__data-box'))
|
2018-07-10 17:43:17 +02:00
|
|
|
const confirmDataText = await confirmDataDiv.getText()
|
2020-04-23 15:08:03 +02:00
|
|
|
assert.ok(confirmDataText.includes('Origin:'))
|
|
|
|
assert.ok(confirmDataText.includes('127.0.0.1'))
|
|
|
|
assert.ok(confirmDataText.includes('Bytes:'))
|
|
|
|
assert.ok(confirmDataText.includes('675'))
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//li[contains(text(), 'Details')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('confirms a deploy contract transaction', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2019-01-24 16:58:47 +01:00
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2019-02-08 15:22:19 +01:00
|
|
|
return confirmedTxes.length === 6
|
2018-08-23 05:17:37 +02:00
|
|
|
}, 10000)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txAction = await driver.findElements(By.css('.list-item__heading'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txAction[0], /Contract\sDeployment/u), 10000)
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('calls and confirms a contract method where ETH is sent', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(dapp)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
let contractStatus = await driver.findElement(By.css('#contractStatus'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(contractStatus, /Deployed/u), 15000)
|
2018-07-24 19:24:13 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('#depositButton'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-07-24 19:24:13 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
contractStatus = await driver.findElement(By.css('#contractStatus'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(contractStatus, /Deposit\sinitiated/u), 10000)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(extension)
|
|
|
|
await driver.delay(largeDelayMs * 2)
|
2018-06-22 14:13:01 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.findElements(By.css('.transaction-list-item'))
|
2020-05-26 22:49:11 +02:00
|
|
|
const txListValue = await driver.findClickableElement(By.css('.transaction-list-item__primary-currency'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txListValue, /-4\s*ETH/u), 10000)
|
2018-07-11 19:21:58 +02:00
|
|
|
await txListValue.click()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
|
|
|
// Set the gas limit
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.confirm-detail-row__header-text--edit'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const gasModal = await driver.findElement(By.css('span .modal'))
|
|
|
|
await driver.delay(regularDelayMs)
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.page-container__tab:nth-of-type(2)'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input'))
|
2019-07-03 22:33:44 +02:00
|
|
|
const gasLimitValue = await gasLimitInput.getAttribute('value')
|
|
|
|
assert(Number(gasLimitValue) < 100000, 'Gas Limit too high')
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2020-04-30 05:48:36 +02:00
|
|
|
await gasPriceInput.clear()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2018-06-11 15:08:24 +02:00
|
|
|
await gasPriceInput.sendKeys('10')
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2020-04-30 05:48:36 +02:00
|
|
|
|
|
|
|
await gasLimitInput.clear()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2018-06-11 15:08:24 +02:00
|
|
|
await gasLimitInput.sendKeys('60001')
|
Use `AdvancedGasInputs` in `AdvancedTabContent` (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`
The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.
The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.
Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.
The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.
Closes #6872
* Cleanup send components
Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 14:23:15 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(1000)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Save')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
|
|
|
await driver.wait(until.stalenessOf(gasModal))
|
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2019-01-24 16:58:47 +01:00
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2019-02-08 15:22:19 +01:00
|
|
|
return confirmedTxes.length === 7
|
2018-08-23 05:17:37 +02:00
|
|
|
}, 10000)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txValues = await driver.findElements(By.css('.transaction-list-item__primary-currency'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txValues[0], /-4\s*ETH/u), 10000)
|
2018-06-22 14:13:01 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('calls and confirms a contract method where ETH is received', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(dapp)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-22 14:13:01 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('#withdrawButton'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-22 14:13:01 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(extension)
|
|
|
|
await driver.delay(largeDelayMs * 2)
|
2018-06-22 14:13:01 +02:00
|
|
|
|
2020-04-30 19:37:01 +02:00
|
|
|
await driver.clickElement(By.css('.transaction-list__pending-transactions .transaction-list-item'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-22 14:13:01 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-22 14:13:01 +02:00
|
|
|
|
2019-01-24 16:58:47 +01:00
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2019-02-08 15:22:19 +01:00
|
|
|
return confirmedTxes.length === 8
|
2018-08-23 05:17:37 +02:00
|
|
|
}, 10000)
|
2018-06-11 15:08:24 +02:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txValues = await driver.findElement(By.css('.transaction-list-item__primary-currency'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txValues, /-0\s*ETH/u), 10000)
|
2018-06-22 14:13:01 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.closeAllWindowHandlesExcept([extension, dapp])
|
|
|
|
await driver.switchToWindow(extension)
|
2018-06-22 14:13:01 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('renders the correct ETH balance', async function () {
|
2020-07-09 22:33:37 +02:00
|
|
|
const balance = await driver.findElement(By.css('[data-testid="eth-overview__primary-currency"]'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(balance, /^87.*\s*ETH.*$/u), 10000)
|
2019-10-31 17:27:22 +01:00
|
|
|
const tokenAmount = await balance.getText()
|
2020-08-19 18:27:05 +02:00
|
|
|
assert.ok((/^87.*\s*ETH.*$/u).test(tokenAmount))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-11 15:08:24 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Add a custom token from a dapp', function () {
|
|
|
|
it('creates a new token', async function () {
|
2018-08-13 19:31:07 +02:00
|
|
|
let windowHandles = await driver.getAllWindowHandles()
|
2018-07-07 00:55:30 +02:00
|
|
|
const extension = windowHandles[0]
|
|
|
|
const dapp = windowHandles[1]
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs * 2)
|
2018-06-21 18:29:20 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(dapp)
|
|
|
|
await driver.delay(regularDelayMs * 2)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Create Token')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2018-08-13 19:31:07 +02:00
|
|
|
windowHandles = await driver.getAllWindowHandles()
|
|
|
|
const popup = windowHandles[2]
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(popup)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.confirm-detail-row__header-text--edit'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-12-12 15:54:03 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//li[contains(text(), 'Advanced')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(tinyDelayMs)
|
2018-12-12 15:54:03 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input'))
|
2018-12-12 15:54:03 +01:00
|
|
|
assert(gasPriceInput.getAttribute('value'), 20)
|
|
|
|
assert(gasLimitInput.getAttribute('value'), 4700000)
|
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Save')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-12-12 15:54:03 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(dapp)
|
|
|
|
await driver.delay(tinyDelayMs)
|
2018-06-21 18:29:20 +02:00
|
|
|
|
2018-07-07 00:55:30 +02:00
|
|
|
const tokenContractAddress = await driver.findElement(By.css('#tokenAddress'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(tokenContractAddress, /0x/u))
|
2018-07-07 00:55:30 +02:00
|
|
|
tokenAddress = await tokenContractAddress.getText()
|
2018-06-21 18:29:20 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
|
|
|
await driver.closeAllWindowHandlesExcept([extension, dapp])
|
|
|
|
await driver.delay(regularDelayMs)
|
|
|
|
await driver.switchToWindow(extension)
|
|
|
|
await driver.delay(largeDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('clicks on the Add Token button', async function () {
|
2020-05-27 22:28:33 +02:00
|
|
|
await driver.clickElement(By.css(`[data-testid="home__asset-tab"]`))
|
2020-03-31 15:31:32 +02:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Add Token')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('picks the newly created Test token', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath("//li[contains(text(), 'Custom Token')]"))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const newTokenAddress = await driver.findElement(By.css('#custom-address'))
|
2018-05-25 03:17:26 +02:00
|
|
|
await newTokenAddress.sendKeys(tokenAddress)
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Next')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Add Tokens')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('renders the balance for the new token', async function () {
|
2020-05-21 19:33:48 +02:00
|
|
|
const balance = await driver.findElement(By.css('.wallet-overview .token-overview__primary-balance'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(balance, /^10\s*TST\s*$/u))
|
2018-05-25 03:17:26 +02:00
|
|
|
const tokenAmount = await balance.getText()
|
2020-08-19 18:27:05 +02:00
|
|
|
assert.ok((/^10\s*TST\s*$/u).test(tokenAmount))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-05-25 03:17:26 +02:00
|
|
|
})
|
|
|
|
})
|
2018-06-07 14:37:41 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Send token from inside MetaMask', function () {
|
2018-06-07 18:53:54 +02:00
|
|
|
let gasModal
|
2018-06-07 14:37:41 +02:00
|
|
|
it('starts to send a transaction', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Send')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-07 14:37:41 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const inputAddress = await driver.findElement(By.css('input[placeholder="Search, public address (0x), or ENS"]'))
|
2018-06-07 14:37:41 +02:00
|
|
|
await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970')
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const inputAmount = await driver.findElement(By.css('.unit-input__input'))
|
2019-06-28 05:52:21 +02:00
|
|
|
await inputAmount.sendKeys('1')
|
2018-06-07 14:37:41 +02:00
|
|
|
|
|
|
|
// Set the gas limit
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.advanced-gas-options-btn'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-07 14:37:41 +02:00
|
|
|
|
2018-06-07 18:53:54 +02:00
|
|
|
gasModal = await driver.findElement(By.css('span .modal'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-07 18:53:54 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('opens customize gas modal', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.findElement(By.css('.page-container__title'))
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Save')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-07 18:53:54 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('transitions to the confirm screen', async function () {
|
2018-06-07 18:53:54 +02:00
|
|
|
await driver.wait(until.stalenessOf(gasModal))
|
2018-06-07 14:37:41 +02:00
|
|
|
|
|
|
|
// Continue to next screen
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Next')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-07 14:37:41 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('displays the token transfer data', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//li[contains(text(), 'Data')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const functionType = await driver.findElement(By.css('.confirm-page-container-content__function-type'))
|
2018-07-10 17:43:17 +02:00
|
|
|
const functionTypeText = await functionType.getText()
|
2019-03-29 15:48:08 +01:00
|
|
|
assert.equal(functionTypeText, 'Transfer')
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const tokenAmount = await driver.findElement(By.css('.confirm-page-container-summary__title-text'))
|
2019-06-28 05:52:21 +02:00
|
|
|
const tokenAmountText = await tokenAmount.getText()
|
|
|
|
assert.equal(tokenAmountText, '1 TST')
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmDataDiv = await driver.findElement(By.css('.confirm-page-container-content__data-box'))
|
2018-07-10 17:43:17 +02:00
|
|
|
const confirmDataText = await confirmDataDiv.getText()
|
2019-03-28 13:23:38 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2020-08-14 13:48:42 +02:00
|
|
|
assert(confirmDataText.match(/0xa9059cbb0000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c97/u))
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//li[contains(text(), 'Details')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
})
|
|
|
|
|
2018-06-07 18:53:54 +02:00
|
|
|
it('submits the transaction', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-07 14:37:41 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2019-01-24 16:58:47 +01:00
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2018-08-07 10:57:46 +02:00
|
|
|
return confirmedTxes.length === 1
|
2018-08-23 05:17:37 +02:00
|
|
|
}, 10000)
|
2019-10-31 17:27:22 +01:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txValues = await driver.findElements(By.css('.transaction-list-item__primary-currency'))
|
2019-10-31 17:27:22 +01:00
|
|
|
assert.equal(txValues.length, 1)
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txValues[0], /-1\s*TST/u), 10000)
|
2019-10-31 17:27:22 +01:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txStatuses = await driver.findElements(By.css('.list-item__heading'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txStatuses[0], /Send\sTST/u), 10000)
|
2018-06-07 18:53:54 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Send a custom token from dapp', function () {
|
2018-06-19 17:44:01 +02:00
|
|
|
let gasModal
|
2020-02-11 17:51:13 +01:00
|
|
|
it('sends an already created token', async function () {
|
2018-07-07 00:55:30 +02:00
|
|
|
const windowHandles = await driver.getAllWindowHandles()
|
|
|
|
const extension = windowHandles[0]
|
2020-01-13 16:07:32 +01:00
|
|
|
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-07 18:53:54 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(dapp)
|
|
|
|
await driver.delay(tinyDelayMs)
|
2018-06-07 18:53:54 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Transfer Tokens')]`))
|
2018-06-07 18:53:54 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(extension)
|
|
|
|
await driver.delay(largeDelayMs)
|
2018-06-07 18:53:54 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.findElements(By.css('.transaction-list__pending-transactions'))
|
2020-05-26 22:49:11 +02:00
|
|
|
const txListValue = await driver.findClickableElement(By.css('.transaction-list-item__primary-currency'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txListValue, /-1.5\s*TST/u), 10000)
|
2018-07-11 19:21:58 +02:00
|
|
|
await txListValue.click()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-27 04:14:38 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const transactionAmounts = await driver.findElements(By.css('.currency-display-component__text'))
|
2019-07-03 22:33:44 +02:00
|
|
|
const transactionAmount = transactionAmounts[0]
|
|
|
|
assert(await transactionAmount.getText(), '1.5 TST')
|
|
|
|
|
2018-06-19 17:44:01 +02:00
|
|
|
// Set the gas limit
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.confirm-detail-row__header-text--edit'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-19 17:44:01 +02:00
|
|
|
|
|
|
|
gasModal = await driver.findElement(By.css('span .modal'))
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('customizes gas', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.page-container__tab:nth-of-type(2)'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-19 17:44:01 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input'))
|
2019-01-24 16:58:47 +01:00
|
|
|
|
2020-04-30 05:48:36 +02:00
|
|
|
await gasPriceInput.clear()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2018-06-19 17:44:01 +02:00
|
|
|
await gasPriceInput.sendKeys('10')
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2020-04-30 05:48:36 +02:00
|
|
|
|
|
|
|
await gasLimitInput.clear()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2018-06-19 17:44:01 +02:00
|
|
|
await gasLimitInput.sendKeys('60000')
|
Use `AdvancedGasInputs` in `AdvancedTabContent` (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`
The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.
The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.
Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.
The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.
Closes #6872
* Cleanup send components
Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 14:23:15 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(1000)
|
2018-06-27 18:20:44 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.page-container__footer-button'))
|
2018-06-19 17:44:01 +02:00
|
|
|
await driver.wait(until.stalenessOf(gasModal))
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const gasFeeInputs = await driver.findElements(By.css('.confirm-detail-row__primary'))
|
2019-01-24 16:58:47 +01:00
|
|
|
const renderedGasFee = await gasFeeInputs[0].getText()
|
|
|
|
assert.equal(renderedGasFee, '0.0006')
|
2018-06-19 17:44:01 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('submits the transaction', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
const tokenAmount = await driver.findElement(By.css('.confirm-page-container-summary__title-text'))
|
2019-06-28 05:52:21 +02:00
|
|
|
const tokenAmountText = await tokenAmount.getText()
|
|
|
|
assert.equal(tokenAmountText, '1.5 TST')
|
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-07 18:53:54 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2019-01-24 16:58:47 +01:00
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2018-08-07 10:57:46 +02:00
|
|
|
return confirmedTxes.length === 2
|
2018-08-23 05:17:37 +02:00
|
|
|
}, 10000)
|
2018-06-07 18:53:54 +02:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txValues = await driver.findElements(By.css('.transaction-list-item__primary-currency'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txValues[0], /-1.5\s*TST/u))
|
2020-05-26 22:49:11 +02:00
|
|
|
const txStatuses = await driver.findElements(By.css('.list-item__heading'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txStatuses[0], /Send\sTST/u), 10000)
|
2018-06-08 15:46:47 +02:00
|
|
|
|
2020-05-21 19:33:48 +02:00
|
|
|
const tokenBalanceAmount = await driver.findElements(By.css('.token-overview__primary-balance'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(tokenBalanceAmount[0], /7.5\s*TST/u), 10000)
|
2018-06-08 15:46:47 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Approves a custom token from dapp', function () {
|
2018-07-10 17:43:17 +02:00
|
|
|
let gasModal
|
2020-02-11 17:51:13 +01:00
|
|
|
it('approves an already created token', async function () {
|
2018-07-10 17:43:17 +02:00
|
|
|
const windowHandles = await driver.getAllWindowHandles()
|
|
|
|
const extension = windowHandles[0]
|
2020-01-13 16:07:32 +01:00
|
|
|
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
|
|
|
await driver.closeAllWindowHandlesExcept([extension, dapp])
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(dapp)
|
|
|
|
await driver.delay(tinyDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Approve Tokens')]`))
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(extension)
|
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2019-01-24 16:58:47 +01:00
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const pendingTxes = await driver.findElements(By.css('.transaction-list__pending-transactions .transaction-list-item'))
|
2018-08-07 10:57:46 +02:00
|
|
|
return pendingTxes.length === 1
|
|
|
|
}, 10000)
|
|
|
|
|
2020-07-21 17:45:14 +02:00
|
|
|
const [txtListHeading] = await driver.findElements(By.css('.transaction-list-item .list-item__heading'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txtListHeading, /Approve TST spend limit/u))
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.transaction-list-item'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('displays the token approval data', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.confirm-approve-content__view-full-tx-button'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const functionType = await driver.findElement(By.css('.confirm-approve-content__data .confirm-approve-content__small-text'))
|
2018-07-10 17:43:17 +02:00
|
|
|
const functionTypeText = await functionType.getText()
|
2019-11-05 16:13:48 +01:00
|
|
|
assert.equal(functionTypeText, 'Function: Approve')
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmDataDiv = await driver.findElement(By.css('.confirm-approve-content__data__data-block'))
|
2018-07-10 17:43:17 +02:00
|
|
|
const confirmDataText = await confirmDataDiv.getText()
|
2020-08-14 13:48:42 +02:00
|
|
|
assert(confirmDataText.match(/0x095ea7b30000000000000000000000009bc5baf874d2da8d216ae9f137804184ee5afef4/u))
|
2018-07-10 17:43:17 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('opens the gas edit modal', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.confirm-approve-content__small-blue-text.cursor-pointer'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
|
|
|
|
gasModal = await driver.findElement(By.css('span .modal'))
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('customizes gas', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.page-container__tab:nth-of-type(2)'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const [gasPriceInput, gasLimitInput] = await driver.findElements(By.css('.advanced-gas-inputs__gas-edit-row__input'))
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2020-04-30 05:48:36 +02:00
|
|
|
await gasPriceInput.clear()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2018-07-10 17:43:17 +02:00
|
|
|
await gasPriceInput.sendKeys('10')
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2020-04-30 05:48:36 +02:00
|
|
|
|
|
|
|
await gasLimitInput.clear()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2019-05-14 20:14:07 +02:00
|
|
|
await gasLimitInput.sendKeys('60001')
|
Use `AdvancedGasInputs` in `AdvancedTabContent` (#7186)
* Use `AdvancedGasInputs` in `AdvancedTabContent`
The `AdvancedGasInputs` component was originally extracted from the
`AdvancedTabContent` component, duplicating much of the rendering
logic. They have since evolved separately, with bugs being fixed in one
place but not the other.
The inputs and outputs expected weren't exactly the same, as the
`AdvancedGasInputs` component converts the input custom gas price and
limit, and it converts them both in the setter methods as well.
The `GasModalPageContainer` had to be adjusted to avoid converting
these values multiple times.
Both components dealt with input debouncing separately, both in less
than ideal ways. `AdvancedTabContent` didn't debounce either field, but
it did debounce the check for whether the gas limit field was below the
minimum value. So if a less-than-minimum value was set, it would be
propogated upwards and could be saved if the user clicked 'Save'
quickly enough. After a second delay it would snap back to the minimum
value. The `AdvancedGasInputs` component debounced both fields, but
it would replace any gas limit below the minimum with the minimum
value. This led to a problem where a brief pause during typing would
reset the field to 21000.
The `AdvancedGasInputs` approach was chosen, except that it was
updated to no longer change the gas limit if it was below the minimum.
Instead it displays an error. Parent components were checked to ensure
they would detect the error case of the gas limit being set too low,
and prevent the form submission in those cases. Of the three parents,
one had already dealt with it correctly, one needed to convert the
gas limit from hex first, and another needed the gas limit check added.
Closes #6872
* Cleanup send components
Empty README files have been removed, and a mistake in the index file
for the send page has been corrected. The Gas Slider component class
name was updated as well; it looks like it was originally created from
`AdvancedTabContent`, so it still had that class name.
2019-10-23 14:23:15 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(1000)
|
2018-07-10 17:43:17 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.page-container__footer-button'))
|
2018-07-10 17:43:17 +02:00
|
|
|
await driver.wait(until.stalenessOf(gasModal))
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const gasFeeInEth = await driver.findElement(By.css('.confirm-approve-content__transaction-details-content__secondary-fee'))
|
2019-11-19 14:41:28 +01:00
|
|
|
assert.equal(await gasFeeInEth.getText(), '0.0006 ETH')
|
2018-07-10 17:43:17 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('edits the permission', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
const editButtons = await driver.findClickableElements(By.css('.confirm-approve-content__small-blue-text.cursor-pointer'))
|
2019-11-05 16:13:48 +01:00
|
|
|
await editButtons[1].click()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-11-05 16:13:48 +01:00
|
|
|
|
|
|
|
const permissionModal = await driver.findElement(By.css('span .modal'))
|
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
const radioButtons = await driver.findClickableElements(By.css('.edit-approval-permission__edit-section__radio-button'))
|
2019-11-05 16:13:48 +01:00
|
|
|
await radioButtons[1].click()
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const customInput = await driver.findElement(By.css('input'))
|
|
|
|
await driver.delay(50)
|
2019-11-05 16:13:48 +01:00
|
|
|
await customInput.sendKeys('5')
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-11-05 16:13:48 +01:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Save')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-11-05 16:13:48 +01:00
|
|
|
|
|
|
|
await driver.wait(until.stalenessOf(permissionModal))
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const permissionInfo = await driver.findElements(By.css('.confirm-approve-content__medium-text'))
|
2019-11-05 16:13:48 +01:00
|
|
|
const amountDiv = permissionInfo[0]
|
|
|
|
assert.equal(await amountDiv.getText(), '5 TST')
|
2019-09-16 21:35:21 +02:00
|
|
|
})
|
|
|
|
|
2018-07-10 17:43:17 +02:00
|
|
|
it('submits the transaction', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-07-10 17:43:17 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
2019-01-24 16:58:47 +01:00
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2018-08-07 10:57:46 +02:00
|
|
|
return confirmedTxes.length === 3
|
2018-08-23 05:17:37 +02:00
|
|
|
}, 10000)
|
2018-08-07 10:57:46 +02:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txStatuses = await driver.findElements(By.css('.list-item__heading'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txStatuses[0], /Approve TST spend limit/u))
|
2018-07-10 17:43:17 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-07-20 19:02:49 +02:00
|
|
|
describe('Transfers a custom token from dapp when no gas value is specified', function () {
|
2020-02-11 17:51:13 +01:00
|
|
|
it('transfers an already created token, without specifying gas', async function () {
|
2019-05-14 20:14:07 +02:00
|
|
|
const windowHandles = await driver.getAllWindowHandles()
|
|
|
|
const extension = windowHandles[0]
|
2020-01-13 16:07:32 +01:00
|
|
|
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
|
|
|
await driver.closeAllWindowHandlesExcept([extension, dapp])
|
|
|
|
await driver.delay(regularDelayMs)
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(dapp)
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Transfer Tokens Without Gas')]`))
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(extension)
|
|
|
|
await driver.delay(regularDelayMs)
|
2019-05-14 20:14:07 +02:00
|
|
|
|
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const pendingTxes = await driver.findElements(By.css('.transaction-list__pending-transactions .transaction-list-item'))
|
2019-05-14 20:14:07 +02:00
|
|
|
return pendingTxes.length === 1
|
|
|
|
}, 10000)
|
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const [txListValue] = await driver.findElements(By.css('.transaction-list-item__primary-currency'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txListValue, /-1.5\s*TST/u))
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.transaction-list-item'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-05-14 20:14:07 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('submits the transaction', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs * 2)
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs * 2)
|
2019-05-14 20:14:07 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2019-05-14 20:14:07 +02:00
|
|
|
return confirmedTxes.length === 4
|
|
|
|
}, 10000)
|
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txValues = await driver.findElements(By.css('.transaction-list-item__primary-currency'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txValues[0], /-1.5\s*TST/u))
|
2020-05-26 22:49:11 +02:00
|
|
|
const txStatuses = await driver.findElements(By.css('.list-item__heading'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txStatuses[0], /Send TST/u))
|
2019-05-14 20:14:07 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Approves a custom token from dapp when no gas value is specified', function () {
|
|
|
|
it('approves an already created token', async function () {
|
2019-05-14 20:14:07 +02:00
|
|
|
const windowHandles = await driver.getAllWindowHandles()
|
|
|
|
const extension = windowHandles[0]
|
2020-01-13 16:07:32 +01:00
|
|
|
const dapp = await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles)
|
|
|
|
await driver.closeAllWindowHandlesExcept([extension, dapp])
|
|
|
|
await driver.delay(regularDelayMs)
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(dapp)
|
|
|
|
await driver.delay(tinyDelayMs)
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Approve Tokens Without Gas')]`))
|
2019-05-14 20:14:07 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.switchToWindow(extension)
|
|
|
|
await driver.delay(regularDelayMs)
|
2019-05-14 20:14:07 +02:00
|
|
|
|
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const pendingTxes = await driver.findElements(By.css('.transaction-list__pending-transactions .transaction-list-item'))
|
2019-05-14 20:14:07 +02:00
|
|
|
return pendingTxes.length === 1
|
|
|
|
}, 10000)
|
|
|
|
|
2020-07-21 17:45:14 +02:00
|
|
|
const [txtListHeading] = await driver.findElements(By.css('.transaction-list-item .list-item__heading'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txtListHeading, /Approve TST spend limit/u))
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.transaction-list-item'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-05-14 20:14:07 +02:00
|
|
|
})
|
|
|
|
|
2019-09-16 21:35:21 +02:00
|
|
|
it('shows the correct recipient', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.confirm-approve-content__view-full-tx-button'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-11-05 16:13:48 +01:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const permissionInfo = await driver.findElements(By.css('.confirm-approve-content__medium-text'))
|
2019-11-05 16:13:48 +01:00
|
|
|
const recipientDiv = permissionInfo[1]
|
|
|
|
assert.equal(await recipientDiv.getText(), '0x2f318C33...C970')
|
2019-09-16 21:35:21 +02:00
|
|
|
})
|
|
|
|
|
2019-05-14 20:14:07 +02:00
|
|
|
it('submits the transaction', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(1000)
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Confirm')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-05-14 20:14:07 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('finds the transaction in the transactions list', async function () {
|
|
|
|
await driver.wait(async () => {
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))
|
2019-05-14 20:14:07 +02:00
|
|
|
return confirmedTxes.length === 5
|
|
|
|
}, 10000)
|
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txStatuses = await driver.findElements(By.css('.list-item__heading'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(txStatuses[0], /Approve TST spend limit/u))
|
2019-05-14 20:14:07 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Hide token', function () {
|
|
|
|
it('hides the token when clicked', async function () {
|
2020-06-01 19:54:32 +02:00
|
|
|
await driver.clickElement(By.css('[data-testid="token-options__button"]'))
|
2018-06-11 15:52:44 +02:00
|
|
|
|
2020-06-01 19:54:32 +02:00
|
|
|
await driver.clickElement(By.css('[data-testid="token-options__hide"]'))
|
2018-06-11 15:52:44 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmHideModal = await driver.findElement(By.css('span .modal'))
|
2018-06-11 15:52:44 +02:00
|
|
|
|
2020-06-02 23:47:55 +02:00
|
|
|
await driver.clickElement(By.css('[data-testid="hide-token-confirmation__hide"]'))
|
2018-06-11 15:52:44 +02:00
|
|
|
|
|
|
|
await driver.wait(until.stalenessOf(confirmHideModal))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Add existing token using search', function () {
|
|
|
|
it('clicks on the Add Token button', async function () {
|
2020-03-31 15:31:32 +02:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Add Token')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-08 15:46:47 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('can pick a token from the existing options', async function () {
|
2020-01-13 16:07:32 +01:00
|
|
|
const tokenSearch = await driver.findElement(By.css('#search-tokens'))
|
2018-06-08 15:46:47 +02:00
|
|
|
await tokenSearch.sendKeys('BAT')
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-08 15:46:47 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath("//span[contains(text(), 'BAT')]"))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-08 15:46:47 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Next')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-08 15:46:47 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Add Tokens')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2018-06-08 15:46:47 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('renders the balance for the chosen token', async function () {
|
2020-05-21 19:33:48 +02:00
|
|
|
const balance = await driver.findElement(By.css('.token-overview__primary-balance'))
|
2020-08-14 13:48:42 +02:00
|
|
|
await driver.wait(until.elementTextMatches(balance, /0\s*BAT/u))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-06-07 14:37:41 +02:00
|
|
|
})
|
|
|
|
})
|
2018-08-19 19:25:33 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Stores custom RPC history', function () {
|
2018-08-19 19:25:33 +02:00
|
|
|
const customRpcUrls = [
|
2019-03-29 04:14:00 +01:00
|
|
|
'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',
|
2018-08-19 19:25:33 +02:00
|
|
|
]
|
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
customRpcUrls.forEach((customRpcUrl) => {
|
2020-02-11 17:51:13 +01:00
|
|
|
it(`creates custom RPC: ${customRpcUrl}`, async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.network-name'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-08-19 19:25:33 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//span[contains(text(), 'Custom RPC')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-08-19 19:25:33 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.findElement(By.css('.settings-page__sub-header-text'))
|
2019-05-09 19:27:14 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const customRpcInputs = await driver.findElements(By.css('input[type="text"]'))
|
2019-05-09 19:27:14 +02:00
|
|
|
const customRpcInput = customRpcInputs[1]
|
2018-08-19 19:25:33 +02:00
|
|
|
await customRpcInput.clear()
|
|
|
|
await customRpcInput.sendKeys(customRpcUrl)
|
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.network-form__footer .btn-secondary'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs * 2)
|
2018-08-19 19:25:33 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('selects another provider', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.network-name'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-08-19 19:25:33 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//span[contains(text(), 'Main Ethereum Network')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs * 2)
|
2018-08-19 19:25:33 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('finds all recent RPCs in history', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.network-name'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2018-08-19 19:25:33 +02:00
|
|
|
|
|
|
|
// only recent 3 are found and in correct order (most recent at the top)
|
2020-01-13 16:07:32 +01:00
|
|
|
const customRpcs = await driver.findElements(By.xpath(`//span[contains(text(), 'http://127.0.0.1:8545/')]`))
|
2018-08-19 19:25:33 +02:00
|
|
|
|
2018-10-01 16:54:30 +02:00
|
|
|
assert.equal(customRpcs.length, customRpcUrls.length)
|
2018-08-19 19:25:33 +02:00
|
|
|
})
|
2019-06-17 16:05:47 +02:00
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('deletes a custom RPC', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
const networkListItems = await driver.findClickableElements(By.css('.networks-tab__networks-list-name'))
|
2019-06-17 16:05:47 +02:00
|
|
|
const lastNetworkListItem = networkListItems[networkListItems.length - 1]
|
|
|
|
await lastNetworkListItem.click()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(100)
|
2019-06-17 16:05:47 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.btn-danger'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-07-02 14:13:02 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const confirmDeleteNetworkModal = await driver.findElement(By.css('span .modal'))
|
2019-07-02 14:13:02 +02:00
|
|
|
|
|
|
|
const byConfirmDeleteNetworkButton = By.css('.button.btn-danger.modal-container__footer-button')
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(byConfirmDeleteNetworkButton)
|
2019-07-02 14:13:02 +02:00
|
|
|
|
|
|
|
await driver.wait(until.stalenessOf(confirmDeleteNetworkModal))
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const newNetworkListItems = await driver.findElements(By.css('.networks-tab__networks-list-name'))
|
2019-06-17 16:05:47 +02:00
|
|
|
|
|
|
|
assert.equal(networkListItems.length - 1, newNetworkListItems.length)
|
|
|
|
})
|
2018-08-19 19:25:33 +02:00
|
|
|
})
|
2018-08-03 22:11:31 +02:00
|
|
|
})
|