|
|
@ -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() |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('initiates a send from the dapp', async () => { |
|
|
|
|
|
|
|
await driver.switchTo().window(dapp) |
|
|
|
await driver.switchTo().window(dapp) |
|
|
|
await delay(regularDelayMs) |
|
|
|
await delay(regularDelayMs) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('initiates a send from the dapp', async () => { |
|
|
|
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)) |
|
|
|
|
|
|
|
|
|
|
|