mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Refactor failing contract with ganache seeder (#15601)
This commit is contained in:
parent
0cb6fd1202
commit
71b3f01db5
@ -1,7 +1,9 @@
|
|||||||
const { strict: assert } = require('assert');
|
const { strict: assert } = require('assert');
|
||||||
const { convertToHexValue, withFixtures } = require('../helpers');
|
const { convertToHexValue, withFixtures } = require('../helpers');
|
||||||
|
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
|
||||||
|
|
||||||
describe('Failing contract interaction ', function () {
|
describe('Failing contract interaction ', function () {
|
||||||
|
const smartContract = SMART_CONTRACTS.FAILING;
|
||||||
const ganacheOptions = {
|
const ganacheOptions = {
|
||||||
hardfork: 'london',
|
hardfork: 'london',
|
||||||
accounts: [
|
accounts: [
|
||||||
@ -18,41 +20,25 @@ describe('Failing contract interaction ', function () {
|
|||||||
dapp: true,
|
dapp: true,
|
||||||
fixtures: 'connected-state',
|
fixtures: 'connected-state',
|
||||||
ganacheOptions,
|
ganacheOptions,
|
||||||
|
smartContract,
|
||||||
title: this.test.title,
|
title: this.test.title,
|
||||||
},
|
},
|
||||||
async ({ driver }) => {
|
async ({ driver, contractRegistry }) => {
|
||||||
|
const contractAddress = await contractRegistry.getContractAddress(
|
||||||
|
smartContract,
|
||||||
|
);
|
||||||
await driver.navigate();
|
await driver.navigate();
|
||||||
await driver.fill('#password', 'correct horse battery staple');
|
await driver.fill('#password', 'correct horse battery staple');
|
||||||
await driver.press('#password', driver.Key.ENTER);
|
await driver.press('#password', driver.Key.ENTER);
|
||||||
|
|
||||||
// deploy contract
|
await driver.openNewPage(
|
||||||
await driver.openNewPage('http://127.0.0.1:8080/');
|
`http://127.0.0.1:8080/?contract=${contractAddress}`,
|
||||||
await driver.clickElement('#deployFailingButton');
|
);
|
||||||
await driver.waitUntilXWindowHandles(3);
|
|
||||||
let windowHandles = await driver.getAllWindowHandles();
|
let windowHandles = await driver.getAllWindowHandles();
|
||||||
const extension = windowHandles[0];
|
const extension = windowHandles[0];
|
||||||
const dapp = await driver.switchToWindowWithTitle(
|
|
||||||
'E2E Test Dapp',
|
|
||||||
windowHandles,
|
|
||||||
);
|
|
||||||
await driver.switchToWindowWithTitle(
|
|
||||||
'MetaMask Notification',
|
|
||||||
windowHandles,
|
|
||||||
);
|
|
||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
|
||||||
await driver.waitUntilXWindowHandles(2);
|
|
||||||
await driver.switchToWindow(extension);
|
|
||||||
await driver.clickElement('[data-testid="home__activity-tab"]');
|
|
||||||
await driver.waitForSelector(
|
|
||||||
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(1)',
|
|
||||||
{ timeout: 10000 },
|
|
||||||
);
|
|
||||||
const completedTx = await driver.findElement('.list-item__title');
|
|
||||||
const completedTxText = await completedTx.getText();
|
|
||||||
assert.equal(completedTxText, 'Contract deployment');
|
|
||||||
|
|
||||||
// calls failing contract method
|
// waits for deployed contract and calls failing contract method
|
||||||
await driver.switchToWindow(dapp);
|
await driver.findClickableElement('#deployButton');
|
||||||
await driver.clickElement('#sendFailingButton');
|
await driver.clickElement('#sendFailingButton');
|
||||||
await driver.waitUntilXWindowHandles(3);
|
await driver.waitUntilXWindowHandles(3);
|
||||||
windowHandles = await driver.getAllWindowHandles();
|
windowHandles = await driver.getAllWindowHandles();
|
||||||
@ -81,8 +67,9 @@ describe('Failing contract interaction ', function () {
|
|||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
||||||
await driver.waitUntilXWindowHandles(2);
|
await driver.waitUntilXWindowHandles(2);
|
||||||
await driver.switchToWindow(extension);
|
await driver.switchToWindow(extension);
|
||||||
|
await driver.clickElement({ text: 'Activity', tag: 'button' });
|
||||||
await driver.waitForSelector(
|
await driver.waitForSelector(
|
||||||
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(2)',
|
'.transaction-list__completed-transactions .transaction-list-item:nth-of-type(1)',
|
||||||
{ timeout: 10000 },
|
{ timeout: 10000 },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user