diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 27e90a7668..4602110171 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -70,14 +70,14 @@ export default defineConfig({ provider: sepoliaProvider, networkType: 'parentChain', sourceWallet: localWallet, - amount: utils.parseUnits('0.0001', 6) + amount: utils.parseUnits('0.0002', 6) }), fundUsdc({ address: userWalletAddress, provider: arbSepoliaProvider, networkType: 'childChain', sourceWallet: localWallet, - amount: utils.parseUnits('0.0001', 6) + amount: utils.parseUnits('0.0002', 6) }) ]) diff --git a/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts b/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts index 5c596b1f97..2b5ef93310 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/cypress.d.ts @@ -19,7 +19,8 @@ import { findTransactionDetailsCustomDestinationAddress, findTransactionInTransactionHistory, findClaimButton, - selectTransactionsPanelTab + selectTransactionsPanelTab, + confirmSpending } from '../support/commands' import { NetworkType, NetworkName } from '../support/common' @@ -62,6 +63,7 @@ declare global { findTransactionDetailsCustomDestinationAddress: typeof findTransactionDetailsCustomDestinationAddress findTransactionInTransactionHistory: typeof findTransactionInTransactionHistory findClaimButton: typeof findClaimButton + confirmSpending: typeof confirmSpending } } } diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts index c0a1ea4e4e..3af8f09699 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/approveToken.cy.ts @@ -40,12 +40,11 @@ describe('Approve token and deposit afterwards', () => { cy.findByRole('button', { name: /Pay approval fee of/ }).click() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: '1', + cy.confirmSpending({ shouldWaitForPopupClosure: true - }).then(approved => { - cy.wrap(approved).should('be.true') }) + + // TODO: add an assertion here }) }) }) diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts index 932334f308..c2f03870b5 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/depositCctp.cy.ts @@ -76,7 +76,7 @@ describe('Deposit USDC through CCTP', () => { tokenAddress: CommonAddress.Sepolia.USDC }) - cy.typeAmount(USDCAmountToSend) + cy.findByPlaceholderText(/enter amount/i).type(String(USDCAmountToSend)) cy.findGasFeeSummary(zeroToLessThanOneETH) cy.findGasFeeForChain('Sepolia', zeroToLessThanOneETH) cy.findGasFeeForChain( @@ -88,11 +88,8 @@ describe('Deposit USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString(), + cy.confirmSpending({ shouldWaitForPopupClosure: true - }).then(approved => { - cy.wrap(approved).should('be.true') }) // eslint-disable-next-line @@ -110,11 +107,8 @@ describe('Deposit USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpDeposit() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString(), + cy.confirmSpending({ shouldWaitForPopupClosure: true - }).then(approved => { - cy.wrap(approved).should('be.true') }) // eslint-disable-next-line diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts index b75e5ab54d..718216dd13 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts @@ -66,10 +66,11 @@ describe('Withdraw USDC through CCTP', () => { tokenName: 'USDC', tokenAddress: CommonAddress.ArbitrumSepolia.USDC }) + + cy.findByPlaceholderText(/enter amount/i).type(String(USDCAmountToSend)) }) it('should initiate withdrawing USDC to the same address through CCTP successfully', () => { - cy.typeAmount(USDCAmountToSend) cy.findByText('Gas estimates are not available for this action.').should( 'be.visible' ) @@ -78,13 +79,9 @@ describe('Withdraw USDC through CCTP', () => { cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString(), + cy.confirmSpending({ shouldWaitForPopupClosure: true - }).then(approved => { - cy.wrap(approved).should('be.true') }) - // eslint-disable-next-line cy.wait(40_000) cy.confirmMetamaskTransaction(undefined) @@ -96,17 +93,12 @@ describe('Withdraw USDC through CCTP', () => { }) it('should initiate withdrawing USDC to custom destination address through CCTP successfully', () => { - cy.typeAmount(USDCAmountToSend) - // cy.findByPlaceholderText(/enter amount/i).type(String(USDCAmountToSend)) cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.confirmMetamaskPermissionToSpend({ - spendLimit: USDCAmountToSend.toString(), + cy.confirmSpending({ shouldWaitForPopupClosure: true - }).then(approved => { - cy.wrap(approved).should('be.true') }) // eslint-disable-next-line diff --git a/packages/arb-token-bridge-ui/tests/support/commands.ts b/packages/arb-token-bridge-ui/tests/support/commands.ts index 31c661cd8c..af0e1e1eb7 100644 --- a/packages/arb-token-bridge-ui/tests/support/commands.ts +++ b/packages/arb-token-bridge-ui/tests/support/commands.ts @@ -321,6 +321,17 @@ export function findClaimButton( return cy.findByLabelText(`Claim ${amountToClaim}`) } +/** + * Currently, Synpress confirmMetamaskPermissionToSpend is clicking only once + * We need to call it twice to confirm it + */ +export function confirmSpending( + params: Parameters[0] +) { + cy.confirmMetamaskPermissionToSpend(params) + cy.confirmMetamaskPermissionToSpend(params) +} + Cypress.Commands.addAll({ connectToApp, login, @@ -340,5 +351,6 @@ Cypress.Commands.addAll({ closeTransactionDetails, findTransactionInTransactionHistory, findClaimButton, - findTransactionDetailsCustomDestinationAddress + findTransactionDetailsCustomDestinationAddress, + confirmSpending })