1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-12 04:37:13 +01:00
metamask-extension/test/e2e/tests/dapp-tx-edit.spec.js
Mark Stacey 69ccb37cb9 Fix e2e test
The new e2e test added for the bug fix being released here has been
updated to use the old e2e test fixtures, rather than the fixture-
builder. The fixture builder is not available on this branch yet.
2022-11-15 13:05:25 -03:30

103 lines
3.5 KiB
JavaScript

const { strict: assert } = require('assert');
const { convertToHexValue, withFixtures } = require('../helpers');
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
describe('Editing confirmations of dapp initiated contract interactions', function () {
const ganacheOptions = {
accounts: [
{
secretKey:
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
balance: convertToHexValue(25000000000000000000),
},
],
};
const smartContract = SMART_CONTRACTS.PIGGYBANK;
it('should NOT show an edit button on a contract interaction confirmation iniated by a dapp', async function () {
await withFixtures(
{
dapp: true,
fixtures: 'connected-state',
ganacheOptions,
smartContract,
title: this.test.title,
},
async ({ driver, contractRegistry }) => {
const contractAddress = await contractRegistry.getContractAddress(
smartContract,
);
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
// deploy contract
await driver.openNewPage(
`http://127.0.0.1:8080/?contract=${contractAddress}`,
);
// wait for deployed contract, calls and confirms a contract method where ETH is sent
await driver.findClickableElement('#deployButton');
await driver.clickElement('#depositButton');
await driver.waitUntilXWindowHandles(3);
const windowHandles = await driver.getAllWindowHandles();
await driver.switchToWindowWithTitle(
'MetaMask Notification',
windowHandles,
);
await driver.waitForSelector({
css: '.confirm-page-container-summary__action__name',
text: 'Deposit',
});
const editTransactionButton = await driver.isElementPresentAndVisible(
'[data-testid="confirm-page-back-edit-button"]',
);
assert.equal(
editTransactionButton,
false,
`Edit transaction button should not be visible on a contract interaction created by a dapp`,
);
},
);
});
it('should show an edit button on a simple ETH send iniated by a dapp', async function () {
await withFixtures(
{
dapp: true,
fixtures: 'connected-state',
ganacheOptions,
smartContract,
title: this.test.title,
},
async ({ driver }) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.openNewPage(`http://127.0.0.1:8080/`);
await driver.clickElement('#sendButton');
await driver.waitUntilXWindowHandles(3);
const windowHandles = await driver.getAllWindowHandles();
await driver.switchToWindowWithTitle(
'MetaMask Notification',
windowHandles,
);
await driver.waitForSelector({
css: '.confirm-page-container-summary__action__name',
text: 'Sending ETH',
});
const editTransactionButton = await driver.isElementPresentAndVisible(
'[data-testid="confirm-page-back-edit-button"]',
);
assert.equal(
editTransactionButton,
true,
`Edit transaction button should be visible on a contract interaction created by a dapp`,
);
},
);
});
});