1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 10:30:04 +01:00
metamask-extension/test/e2e/swaps/swap-eth.spec.js

97 lines
2.7 KiB
JavaScript
Raw Normal View History

const { withFixtures } = require('../helpers');
const {
withFixturesOptions,
loadExtension,
buildQuote,
reviewQuote,
waitForTransactionToComplete,
checkActivityTransaction,
2023-06-15 20:17:21 +02:00
changeExchangeRate,
} = require('./shared');
describe('Swap Eth for another Token', function () {
it('Completes second Swaps while first swap is processing', async function () {
withFixturesOptions.ganacheOptions.blockTime = 10;
await withFixtures(
{
...withFixturesOptions,
failOnConsoleError: false,
title: this.test.title,
},
async ({ driver }) => {
await loadExtension(driver);
await buildQuote(driver, {
amount: 0.001,
swapTo: 'USDC',
});
await reviewQuote(driver, {
2023-06-15 20:17:21 +02:00
amount: 0.001,
swapFrom: 'TESTETH',
swapTo: 'USDC',
});
await driver.clickElement({ text: 'Swap', tag: 'button' });
await driver.clickElement({ text: 'View in activity', tag: 'button' });
await buildQuote(driver, {
amount: 0.003,
swapTo: 'DAI',
});
await reviewQuote(driver, {
2023-06-15 20:17:21 +02:00
amount: 0.003,
swapFrom: 'TESTETH',
swapTo: 'DAI',
});
await driver.clickElement({ text: 'Swap', tag: 'button' });
2023-06-15 20:17:21 +02:00
await waitForTransactionToComplete(driver, { tokenName: 'DAI' });
await checkActivityTransaction(driver, {
index: 0,
amount: '0.003',
swapFrom: 'TESTETH',
swapTo: 'DAI',
});
await checkActivityTransaction(driver, {
index: 1,
amount: '0.001',
swapFrom: 'TESTETH',
swapTo: 'USDC',
});
},
);
});
2023-06-15 20:17:21 +02:00
it('Completes a Swap between ETH and DAI after changing initial rate', async function () {
await withFixtures(
{
...withFixturesOptions,
title: this.test.title,
},
async ({ driver }) => {
await loadExtension(driver);
await buildQuote(driver, {
amount: 2,
swapTo: 'DAI',
});
await reviewQuote(driver, {
2023-06-15 20:17:21 +02:00
amount: 2,
swapFrom: 'TESTETH',
swapTo: 'DAI',
});
await changeExchangeRate(driver);
await reviewQuote(driver, {
amount: 2,
swapFrom: 'TESTETH',
swapTo: 'DAI',
2023-06-15 20:17:21 +02:00
skipCounter: true,
});
await driver.clickElement({ text: 'Swap', tag: 'button' });
2023-06-15 20:17:21 +02:00
await waitForTransactionToComplete(driver, { tokenName: 'DAI' });
await checkActivityTransaction(driver, {
index: 0,
amount: '2',
swapFrom: 'TESTETH',
swapTo: 'DAI',
});
},
);
});
});