Skip to content

Commit

Permalink
Add accept reject decrypt message
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhoheiser committed Mar 4, 2022
1 parent c42a2fd commit 491b5b5
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
19 changes: 19 additions & 0 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const {
confirmPageElements,
signaturePageElements,
encryptionPublicKeyPageElements,
decryptPageElements,
} = require('../pages/metamask/notification-page');
const {
settingsPageElements,
Expand Down Expand Up @@ -510,6 +511,24 @@ module.exports = {
await puppeteer.metamaskWindow().waitForTimeout(3000);
return true;
},
confirmDecryptionRequest: async () => {
const notificationPage = await puppeteer.switchToMetamaskNotification();
await puppeteer.waitAndClick(
decryptPageElements.confirmDecryptionRequestButton,
notificationPage,
);
await puppeteer.metamaskWindow().waitForTimeout(3000);
return true;
},
rejectDecryptionRequest: async () => {
const notificationPage = await puppeteer.switchToMetamaskNotification();
await puppeteer.waitAndClick(
decryptPageElements.rejectDecryptionRequestButton,
notificationPage,
);
await puppeteer.metamaskWindow().waitForTimeout(3000);
return true;
},
allowToAddNetwork: async () => {
const notificationPage = await puppeteer.switchToMetamaskNotification();
await puppeteer.waitAndClick(
Expand Down
6 changes: 6 additions & 0 deletions pages/metamask/notification-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ module.exports.encryptionPublicKeyPageElements = {
rejectEncryptionPublicKeyButton,
};

const confirmDecryptionRequestButton = `${notificationPage} .request-decrypt-message__footer__sign-button`;
const rejectDecryptionRequestButton = `${notificationPage} .request-decrypt-message__footer__cancel-button`;
module.exports.decryptPageElements = {
confirmDecryptionRequestButton,
rejectDecryptionRequestButton,
};
8 changes: 8 additions & 0 deletions plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ module.exports = (on, config) => {
const rejected = await metamask.rejectEncryptionPublicKeyRequest();
return rejected;
},
confirmMetamaskDecryptionRequest: async () => {
const confirmed = await metamask.confirmDecryptionRequest();
return confirmed;
},
rejectMetamaskDecryptionRequest: async () => {
const rejected = await metamask.rejectDecryptionRequest();
return rejected;
},
confirmMetamaskPermissionToSpend: async () => {
const confirmed = await metamask.confirmPermissionToSpend();
return confirmed;
Expand Down
8 changes: 8 additions & 0 deletions support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ Cypress.Commands.add('rejectMetamaskEncryptionPublicKeyRequest', () => {
return cy.task('rejectMetamaskEncryptionPublicKeyRequest');
});

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

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

Cypress.Commands.add('rejectMetamaskSignatureRequest', () => {
return cy.task('rejectMetamaskSignatureRequest');
});
Expand Down
12 changes: 12 additions & 0 deletions support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ declare namespace Cypress {
* cy.rejectMetamaskEncryptionPublicKeyRequest()
*/
rejectMetamaskEncryptionPublicKeyRequest(): Chainable<Subject>;
/**
* Confirm metamask request to decrypt message with private key
* @example
* cy.confirmMetamaskDecryptionRequest()
*/
confirmMetamaskDecryptionRequest(): Chainable<Subject>;
/**
* Reject metamask request to decrypt message with private key
* @example
* cy.rejectMetamaskDecryptionRequest()
*/
rejectMetamaskDecryptionRequest(): Chainable<Subject>;
/**
* Confirm metamask permission to spend asset
* @example
Expand Down

0 comments on commit 491b5b5

Please sign in to comment.