Skip to content

Commit

Permalink
Merge pull request #112 from OasisDEX/test-improvements-open
Browse files Browse the repository at this point in the history
Test improvements and re-enabling a couple of 'Open position' tests
  • Loading branch information
juan-langa authored Dec 22, 2023
2 parents 9648617 + 26c01fc commit e5586c5
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ test.describe('Aave v3 Multiply Arbitrum', async () => {
expect(updatedLoanToValue2).toBeLessThan(updatedLoanToValue);
});

test('It should open existent Aave V3 Multiply Arbitrum vault page @regression', async ({
test('It should open an existing Aave V3 Multiply Arbitrum vault page @regression', async ({
app,
}) => {
test.setTimeout(longTestTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ test.describe('Aave v3 Multiply Ethereum', async () => {
);
});

test('It should open existent Aave V3 Multiply Ethereum vault page @regression', async ({
test('It should open an existing Aave V3 Multiply Ethereum vault page @regression', async ({
app,
}) => {
test.setTimeout(longTestTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test.describe('Aave v3 Borrow Optimism', async () => {
await app.position.setup.orderInformation.shouldHaveTransactionFee({ fee: '0' });
});

test('It should open existent Aave V3 Borrow Optimism vault page @regression', async ({
test('It should open an existing Aave V3 Borrow Optimism vault page @regression', async ({
app,
}) => {
test.setTimeout(longTestTimeout);
Expand Down
2 changes: 1 addition & 1 deletion tests/noWallet/maker/makerMultiply.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test } from '#noWalletFixtures';
import { longTestTimeout } from 'utils/config';

test.describe('Maker Multiply', async () => {
test('It should open existent Maker Multiply Ethereum vault page @regression', async ({
test.skip('It should open an existing Maker Multiply Ethereum vault page @regression', async ({
app,
}) => {
test.setTimeout(longTestTimeout);
Expand Down
2 changes: 1 addition & 1 deletion tests/noWallet/spark/sparkEarn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ test.describe('Spark Earn', async () => {
expect(updatedLoanToValue2).toBeLessThan(updatedLoanToValue);
});

test('It should open existent Spark Earn Ethereum vault page @regression', async ({ app }) => {
test('It should open an existing Spark Earn Ethereum vault page @regression', async ({ app }) => {
test.setTimeout(veryLongTestTimeout);

test.info().annotations.push({
Expand Down
97 changes: 43 additions & 54 deletions tests/withWallet/aaveV3/base/aaveV3BorrowBase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as tenderly from 'utils/tenderly';
import { setup } from 'utils/setup';
import {
extremelyLongTestTimeout,
baseUrl,
veryLongTestTimeout,
longTestTimeout,
positionTimeout,
Expand All @@ -31,10 +30,10 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
await resetState();
});

test('It should deposit extra collateral on an existent Aave V3 Borrow Base position @regression', async () => {
test('It should open an Aave V3 Borrow Base position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '13035',
description: '12473',
});

test.setTimeout(extremelyLongTestTimeout);
Expand All @@ -47,16 +46,48 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
({ forkId, walletAddress } = await setup({ app, network: 'base' }));
});

await tenderly.changeAccountOwner({
account: '0x94a7bf1ba459f3895e3936c4c6bc32eea266fc21',
newOwner: walletAddress,
forkId,
await app.page.goto('/base/aave/v3/borrow/ethusdbc#simulate');
// Depositing collateral too quickly after loading page returns wrong simulation results
await app.position.overview.waitForComponentToBeStable();
await app.position.setup.deposit({ token: 'ETH', amount: '9.12345' });
await app.position.setup.borrow({ token: 'USDBC', amount: '2000' });
await app.position.setup.createSmartDeFiAccount();

// Smart DeFi Acount creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.createSmartDeFiAccount();
await test.step('Metamask: ConfirmAddToken', async () => {
await metamask.confirmAddToken();
});
await app.position.setup.continueShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();
await app.position.setup.openBorrowPosition1Of2();

// Position creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.setup.goToPositionShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage collateral');
});

test('It should deposit extra collateral on an existent Aave V3 Borrow Base position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '13035',
});

await app.page.goto('/base/aave/v3/2#overview');
test.setTimeout(veryLongTestTimeout);

await app.position.manage.shouldBeVisible('Manage collateral');
await app.position.manage.deposit({ token: 'ETH', amount: '15' });
await app.position.manage.deposit({ token: 'ETH', amount: '1' });

// Confirm action randomly fails - Retry until it's applied.
await expect(async () => {
Expand All @@ -73,7 +104,7 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
value: '[0-9]{2},[0-9]{3}.[0-9]{2}',
token: 'USDBC',
});
await app.position.overview.shouldHaveExposure({ amount: '15.00000', token: 'ETH' });
await app.position.overview.shouldHaveExposure({ amount: '10.[0-9]{5}', token: 'ETH' });
});

test('It should adjust risk of an existent Aave V3 Borrow Base position - Up @regression', async () => {
Expand All @@ -91,7 +122,7 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
const initialLoanToValue = await app.position.manage.getLoanToValue();

await app.position.manage.waitForSliderToBeEditable();
await app.position.manage.moveSlider({ value: 0.7 });
await app.position.manage.moveSlider({ value: 0.4 });

await app.position.manage.adjustRisk();

Expand Down Expand Up @@ -128,7 +159,7 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
const initialLoanToValue = await app.position.manage.getLoanToValue();

await app.position.manage.waitForSliderToBeEditable();
await app.position.manage.moveSlider({ value: 0.3 });
await app.position.manage.moveSlider({ value: 0.2 });

await app.position.manage.adjustRisk();

Expand Down Expand Up @@ -193,46 +224,4 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
await app.position.overview.shouldHaveExposure({ amount: '0.00000', token: 'ETH' });
await app.position.overview.shouldHaveDebt({ amount: '0.0000', token: 'USDBC' });
});

test('It should open an Aave V3 Borrow Base position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '12473',
});

test.skip(baseUrl.includes('staging') || baseUrl.includes('//summer.fi'));

test.setTimeout(extremelyLongTestTimeout);

await app.page.goto('/base/aave/v3/borrow/ethusdbc#simulate');
// Depositing collateral too quickly after loading page returns wrong simulation results
await app.position.overview.waitForComponentToBeStable();
await app.position.setup.deposit({ token: 'ETH', amount: '9.12345' });
await app.position.setup.borrow({ token: 'USDBC', amount: '2000' });
await app.position.setup.createSmartDeFiAccount();

// Smart DeFi Acount creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.createSmartDeFiAccount();
await test.step('Metamask: ConfirmAddToken', async () => {
await metamask.confirmAddToken();
});
await app.position.setup.continueShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();
await app.position.setup.openBorrowPosition1Of2();

// Position creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.setup.goToPositionShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage ');
});
});
113 changes: 51 additions & 62 deletions tests/withWallet/aaveV3/base/aaveV3EarnBase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as tenderly from 'utils/tenderly';
import { setup } from 'utils/setup';
import {
extremelyLongTestTimeout,
baseUrl,
veryLongTestTimeout,
longTestTimeout,
positionTimeout,
Expand All @@ -31,10 +30,10 @@ test.describe('Aave V3 Earn - Base - Wallet connected', async () => {
await resetState();
});

test('It should adjust risk of an existent Aave V3 Earn Base position - Down @regression', async () => {
test('It should open an Aave V3 Earn Base position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '13069',
description: '12471',
});

test.setTimeout(extremelyLongTestTimeout);
Expand All @@ -49,21 +48,64 @@ test.describe('Aave V3 Earn - Base - Wallet connected', async () => {
await tenderly.setCbEthBalanceBase({ forkId, walletAddress, cbEthBalance: '20' });
});

await tenderly.changeAccountOwner({
account: '0x773aa707436b0ea8829f1aae6dcfbe3ba8508a3e',
newOwner: walletAddress,
forkId,
await app.page.goto('/base/aave/v3/earn/cbetheth#simulate');
// Depositing collateral too quickly after loading page returns wrong simulation results
await app.position.overview.waitForComponentToBeStable();
await app.position.setup.deposit({ token: 'CBETH', amount: '5' });
await app.position.setup.createSmartDeFiAccount();

// Smart DeFi Acount creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.createSmartDeFiAccount();
await test.step('Metamask: ConfirmAddToken', async () => {
await metamask.confirmAddToken();
});
await app.position.setup.continueShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();

// Setting up allowance randomly fails - Retry until it's set.
await expect(async () => {
await app.position.setup.setupAllowance();
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();
await app.position.setup.openMultiplyPosition1Of2();

// Position creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.setup.goToPositionShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage ');
});

test('It should adjust risk of an existent Aave V3 Earn Base position - Down @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '13069',
});

await app.page.goto('/base/aave/v3/18#overview');
test.setTimeout(extremelyLongTestTimeout);

await app.position.manage.shouldBeVisible('Manage Earn position');

const initialLiqPrice = await app.position.manage.getLiquidationPrice();
const initialLoanToValue = await app.position.manage.getLoanToValue();

await app.position.manage.waitForSliderToBeEditable();
await app.position.manage.moveSlider({ value: 0.3 });
await app.position.manage.moveSlider({ value: 0.1 });

await app.position.manage.adjustRisk();

Expand Down Expand Up @@ -162,57 +204,4 @@ test.describe('Aave V3 Earn - Base - Wallet connected', async () => {
await app.position.overview.shouldHaveMultiple('1');
await app.position.overview.shouldHaveBuyingPower('0.00');
});

test('It should open an Aave V3 Earn Base position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '12471',
});

test.skip(baseUrl.includes('staging') || baseUrl.includes('//summer.fi'));

test.setTimeout(extremelyLongTestTimeout);

await app.page.goto('/base/aave/v3/earn/cbetheth#simulate');
// Depositing collateral too quickly after loading page returns wrong simulation results
await app.position.overview.waitForComponentToBeStable();
await app.position.setup.deposit({ token: 'CBETH', amount: '20' });
await app.position.setup.createSmartDeFiAccount();

// Smart DeFi Acount creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.createSmartDeFiAccount();
await test.step('Metamask: ConfirmAddToken', async () => {
await metamask.confirmAddToken();
});
await app.position.setup.continueShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();

// Setting up allowance randomly fails - Retry until it's set.
await expect(async () => {
await app.position.setup.setupAllowance();
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();
await app.position.setup.openMultiplyPosition1Of2();

// Position creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.setup.goToPositionShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage ');
});
});

0 comments on commit e5586c5

Please sign in to comment.