Skip to content

Commit

Permalink
Merge pull request #96 from OasisDEX/confirm-or-retry
Browse files Browse the repository at this point in the history
Reducing test flakiness with retries for 'Confirm' action
  • Loading branch information
juan-langa authored Dec 12, 2023
2 parents 935a28e + c7d603b commit ef912bd
Show file tree
Hide file tree
Showing 19 changed files with 409 additions and 220 deletions.
4 changes: 2 additions & 2 deletions tests/withWallet/aaveV2/aaveV2Earn.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 { hooksTimeout, extremelyLongTestTimeout, baseUrl } from 'utils/config';
import { hooksTimeout, extremelyLongTestTimeout, baseUrl, longTestTimeout } from 'utils/config';
import { App } from 'src/app';

let context: BrowserContext;
Expand Down Expand Up @@ -64,7 +64,7 @@ test.describe('Aave V2 Earn - Wallet connected', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.setup.goToPositionShouldBeVisible();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage ');
Expand Down
19 changes: 12 additions & 7 deletions tests/withWallet/aaveV2/aaveV2Multiply.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ 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 { extremelyLongTestTimeout, baseUrl, veryLongTestTimeout } from 'utils/config';
import {
extremelyLongTestTimeout,
baseUrl,
veryLongTestTimeout,
longTestTimeout,
} from 'utils/config';
import { App } from 'src/app';

let context: BrowserContext;
Expand Down Expand Up @@ -61,7 +66,7 @@ test.describe('Aave v2 Multiply - Wallet connected', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

Expand Down Expand Up @@ -98,7 +103,7 @@ test.describe('Aave v2 Multiply - Wallet connected', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

Expand Down Expand Up @@ -133,7 +138,7 @@ test.describe('Aave v2 Multiply - Wallet connected', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

Expand Down Expand Up @@ -168,7 +173,7 @@ test.describe('Aave v2 Multiply - Wallet connected', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

Expand Down Expand Up @@ -207,7 +212,7 @@ test.describe('Aave v2 Multiply - Wallet connected', async () => {
await metamask.confirmAddToken();
});
await app.position.setup.continueShouldBeVisible();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();
await app.position.setup.openMultiplyPosition1Of2();
Expand All @@ -219,7 +224,7 @@ test.describe('Aave v2 Multiply - Wallet connected', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.setup.goToPositionShouldBeVisible();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage ');
Expand Down
4 changes: 2 additions & 2 deletions tests/withWallet/aaveV3/arbitrum/aaveV3BorrowArbitrum.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 { hooksTimeout, extremelyLongTestTimeout, baseUrl } from 'utils/config';
import { hooksTimeout, extremelyLongTestTimeout, baseUrl, longTestTimeout } from 'utils/config';
import { App } from 'src/app';

let context: BrowserContext;
Expand Down Expand Up @@ -65,7 +65,7 @@ test.describe('Aave V3 Borrow - Arbitrum - Wallet connected', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.setup.goToPositionShouldBeVisible();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage ');
Expand Down
55 changes: 37 additions & 18 deletions tests/withWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ 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, veryLongTestTimeout } from 'utils/config';
import {
baseUrl,
extremelyLongTestTimeout,
longTestTimeout,
veryLongTestTimeout,
} from 'utils/config';
import { App } from 'src/app';

let context: BrowserContext;
Expand Down Expand Up @@ -57,7 +62,7 @@ test.describe('Aave v3 Multiply - Arbitrum - Wallet connected', async () => {
await metamask.confirmAddToken();
});
await app.position.setup.continueShouldBeVisible();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();
await app.position.setup.openMultiplyPosition1Of2();
Expand All @@ -69,7 +74,7 @@ test.describe('Aave v3 Multiply - Arbitrum - Wallet connected', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.setup.goToPositionShouldBeVisible();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage ');
Expand Down Expand Up @@ -112,11 +117,16 @@ test.describe('Aave v3 Multiply - Arbitrum - Wallet connected', async () => {
await app.position.manage.moveSlider({ value: 0.9 });

await app.position.manage.adjustRisk();
await app.position.manage.confirm();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();

// Confirm action randomly fails - Retry until it's applied.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

await app.position.manage.shouldBeVisible('Manage Multiply position');
Expand Down Expand Up @@ -156,11 +166,16 @@ test.describe('Aave v3 Multiply - Arbitrum - Wallet connected', async () => {
await app.position.manage.moveSlider({ value: 0.3 });

await app.position.manage.adjustRisk();
await app.position.manage.confirm();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();

// Confirm action randomly fails - Retry until it's applied.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

await app.position.manage.shouldBeVisible('Manage Multiply position');
Expand Down Expand Up @@ -200,12 +215,16 @@ test.describe('Aave v3 Multiply - Arbitrum - Wallet connected', async () => {
token: 'DAI',
amount: '[1-6].[0-9]{3,4}',
});
await app.position.manage.confirm();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});

await app.position.manage.shouldShowSuccessScreen();
// Confirm action randomly fails - Retry until it's applied.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

await app.page.goto('/arbitrum/aave/v3/1#overview');
Expand Down
69 changes: 46 additions & 23 deletions tests/withWallet/aaveV3/base/aaveV3BorrowBase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ 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 { extremelyLongTestTimeout, baseUrl, veryLongTestTimeout } from 'utils/config';
import {
extremelyLongTestTimeout,
baseUrl,
veryLongTestTimeout,
longTestTimeout,
} from 'utils/config';
import { App } from 'src/app';

let context: BrowserContext;
Expand Down Expand Up @@ -52,11 +57,15 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
await app.position.manage.shouldBeVisible('Manage collateral');
await app.position.manage.enter({ token: 'ETH', amount: '15' });

await app.position.manage.confirm();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
// Confirm action randomly fails - Retry until it's applied.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

await app.position.overview.shouldHaveNetValue({
Expand Down Expand Up @@ -84,11 +93,16 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
await app.position.manage.moveSlider({ value: 0.7 });

await app.position.manage.adjustRisk();
await app.position.manage.confirm();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();

// Confirm action randomly fails - Retry until it's applied.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

await app.position.manage.shouldBeVisible('Manage collateral');
Expand Down Expand Up @@ -116,11 +130,16 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
await app.position.manage.moveSlider({ value: 0.3 });

await app.position.manage.adjustRisk();
await app.position.manage.confirm();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();

// Confirm action randomly fails - Retry until it's applied.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

await app.position.manage.shouldBeVisible('Manage collateral');
Expand Down Expand Up @@ -149,12 +168,16 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
token: 'ETH',
amount: '[0-9]{1,2}.[0-9]{1,2}',
});
await app.position.manage.confirm();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});

await app.position.manage.shouldShowSuccessScreen();
// Confirm action randomly fails - Retry until it's applied.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

await app.page.goto('/base/aave/v3/2#overview');
Expand Down Expand Up @@ -190,7 +213,7 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
await metamask.confirmAddToken();
});
await app.position.setup.continueShouldBeVisible();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();
await app.position.setup.openBorrowPosition1Of2();
Expand All @@ -202,7 +225,7 @@ test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.setup.goToPositionShouldBeVisible();
}).toPass();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage ');
Expand Down
Loading

0 comments on commit ef912bd

Please sign in to comment.