mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Update e2e tests for new gas customization modal.
This commit is contained in:
parent
79de7a45ae
commit
a8259f7f6a
4
test/e2e/beta/fetch-mocks.js
Normal file
4
test/e2e/beta/fetch-mocks.js
Normal file
File diff suppressed because one or more lines are too long
@ -17,6 +17,7 @@ const {
|
|||||||
findElement,
|
findElement,
|
||||||
findElements,
|
findElements,
|
||||||
} = require('./helpers')
|
} = require('./helpers')
|
||||||
|
const fetchMockResponses = require('./fetch-mocks.js')
|
||||||
|
|
||||||
|
|
||||||
describe('Using MetaMask with an existing account', function () {
|
describe('Using MetaMask with an existing account', function () {
|
||||||
@ -62,6 +63,18 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await driver.get(extensionUrl)
|
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 () {
|
afterEach(async function () {
|
||||||
if (process.env.SELENIUM_BROWSER === 'chrome') {
|
if (process.env.SELENIUM_BROWSER === 'chrome') {
|
||||||
const errors = await checkBrowserForConsoleErrors(driver)
|
const errors = await checkBrowserForConsoleErrors(driver)
|
||||||
@ -230,7 +243,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('Send ETH from inside MetaMask', () => {
|
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')]`))
|
const sendButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Send')]`))
|
||||||
await sendButton.click()
|
await sendButton.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
@ -241,7 +254,7 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
await inputAmount.sendKeys('1')
|
await inputAmount.sendKeys('1')
|
||||||
|
|
||||||
// Set the gas limit
|
// 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 configureGas.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
|
@ -276,9 +276,11 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
const inputValue = await inputAmount.getAttribute('value')
|
const inputValue = await inputAmount.getAttribute('value')
|
||||||
assert.equal(inputValue, '1')
|
assert.equal(inputValue, '1')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('opens and closes the gas modal', async function () {
|
||||||
// Set the gas limit
|
// 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 configureGas.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
@ -286,9 +288,11 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`))
|
const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`))
|
||||||
await save.click()
|
await save.click()
|
||||||
await driver.wait(until.stalenessOf(gasModal))
|
await driver.wait(until.stalenessOf(gasModal), 10000)
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('clicks through to the confirm screen', async function () {
|
||||||
// Continue to next screen
|
// Continue to next screen
|
||||||
const nextScreen = await findElement(driver, By.xpath(`//button[contains(text(), 'Next')]`))
|
const nextScreen = await findElement(driver, By.xpath(`//button[contains(text(), 'Next')]`))
|
||||||
await nextScreen.click()
|
await nextScreen.click()
|
||||||
|
@ -22,6 +22,7 @@ const {
|
|||||||
verboseReportOnFailure,
|
verboseReportOnFailure,
|
||||||
waitUntilXWindowHandles,
|
waitUntilXWindowHandles,
|
||||||
} = require('./helpers')
|
} = require('./helpers')
|
||||||
|
const fetchMockResponses = require('./fetch-mocks.js')
|
||||||
|
|
||||||
describe('MetaMask', function () {
|
describe('MetaMask', function () {
|
||||||
let extensionId
|
let extensionId
|
||||||
@ -66,6 +67,18 @@ describe('MetaMask', function () {
|
|||||||
await driver.get(extensionUrl)
|
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 () {
|
afterEach(async function () {
|
||||||
if (process.env.SELENIUM_BROWSER === 'chrome') {
|
if (process.env.SELENIUM_BROWSER === 'chrome') {
|
||||||
const errors = await checkBrowserForConsoleErrors(driver)
|
const errors = await checkBrowserForConsoleErrors(driver)
|
||||||
@ -336,7 +349,7 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('Send ETH from inside MetaMask', () => {
|
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')]`))
|
const sendButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Send')]`))
|
||||||
await sendButton.click()
|
await sendButton.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
@ -350,12 +363,11 @@ describe('MetaMask', function () {
|
|||||||
assert.equal(inputValue, '1')
|
assert.equal(inputValue, '1')
|
||||||
|
|
||||||
// Set the gas limit
|
// 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 configureGas.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const gasModal = await driver.findElement(By.css('span .modal'))
|
const gasModal = await driver.findElement(By.css('span .modal'))
|
||||||
|
|
||||||
const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`))
|
const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`))
|
||||||
await save.click()
|
await save.click()
|
||||||
await driver.wait(until.stalenessOf(gasModal))
|
await driver.wait(until.stalenessOf(gasModal))
|
||||||
@ -404,12 +416,12 @@ describe('MetaMask', function () {
|
|||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
const approveButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Connect')]`))
|
const approveButton = await findElement(driver, By.xpath(`//button[contains(text(), 'Connect')]`))
|
||||||
await approveButton.click()
|
await approveButton.click()
|
||||||
|
|
||||||
|
await driver.switchTo().window(dapp)
|
||||||
|
await delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('initiates a send from the dapp', async () => {
|
it('initiates a send from the dapp', async () => {
|
||||||
await driver.switchTo().window(dapp)
|
|
||||||
await delay(regularDelayMs)
|
|
||||||
|
|
||||||
const send3eth = await findElement(driver, By.xpath(`//button[contains(text(), 'Send')]`), 10000)
|
const send3eth = await findElement(driver, By.xpath(`//button[contains(text(), 'Send')]`), 10000)
|
||||||
await send3eth.click()
|
await send3eth.click()
|
||||||
await delay(5000)
|
await delay(5000)
|
||||||
@ -658,9 +670,12 @@ describe('MetaMask', function () {
|
|||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
const gasModal = await findElement(driver, By.css('span .modal'))
|
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.clear()
|
||||||
await gasPriceInput.sendKeys('10')
|
await gasPriceInput.sendKeys('10')
|
||||||
await gasLimitInput.clear()
|
await gasLimitInput.clear()
|
||||||
@ -815,15 +830,16 @@ describe('MetaMask', function () {
|
|||||||
await inputAmount.sendKeys('50')
|
await inputAmount.sendKeys('50')
|
||||||
|
|
||||||
// Set the gas limit
|
// 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 configureGas.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
|
|
||||||
gasModal = await driver.findElement(By.css('span .modal'))
|
gasModal = await driver.findElement(By.css('span .modal'))
|
||||||
|
await delay(regularDelayMs)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('opens customizes gas modal', async () => {
|
it('opens customize gas modal', async () => {
|
||||||
await driver.wait(until.elementLocated(By.css('.send-v2__customize-gas__title')))
|
await driver.wait(until.elementLocated(By.css('.page-container__title')))
|
||||||
const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`))
|
const save = await findElement(driver, By.xpath(`//button[contains(text(), 'Save')]`))
|
||||||
await save.click()
|
await save.click()
|
||||||
await delay(regularDelayMs)
|
await delay(regularDelayMs)
|
||||||
@ -919,9 +935,11 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('customizes gas', async () => {
|
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 gasPriceInput.clear()
|
||||||
await delay(tinyDelayMs)
|
await delay(tinyDelayMs)
|
||||||
await gasPriceInput.sendKeys('10')
|
await gasPriceInput.sendKeys('10')
|
||||||
@ -938,7 +956,7 @@ describe('MetaMask', function () {
|
|||||||
await gasLimitInput.sendKeys(Key.BACK_SPACE)
|
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 save.click()
|
||||||
await driver.wait(until.stalenessOf(gasModal))
|
await driver.wait(until.stalenessOf(gasModal))
|
||||||
|
|
||||||
@ -1042,9 +1060,11 @@ describe('MetaMask', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('customizes gas', async () => {
|
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 gasPriceInput.clear()
|
||||||
await delay(tinyDelayMs)
|
await delay(tinyDelayMs)
|
||||||
await gasPriceInput.sendKeys('10')
|
await gasPriceInput.sendKeys('10')
|
||||||
@ -1061,7 +1081,7 @@ describe('MetaMask', function () {
|
|||||||
await gasLimitInput.sendKeys(Key.BACK_SPACE)
|
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 save.click()
|
||||||
await driver.wait(until.stalenessOf(gasModal))
|
await driver.wait(until.stalenessOf(gasModal))
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ export function fetchGasEstimates (blockTime) {
|
|||||||
priceAndTimeEstimatesLastRetrieved,
|
priceAndTimeEstimatesLastRetrieved,
|
||||||
priceAndTimeEstimates,
|
priceAndTimeEstimates,
|
||||||
} = getState().gas
|
} = getState().gas
|
||||||
const timeLastRetrieved = priceAndTimeEstimatesLastRetrieved || loadLocalStorageData('GAS_API_ESTIMATES_LAST_RETRIEVED')
|
const timeLastRetrieved = priceAndTimeEstimatesLastRetrieved || loadLocalStorageData('GAS_API_ESTIMATES_LAST_RETRIEVED') || 0
|
||||||
|
|
||||||
dispatch(gasEstimatesLoadingStarted())
|
dispatch(gasEstimatesLoadingStarted())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user