diff --git a/commands/keplr.js b/commands/keplr.js index 98ed4d8b3..978703747 100644 --- a/commands/keplr.js +++ b/commands/keplr.js @@ -141,39 +141,20 @@ const keplr = { ); }, async acceptAccess() { - const result = await playwright.switchToKeplrNotification(); - - if ( - result.err && - result.message === 'Unable to Switch to Notification Window' - ) { - let pages = await playwright.browser().contexts()[0].pages(); - - for (const page of pages) { - const pageContent = await page.textContent('html'); - if ( - pageContent.includes('agoric1p2aqakv3ulz4qfy2nut86j9gx0dx0yw09h96md') - ) { - return true; - } - } - - return false; - } - + const notificationPage = await playwright.switchToKeplrNotification(); await playwright.waitAndClick( notificationPageElements.approveButton, - result.page, + notificationPage, { waitForEvent: 'close' }, ); return true; }, async confirmTransaction() { - const result = await playwright.switchToKeplrNotification(); + const notificationPage = await playwright.switchToKeplrNotification(); await playwright.waitAndClick( notificationPageElements.approveButton, - result.page, + notificationPage, { waitForEvent: 'close' }, ); return true; diff --git a/commands/playwright-keplr.js b/commands/playwright-keplr.js index 12d7e8b71..566a8cc14 100644 --- a/commands/playwright-keplr.js +++ b/commands/playwright-keplr.js @@ -385,7 +385,7 @@ module.exports = { retries = 0; await page.bringToFront(); await module.exports.waitUntilStable(page); - return { page, err: false }; + return page } } await sleep(200); @@ -394,10 +394,9 @@ module.exports = { return await module.exports.switchToKeplrNotification(); } else if (retries >= 50) { retries = 0; - return { - err: true, - message: 'Unable to Switch to Notification Window', - }; + throw new Error( + '[switchToKeplrNotification] Max amount of retries to switch to keplr notification window has been reached. It was never found.', + ); } }, }; diff --git a/tests/e2e/specs/keplr/keplr-spec.js b/tests/e2e/specs/keplr/keplr-spec.js index fff79e212..0ae80d618 100644 --- a/tests/e2e/specs/keplr/keplr-spec.js +++ b/tests/e2e/specs/keplr/keplr-spec.js @@ -24,11 +24,10 @@ describe('Keplr', () => { expect(setupFinished).to.be.true; cy.visit('/'); + // We're not calling the acceptAccess function + // The assumption here is that user is already connected to the wallet when the first test case ran cy.contains('Connect Wallet').click(); - cy.acceptAccess().then(taskCompleted => { - expect(taskCompleted).to.be.true; - cy.makeOfferAndConfirmTransaction(); - }); + cy.makeOfferAndConfirmTransaction(); }); }); });