Skip to content

Commit

Permalink
Add permission revoking actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal2228 authored and duckception committed Oct 18, 2023
1 parent d5d3834 commit 43bd4f3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
18 changes: 18 additions & 0 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,24 @@ const metamask = {
);
return true;
},
async confirmRevokePermissionToAll() {
const notificationPage = await playwright.switchToMetamaskNotification();
await playwright.waitAndClick(
notificationPageElements.allowToSpendButton,
notificationPage,
{ waitForEvent: 'close' },
);
return true;
},
async rejectRevokePermissionToAll() {
const notificationPage = await playwright.switchToMetamaskNotification();
await playwright.waitAndClick(
notificationPageElements.rejectToSpendButton,
notificationPage,
{ waitForEvent: 'close' },
);
return true;
},
async allowToAddNetwork({ waitForEvent } = {}) {
const notificationPage = await playwright.switchToMetamaskNotification();
if (waitForEvent) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ module.exports = (on, config) => {
confirmMetamaskPermissionToApproveAll:
metamask.confirmPermissionToApproveAll,
rejectMetamaskPermissionToApproveAll: metamask.rejectPermissionToApproveAll,
confirmMetamaskRevokePermissionToAll: metamask.confirmRevokePermissionToAll,
rejectMetamaskRevokePermissionToAll: metamask.rejectRevokePermissionToAll,
acceptMetamaskAccess: metamask.acceptAccess,
rejectMetamaskAccess: metamask.rejectAccess,
confirmMetamaskTransaction: metamask.confirmTransaction,
Expand Down
8 changes: 8 additions & 0 deletions support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ Cypress.Commands.add('confirmMetamaskPermissionToApproveAll', () => {
return cy.task('confirmMetamaskPermissionToApproveAll');
});

Cypress.Commands.add('confirmMetamaskRevokePermissionToAll', () => {
return cy.task('confirmMetamaskRevokePermissionToAll');
});

Cypress.Commands.add('rejectMetamaskRevokePermissionToAll', () => {
return cy.task('rejectMetamaskRevokePermissionToAll');
});

Cypress.Commands.add('allowMetamaskToAddNetwork', waitForEvent => {
return cy.task('allowMetamaskToAddNetwork', { waitForEvent });
});
Expand Down
12 changes: 12 additions & 0 deletions support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,18 @@ declare namespace Cypress {
* cy.rejectMetamaskPermissionToApproveAll()
*/
rejectMetamaskPermissionToApproveAll(): Chainable<boolean>;
/**
* Confirm metamask revoking permission to access all elements (example: collectibles)
* @example
* cy.confirmMetamaskRevokePermissionToAll()
*/
confirmMetamaskRevokePermissionToAll(): Chainable<boolean>;
/**
* Reject metamask revoking permission to access all elements (example: collectibles)
* @example
* cy.rejectMetamaskRevokePermissionToAll()
*/
rejectMetamaskRevokePermissionToAll(): Chainable<boolean>;
/**
* Reject metamask permission to spend asset
* @example
Expand Down

0 comments on commit 43bd4f3

Please sign in to comment.