Skip to content

Commit

Permalink
feat: Cypress API expanded by confirmTransactionAndWaitForMining
Browse files Browse the repository at this point in the history
  • Loading branch information
matstyler committed Aug 8, 2024
1 parent b715a00 commit 8a35ca4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
13 changes: 13 additions & 0 deletions wallets/metamask/src/cypress/configureSynpress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
})

Expand Down
4 changes: 4 additions & 0 deletions wallets/metamask/src/cypress/support/synpressCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ declare global {
decrypt(): Chainable<void>
confirmSignature(): Chainable<void>
confirmTransaction(): Chainable<void>
confirmTransactionAndWaitForMining(): Chainable<void>
}
}
}
Expand Down Expand Up @@ -122,4 +123,7 @@ export default function synpressCommands() {
Cypress.Commands.add('confirmTransaction', () => {
return cy.task('confirmTransaction')
})
Cypress.Commands.add('confirmTransactionAndWaitForMining', () => {
return cy.task('confirmTransactionAndWaitForMining')
})
}
1 change: 0 additions & 1 deletion wallets/metamask/test/cypress/addNewToken.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
before(() => {
cy.getNetwork().then((network) => {
console.log(network)
if (network !== 'Anvil') {
cy.switchNetwork('Anvil')
}
Expand Down
19 changes: 19 additions & 0 deletions wallets/metamask/test/cypress/batchTransfer.cy.ts
Original file line number Diff line number Diff line change
@@ -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')
})
})

0 comments on commit 8a35ca4

Please sign in to comment.