From 8a35ca4071b74885b011904dc2ea0b64d1a4f725 Mon Sep 17 00:00:00 2001 From: matstyler Date: Thu, 8 Aug 2024 12:38:46 +0200 Subject: [PATCH] feat: Cypress API expanded by confirmTransactionAndWaitForMining --- .../metamask/src/cypress/configureSynpress.ts | 13 +++++++++++++ .../src/cypress/support/synpressCommands.ts | 4 ++++ .../metamask/test/cypress/addNewToken.cy.ts | 1 - .../metamask/test/cypress/batchTransfer.cy.ts | 19 +++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 wallets/metamask/test/cypress/batchTransfer.cy.ts diff --git a/wallets/metamask/src/cypress/configureSynpress.ts b/wallets/metamask/src/cypress/configureSynpress.ts index 90744be65..d5a970c54 100644 --- a/wallets/metamask/src/cypress/configureSynpress.ts +++ b/wallets/metamask/src/cypress/configureSynpress.ts @@ -278,6 +278,19 @@ export default function configureSynpress(on: Cypress.PluginEvents, config: Cypr .catch(() => { return false }) + }, + + async confirmTransactionAndWaitForMining() { + const metamask = getPlaywrightMetamask(context, metamaskExtensionPage, metamaskExtensionId) + + return metamask + .confirmTransactionAndWaitForMining() + .then(() => { + return true + }) + .catch(() => { + return false + }) } }) diff --git a/wallets/metamask/src/cypress/support/synpressCommands.ts b/wallets/metamask/src/cypress/support/synpressCommands.ts index a0cf879f7..53260c7fb 100644 --- a/wallets/metamask/src/cypress/support/synpressCommands.ts +++ b/wallets/metamask/src/cypress/support/synpressCommands.ts @@ -40,6 +40,7 @@ declare global { decrypt(): Chainable confirmSignature(): Chainable confirmTransaction(): Chainable + confirmTransactionAndWaitForMining(): Chainable } } } @@ -122,4 +123,7 @@ export default function synpressCommands() { Cypress.Commands.add('confirmTransaction', () => { return cy.task('confirmTransaction') }) + Cypress.Commands.add('confirmTransactionAndWaitForMining', () => { + return cy.task('confirmTransactionAndWaitForMining') + }) } diff --git a/wallets/metamask/test/cypress/addNewToken.cy.ts b/wallets/metamask/test/cypress/addNewToken.cy.ts index 9a8803fff..535c4710c 100644 --- a/wallets/metamask/test/cypress/addNewToken.cy.ts +++ b/wallets/metamask/test/cypress/addNewToken.cy.ts @@ -1,6 +1,5 @@ before(() => { cy.getNetwork().then((network) => { - console.log(network) if (network !== 'Anvil') { cy.switchNetwork('Anvil') } diff --git a/wallets/metamask/test/cypress/batchTransfer.cy.ts b/wallets/metamask/test/cypress/batchTransfer.cy.ts new file mode 100644 index 000000000..b86705344 --- /dev/null +++ b/wallets/metamask/test/cypress/batchTransfer.cy.ts @@ -0,0 +1,19 @@ +before(() => { + cy.get('#deployERC1155Button').click() + + cy.confirmTransaction().then(() => { + cy.wait(5000) + + cy.get('#batchMintButton').click() + + cy.confirmTransactionAndWaitForMining() + }) +}) + +it('should perform batch ERC115 transfer', () => { + cy.get('#batchTransferFromButton').click() + + cy.confirmTransaction().then(() => { + cy.get('#erc1155Status').should('have.text', 'Batch Transfer From completed') + }) +})