Skip to content

Commit

Permalink
Move E2E tests for Swaps into its own folder, move shared things into…
Browse files Browse the repository at this point in the history
… its own shared.js file
  • Loading branch information
dan437 committed Oct 25, 2022
1 parent 32692dc commit 5bf3d79
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 91 deletions.
52 changes: 52 additions & 0 deletions test/e2e/swaps/shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const ganacheOptions = {
accounts: [
{
secretKey:
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
balance: 25000000000000000000,
},
],
};

const defaultFixturesOptions = {
fixtures: 'special-settings',
failOnConsoleError: false,
ganacheOptions,
};

const loadSwaps = async (driver) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.clickElement(
'.wallet-overview__buttons .icon-button:nth-child(3)',
);
};

const buildQuote = async (driver, options) => {
await driver.clickElement(
'[class*="dropdown-search-list"] + div[class*="MuiFormControl-root MuiTextField-root"]',
);
await driver.fill('input[placeholder*="0"]', options.amount);
await driver.clickElement(
'[class="dropdown-search-list__closed-primary-label dropdown-search-list__select-default"]',
);
await driver.wait(async () => {
const tokens = await driver.findElements('.searchable-item-list__item');
return tokens.length > 1;
}, 10000);
await driver.clickElement('.searchable-item-list__labels');
await driver.clickElement('.dropdown-input-pair__to');
await driver.clickElement('[placeholder="Search name or paste address"]');
await driver.fill(
'[placeholder="Search name or paste address"]',
options.swapTo,
);
await driver.clickElement('.searchable-item-list__primary-label');
};

module.exports = {
defaultFixturesOptions,
loadSwaps,
buildQuote,
};
Original file line number Diff line number Diff line change
@@ -1,57 +1,21 @@
const { strict: assert } = require('assert');

const { withFixtures } = require('../helpers');
const { defaultFixturesOptions, loadSwaps, buildQuote } = require('./shared');

describe('Swap Eth for another Token', function () {
const ganacheOptions = {
accounts: [
{
secretKey:
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
balance: 25000000000000000000,
},
],
};
it('Completes a Swap between Eth and Matic', async function () {
await withFixtures(
{
fixtures: 'special-settings',
ganacheOptions,
...defaultFixturesOptions,
title: this.test.title,
failOnConsoleError: false,
driverOptions: {
timeOut: 20000,
},
},
async ({ driver }) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.clickElement(
'.wallet-overview__buttons .icon-button:nth-child(3)',
);
await driver.clickElement(
'[class*="dropdown-search-list"] + div[class*="MuiFormControl-root MuiTextField-root"]',
);
await driver.fill('input[placeholder*="0"]', '2');
await driver.clickElement(
'[class*="dropdown-search-list"] + div[class*="MuiFormControl-root MuiTextField-root"]',
);
await driver.clickElement(
'[class="dropdown-search-list__closed-primary-label dropdown-search-list__select-default"]',
);
await driver.clickElement(
'[placeholder="Search name or paste address"]',
);
await driver.fill(
'[placeholder="Search name or paste address"]',
'DAI',
);
await driver.waitForSelector(
'[class="searchable-item-list__primary-label"]',
);
await driver.clickElement(
'[class="searchable-item-list__primary-label"]',
);
await loadSwaps(driver);
await buildQuote(driver, {
amount: 2,
swapTo: 'DAI',
});
await driver.clickElement({ text: 'Review swap', tag: 'button' });
await driver.waitForSelector('[class*="box--align-items-center"]');
const estimatedEth = await driver.waitForSelector({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,9 @@
const { strict: assert } = require('assert');

const { withFixtures } = require('../helpers');
const { defaultFixturesOptions, loadSwaps, buildQuote } = require('./shared');

describe('Swaps - notifications', function () {
const ganacheOptions = {
accounts: [
{
secretKey:
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
balance: 25000000000000000000,
},
],
};

const defaultFixturesOptions = {
fixtures: 'special-settings',
failOnConsoleError: false,
ganacheOptions,
};

const loadSwaps = async (driver) => {
await driver.navigate();
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
await driver.clickElement(
'.wallet-overview__buttons .icon-button:nth-child(3)',
);
};

const buildQuote = async (driver, options) => {
await driver.clickElement(
'[class*="dropdown-search-list"] + div[class*="MuiFormControl-root MuiTextField-root"]',
);
await driver.fill('input[placeholder*="0"]', options.amount);
await driver.clickElement(
'[class="dropdown-search-list__closed-primary-label dropdown-search-list__select-default"]',
);
await driver.wait(async () => {
const tokens = await driver.findElements('.searchable-item-list__item');
return tokens.length > 1;
}, 10000);
await driver.clickElement('.searchable-item-list__labels');
await driver.clickElement('.dropdown-input-pair__to');
await driver.clickElement('[placeholder="Search name or paste address"]');
await driver.fill(
'[placeholder="Search name or paste address"]',
options.swapTo,
);
await driver.clickElement('.searchable-item-list__primary-label');
};

it('tests notifications for verified token on 1 source and price difference', async function () {
await withFixtures(
{
Expand Down

0 comments on commit 5bf3d79

Please sign in to comment.