diff --git a/wallets/metamask/cypress.config.ts b/wallets/metamask/cypress.config.ts index fb9e2c158..18b0c5dd6 100644 --- a/wallets/metamask/cypress.config.ts +++ b/wallets/metamask/cypress.config.ts @@ -12,5 +12,8 @@ export default defineConfig({ async setupNodeEvents(on, config) { return configureSynpress(on, config) } - } + }, + + defaultCommandTimeout: 12_000, + taskTimeout: 15_000 }) diff --git a/wallets/metamask/src/cypress/MetaMask.ts b/wallets/metamask/src/cypress/MetaMask.ts index 16cded469..5c4cdf854 100644 --- a/wallets/metamask/src/cypress/MetaMask.ts +++ b/wallets/metamask/src/cypress/MetaMask.ts @@ -285,6 +285,13 @@ export default class MetaMask { } async confirmTransactionAndWaitForMining() { + await waitFor( + () => + this.metamaskExtensionPage.locator(TransactionPage.nftApproveAllConfirmationPopup.approveButton).isVisible(), + 5_000, + false + ) + return this.metamaskPlaywright .confirmTransactionAndWaitForMining() .then(() => { diff --git a/wallets/metamask/test/cypress/batchTransfer.cy.ts b/wallets/metamask/test/cypress/batchTransfer.cy.ts index b86705344..70fc2da53 100644 --- a/wallets/metamask/test/cypress/batchTransfer.cy.ts +++ b/wallets/metamask/test/cypress/batchTransfer.cy.ts @@ -1,4 +1,6 @@ before(() => { + cy.switchNetwork('Anvil') + cy.get('#deployERC1155Button').click() cy.confirmTransaction().then(() => { diff --git a/wallets/metamask/test/cypress/confirmSignature.cy.ts b/wallets/metamask/test/cypress/confirmSignature.cy.ts index d336ecdc6..603c40ea7 100644 --- a/wallets/metamask/test/cypress/confirmSignature.cy.ts +++ b/wallets/metamask/test/cypress/confirmSignature.cy.ts @@ -1,7 +1,3 @@ -before(() => { - cy.switchNetwork('Anvil') -}) - it('should confirm `personal_sign`', () => { cy.get('#personalSign').click() diff --git a/wallets/metamask/test/cypress/confirmTransaction.cy.ts b/wallets/metamask/test/cypress/confirmTransaction.cy.ts index 84d693e8d..8c42e74cc 100644 --- a/wallets/metamask/test/cypress/confirmTransaction.cy.ts +++ b/wallets/metamask/test/cypress/confirmTransaction.cy.ts @@ -15,14 +15,6 @@ const connectDeployAndMintNft = () => { }) } -before(() => { - cy.connectToAnvil().then(() => { - cy.get('#connectButton').click() - - cy.connectToDapp() - }) -}) - describe('with default gas setting', () => { it('should confirm contract deployment', () => { cy.get('#tokenAddresses').should('be.empty') diff --git a/wallets/metamask/test/cypress/confirmTransactionAndWaitForMining.cy.ts b/wallets/metamask/test/cypress/confirmTransactionAndWaitForMining.cy.ts new file mode 100644 index 000000000..b88d9d13f --- /dev/null +++ b/wallets/metamask/test/cypress/confirmTransactionAndWaitForMining.cy.ts @@ -0,0 +1,32 @@ +it('should confirm contract deployment and wait for mining', () => { + cy.get('#tokenAddresses').should('be.empty') + cy.get('#createToken').click() + + cy.confirmTransactionAndWaitForMining().then(() => { + cy.get('#tokenAddresses').should('include', /^0x/) + }) +}) + +it('should confirm legacy transaction and wait for mining', () => { + cy.get('#sendButton').click() + + cy.confirmTransactionAndWaitForMining() +}) + +it('should confirm EIP-1559 transaction and wait for mining', () => { + cy.get('#sendEIP1559Button').click() + + cy.confirmTransactionAndWaitForMining().then(() => { + cy.get('#tokenAddresses').should('include', /^0x/) + }) +}) + +it('should work correctly when calling sequentially', () => { + cy.get('#sendEIP1559Button').click() + cy.confirmTransactionAndWaitForMining().then(() => { + cy.get('#sendEIP1559Button').click() + cy.confirmTransactionAndWaitForMining().then(() => { + cy.get('#tokenAddresses').should('include', /^0x/) + }) + }) +}) diff --git a/wallets/metamask/test/cypress/connectToDapp.cy.ts b/wallets/metamask/test/cypress/connectToDapp.cy.ts index dcc9d60de..54e999e96 100644 --- a/wallets/metamask/test/cypress/connectToDapp.cy.ts +++ b/wallets/metamask/test/cypress/connectToDapp.cy.ts @@ -6,5 +6,5 @@ it('should connect account to the app', () => { cy.get('#connectButton').click() cy.connectToDapp() - cy.get('#accounts').should('contain', '0x') + cy.get('#accounts').should('include', /^0x/) }) diff --git a/wallets/metamask/test/cypress/rejectAddNetwork.cy.ts b/wallets/metamask/test/cypress/rejectAddNetwork.cy.ts index 1e23a418d..c2993db90 100644 --- a/wallets/metamask/test/cypress/rejectAddNetwork.cy.ts +++ b/wallets/metamask/test/cypress/rejectAddNetwork.cy.ts @@ -1,18 +1,9 @@ it('should reject new network request', () => { - cy.createAnvilNode({ - chainId: 1338, - port: 8546 - }).then(() => { - cy.get('#addEthereumChain').click() + cy.get('#addEthereumChain').click() - cy.rejectNewNetwork().then(() => { - cy.get('#chainId').should('have.text', '0x1') + cy.rejectNewNetwork().then(() => { + cy.get('#chainId').should('have.text', '0x7a69') - cy.emptyAnvilNode() - }) + cy.emptyAnvilNode() }) }) - -after(() => { - cy.switchNetwork('Ethereum Mainnet') -})