Skip to content

Commit

Permalink
Improvements for flaky tests due to RETRY trnsactions
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-langa committed Dec 4, 2023
1 parent e3bfaf8 commit 18ef599
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test.describe('Aave v3 Borrow Ethereum', async () => {

await app.position.overview.shouldHaveLiquidationPriceAfterPill('[1-9][0-9]{2}.[0-9]{2}');
await app.position.overview.shouldHaveLoanToValueAfterPill('[0-9]{1,2}.[0-9]{2}%');
await app.position.overview.shouldHaveNetValueAfterPill('[5-9][0-9],[0-9]{3}.[0-9]{2}');
await app.position.overview.shouldHaveNetValueAfterPill('[0-9]{2,3},[0-9]{3}.[0-9]{2}');
await app.position.overview.shouldHaveDebtAfterPill({ amount: '10,000.0000', token: 'USDC' });
await app.position.setup.orderInformation.shouldHaveOutstandingDebt({
token: 'USDC',
Expand Down
4 changes: 2 additions & 2 deletions tests/noWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ test.describe('Aave v3 Earn Ethereum', async () => {
dollarsAmount: '[1-9][0-9]{2},[0-9]{3}.[0-9]{2}',
});
await app.position.setup.orderInformation.shouldHavePriceImpact({
amount: '1.[0-9]{4}',
percentage: '0.[0-9]{2}',
amount: '[0-3].[0-9]{4}',
percentage: '[0-4].[0-9]{2}',
});
await app.position.setup.orderInformation.shouldHaveSlippageLimit('0.[0-9]{2}');
await app.position.setup.orderInformation.shouldHaveMultiply({
Expand Down
4 changes: 2 additions & 2 deletions tests/noWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test.describe('Aave v3 Multiply Ethereum', async () => {
await app.position.overview.waitForComponentToBeStable();
await app.position.setup.deposit({ token: 'WBTC', amount: '2.5' });

await app.position.overview.shouldHaveLiquidationPriceAfterPill('[4-9],[0-9]{3}.[0-9]{2}');
await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9]{1,2},[0-9]{3}.[0-9]{2}');
await app.position.overview.shouldHaveLoanToValueAfterPill('[1-4][0-9].[0-9]{2}%');
await app.position.overview.shouldHaveBorrowCostAfterPill('[0-9].[0-9]{2}');
await app.position.overview.shouldHaveNetValueAfterPill('[0-9]{2,3},[0-9]{3}.[0-9]{2}');
Expand Down Expand Up @@ -67,7 +67,7 @@ test.describe('Aave v3 Multiply Ethereum', async () => {
future: '[1-2][0-9].[0-9]{2}',
});
await app.position.setup.orderInformation.shouldHaveTransactionFee({
fee: '[2-4][0-9].[0-9]{2}',
fee: '[0-9]{1,2}.[0-9]{2}',
token: 'USDC',
});
});
Expand Down
45 changes: 30 additions & 15 deletions tests/withWallet/aaveV2/aaveV2Multiply.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,16 @@ test.describe('Aave v2 Multiply - Wallet connected', async () => {
await app.position.manage.openManageOptions({ currentLabel: 'Adjust' });
await app.position.manage.select('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();

await app.position.manage.ok();

await app.position.overview.shouldHaveNetValue({
Expand Down Expand Up @@ -85,11 +90,16 @@ test.describe('Aave v2 Multiply - 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();

// Risk adjustment 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();

await app.position.manage.ok();

await app.position.manage.shouldBeVisible('Manage Multiply position');
Expand All @@ -115,11 +125,16 @@ test.describe('Aave v2 Multiply - 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();

// Risk adjustment 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();

await app.position.manage.ok();

await app.position.manage.shouldBeVisible('Manage Multiply position');
Expand Down
104 changes: 69 additions & 35 deletions tests/withWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,16 @@ test.describe('Aave V3 Earn - Ethereum - Wallet connected', async () => {
await app.position.setup.continueShouldBeVisible();
}).toPass();
await app.position.setup.continue();
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();

await app.position.manage.ok();

await app.position.overview.shouldHaveNetValue({
Expand All @@ -93,11 +98,16 @@ test.describe('Aave V3 Earn - Ethereum - Wallet connected', async () => {
await app.position.manage.select('Manage collateral');
await app.position.manage.withdrawCollateral();
await app.position.manage.enter({ token: 'WSTETH', amount: '5' });
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();

await app.position.manage.ok();

await app.position.overview.shouldHaveTotalCollateral({ amount: '15.00000', token: 'WSTETH' });
Expand All @@ -117,11 +127,16 @@ test.describe('Aave V3 Earn - Ethereum - Wallet connected', async () => {
await app.position.manage.openManageOptions({ currentLabel: 'Adjust' });
await app.position.manage.select('Manage debt');
await app.position.manage.enter({ token: 'ETH', amount: '5' });
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();

await app.position.manage.ok();

await app.position.overview.shouldHaveDebt({ amount: '5.00000', token: 'ETH' });
Expand All @@ -142,11 +157,16 @@ test.describe('Aave V3 Earn - Ethereum - Wallet connected', async () => {
await app.position.manage.select('Manage debt');
await app.position.manage.payBackDebt();
await app.position.manage.enter({ token: 'ETH', amount: '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();

await app.position.manage.ok();

await app.position.overview.shouldHaveDebt({ amount: '3.00000', token: 'ETH' });
Expand All @@ -168,11 +188,16 @@ test.describe('Aave V3 Earn - Ethereum - 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();

// Risk adjustment 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();

await app.position.manage.ok();

await app.position.manage.shouldBeVisible('Manage Earn position');
Expand All @@ -195,11 +220,16 @@ test.describe('Aave V3 Earn - Ethereum - 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();

// Risk adjustment 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();

await app.position.manage.ok();

await app.position.manage.shouldBeVisible('Manage Earn position');
Expand All @@ -223,12 +253,16 @@ test.describe('Aave V3 Earn - Ethereum - Wallet connected', async () => {
token: 'WSTETH',
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();
// Closing position randomly fails - Retry until it's closed.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass();

await app.position.manage.ok();

await app.page.goto('/ethereum/aave/v3/317#overview');
Expand Down
44 changes: 29 additions & 15 deletions tests/withWallet/aaveV3/optimism/aaveV3BorrowOptimism.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,16 @@ test.describe('Aave V3 Borrow - Optimism - 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();

await app.position.manage.ok();

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

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();

await app.position.manage.ok();

await app.position.manage.shouldBeVisible('Manage collateral');
Expand Down Expand Up @@ -174,12 +184,16 @@ test.describe('Aave V3 Borrow - Optimism - Wallet connected', async () => {
token: 'WBTC',
amount: '<0.001',
});
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();

await app.position.manage.ok();

await app.page.goto('/optimism/aave/v3/4#overview');
Expand Down
Loading

0 comments on commit 18ef599

Please sign in to comment.