Update e2e tests for new gas customization modal.

feature/default_network_editable
Dan Miller 6 years ago
parent 79de7a45ae
commit a8259f7f6a
  1. 4
      test/e2e/beta/fetch-mocks.js
  2. 17
      test/e2e/beta/from-import-beta-ui.spec.js
  3. 8
      test/e2e/beta/metamask-beta-responsive-ui.spec.js
  4. 52
      test/e2e/beta/metamask-beta-ui.spec.js
  5. 2
      ui/app/ducks/gas.duck.js

File diff suppressed because one or more lines are too long

@ -17,6 +17,7 @@ const {
findElement,
findElements,
} = require('./helpers')
const fetchMockResponses = require('./fetch-mocks.js')
describe('Using MetaMask with an existing account', function () {
@ -62,6 +63,18 @@ describe('Using MetaMask with an existing account', function () {
await driver.get(extensionUrl)
})
beforeEach(async function () {
await driver.executeScript(
'window.fetch = ' +
'(...args) => { ' +
'if (args[0] === "https://ethgasstation.info/json/ethgasAPI.json") { return ' +
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.ethGasBasic + '\')) }); } else if ' +
'(args[0] === "https://ethgasstation.info/json/predictTable.json") { return ' +
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.ethGasPredictTable + '\')) }); } ' +
'return window.fetch(...args); }'
)
})
afterEach(async function () {
if (process.env.SELENIUM_BROWSER === 'chrome') {
const errors = await checkBrowserForConsoleErrors(driver)
@ -230,7 +243,7 @@ describe('Using MetaMask with an existing account', function () {
})
describe('Send ETH from inside MetaMask', () => {
it('starts to send a transaction', async function () {
it('starts a send transaction', async function () {
const sendButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Send')]`))
await sendButton.click()
await delay(regularDelayMs)
@ -241,7 +254,7 @@ describe('Using MetaMask with an existing account', function () {
await inputAmount.sendKeys('1')
// Set the gas limit
const configureGas = await findElement(driver, By.css('.send-v2__gas-fee-display button'))
const configureGas = await findElement(driver, By.css('.advanced-gas-options-btn'))
await configureGas.click()
await delay(regularDelayMs)

@ -276,9 +276,11 @@ describe('MetaMask', function () {
const inputValue = await inputAmount.getAttribute('value')
assert.equal(inputValue, '1')
})
it('opens and closes the gas modal', async function () {
// Set the gas limit
const configureGas = await findElement(driver, By.css('.send-v2__gas-fee-display button'))
const configureGas = await findElement(driver, By.css('.advanced-gas-options-btn'))
await configureGas.click()
await delay(regularDelayMs)
@ -286,9 +288,11 @@ describe('MetaMask', function () {
const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`))
await save.click()
await driver.wait(until.stalenessOf(gasModal))
await driver.wait(until.stalenessOf(gasModal), 10000)
await delay(regularDelayMs)
})
it('clicks through to the confirm screen', async function () {
// Continue to next screen
const nextScreen = await findElement(driver, By.xpath(`//button[contains(text(), 'Next')]`))
await nextScreen.click()

@ -22,6 +22,7 @@ const {
verboseReportOnFailure,
waitUntilXWindowHandles,
} = require('./helpers')
const fetchMockResponses = require('./fetch-mocks.js')
describe('MetaMask', function () {
let extensionId
@ -66,6 +67,18 @@ describe('MetaMask', function () {
await driver.get(extensionUrl)
})
beforeEach(async function () {
await driver.executeScript(
'window.fetch = ' +
'(...args) => { ' +
'if (args[0] === "https://ethgasstation.info/json/ethgasAPI.json") { return ' +
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.ethGasBasic + '\')) }); } else if ' +
'(args[0] === "https://ethgasstation.info/json/predictTable.json") { return ' +
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.ethGasPredictTable + '\')) }); } ' +
'return window.fetch(...args); }'
)
})
afterEach(async function () {
if (process.env.SELENIUM_BROWSER === 'chrome') {
const errors = await checkBrowserForConsoleErrors(driver)
@ -336,7 +349,7 @@ describe('MetaMask', function () {
})
describe('Send ETH from inside MetaMask', () => {
it('starts to send a transaction', async function () {
it('starts a send transaction', async function () {
const sendButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Send')]`))
await sendButton.click()
await delay(regularDelayMs)
@ -350,12 +363,11 @@ describe('MetaMask', function () {
assert.equal(inputValue, '1')
// Set the gas limit
const configureGas = await findElement(driver, By.css('.send-v2__gas-fee-display button'))
const configureGas = await findElement(driver, By.css('.advanced-gas-options-btn'))
await configureGas.click()
await delay(regularDelayMs)
const gasModal = await driver.findElement(By.css('span .modal'))
const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`))
await save.click()
await driver.wait(until.stalenessOf(gasModal))
@ -404,12 +416,12 @@ describe('MetaMask', function () {
await delay(regularDelayMs)
const approveButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Connect')]`))
await approveButton.click()
})
it('initiates a send from the dapp', async () => {
await driver.switchTo().window(dapp)
await delay(regularDelayMs)
})
it('initiates a send from the dapp', async () => {
const send3eth = await findElement(driver, By.xpath(`//button[contains(text(), 'Send')]`), 10000)
await send3eth.click()
await delay(5000)
@ -658,9 +670,12 @@ describe('MetaMask', function () {
await delay(regularDelayMs)
const gasModal = await findElement(driver, By.css('span .modal'))
await driver.wait(until.elementLocated(By.css('.customize-gas__title')), 10000)
await delay(regularDelayMs)
const modalTabs = await findElements(driver, By.css('.page-container__tab'))
await modalTabs[1].click()
await delay(regularDelayMs)
const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.customize-gas-input'))
const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input'))
await gasPriceInput.clear()
await gasPriceInput.sendKeys('10')
await gasLimitInput.clear()
@ -815,15 +830,16 @@ describe('MetaMask', function () {
await inputAmount.sendKeys('50')
// Set the gas limit
const configureGas = await findElement(driver, By.css('.send-v2__gas-fee-display button'))
const configureGas = await findElement(driver, By.css('.advanced-gas-options-btn'))
await configureGas.click()
await delay(regularDelayMs)
gasModal = await driver.findElement(By.css('span .modal'))
await delay(regularDelayMs)
})
it('opens customizes gas modal', async () => {
await driver.wait(until.elementLocated(By.css('.send-v2__customize-gas__title')))
it('opens customize gas modal', async () => {
await driver.wait(until.elementLocated(By.css('.page-container__title')))
const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`))
await save.click()
await delay(regularDelayMs)
@ -919,9 +935,11 @@ describe('MetaMask', function () {
})
it('customizes gas', async () => {
await driver.wait(until.elementLocated(By.css('.customize-gas__title')))
const modalTabs = await findElements(driver, By.css('.page-container__tab'))
await modalTabs[1].click()
await delay(regularDelayMs)
const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.customize-gas-input'))
const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input'))
await gasPriceInput.clear()
await delay(tinyDelayMs)
await gasPriceInput.sendKeys('10')
@ -938,7 +956,7 @@ describe('MetaMask', function () {
await gasLimitInput.sendKeys(Key.BACK_SPACE)
}
const save = await findElement(driver, By.css('.customize-gas__save'))
const save = await findElement(driver, By.css('.page-container__footer-button'))
await save.click()
await driver.wait(until.stalenessOf(gasModal))
@ -1042,9 +1060,11 @@ describe('MetaMask', function () {
})
it('customizes gas', async () => {
await driver.wait(until.elementLocated(By.css('.customize-gas__title')))
const modalTabs = await findElements(driver, By.css('.page-container__tab'))
await modalTabs[1].click()
await delay(regularDelayMs)
const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.customize-gas-input'))
const [gasPriceInput, gasLimitInput] = await findElements(driver, By.css('.advanced-tab__gas-edit-row__input'))
await gasPriceInput.clear()
await delay(tinyDelayMs)
await gasPriceInput.sendKeys('10')
@ -1061,7 +1081,7 @@ describe('MetaMask', function () {
await gasLimitInput.sendKeys(Key.BACK_SPACE)
}
const save = await findElement(driver, By.css('.customize-gas__save'))
const save = await findElement(driver, By.css('.page-container__footer-button'))
await save.click()
await driver.wait(until.stalenessOf(gasModal))

@ -207,7 +207,7 @@ export function fetchGasEstimates (blockTime) {
priceAndTimeEstimatesLastRetrieved,
priceAndTimeEstimates,
} = getState().gas
const timeLastRetrieved = priceAndTimeEstimatesLastRetrieved || loadLocalStorageData('GAS_API_ESTIMATES_LAST_RETRIEVED')
const timeLastRetrieved = priceAndTimeEstimatesLastRetrieved || loadLocalStorageData('GAS_API_ESTIMATES_LAST_RETRIEVED') || 0
dispatch(gasEstimatesLoadingStarted())

Loading…
Cancel
Save