mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
03732af6f4
* Added test for submitting second swap without waiting for first one to finish * Added more test code * Removed look around Review Swap button * Added test verification for the transaction details * Changed mocked API for token import * Added assert error messages * Fixed lint errors * Removed empty lines and improved coding consistency * Removed empty lines
89 lines
2.4 KiB
JavaScript
89 lines
2.4 KiB
JavaScript
const { withFixtures } = require('../helpers');
|
|
const {
|
|
withFixturesOptions,
|
|
loadExtension,
|
|
buildQuote,
|
|
reviewQuote,
|
|
waitForTransactionToComplete,
|
|
checkActivityTransaction,
|
|
} = 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, {
|
|
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, {
|
|
amount: '0.003',
|
|
swapFrom: 'TESTETH',
|
|
swapTo: 'DAI',
|
|
});
|
|
await driver.clickElement({ text: 'Swap', tag: 'button' });
|
|
await waitForTransactionToComplete(driver, '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',
|
|
});
|
|
},
|
|
);
|
|
});
|
|
it('Completes a Swap between Eth and Dai', async function () {
|
|
await withFixtures(
|
|
{
|
|
...withFixturesOptions,
|
|
title: this.test.title,
|
|
},
|
|
async ({ driver }) => {
|
|
await loadExtension(driver);
|
|
await buildQuote(driver, {
|
|
amount: 2,
|
|
swapTo: 'DAI',
|
|
});
|
|
await reviewQuote(driver, {
|
|
amount: '2',
|
|
swapFrom: 'TESTETH',
|
|
swapTo: 'DAI',
|
|
});
|
|
await driver.clickElement({ text: 'Swap', tag: 'button' });
|
|
await waitForTransactionToComplete(driver, 'DAI');
|
|
await checkActivityTransaction(driver, {
|
|
index: 0,
|
|
amount: '2',
|
|
swapFrom: 'TESTETH',
|
|
swapTo: 'DAI',
|
|
});
|
|
},
|
|
);
|
|
});
|
|
});
|