mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Add e2e tests for queuing multiple transactions (#19411)
This commit is contained in:
parent
7949ec9cd4
commit
ed702af8ce
@ -1,7 +1,13 @@
|
|||||||
const { convertToHexValue, withFixtures } = require('../helpers');
|
const assert = require('assert');
|
||||||
|
const {
|
||||||
|
convertToHexValue,
|
||||||
|
withFixtures,
|
||||||
|
openDapp,
|
||||||
|
regularDelayMs,
|
||||||
|
} = require('../helpers');
|
||||||
const FixtureBuilder = require('../fixture-builder');
|
const FixtureBuilder = require('../fixture-builder');
|
||||||
|
|
||||||
describe('Confirm transactions', function () {
|
describe('Multiple transactions', function () {
|
||||||
const ganacheOptions = {
|
const ganacheOptions = {
|
||||||
hardfork: 'london',
|
hardfork: 'london',
|
||||||
accounts: [
|
accounts: [
|
||||||
@ -12,11 +18,13 @@ describe('Confirm transactions', function () {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
it('should be able to confirm multiple transactions', async function () {
|
|
||||||
|
it('creates multiple queued transactions, then confirms', async function () {
|
||||||
await withFixtures(
|
await withFixtures(
|
||||||
{
|
{
|
||||||
|
dapp: true,
|
||||||
fixtures: new FixtureBuilder()
|
fixtures: new FixtureBuilder()
|
||||||
.withTransactionControllerMultipleTransactions()
|
.withPermissionControllerConnectedToTestDapp()
|
||||||
.build(),
|
.build(),
|
||||||
ganacheOptions,
|
ganacheOptions,
|
||||||
title: this.test.title,
|
title: this.test.title,
|
||||||
@ -26,42 +34,58 @@ describe('Confirm transactions', function () {
|
|||||||
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);
|
||||||
|
|
||||||
// confirm multiple transactions
|
// initiates a transaction from the dapp
|
||||||
await driver.waitForSelector({
|
await openDapp(driver);
|
||||||
text: 'Reject 4 transactions',
|
// creates first transaction
|
||||||
tag: 'a',
|
await driver.clickElement({
|
||||||
|
text: 'Send EIP 1559 Transaction',
|
||||||
|
tag: 'button',
|
||||||
});
|
});
|
||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
await driver.waitUntilXWindowHandles(3);
|
||||||
await driver.waitForSelector({
|
const windowHandles = await driver.getAllWindowHandles();
|
||||||
text: 'Reject 3 transactions',
|
const extensionTab = windowHandles[0];
|
||||||
tag: 'a',
|
const dApp = windowHandles[1];
|
||||||
|
const confirmation = windowHandles[2];
|
||||||
|
|
||||||
|
await driver.switchToWindow(dApp);
|
||||||
|
|
||||||
|
// creates second transaction
|
||||||
|
await driver.clickElement({
|
||||||
|
text: 'Send EIP 1559 Transaction',
|
||||||
|
tag: 'button',
|
||||||
});
|
});
|
||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
await driver.switchToWindow(confirmation);
|
||||||
|
|
||||||
|
// confirms second transaction
|
||||||
await driver.waitForSelector({
|
await driver.waitForSelector({
|
||||||
text: 'Reject 2 transactions',
|
text: 'Reject 2 transactions',
|
||||||
tag: 'a',
|
tag: 'a',
|
||||||
});
|
});
|
||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
||||||
|
|
||||||
await driver.waitForElementNotPresent('.loading-overlay__spinner');
|
await driver.waitForElementNotPresent('.loading-overlay__spinner');
|
||||||
|
// confirms first transaction
|
||||||
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
||||||
|
|
||||||
|
await driver.waitUntilXWindowHandles(2);
|
||||||
|
await driver.switchToWindow(extensionTab);
|
||||||
|
await driver.delay(regularDelayMs);
|
||||||
await driver.clickElement('[data-testid="home__activity-tab"]');
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
||||||
await driver.wait(async () => {
|
|
||||||
const confirmedTxes = await driver.findElements(
|
const confirmedTxes = await driver.findElements(
|
||||||
'.transaction-list__completed-transactions .transaction-list-item',
|
'.transaction-list__completed-transactions .transaction-list-item',
|
||||||
);
|
);
|
||||||
return confirmedTxes.length === 4;
|
|
||||||
}, 10000);
|
assert.equal(confirmedTxes.length, 2);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to reject multiple transactions', async function () {
|
it('creates multiple queued transactions, then rejects', async function () {
|
||||||
await withFixtures(
|
await withFixtures(
|
||||||
{
|
{
|
||||||
|
dapp: true,
|
||||||
fixtures: new FixtureBuilder()
|
fixtures: new FixtureBuilder()
|
||||||
.withTransactionControllerMultipleTransactions()
|
.withPermissionControllerConnectedToTestDapp()
|
||||||
.build(),
|
.build(),
|
||||||
ganacheOptions,
|
ganacheOptions,
|
||||||
title: this.test.title,
|
title: this.test.title,
|
||||||
@ -71,27 +95,50 @@ describe('Confirm transactions', function () {
|
|||||||
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);
|
||||||
|
|
||||||
// confirm multiple transactions
|
// initiates a transaction from the dapp
|
||||||
await driver.waitForSelector({
|
await openDapp(driver);
|
||||||
text: 'Reject 4 transactions',
|
// creates first transaction
|
||||||
tag: 'a',
|
await driver.clickElement({
|
||||||
|
text: 'Send EIP 1559 Transaction',
|
||||||
|
tag: 'button',
|
||||||
});
|
});
|
||||||
await driver.clickElement({ text: 'Reject', tag: 'button' });
|
await driver.waitUntilXWindowHandles(3);
|
||||||
await driver.waitForSelector({
|
const windowHandles = await driver.getAllWindowHandles();
|
||||||
text: 'Reject 3 transactions',
|
const extension = windowHandles[0];
|
||||||
tag: 'a',
|
const confirmation = windowHandles[2];
|
||||||
|
await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles);
|
||||||
|
|
||||||
|
// creates second transaction
|
||||||
|
await driver.clickElement({
|
||||||
|
text: 'Send EIP 1559 Transaction',
|
||||||
|
tag: 'button',
|
||||||
});
|
});
|
||||||
await driver.clickElement({ text: 'Reject', tag: 'button' });
|
await driver.switchToWindow(confirmation);
|
||||||
|
|
||||||
|
// rejects second transaction
|
||||||
await driver.waitForSelector({
|
await driver.waitForSelector({
|
||||||
text: 'Reject 2 transactions',
|
text: 'Reject 2 transactions',
|
||||||
tag: 'a',
|
tag: 'a',
|
||||||
});
|
});
|
||||||
await driver.clickElement({ text: 'Reject', tag: 'button' });
|
await driver.clickElement({ text: 'Reject', tag: 'button' });
|
||||||
|
|
||||||
await driver.waitForElementNotPresent('.loading-overlay__spinner');
|
await driver.waitForElementNotPresent('.loading-overlay__spinner');
|
||||||
|
// rejects first transaction
|
||||||
await driver.clickElement({ text: 'Reject', tag: 'button' });
|
await driver.clickElement({ text: 'Reject', tag: 'button' });
|
||||||
|
|
||||||
await driver.waitForSelector('[data-testid="home__activity-tab"]');
|
await driver.waitUntilXWindowHandles(2);
|
||||||
|
await driver.switchToWindow(extension);
|
||||||
|
await driver.delay(regularDelayMs);
|
||||||
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
||||||
|
|
||||||
|
const isTransactionListEmpty = await driver.isElementPresentAndVisible(
|
||||||
|
'.transaction-list__empty-text',
|
||||||
|
);
|
||||||
|
assert.equal(isTransactionListEmpty, true);
|
||||||
|
|
||||||
|
// should not be present
|
||||||
|
await driver.assertElementNotPresent(
|
||||||
|
'.transaction-list__completed-transactions .transaction-list-item',
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user