diff --git a/commands/metamask.js b/commands/metamask.js index e1b6ae460..c2021ab5d 100644 --- a/commands/metamask.js +++ b/commands/metamask.js @@ -424,8 +424,14 @@ module.exports = { await puppeteer.metamaskWindow().waitForTimeout(1000); return true; }, - acceptAccess: async () => { + acceptAccess: async (allAccounts) => { const notificationPage = await puppeteer.switchToMetamaskNotification(); + if (allAccounts === true) { + await puppeteer.waitAndClick( + notificationPageElements.selectAllCheck, + notificationPage, + ); + } await puppeteer.waitAndClick( notificationPageElements.nextButton, notificationPage, diff --git a/pages/metamask/notification-page.js b/pages/metamask/notification-page.js index 6a651a8da..4f2c4d158 100644 --- a/pages/metamask/notification-page.js +++ b/pages/metamask/notification-page.js @@ -2,11 +2,13 @@ const notificationPage = '.notification'; const nextButton = `${notificationPage} .permissions-connect-choose-account__bottom-buttons button:nth-child(2)`; const allowToSpendButton = `${notificationPage} [data-testid="page-container-footer-next"]`; const rejectToSpendButton = `${notificationPage} [data-testid="page-container-footer-cancel"]`; +const selectAllCheck = `${notificationPage} .permissions-connect-choose-account__header-check-box`; module.exports.notificationPageElements = { notificationPage, nextButton, allowToSpendButton, rejectToSpendButton, + selectAllCheck, }; const confirmSignatureRequestButton = `${notificationPage} .request-signature__footer__sign-button`; diff --git a/plugins/index.js b/plugins/index.js index 8d0f91271..e84426930 100644 --- a/plugins/index.js +++ b/plugins/index.js @@ -155,8 +155,8 @@ module.exports = (on, config) => { const rejected = await metamask.rejectPermissionToSpend(); return rejected; }, - acceptMetamaskAccess: async () => { - const accepted = await metamask.acceptAccess(); + acceptMetamaskAccess: async (allAccounts) => { + const accepted = await metamask.acceptAccess(allAccounts); return accepted; }, confirmMetamaskTransaction: async gasConfig => { diff --git a/support/commands.js b/support/commands.js index 611329a41..1efcc2f58 100644 --- a/support/commands.js +++ b/support/commands.js @@ -95,8 +95,8 @@ Cypress.Commands.add('rejectMetamaskPermissionToSpend', () => { return cy.task('rejectMetamaskPermissionToSpend'); }); -Cypress.Commands.add('acceptMetamaskAccess', () => { - return cy.task('acceptMetamaskAccess'); +Cypress.Commands.add('acceptMetamaskAccess', (allAccounts) => { + return cy.task('acceptMetamaskAccess', allAccounts); }); Cypress.Commands.add('confirmMetamaskTransaction', gasConfig => { diff --git a/support/index.d.ts b/support/index.d.ts index 8b5ecd0f1..a6024dcc9 100644 --- a/support/index.d.ts +++ b/support/index.d.ts @@ -148,8 +148,9 @@ declare namespace Cypress { * Accept metamask access request * @example * cy.acceptMetamaskAccess() + * cy.acceptMetamaskAccess(true) */ - acceptMetamaskAccess(): Chainable; + acceptMetamaskAccess(allAccounts: boolean | undefined): Chainable; /** * Confirm metamask atransaction * @example