Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Lock API for Cypress #1218

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions wallets/metamask/src/cypress/MetaMask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
6 changes: 5 additions & 1 deletion wallets/metamask/src/cypress/configureSynpress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions wallets/metamask/src/cypress/support/synpressCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ declare global {
confirmTransactionAndWaitForMining(): Chainable<void>
openTransactionDetails(txIndex: number): Chainable<void>
closeTransactionDetails(): Chainable<void>

lock(): Chainable<void>
unlock(): Chainable<void>
}
}
}
Expand Down Expand Up @@ -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')
})
}
5 changes: 5 additions & 0 deletions wallets/metamask/test/cypress/lock.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
it('should lock & unlock the wallet without any error', () => {
cy.lock().then(() => {
cy.unlock()
})
})
Loading