From 18ef5998e972cf49c5f88bfb1793077e2cbe7f09 Mon Sep 17 00:00:00 2001 From: juan-langa Date: Mon, 4 Dec 2023 11:28:04 +0100 Subject: [PATCH] Improvements for flaky tests due to RETRY trnsactions --- .../ethereum/aaveV3BorrowEthereum.spec.ts | 2 +- .../ethereum/aaveV3EarnEthereum.spec.ts | 4 +- .../ethereum/aaveV3MultiplyEthereum.spec.ts | 4 +- .../withWallet/aaveV2/aaveV2Multiply.spec.ts | 45 ++++-- .../ethereum/aaveV3EarnEthereum.spec.ts | 104 ++++++++---- .../optimism/aaveV3BorrowOptimism.spec.ts | 44 +++-- tests/withWallet/spark/sparkBorrow.spec.ts | 150 ++++++++++++------ 7 files changed, 232 insertions(+), 121 deletions(-) diff --git a/tests/noWallet/aaveV3/ethereum/aaveV3BorrowEthereum.spec.ts b/tests/noWallet/aaveV3/ethereum/aaveV3BorrowEthereum.spec.ts index c0a2b36..cc687f5 100644 --- a/tests/noWallet/aaveV3/ethereum/aaveV3BorrowEthereum.spec.ts +++ b/tests/noWallet/aaveV3/ethereum/aaveV3BorrowEthereum.spec.ts @@ -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', diff --git a/tests/noWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts b/tests/noWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts index 943284c..fb18040 100644 --- a/tests/noWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts +++ b/tests/noWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts @@ -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({ diff --git a/tests/noWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts b/tests/noWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts index 1c8832b..a61eecc 100644 --- a/tests/noWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts +++ b/tests/noWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts @@ -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}'); @@ -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', }); }); diff --git a/tests/withWallet/aaveV2/aaveV2Multiply.spec.ts b/tests/withWallet/aaveV2/aaveV2Multiply.spec.ts index 61a3693..48b451c 100644 --- a/tests/withWallet/aaveV2/aaveV2Multiply.spec.ts +++ b/tests/withWallet/aaveV2/aaveV2Multiply.spec.ts @@ -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({ @@ -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'); @@ -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'); diff --git a/tests/withWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts b/tests/withWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts index 74e10f2..501ed3d 100644 --- a/tests/withWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts +++ b/tests/withWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts @@ -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({ @@ -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' }); @@ -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' }); @@ -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' }); @@ -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'); @@ -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'); @@ -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'); diff --git a/tests/withWallet/aaveV3/optimism/aaveV3BorrowOptimism.spec.ts b/tests/withWallet/aaveV3/optimism/aaveV3BorrowOptimism.spec.ts index 47d0827..a4058f0 100644 --- a/tests/withWallet/aaveV3/optimism/aaveV3BorrowOptimism.spec.ts +++ b/tests/withWallet/aaveV3/optimism/aaveV3BorrowOptimism.spec.ts @@ -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'); @@ -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'); @@ -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'); diff --git a/tests/withWallet/spark/sparkBorrow.spec.ts b/tests/withWallet/spark/sparkBorrow.spec.ts index fe329e2..61785e5 100644 --- a/tests/withWallet/spark/sparkBorrow.spec.ts +++ b/tests/withWallet/spark/sparkBorrow.spec.ts @@ -59,11 +59,16 @@ test.describe('Spark Borrow - 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'); @@ -91,11 +96,16 @@ test.describe('Spark Borrow - 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'); @@ -122,14 +132,18 @@ test.describe('Spark Borrow - Wallet connected', async () => { await app.position.manage.closeTo('DAI'); await app.position.manage.shouldHaveTokenAmountAfterClosing({ token: 'DAI', - amount: '0.[0-9]{3,4}', - }); - await app.position.manage.confirm(); - await test.step('Metamask: ConfirmPermissionToSpend', async () => { - await metamask.confirmPermissionToSpend(); + amount: '[0-3].[0-9]{3,4}', }); - 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('/ethereum/spark/v3/1474#overview'); @@ -215,11 +229,16 @@ test.describe('Spark Borrow - Wallet connected', async () => { }).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({ @@ -242,11 +261,16 @@ test.describe('Spark Borrow - Wallet connected', async () => { await app.position.manage.withdrawCollateral(); await app.position.manage.enter({ token: 'WBTC', amount: '0.1' }); - 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.shouldHaveExposure({ amount: '0.90000', token: 'WBTC' }); @@ -266,11 +290,16 @@ test.describe('Spark Borrow - Wallet connected', async () => { await app.position.manage.openManageOptions({ currentLabel: 'Manage WBTC' }); await app.position.manage.select('Manage debt'); await app.position.manage.enter({ token: 'DAI', amount: '5000' }); - 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,000.0000', token: 'DAI' }); @@ -301,11 +330,16 @@ test.describe('Spark Borrow - 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.shouldHaveDebt({ amount: '2,000.[0-9]{4}', token: 'DAI' }); @@ -330,11 +364,16 @@ test.describe('Spark Borrow - 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'); @@ -362,11 +401,16 @@ test.describe('Spark Borrow - 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'); @@ -395,12 +439,16 @@ test.describe('Spark Borrow - Wallet connected', async () => { token: 'WBTC', amount: '0.[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(); + await app.position.manage.ok(); await app.page.goto('/ethereum/spark/v3/1669#overview');