Skip to content

Commit

Permalink
Merge pull request #108 from OasisDEX/tests-improvements-custom-timeo…
Browse files Browse the repository at this point in the history
…ut-liq-price

Improvements - Extending timeout for liq price only wheen needed
  • Loading branch information
juan-langa authored Dec 20, 2023
2 parents e8bc053 + eafcf75 commit 69eb598
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 17 deletions.
11 changes: 8 additions & 3 deletions src/pages/position/overview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { step } from '#noWalletFixtures';
import { expect, Page } from '@playwright/test';
import { positionTimeout } from 'utils/config';
import { expectDefaultTimeout, positionTimeout } from 'utils/config';

export class Overview {
readonly page: Page;
Expand Down Expand Up @@ -72,11 +72,16 @@ export class Overview {
@param price - It must be regExp string representing the the whole amount
*/
@step
async shouldHaveLiquidationPrice({ price, token }: { price: string; token?: string }) {
async shouldHaveLiquidationPrice(
{ price, token, timeout }: { price: string; token?: string; timeout?: number } = {
price: '',
timeout: expectDefaultTimeout,
}
) {
const regExp = new RegExp(`${price}${token ? ` ${token}` : ''}`);
await expect(
this.page.getByText('Liquidation Price').locator('xpath=//following-sibling::p[1]')
).toContainText(regExp, { timeout: positionTimeout });
).toContainText(regExp, { timeout });
}

@step
Expand Down
7 changes: 6 additions & 1 deletion tests/withWallet/aaveV2/aaveV2Multiply.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
baseUrl,
veryLongTestTimeout,
longTestTimeout,
positionTimeout,
} from 'utils/config';
import { App } from 'src/app';

Expand Down Expand Up @@ -178,7 +179,11 @@ test.describe('Aave v2 Multiply - Wallet connected', async () => {
await app.position.manage.ok();

await app.page.goto('/ethereum/aave/v2/178#overview');
await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'USDC' });
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: 'USDC' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
baseUrl,
extremelyLongTestTimeout,
longTestTimeout,
positionTimeout,
veryLongTestTimeout,
} from 'utils/config';
import { App } from 'src/app';
Expand Down Expand Up @@ -228,7 +229,11 @@ test.describe('Aave v3 Multiply - Arbitrum - Wallet connected', async () => {
await app.position.manage.ok();

await app.page.goto('/arbitrum/aave/v3/1#overview');
await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'DAI' });
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: 'DAI' });
Expand Down
7 changes: 6 additions & 1 deletion tests/withWallet/aaveV3/base/aaveV3BorrowBase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
baseUrl,
veryLongTestTimeout,
longTestTimeout,
positionTimeout,
} from 'utils/config';
import { App } from 'src/app';

Expand Down Expand Up @@ -181,7 +182,11 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
await app.position.manage.ok();

await app.page.goto('/base/aave/v3/2#overview');
await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'USDBC' });
await app.position.overview.shouldHaveLiquidationPrice({
price: '0.00',
token: 'USDBC',
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: 'USDBC' });
Expand Down
7 changes: 6 additions & 1 deletion tests/withWallet/aaveV3/base/aaveV3EarnBase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
baseUrl,
veryLongTestTimeout,
longTestTimeout,
positionTimeout,
} from 'utils/config';
import { App } from 'src/app';

Expand Down Expand Up @@ -148,7 +149,11 @@ test.describe('Aave V3 Earn - Base - Wallet connected', async () => {
await app.position.manage.ok();

await app.page.goto('/base/aave/v3/18#overview');
await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'CBETH' });
await app.position.overview.shouldHaveLiquidationPrice({
price: '0.00',
token: 'CBETH',
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: 'CBETH' });
Expand Down
8 changes: 6 additions & 2 deletions tests/withWallet/aaveV3/base/aaveV3MultiplyBase.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 metamask from '@synthetixio/synpress/commands/metamask';
import * as tenderly from 'utils/tenderly';
import { setup } from 'utils/setup';
import { baseUrl, extremelyLongTestTimeout, longTestTimeout } from 'utils/config';
import { baseUrl, extremelyLongTestTimeout, longTestTimeout, positionTimeout } from 'utils/config';
import { App } from 'src/app';

