diff --git a/wallets/metamask/src/cypress/MetaMask.ts b/wallets/metamask/src/cypress/MetaMask.ts index 5c4cdf854..2b087a155 100644 --- a/wallets/metamask/src/cypress/MetaMask.ts +++ b/wallets/metamask/src/cypress/MetaMask.ts @@ -323,4 +323,22 @@ export default class MetaMask { return false }) } + + // Lock/Unlock + + async lock() { + await this.metamaskPlaywright.lock() + await expect( + this.metamaskExtensionPage.locator(this.metamaskPlaywright.lockPage.selectors.submitButton) + ).toBeVisible() + + return true + } + + async unlock() { + await this.metamaskPlaywright.unlock() + await expect(this.metamaskExtensionPage.locator(this.metamaskPlaywright.homePage.selectors.logo)).toBeVisible() + + return true + } } diff --git a/wallets/metamask/src/cypress/configureSynpress.ts b/wallets/metamask/src/cypress/configureSynpress.ts index 464190cf6..81be45bff 100644 --- a/wallets/metamask/src/cypress/configureSynpress.ts +++ b/wallets/metamask/src/cypress/configureSynpress.ts @@ -120,7 +120,11 @@ export default function configureSynpress(on: Cypress.PluginEvents, config: Cypr rejectTransaction: () => metamask?.rejectTransaction(), confirmTransactionAndWaitForMining: () => metamask?.confirmTransactionAndWaitForMining(), openTransactionDetails: (txIndex: number) => metamask?.openTransactionDetails(txIndex), - closeTransactionDetails: () => metamask?.closeTransactionDetails() + closeTransactionDetails: () => metamask?.closeTransactionDetails(), + + // Lock/Unlock + lock: () => metamask?.lock(), + unlock: () => metamask?.unlock() }) return { diff --git a/wallets/metamask/src/cypress/support/synpressCommands.ts b/wallets/metamask/src/cypress/support/synpressCommands.ts index 089863af3..68c048dff 100644 --- a/wallets/metamask/src/cypress/support/synpressCommands.ts +++ b/wallets/metamask/src/cypress/support/synpressCommands.ts @@ -57,6 +57,9 @@ declare global { confirmTransactionAndWaitForMining(): Chainable openTransactionDetails(txIndex: number): Chainable closeTransactionDetails(): Chainable + + lock(): Chainable + unlock(): Chainable } } } @@ -184,4 +187,11 @@ export default function synpressCommands() { Cypress.Commands.add('closeTransactionDetails', () => { return cy.task('closeTransactionDetails') }) + + Cypress.Commands.add('lock', () => { + return cy.task('lock') + }) + Cypress.Commands.add('unlock', () => { + return cy.task('unlock') + }) } diff --git a/wallets/metamask/test/cypress/lock.cy.ts b/wallets/metamask/test/cypress/lock.cy.ts new file mode 100644 index 000000000..dbd67aed2 --- /dev/null +++ b/wallets/metamask/test/cypress/lock.cy.ts @@ -0,0 +1,5 @@ +it('should lock & unlock the wallet without any error', () => { + cy.lock().then(() => { + cy.unlock() + }) +})