Skip to content

Commit

Permalink
Maker Multiply - Switch to Borrow & back to Multiply
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-langa committed Apr 3, 2024
1 parent 7eaf6ed commit 4eabf10
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/pages/position/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
20 changes: 20 additions & 0 deletions src/pages/position/manage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
24 changes: 23 additions & 1 deletion src/pages/position/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion tests/withWallet/maker/makerBorrow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
Expand Down
42 changes: 40 additions & 2 deletions tests/withWallet/maker/makerMultiply.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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' });
Expand Down
2 changes: 1 addition & 1 deletion tests/withWallet/spark/earn/sparkEarn2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 4eabf10

Please sign in to comment.