let context: BrowserContext;
Expand Down Expand Up @@ -139,7 +139,11 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => {

await app.position.manage.ok();

await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'USDBC' });
await app.position.overview.shouldHaveLiquidationPrice({
price: '0.00',
token: 'USDBC',
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: 'USDBC' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
baseUrl,
extremelyLongTestTimeout,
longTestTimeout,
positionTimeout,
veryLongTestTimeout,
} from 'utils/config';
import { App } from 'src/app';
Expand Down Expand Up @@ -202,7 +203,11 @@ test.describe('Aave V3 Borrow - Ethereum - Wallet connected', async () => {
await app.position.manage.ok();

await app.page.goto('/ethereum/aave/v3/1277#overview');
await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'ETH' });
await app.position.overview.shouldHaveLiquidationPrice({
price: '0.00',
token: 'ETH',
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' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
baseUrl,
extremelyLongTestTimeout,
longTestTimeout,
positionTimeout,
veryLongTestTimeout,
} from 'utils/config';
import { App } from 'src/app';
Expand Down Expand Up @@ -240,7 +241,11 @@ test.describe('Aave v3 Multiply - Ethereum - Wallet connected', async () => {
await app.position.manage.ok();

await app.page.goto('/ethereum/aave/v3/1218');
await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'USDC' });
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: 'USDC' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
baseUrl,
extremelyLongTestTimeout,
longTestTimeout,
positionTimeout,
veryLongTestTimeout,
} from 'utils/config';
import { App } from 'src/app';
Expand Down Expand Up @@ -202,7 +203,11 @@ test.describe('Aave V3 Borrow - Optimism - Wallet connected', async () => {
await app.position.manage.ok();

await app.page.goto('/optimism/aave/v3/4#overview');
await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'DAI' });
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: 'DAI' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
baseUrl,
extremelyLongTestTimeout,
longTestTimeout,
positionTimeout,
veryLongTestTimeout,
} from 'utils/config';
import { App } from 'src/app';
Expand Down Expand Up @@ -227,7 +228,11 @@ test.describe('Aave v3 Multiply - Optimism - Wallet connected', async () => {
await app.position.manage.ok();

await app.page.goto('/optimism/aave/v3/2#overview');
await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'USDC' });
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: 'USDC' });
Expand Down
13 changes: 11 additions & 2 deletions tests/withWallet/spark/sparkBorrow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
baseUrl,
extremelyLongTestTimeout,
longTestTimeout,
positionTimeout,
veryLongTestTimeout,
} from 'utils/config';
import { App } from 'src/app';
Expand Down Expand Up @@ -287,7 +288,11 @@ test.describe('Spark Borrow - Wallet connected', async () => {
await app.position.manage.ok();

await app.page.goto('/ethereum/spark/v3/1474#overview');
await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'DAI' });
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: 'DAI' });
Expand Down Expand Up @@ -337,7 +342,11 @@ test.describe('Spark Borrow - Wallet connected', async () => {
await app.position.manage.ok();

await app.page.goto('/ethereum/spark/v3/1474#overview');
await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'DAI' });
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: 'DAI' });
Expand Down
7 changes: 6 additions & 1 deletion tests/withWallet/spark/sparkEarn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
veryLongTestTimeout,
baseUrl,
longTestTimeout,
positionTimeout,
} from 'utils/config';
import { App } from 'src/app';

Expand Down Expand Up @@ -152,7 +153,11 @@ test.describe('Spark Earn - Wallet connected', async () => {

await app.position.manage.ok();

await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'ETH' });
await app.position.overview.shouldHaveLiquidationPrice({
price: '0.00',
token: 'ETH',
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' });
Expand Down
7 changes: 6 additions & 1 deletion tests/withWallet/spark/sparkMultiply.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
baseUrl,
extremelyLongTestTimeout,
longTestTimeout,
positionTimeout,
veryLongTestTimeout,
} from 'utils/config';
import { App } from 'src/app';
Expand Down Expand Up @@ -158,7 +159,11 @@ test.describe('Spark Multiply - Wallet connected', async () => {

await app.position.manage.ok();

await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', token: 'DAI' });
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: 'DAI' });
Expand Down

0 comments on commit 69eb598

Please sign in to comment.