From eafcf75abc8c8e3280a053af3b7cfd2b16ae3f61 Mon Sep 17 00:00:00 2001 From: juan-langa Date: Wed, 20 Dec 2023 16:03:23 +0100 Subject: [PATCH] Improvements - Extending timeout for liq price only wheen needed --- src/pages/position/overview.ts | 11 ++++++++--- tests/withWallet/aaveV2/aaveV2Multiply.spec.ts | 7 ++++++- .../aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts | 7 ++++++- .../withWallet/aaveV3/base/aaveV3BorrowBase.spec.ts | 7 ++++++- tests/withWallet/aaveV3/base/aaveV3EarnBase.spec.ts | 7 ++++++- .../aaveV3/base/aaveV3MultiplyBase.spec.ts | 8 ++++++-- .../aaveV3/ethereum/aaveV3BorrowEthereum.spec.ts | 7 ++++++- .../aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts | 7 ++++++- .../aaveV3/optimism/aaveV3BorrowOptimism.spec.ts | 7 ++++++- .../aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts | 7 ++++++- tests/withWallet/spark/sparkBorrow.spec.ts | 13 +++++++++++-- tests/withWallet/spark/sparkEarn.spec.ts | 7 ++++++- tests/withWallet/spark/sparkMultiply.spec.ts | 7 ++++++- 13 files changed, 85 insertions(+), 17 deletions(-) diff --git a/src/pages/position/overview.ts b/src/pages/position/overview.ts index c8b5b326..b120ad17 100644 --- a/src/pages/position/overview.ts +++ b/src/pages/position/overview.ts @@ -1,6 +1,6 @@ import { step } from '#noWalletFixtures'; import { expect, Page } from '@playwright/test'; -import { positionTimeout } from 'utils/config'; +import { expectDefaultTimeout, positionTimeout } from 'utils/config'; export class Overview { readonly page: Page; @@ -72,11 +72,16 @@ export class Overview { @param price - It must be regExp string representing the the whole amount */ @step - async shouldHaveLiquidationPrice({ price, token }: { price: string; token?: string }) { + async shouldHaveLiquidationPrice( + { price, token, timeout }: { price: string; token?: string; timeout?: number } = { + price: '', + timeout: expectDefaultTimeout, + } + ) { const regExp = new RegExp(`${price}${token ? ` ${token}` : ''}`); await expect( this.page.getByText('Liquidation Price').locator('xpath=//following-sibling::p[1]') - ).toContainText(regExp, { timeout: positionTimeout }); + ).toContainText(regExp, { timeout }); } @step diff --git a/tests/withWallet/aaveV2/aaveV2Multiply.spec.ts b/tests/withWallet/aaveV2/aaveV2Multiply.spec.ts index 5f17eef7..f079677b 100644 --- a/tests/withWallet/aaveV2/aaveV2Multiply.spec.ts +++ b/tests/withWallet/aaveV2/aaveV2Multiply.spec.ts @@ -9,6 +9,7 @@ import { baseUrl, veryLongTestTimeout, longTestTimeout, + positionTimeout, } from 'utils/config'; import { App } from 'src/app'; @@ -178,7 +179,11 @@ test.describe('Aave v2 Multiply - Wallet connected', async () => { await app.position.manage.ok(); await app.page.goto('/ethereum/aave/v2/178#overview'); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'USDC' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'USDC', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'USDC' }); diff --git a/tests/withWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts b/tests/withWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts index 5843d8c0..2f390c53 100644 --- a/tests/withWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts +++ b/tests/withWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts @@ -8,6 +8,7 @@ import { baseUrl, extremelyLongTestTimeout, longTestTimeout, + positionTimeout, veryLongTestTimeout, } from 'utils/config'; import { App } from 'src/app'; @@ -228,7 +229,11 @@ test.describe('Aave v3 Multiply - Arbitrum - Wallet connected', async () => { await app.position.manage.ok(); await app.page.goto('/arbitrum/aave/v3/1#overview'); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'DAI' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'DAI', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'DAI' }); diff --git a/tests/withWallet/aaveV3/base/aaveV3BorrowBase.spec.ts b/tests/withWallet/aaveV3/base/aaveV3BorrowBase.spec.ts index 7caaa42f..27f21a0f 100644 --- a/tests/withWallet/aaveV3/base/aaveV3BorrowBase.spec.ts +++ b/tests/withWallet/aaveV3/base/aaveV3BorrowBase.spec.ts @@ -9,6 +9,7 @@ import { baseUrl, veryLongTestTimeout, longTestTimeout, + positionTimeout, } from 'utils/config'; import { App } from 'src/app'; @@ -181,7 +182,11 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => { await app.position.manage.ok(); await app.page.goto('/base/aave/v3/2#overview'); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'USDBC' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'USDBC', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'USDBC' }); diff --git a/tests/withWallet/aaveV3/base/aaveV3EarnBase.spec.ts b/tests/withWallet/aaveV3/base/aaveV3EarnBase.spec.ts index 63506cb2..dbe3a3c7 100644 --- a/tests/withWallet/aaveV3/base/aaveV3EarnBase.spec.ts +++ b/tests/withWallet/aaveV3/base/aaveV3EarnBase.spec.ts @@ -9,6 +9,7 @@ import { baseUrl, veryLongTestTimeout, longTestTimeout, + positionTimeout, } from 'utils/config'; import { App } from 'src/app'; @@ -148,7 +149,11 @@ test.describe('Aave V3 Earn - Base - Wallet connected', async () => { await app.position.manage.ok(); await app.page.goto('/base/aave/v3/18#overview'); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'CBETH' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'CBETH', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'CBETH' }); diff --git a/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts b/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts index 424670cd..6fe8a150 100644 --- a/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts +++ b/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts @@ -4,7 +4,7 @@ import { resetState } from '@synthetixio/synpress/commands/synpress'; import * as metamask from '@synthetixio/synpress/commands/metamask'; import * as tenderly from 'utils/tenderly'; import { setup } from 'utils/setup'; -import { baseUrl, extremelyLongTestTimeout, longTestTimeout } from 'utils/config'; +import { baseUrl, extremelyLongTestTimeout, longTestTimeout, positionTimeout } from 'utils/config'; import { App } from 'src/app'; let context: BrowserContext; @@ -139,7 +139,11 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => { await app.position.manage.ok(); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'USDBC' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'USDBC', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'USDBC' }); diff --git a/tests/withWallet/aaveV3/ethereum/aaveV3BorrowEthereum.spec.ts b/tests/withWallet/aaveV3/ethereum/aaveV3BorrowEthereum.spec.ts index bf63da2f..20b3ffc0 100644 --- a/tests/withWallet/aaveV3/ethereum/aaveV3BorrowEthereum.spec.ts +++ b/tests/withWallet/aaveV3/ethereum/aaveV3BorrowEthereum.spec.ts @@ -8,6 +8,7 @@ import { baseUrl, extremelyLongTestTimeout, longTestTimeout, + positionTimeout, veryLongTestTimeout, } from 'utils/config'; import { App } from 'src/app'; @@ -202,7 +203,11 @@ test.describe('Aave V3 Borrow - Ethereum - Wallet connected', async () => { await app.position.manage.ok(); await app.page.goto('/ethereum/aave/v3/1277#overview'); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'ETH' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'ETH', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'ETH' }); diff --git a/tests/withWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts b/tests/withWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts index 5c9f6b7c..ce37095e 100644 --- a/tests/withWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts +++ b/tests/withWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts @@ -8,6 +8,7 @@ import { baseUrl, extremelyLongTestTimeout, longTestTimeout, + positionTimeout, veryLongTestTimeout, } from 'utils/config'; import { App } from 'src/app'; @@ -240,7 +241,11 @@ test.describe('Aave v3 Multiply - Ethereum - Wallet connected', async () => { await app.position.manage.ok(); await app.page.goto('/ethereum/aave/v3/1218'); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'USDC' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'USDC', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'USDC' }); diff --git a/tests/withWallet/aaveV3/optimism/aaveV3BorrowOptimism.spec.ts b/tests/withWallet/aaveV3/optimism/aaveV3BorrowOptimism.spec.ts index 2211eb86..771c85d1 100644 --- a/tests/withWallet/aaveV3/optimism/aaveV3BorrowOptimism.spec.ts +++ b/tests/withWallet/aaveV3/optimism/aaveV3BorrowOptimism.spec.ts @@ -8,6 +8,7 @@ import { baseUrl, extremelyLongTestTimeout, longTestTimeout, + positionTimeout, veryLongTestTimeout, } from 'utils/config'; import { App } from 'src/app'; @@ -202,7 +203,11 @@ test.describe('Aave V3 Borrow - Optimism - Wallet connected', async () => { await app.position.manage.ok(); await app.page.goto('/optimism/aave/v3/4#overview'); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'DAI' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'DAI', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'DAI' }); diff --git a/tests/withWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts b/tests/withWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts index 8245ad57..b6169804 100644 --- a/tests/withWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts +++ b/tests/withWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts @@ -8,6 +8,7 @@ import { baseUrl, extremelyLongTestTimeout, longTestTimeout, + positionTimeout, veryLongTestTimeout, } from 'utils/config'; import { App } from 'src/app'; @@ -227,7 +228,11 @@ test.describe('Aave v3 Multiply - Optimism - Wallet connected', async () => { await app.position.manage.ok(); await app.page.goto('/optimism/aave/v3/2#overview'); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'USDC' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'USDC', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'USDC' }); diff --git a/tests/withWallet/spark/sparkBorrow.spec.ts b/tests/withWallet/spark/sparkBorrow.spec.ts index 331be6e9..def1884e 100644 --- a/tests/withWallet/spark/sparkBorrow.spec.ts +++ b/tests/withWallet/spark/sparkBorrow.spec.ts @@ -8,6 +8,7 @@ import { baseUrl, extremelyLongTestTimeout, longTestTimeout, + positionTimeout, veryLongTestTimeout, } from 'utils/config'; import { App } from 'src/app'; @@ -287,7 +288,11 @@ test.describe('Spark Borrow - Wallet connected', async () => { await app.position.manage.ok(); await app.page.goto('/ethereum/spark/v3/1474#overview'); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'DAI' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'DAI', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'DAI' }); @@ -337,7 +342,11 @@ test.describe('Spark Borrow - Wallet connected', async () => { await app.position.manage.ok(); await app.page.goto('/ethereum/spark/v3/1474#overview'); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'DAI' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'DAI', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'DAI' }); diff --git a/tests/withWallet/spark/sparkEarn.spec.ts b/tests/withWallet/spark/sparkEarn.spec.ts index 3e99a5db..956462c5 100644 --- a/tests/withWallet/spark/sparkEarn.spec.ts +++ b/tests/withWallet/spark/sparkEarn.spec.ts @@ -9,6 +9,7 @@ import { veryLongTestTimeout, baseUrl, longTestTimeout, + positionTimeout, } from 'utils/config'; import { App } from 'src/app'; @@ -152,7 +153,11 @@ test.describe('Spark Earn - Wallet connected', async () => { await app.position.manage.ok(); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'ETH' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'ETH', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'ETH' }); diff --git a/tests/withWallet/spark/sparkMultiply.spec.ts b/tests/withWallet/spark/sparkMultiply.spec.ts index 230bdc43..67faa1a0 100644 --- a/tests/withWallet/spark/sparkMultiply.spec.ts +++ b/tests/withWallet/spark/sparkMultiply.spec.ts @@ -8,6 +8,7 @@ import { baseUrl, extremelyLongTestTimeout, longTestTimeout, + positionTimeout, veryLongTestTimeout, } from 'utils/config'; import { App } from 'src/app'; @@ -158,7 +159,11 @@ test.describe('Spark Multiply - Wallet connected', async () => { await app.position.manage.ok(); - await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'DAI' }); + await app.position.overview.shouldHaveLiquidationPrice({ + price: '0.00', + token: 'DAI', + timeout: positionTimeout, + }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveBorrowCost('0.00'); await app.position.overview.shouldHaveNetValue({ value: '0.00', token: 'DAI' });