From 9b4db0dde615bf3a6f5db4d104e613ac265fcdcc Mon Sep 17 00:00:00 2001 From: juan-langa Date: Fri, 19 Jan 2024 10:40:54 +0100 Subject: [PATCH] Improvements for Aave and Pool finder tests --- .../ajna/poolFinder/borrowPoolFinder.spec.ts | 9 +++ .../Multiply/aaveV3MultiplyEthereum1.spec.ts | 56 ------------------- .../Multiply/aaveV3MultiplyEthereum2.spec.ts | 43 ++++++++++++++ 3 files changed, 52 insertions(+), 56 deletions(-) diff --git a/tests/noWallet/ajna/poolFinder/borrowPoolFinder.spec.ts b/tests/noWallet/ajna/poolFinder/borrowPoolFinder.spec.ts index f98f6c2..f6d80e0 100644 --- a/tests/noWallet/ajna/poolFinder/borrowPoolFinder.spec.ts +++ b/tests/noWallet/ajna/poolFinder/borrowPoolFinder.spec.ts @@ -1,4 +1,5 @@ import { test } from '#noWalletFixtures'; +import { positionTimeout } from 'utils/config'; import { ajnaPoolAddress, usdcContractAddress, wEthContractAddress } from 'utils/testData'; test.describe('Pool finder - Borrow', async () => { @@ -33,6 +34,8 @@ test.describe('Pool finder - Borrow', async () => { description: '10913', }); + test.setTimeout(positionTimeout); + await app.poolFinder.filterBy({ filter: 'Pool address', value: ajnaPoolAddress }); await app.poolFinder.list.shouldHavePoolsCount(1); await app.poolFinder.list.shouldHaveTokensPair('WSTETH/ETH'); @@ -47,6 +50,8 @@ test.describe('Pool finder - Borrow', async () => { description: '10912', }); + test.setTimeout(positionTimeout); + await app.poolFinder.filterBy({ filter: 'Collateral token', value: wEthContractAddress }); await app.poolFinder.list.shouldHaveOneOrMorePools(); await app.poolFinder.list.allPoolsShouldBe('Borrow'); @@ -61,6 +66,8 @@ test.describe('Pool finder - Borrow', async () => { description: '10914', }); + test.setTimeout(positionTimeout); + await app.poolFinder.filterBy({ filter: 'Quote token', value: wEthContractAddress }); await app.poolFinder.list.shouldHaveOneOrMorePools(); await app.poolFinder.list.allPoolsShouldBe('Borrow'); @@ -75,6 +82,8 @@ test.describe('Pool finder - Borrow', async () => { description: '11553', }); + test.setTimeout(positionTimeout); + await app.poolFinder.filterBy({ filter: 'Collateral token', value: wEthContractAddress }); await app.poolFinder.filterBy({ filter: 'Quote token', value: usdcContractAddress }); await app.poolFinder.list.shouldHavePoolsCount(1); diff --git a/tests/withWallet/aaveV3/ethereum/Multiply/aaveV3MultiplyEthereum1.spec.ts b/tests/withWallet/aaveV3/ethereum/Multiply/aaveV3MultiplyEthereum1.spec.ts index 67d5f6f..9e550a1 100644 --- a/tests/withWallet/aaveV3/ethereum/Multiply/aaveV3MultiplyEthereum1.spec.ts +++ b/tests/withWallet/aaveV3/ethereum/Multiply/aaveV3MultiplyEthereum1.spec.ts @@ -231,62 +231,6 @@ test.describe('Aave v3 Multiply - Ethereum - Wallet connected', async () => { expect(updatedLoanToValue).toBeLessThan(initialLoanToValue); }); - test('It should close an existent Aave V3 Multiply Ethereum position - Close to collateral token (ETH) @regression', async () => { - test.info().annotations.push({ - type: 'Test case', - description: '12057', - }); - - test.setTimeout(veryLongTestTimeout); - // New fork needed to be able to close a Multiply position - await test.step('Test setup - New fork', async () => { - ({ forkId } = await setupNewFork({ app, network: 'mainnet' })); - await tenderly.setEthBalance({ forkId, walletAddress, ethBalance: '100' }); - }); - - await tenderly.changeAccountOwner({ - account: '0x16f2c35e062c14f57475de0a466f7e08b03a9c7d', - newOwner: walletAddress, - forkId, - }); - - await app.page.goto('/ethereum/aave/v3/1218#overview'); - - await app.position.manage.openManageOptions({ currentLabel: 'Adjust' }); - await app.position.manage.select('Close position'); - - await app.position.manage.closeTo('ETH'); - await app.position.manage.shouldHaveTokenAmountAfterClosing({ - token: 'ETH', - amount: '0.[0-9]{3,4}', - }); - - // Transaction randomly fails - Retry until it's completed. - await expect(async () => { - await app.position.setup.confirmOrRetry(); - await test.step('Metamask: ConfirmPermissionToSpend', async () => { - await metamask.confirmPermissionToSpend(); - }); - await app.position.manage.shouldShowSuccessScreen(); - }).toPass({ timeout: longTestTimeout }); - - await app.position.manage.ok(); - - await app.page.goto('/ethereum/aave/v3/1218'); - 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: 'ETH' }); - await app.position.overview.shouldHaveExposure({ amount: '0.00000', token: 'ETH' }); - await app.position.overview.shouldHaveDebt({ amount: '0.0000', token: 'USDC' }); - await app.position.overview.shouldHaveMultiple('1'); - await app.position.overview.shouldHaveBuyingPower('0.00'); - }); - test.skip('It should list an opened Aave v3 Multiply Ethereum position in portfolio', async () => { test.info().annotations.push( { diff --git a/tests/withWallet/aaveV3/ethereum/Multiply/aaveV3MultiplyEthereum2.spec.ts b/tests/withWallet/aaveV3/ethereum/Multiply/aaveV3MultiplyEthereum2.spec.ts index 1a96fed..25e8b0c 100644 --- a/tests/withWallet/aaveV3/ethereum/Multiply/aaveV3MultiplyEthereum2.spec.ts +++ b/tests/withWallet/aaveV3/ethereum/Multiply/aaveV3MultiplyEthereum2.spec.ts @@ -211,4 +211,47 @@ test.describe('Aave v3 Multiply - Ethereum - Wallet connected', async () => { }); await app.position.overview.shouldHaveDebt({ amount: '8,[0-9]{3}.[0-9]{4}', token: 'DAI' }); }); + + test('It should close an existent Aave V3 Multiply Ethereum position - Close to collateral token (RETH) @regression', async () => { + test.info().annotations.push({ + type: 'Test case', + description: '12057', + }); + + test.setTimeout(veryLongTestTimeout); + + await app.position.manage.openManageOptions({ currentLabel: 'Adjust' }); + await app.position.manage.select('Close position'); + + await app.position.manage.closeTo('RETH'); + await app.position.manage.shouldHaveTokenAmountAfterClosing({ + token: 'RETH', + amount: '[0-9]{2}.[0-9]{1,2}', + }); + + // Transaction randomly fails - Retry until it's completed. + await expect(async () => { + await app.position.setup.confirmOrRetry(); + await test.step('Metamask: ConfirmPermissionToSpend', async () => { + await metamask.confirmPermissionToSpend(); + }); + await app.position.manage.shouldShowSuccessScreen(); + }).toPass({ timeout: longTestTimeout }); + + await app.position.manage.ok(); + + await app.page.goto('/ethereum/aave/v3/1276#overview'); + 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: 'RETH' }); + await app.position.overview.shouldHaveExposure({ amount: '0.00000', token: 'RETH' }); + await app.position.overview.shouldHaveDebt({ amount: '0.0000', token: 'DAI' }); + await app.position.overview.shouldHaveMultiple('1'); + await app.position.overview.shouldHaveBuyingPower('0.00'); + }); });