diff --git a/src/pages/position/overview.ts b/src/pages/position/overview.ts index a5be59d..eaff3e6 100644 --- a/src/pages/position/overview.ts +++ b/src/pages/position/overview.ts @@ -284,12 +284,15 @@ export class Overview { protocol, }: { amount: string; - protocol?: 'Maker'; + protocol?: 'Maker' | 'Ajna'; }) { let regexObj = new RegExp(`${protocol ? '\\$' : ''}${amount}${protocol ? '' : ' USD'}`); - const locator = protocol - ? this.page.getByText('Buying Power').locator('..') - : this.page.locator('li:has-text("Buying Power")'); + const locator = + protocol === 'Maker' + ? this.page.getByText('Buying Power').locator('..') + : protocol === 'Ajna' + ? this.page.locator('li:has-text("Buying Power")').locator('div') + : this.page.locator('li:has-text("Buying Power")'); await expect(locator.getByText('After')).toContainText(regexObj); } diff --git a/tests/noWallet/ajna/poolFinder/earnPoolFinder.spec.ts b/tests/noWallet/ajna/poolFinder/earnPoolFinder.spec.ts index 82a46d7..db5ac1c 100644 --- a/tests/noWallet/ajna/poolFinder/earnPoolFinder.spec.ts +++ b/tests/noWallet/ajna/poolFinder/earnPoolFinder.spec.ts @@ -37,7 +37,7 @@ test.describe('Pool finder - Earn', async () => { await app.poolFinder.filterBy({ filter: 'Pool address', value: ajnaPoolAddress }); await app.poolFinder.list.shouldHavePoolsCount(1); - await app.poolFinder.list.shouldHaveTokensPair('ETH/USDC'); + await app.poolFinder.list.shouldHaveTokensPair('WSTETH/ETH'); await app.poolFinder.list.allPoolsShouldBe('Earn'); }); diff --git a/tests/withWallet/ajna/ethereum/ajnaMultiplyEthereum.spec.ts b/tests/withWallet/ajna/ethereum/ajnaMultiplyEthereum.spec.ts index 20d5125..ca9cde9 100644 --- a/tests/withWallet/ajna/ethereum/ajnaMultiplyEthereum.spec.ts +++ b/tests/withWallet/ajna/ethereum/ajnaMultiplyEthereum.spec.ts @@ -4,13 +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 { - hooksTimeout, - extremelyLongTestTimeout, - veryLongTestTimeout, - baseUrl, - longTestTimeout, -} from 'utils/config'; +import { extremelyLongTestTimeout, veryLongTestTimeout, longTestTimeout } from 'utils/config'; import { App } from 'src/app'; let context: BrowserContext; @@ -21,17 +15,6 @@ let walletAddress: string; test.describe.configure({ mode: 'serial' }); test.describe('Ajna Ethereum Multiply - Wallet connected', async () => { - test.beforeAll(async () => { - test.setTimeout(hooksTimeout); - - ({ context } = await metamaskSetUp({ network: 'mainnet' })); - let page = await context.newPage(); - app = new App(page); - - ({ forkId, walletAddress } = await setup({ app, network: 'mainnet' })); - await tenderly.setRethBalance({ forkId, walletAddress, rEthBalance: '100' }); - }); - test.afterAll(async () => { await tenderly.deleteFork(forkId); @@ -48,60 +31,79 @@ test.describe('Ajna Ethereum Multiply - Wallet connected', async () => { description: '12729', }); - test.setTimeout(veryLongTestTimeout); + test.setTimeout(extremelyLongTestTimeout); + + await test.step('Test setup', async () => { + ({ context } = await metamaskSetUp({ network: 'mainnet' })); + let page = await context.newPage(); + app = new App(page); + + ({ forkId, walletAddress } = await setup({ app, network: 'mainnet' })); - await app.page.goto('/ethereum/ajna/multiply/WBTC-USDC#setup'); + await tenderly.setTokenBalance({ + forkId, + network: 'mainnet', + walletAddress, + token: 'WBTC', + balance: '2', + }); + }); + + await app.page.goto('/ethereum/ajna/multiply/WBTC-DAI#setup'); await app.position.setup.acknowlegeAjnaInfo(); - await app.position.setup.deposit({ token: 'WBTC', amount: '3.123456' }); + await app.position.setup.deposit({ token: 'WBTC', amount: '0.654321' }); - // !!!!! BUG - 'Liquidation Price' returning 0.00 at the moment !!!!!! - await app.position.overview.shouldHaveLiquidationPriceAfterPill('[1-9],[0-9]{3}.[0-9]{2}'); - await app.position.overview.shouldHaveLoanToValueAfterPill('[1-4][0-9].[0-9]{2}%'); - await app.position.overview.shouldHaveNetValueAfterPill('[0-9]{2,3},[0-9]{3}.[0-9]{2}'); + await app.position.overview.shouldHaveLiquidationPriceAfterPill( + '[0-9]{1,2},[0-9]{3}.[0-9]{2} WBTC/DAI' + ); + await app.position.overview.shouldHaveLoanToValueAfterPill('[0-9]{1,2}.[0-9]{2}%'); + await app.position.overview.shouldHaveNetValueAfterPill('\\$[0-9]{1,2},[0-9]{3}.[0-9]{2}'); + await app.position.overview.shouldHaveBuyingPowerAfterPill({ + amount: '[0-9]{1,2},[0-9]{3}(.[0-9]{1,2})?', + protocol: 'Ajna', + }); await app.position.overview.shouldHaveExposureAfterPill({ - amount: '[3-5].[0-9]{4}', + amount: '[0-1].[0-9]{3,4}', token: 'WBTC', }); await app.position.overview.shouldHaveDebtAfterPill({ - amount: '[1-3][0-9],[0-9]{3}.[0-9]{2}', - token: 'USDC', + amount: '[1-9],[0-9]{3}.[0-9]{2}', + token: 'DAI', + protocol: 'Ajna', }); await app.position.overview.shouldHaveMultipleAfterPill('1(.[0-9]{1,2})?'); - await app.position.overview.shouldHaveBuyingPowerAfterPill({ - amount: '[1-9][0-9],[0-9]{3}(.[0-9]{1,2})?', - }); - // !!!!! BUG - 'Liquidation Price' returning 0.00 at the moment !!!!!! + await app.position.setup.shouldHaveLiquidationPrice({ - amount: '[0-9]{1,2},[0-9]{3}(.[0-9]{1,2})? USDC', + amount: '[0-9]{1,2},[0-9]{3}(.[0-9]{1,2})? WBTC/DAI', }); // Ajna LTV displays both current and future values: 0.00% -> 10.00% await app.position.setup.shouldHaveLoanToValue('0.00%10.00'); await app.position.setup.orderInformation.shouldHaveBuyingAmount({ - tokenAmount: '[0-1].[0-9]{4}', + tokenAmount: '0.[0-9]{4}', token: 'WBTC', - dollarsAmount: '[1-3][0-9],[0-9]{3}.[0-9]{2}', + dollarsAmount: '[1-9],[0-9]{3}.[0-9]{2}', protocol: 'Ajna', }); await app.position.setup.orderInformation.shouldHaveTotalExposure({ token: 'WBTC', current: '0.00', - future: '3.[0-9]{3,4}', + future: '[0-1].[0-9]{3,4}', }); await app.position.setup.orderInformation.shouldHavePriceImpact({ - amount: '[2-6][0-9],[0-9]{3}.[0-9]{2}', + amount: '[2-9][0-9],[0-9]{3}.[0-9]{2}', percentage: '[0-9].[0-9]{2}', protocol: 'Ajna', - pair: 'WBTC\\/USDC', + pair: 'WBTC/DAI', }); await app.position.setup.orderInformation.shouldHaveMultiple({ current: '1.00', future: '1(.[0-9]{1,2})?', }); - await app.position.setup.orderInformation.shouldHaveSlippageLimit('0.[0-9]{2}'); + await app.position.setup.orderInformation.shouldHaveSlippageLimit('0.50'); await app.position.setup.orderInformation.shouldHaveDebt({ - token: 'USDC', + token: 'DAI', current: '0.00', - future: '[0-9]{1,2},[0-9]{3}.[0-9]{2}', + future: '[1-9],[0-9]{3}.[0-9]{2}', }); await app.position.setup.orderInformation.shouldHaveLTV({ current: '0.00', @@ -120,14 +122,6 @@ test.describe('Ajna Ethereum Multiply - Wallet connected', async () => { description: '12730', }); - await app.page.goto('/ethereum/ajna/multiply/WBTC-DAI#setup'); - - await app.position.setup.acknowlegeAjnaInfo(); - await app.position.setup.deposit({ token: 'WBTC', amount: '5' }); - - // Wait for simulation values to be updated - await app.position.overview.shouldHaveLoanToValueAfterPill('[1-3][0-9].[0-9]{2}%'); - const initialLiqPrice = await app.position.manage.getLiquidationPrice(); const initialLoanToValue = await app.position.manage.getLoanToValue('Ajna'); @@ -140,11 +134,11 @@ test.describe('Ajna Ethereum Multiply - Wallet connected', async () => { const updatedLiqPrice = await app.position.manage.getLiquidationPrice(); const updatedLoanToValue = await app.position.manage.getLoanToValue('Ajna'); - expect(updatedLiqPrice).toBeLessThan(initialLiqPrice); + expect(updatedLiqPrice).toBeGreaterThan(initialLiqPrice); expect(updatedLoanToValue).toBeGreaterThan(initialLoanToValue); // RISK DOWN - await app.position.setup.moveSlider({ value: 0.3 }); + await app.position.setup.moveSlider({ protocol: 'Ajna', value: 0.3 }); // Wait for simulation to update with new risk await app.position.setup.shouldHaveButtonDisabled('Create Smart DeFi account'); @@ -152,7 +146,7 @@ test.describe('Ajna Ethereum Multiply - Wallet connected', async () => { const updatedLiqPrice2 = await app.position.manage.getLiquidationPrice(); const updatedLoanToValue2 = await app.position.manage.getLoanToValue('Ajna'); - expect(updatedLiqPrice2).toBeGreaterThan(updatedLiqPrice); + expect(updatedLiqPrice2).toBeLessThan(updatedLiqPrice); expect(updatedLoanToValue2).toBeLessThan(updatedLoanToValue); }); @@ -162,13 +156,9 @@ test.describe('Ajna Ethereum Multiply - Wallet connected', async () => { description: '12104', }); - test.skip(baseUrl.includes('staging') || baseUrl.includes('//summer.fi')); - - test.setTimeout(extremelyLongTestTimeout); + test.setTimeout(veryLongTestTimeout); - await app.page.goto('/ethereum/ajna/multiply/RETH-ETH'); - await app.position.setup.acknowlegeAjnaInfo(); - await app.position.setup.deposit({ token: 'RETH', amount: '7.543' }); + await app.position.setup.deposit({ token: 'WBTC', amount: '0.8' }); await app.position.setup.createSmartDeFiAccount(); // Smart DeFi Acount creation randomly fails - Retry until it's created. @@ -182,11 +172,15 @@ test.describe('Ajna Ethereum Multiply - Wallet connected', async () => { await app.position.setup.continue(); - // await app.position.setup.setupAllowance(); - await app.position.setup.approveAllowance(); - await test.step('Metamask: ConfirmAddToken', async () => { - await metamask.confirmAddToken(); - }); + // Setting up allowance randomly fails - Retry until it's set. + await expect(async () => { + await app.position.setup.approveAllowance(); + await test.step('Metamask: ConfirmAddToken', async () => { + await metamask.confirmAddToken(); + }); + await app.position.setup.continueShouldBeVisible(); + }).toPass({ timeout: longTestTimeout }); + await app.position.setup.continue(); // Position creation randomly fails - Retry until it's created. @@ -199,6 +193,7 @@ test.describe('Ajna Ethereum Multiply - Wallet connected', async () => { }).toPass({ timeout: longTestTimeout }); await app.position.setup.goToPosition(); - await app.position.manage.shouldBeVisible('Manage '); + await app.position.setup.continue(); + await app.position.manage.shouldBeVisible('Manage your Ajna Multiply Position'); }); });