2019-07-31 21:56:44 +02:00
|
|
|
const assert = require('assert')
|
|
|
|
const webdriver = require('selenium-webdriver')
|
2020-01-09 04:34:58 +01:00
|
|
|
|
2020-04-30 05:48:36 +02:00
|
|
|
const { By, until } = webdriver
|
2020-08-18 21:18:25 +02:00
|
|
|
const enLocaleMessages = require('../../app/_locales/en/messages.json')
|
2019-07-31 21:56:44 +02:00
|
|
|
const {
|
2020-01-13 16:07:32 +01:00
|
|
|
tinyDelayMs,
|
|
|
|
regularDelayMs,
|
|
|
|
largeDelayMs,
|
2019-07-31 21:56:44 +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')
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2019-12-09 15:40:43 +01:00
|
|
|
const ganacheServer = new Ganache()
|
|
|
|
|
2019-07-31 21:56:44 +02:00
|
|
|
describe('Using MetaMask with an existing account', function () {
|
|
|
|
let driver
|
|
|
|
|
|
|
|
const testSeedPhrase = 'forum vessel pink push lonely enact gentle tail admit parrot grunt dress'
|
|
|
|
|
|
|
|
this.timeout(0)
|
|
|
|
this.bail(true)
|
|
|
|
|
|
|
|
before(async function () {
|
2019-12-09 15:40:43 +01:00
|
|
|
await ganacheServer.start({
|
|
|
|
accounts: [
|
|
|
|
{
|
|
|
|
secretKey: '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9',
|
|
|
|
balance: 25000000000000000000,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
})
|
2020-01-14 18:34:38 +01:00
|
|
|
const result = await buildWebDriver()
|
2019-09-07 09:13:58 +02:00
|
|
|
driver = result.driver
|
2019-07-31 21:56:44 +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)
|
2019-07-31 21:56:44 +02:00
|
|
|
if (errors.length) {
|
2020-02-15 21:34:12 +01:00
|
|
|
const errorReports = errors.map((err) => err.message)
|
2019-07-31 21:56:44 +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)
|
2019-07-31 21:56:44 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
after(async function () {
|
2019-12-09 15:40:43 +01:00
|
|
|
await ganacheServer.quit()
|
2019-07-31 21:56:44 +02:00
|
|
|
await driver.quit()
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('First time flow starting from an existing seed phrase', 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)
|
2019-07-31 21:56:44 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('clicks the "Import Wallet" option', async function () {
|
2020-06-11 16:24:13 +02:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Import wallet')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(largeDelayMs)
|
2019-07-31 21:56:44 +02: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-07-31 21:56:44 +02:00
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
it('imports a seed phrase', async function () {
|
2020-06-11 16:24:13 +02:00
|
|
|
const [seedTextArea] = await driver.findElements(By.css('input[placeholder="Paste seed phrase from clipboard"]'))
|
2019-07-31 21:56:44 +02:00
|
|
|
await seedTextArea.sendKeys(testSeedPhrase)
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
const [password] = await driver.findElements(By.id('password'))
|
2019-07-31 21:56:44 +02:00
|
|
|
await password.sendKeys('correct horse battery staple')
|
2020-01-13 16:07:32 +01:00
|
|
|
const [confirmPassword] = await driver.findElements(By.id('confirm-password'))
|
2019-07-31 21:56:44 +02:00
|
|
|
confirmPassword.sendKeys('correct horse battery staple')
|
|
|
|
|
2020-06-11 16:24:13 +02:00
|
|
|
await driver.clickElement(By.css('.first-time-flow__terms'))
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Import')]`))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-07-31 21:56:44 +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)
|
2019-07-31 21:56:44 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-02-11 17:51:13 +01:00
|
|
|
describe('Send ETH from inside MetaMask', function () {
|
2019-07-31 21:56:44 +02:00
|
|
|
it('starts a send transaction', async function () {
|
2020-10-06 20:28:38 +02:00
|
|
|
await driver.clickElement(By.css('[data-testid="eth-overview-send"]'))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-07-31 21:56:44 +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"]'))
|
2019-07-31 21:56:44 +02:00
|
|
|
await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970')
|
|
|
|
|
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('1')
|
|
|
|
|
|
|
|
// 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)
|
2019-07-31 21:56:44 +02:00
|
|
|
|
|
|
|
const gasModal = await driver.findElement(By.css('span .modal'))
|
|
|
|
|
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-31 21:56:44 +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)
|
2019-07-31 21:56:44 +02: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)
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-04-30 05:48:36 +02:00
|
|
|
await gasLimitInput.clear()
|
|
|
|
await driver.delay(50)
|
2019-07-31 21:56:44 +02:00
|
|
|
await gasLimitInput.sendKeys('25000')
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(1000)
|
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-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Save')]`))
|
2019-07-31 21:56:44 +02:00
|
|
|
await driver.wait(until.stalenessOf(gasModal))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-07-31 21:56:44 +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)
|
2019-07-31 21:56:44 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('has correct value and fee on the confirm screen 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-31 21:56:44 +02:00
|
|
|
const transactionAmount = transactionAmounts[0]
|
|
|
|
assert.equal(await transactionAmount.getText(), '1')
|
|
|
|
|
|
|
|
const transactionFee = transactionAmounts[1]
|
|
|
|
assert.equal(await transactionFee.getText(), '0.00025')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('edits the transaction', async function () {
|
2020-01-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.css('.confirm-page-container-header__back-button'))
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
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'))
|
2020-04-30 05:48:36 +02:00
|
|
|
|
|
|
|
await inputAmount.clear()
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
2019-07-31 21:56:44 +02:00
|
|
|
await inputAmount.sendKeys('2.2')
|
|
|
|
|
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)
|
2019-07-31 21:56:44 +02:00
|
|
|
|
|
|
|
const gasModal = await driver.findElement(By.css('span .modal'))
|
|
|
|
|
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-31 21:56:44 +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)
|
2019-07-31 21:56:44 +02:00
|
|
|
await gasPriceInput.sendKeys('8')
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(50)
|
|
|
|
await driver.delay(tinyDelayMs)
|
|
|
|
await driver.delay(50)
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-04-30 05:48:36 +02:00
|
|
|
await gasLimitInput.clear()
|
|
|
|
await driver.delay(50)
|
2019-07-31 21:56:44 +02:00
|
|
|
await gasLimitInput.sendKeys('100000')
|
|
|
|
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(1000)
|
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-15 20:34:15 +01:00
|
|
|
await driver.clickElement(By.xpath(`//button[contains(text(), 'Save')]`))
|
2019-07-31 21:56:44 +02:00
|
|
|
await driver.wait(until.stalenessOf(gasModal))
|
2020-01-13 16:07:32 +01:00
|
|
|
await driver.delay(regularDelayMs)
|
2019-07-31 21:56:44 +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)
|
2019-07-31 21:56:44 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('has correct updated value on the confirm screen 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-31 21:56:44 +02:00
|
|
|
const transactionAmount = transactionAmounts[0]
|
|
|
|
assert.equal(await transactionAmount.getText(), '2.2')
|
|
|
|
|
|
|
|
const transactionFee = transactionAmounts[1]
|
|
|
|
assert.equal(await transactionFee.getText(), '0.0008')
|
|
|
|
})
|
|
|
|
|
|
|
|
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(regularDelayMs)
|
2019-07-31 21:56:44 +02: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-07-31 21:56:44 +02:00
|
|
|
|
2020-05-26 22:49:11 +02:00
|
|
|
const txValues = await driver.findElements(By.css('.transaction-list-item__primary-currency'))
|
2019-07-31 21:56:44 +02:00
|
|
|
assert.equal(txValues.length, 1)
|
2020-08-19 18:27:05 +02:00
|
|
|
assert.ok((/-2.2\s*ETH/u).test(await txValues[0].getText()))
|
2019-07-31 21:56:44 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|