From 4eabf10645980f77f667ddfedc37d3d3b14a3c99 Mon Sep 17 00:00:00 2001 From: juan-langa Date: Wed, 3 Apr 2024 16:25:29 +0200 Subject: [PATCH] Maker Multiply - Switch to Borrow & back to Multiply --- src/pages/position/index.ts | 7 +++- src/pages/position/manage.ts | 20 +++++++++ src/pages/position/overview.ts | 24 ++++++++++- .../ethereum/aaveV3EarnEthereum.spec.ts | 2 +- tests/withWallet/maker/makerBorrow.spec.ts | 2 +- tests/withWallet/maker/makerMultiply.spec.ts | 42 ++++++++++++++++++- .../withWallet/spark/earn/sparkEarn2.spec.ts | 2 +- 7 files changed, 91 insertions(+), 8 deletions(-) diff --git a/src/pages/position/index.ts b/src/pages/position/index.ts index 18972d6e..2142815d 100644 --- a/src/pages/position/index.ts +++ b/src/pages/position/index.ts @@ -34,10 +34,13 @@ export class Position { } @step - async openPage(url: string) { + async openPage(url: string, args?: { tab: 'Overview' }) { await expect(async () => { await this.page.goto(url); - await this.overview.waitForComponentToBeStable({ timeout: expectDefaultTimeout * 5 }); + await this.overview.waitForComponentToBeStable({ + tab: args?.tab ?? 'Position Info', + timeout: expectDefaultTimeout * 5, + }); }).toPass(); } diff --git a/src/pages/position/manage.ts b/src/pages/position/manage.ts index ce98c4bc..cd47ae58 100644 --- a/src/pages/position/manage.ts +++ b/src/pages/position/manage.ts @@ -200,4 +200,24 @@ export class Manage { async reduceDebt() { await this.page.getByRole('button', { name: 'Reduce Debt' }).click(); } + + @step + async goToBorrowInterface() { + await this.page.getByRole('button', { name: 'Go to Borrow interface' }).click(); + } + + @step + async takeMeToTheBorrowInterface() { + await this.page.getByRole('button', { name: 'Take me to the Borrow interface' }).click(); + } + + @step + async multiplyThisVault() { + await this.page.getByRole('button', { name: 'Multiply this vault' }).click(); + } + + @step + async takeMeToTheMultiplyInterface() { + await this.page.getByRole('button', { name: 'Take me to the Multiply interface' }).click(); + } } diff --git a/src/pages/position/overview.ts b/src/pages/position/overview.ts index 23e77a2d..b5353cce 100644 --- a/src/pages/position/overview.ts +++ b/src/pages/position/overview.ts @@ -369,13 +369,35 @@ export class Overview { } @step - async shouldHaveAvailableToGenerate({ amount, token }: { amount: string; token: string }) { + async shouldHaveAvailableToGenerateAfterPill({ + amount, + token, + }: { + amount: string; + token: string; + }) { const regExp = new RegExp(`${amount} ${token}`); await expect( this.page.locator('li:has-text("Available to Generate")').getByText('After') ).toContainText(regExp); } + @step + async shouldHaveAvailableToGenerate({ + amount, + token, + timeout, + }: { + amount: string; + token: string; + timeout?: number; + }) { + const regExp = new RegExp(`${amount} ${token}`); + await expect(this.page.locator('li:has-text("Available to Generate")')).toContainText(regExp, { + timeout: timeout ?? expectDefaultTimeout, + }); + } + @step async shouldHaveAvailableToBorrow({ amount, token }: { amount: string; token: string }) { const regExp = new RegExp(`${amount} ${token}`); diff --git a/tests/withWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts b/tests/withWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts index 207751f8..30727f87 100644 --- a/tests/withWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts +++ b/tests/withWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts @@ -64,7 +64,7 @@ test.describe('Aave V3 Earn - Ethereum - Wallet connected', async () => { }); }); - test('It should Deposit etxra collateral on an existing Aave V3 Ethereum Earn position @regression', async () => { + test('It should Deposit extra collateral on an existing Aave V3 Ethereum Earn position @regression', async () => { test.info().annotations.push({ type: 'Test case', description: 'xxxxx', diff --git a/tests/withWallet/maker/makerBorrow.spec.ts b/tests/withWallet/maker/makerBorrow.spec.ts index dd839a9b..87cbc17e 100644 --- a/tests/withWallet/maker/makerBorrow.spec.ts +++ b/tests/withWallet/maker/makerBorrow.spec.ts @@ -54,7 +54,7 @@ test.describe('Maker Borrow - Wallet connected', async () => { amount: '[0-9]{1,2}.[0-9]{5}', token: 'ETH', }); - await app.position.overview.shouldHaveAvailableToGenerate({ + await app.position.overview.shouldHaveAvailableToGenerateAfterPill({ amount: '[0-9]{1,2},[0-9]{3}.[0-9]{4}', token: 'DAI', }); diff --git a/tests/withWallet/maker/makerMultiply.spec.ts b/tests/withWallet/maker/makerMultiply.spec.ts index 0e7aa48a..777e4f06 100644 --- a/tests/withWallet/maker/makerMultiply.spec.ts +++ b/tests/withWallet/maker/makerMultiply.spec.ts @@ -4,7 +4,7 @@ import { resetState } from '@synthetixio/synpress/commands/synpress'; import * as tenderly from 'utils/tenderly'; import * as tx from 'utils/tx'; import { setup } from 'utils/setup'; -import { extremelyLongTestTimeout } from 'utils/config'; +import { expectDefaultTimeout, extremelyLongTestTimeout, longTestTimeout } from 'utils/config'; import { App } from 'src/app'; let context: BrowserContext; @@ -90,13 +90,51 @@ test.describe('Maker Multiply - Wallet connected', async () => { await app.position.manage.shouldHaveButton({ label: 'Adjust' }); }); + test('It should switch a Maker Multiply position to Borrow interface', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + test.setTimeout(longTestTimeout); + + await app.position.manage.openManageOptions({ currentLabel: 'Adjust' }); + await app.position.manage.select('Switch to Borrow'); + await app.position.manage.goToBorrowInterface(); + await app.position.manage.takeMeToTheBorrowInterface(); + + await app.position.overview.shouldHaveAvailableToGenerate({ + amount: '[0-9]{1,2},[0-9]{3}.[0-9]{3,4}', + token: 'DAI', + timeout: expectDefaultTimeout * 5, + }); + }); + + test('It should switch a Maker Multiply position (from Borrow) back to Multiply interface', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + test.setTimeout(longTestTimeout); + + await app.position.manage.openManageOptions({ currentLabel: 'ETH' }); + await app.position.manage.select('Switch to Multiply'); + await app.position.manage.multiplyThisVault(); + await app.position.manage.takeMeToTheMultiplyInterface(); + + await app.position.overview.shouldHaveMultiple('[0-9](.[0-9]{1,2})?'); + }); + test('It should allow to simulate a Maker Multiply position before opening it', async () => { test.info().annotations.push({ type: 'Test case', description: '12573', }); - await app.page.goto('/vaults/open-multiply/WSTETH-A'); + test.setTimeout(longTestTimeout); + + await app.position.openPage('/vaults/open-multiply/WSTETH-A', { tab: 'Overview' }); // Depositing collateral too quickly after loading page returns wrong simulation results await app.position.overview.waitForComponentToBeStable({ tab: 'Overview' }); diff --git a/tests/withWallet/spark/earn/sparkEarn2.spec.ts b/tests/withWallet/spark/earn/sparkEarn2.spec.ts index 3a847756..228e23a2 100644 --- a/tests/withWallet/spark/earn/sparkEarn2.spec.ts +++ b/tests/withWallet/spark/earn/sparkEarn2.spec.ts @@ -25,7 +25,7 @@ test.describe('Spark Earn - Wallet connected', async () => { await resetState(); }); - test('It should Deposit etxra collateral on an existing Spark Earn position', async () => { + test('It should Deposit extra collateral on an existing Spark Earn position', async () => { test.info().annotations.push({ type: 'Test case', description: 'xxxxx',