@ -1,16 +1,14 @@
const { strict : assert } = require ( 'assert' ) ;
const { withFixtures } = require ( '../helpers' ) ;
const FixtureBuilder = require ( '../fixture-builder' ) ;
const { ganache Options, loadSwaps , buildQuote } = require ( './shared' ) ;
const { withFixtures Options, loadSwaps , buildQuote } = require ( './shared' ) ;
describe ( 'Swaps - notifications' , function ( ) {
it ( 'tests notifications for verified token on 1 source and price difference' , async function ( ) {
await withFixtures (
{
fixtures : new FixtureBuilder ( ) . build ( ) ,
ganacheOptions ,
failOnConsoleError : false ,
... withFixturesOptions ,
title : this . test . title ,
} ,
async ( { driver } ) => {
@ -46,19 +44,52 @@ describe('Swaps - notifications', function () {
) ;
} ) ;
it ( 'tests a notification for not enough balance' , async function ( ) {
await withFixtures (
{
... withFixturesOptions ,
title : this . test . title ,
} ,
async ( { driver } ) => {
await loadSwaps ( driver ) ;
await buildQuote ( driver , {
amount : 50 ,
swapTo : 'USDC' ,
} ) ;
const reviewSwapButton = await driver . findElement (
'[data-testid="page-container-footer-next"]' ,
) ;
assert . equal ( await reviewSwapButton . getText ( ) , 'Review swap' ) ;
assert . equal ( await reviewSwapButton . isEnabled ( ) , true ) ;
await reviewSwapButton . click ( ) ;
await driver . waitForSelector ( {
css : '[class*="box--align-items-center"]' ,
text : 'Estimated gas fee' ,
} ) ;
await driver . waitForSelector ( {
css : '[class*="actionable-message__message"]' ,
text : 'You need 43.4467 more TESTETH to complete this swap' ,
} ) ;
const swapButton = await driver . findElement (
'[data-testid="page-container-footer-next"]' ,
) ;
assert . equal ( await swapButton . getText ( ) , 'Swap' ) ;
assert . equal ( await swapButton . isEnabled ( ) , false ) ;
} ,
) ;
} ) ;
it ( 'tests notifications for verified token on 0 sources and high slippage' , async function ( ) {
await withFixtures (
{
fixtures : new FixtureBuilder ( ) . build ( ) ,
ganacheOptions ,
failOnConsoleError : false ,
... withFixturesOptions ,
title : this . test . title ,
} ,
async ( { driver } ) => {
await loadSwaps ( driver ) ;
await buildQuote ( driver , {
amount : 2 ,
swapTo : '0x72c9Fb7ED19D3ce51cea5C56B3e023cd918baaDf' ,
swapToContractAddress : '0x72c9Fb7ED19D3ce51cea5C56B3e023cd918baaDf' ,
} ) ;
await driver . waitForSelector ( {
css : '.popover-header__title' ,
@ -96,41 +127,4 @@ describe('Swaps - notifications', function () {
} ,
) ;
} ) ;
it ( 'tests a notification for not enough balance' , async function ( ) {
await withFixtures (
{
fixtures : new FixtureBuilder ( ) . build ( ) ,
ganacheOptions ,
failOnConsoleError : false ,
title : this . test . title ,
} ,
async ( { driver } ) => {
await loadSwaps ( driver ) ;
await buildQuote ( driver , {
amount : 50 ,
swapTo : 'USDC' ,
} ) ;
const reviewSwapButton = await driver . findElement (
'[data-testid="page-container-footer-next"]' ,
) ;
assert . equal ( await reviewSwapButton . getText ( ) , 'Review swap' ) ;
assert . equal ( await reviewSwapButton . isEnabled ( ) , true ) ;
await reviewSwapButton . click ( ) ;
await driver . waitForSelector ( {
css : '[class*="box--align-items-center"]' ,
text : 'Estimated gas fee' ,
} ) ;
await driver . waitForSelector ( {
css : '[class*="actionable-message__message"]' ,
text : 'You need 43.4467 more TESTETH to complete this swap' ,
} ) ;
const swapButton = await driver . findElement (
'[data-testid="page-container-footer-next"]' ,
) ;
assert . equal ( await swapButton . getText ( ) , 'Swap' ) ;
assert . equal ( await swapButton . isEnabled ( ) , false ) ;
} ,
) ;
} ) ;
} ) ;