Skip to content

Commit

Permalink
chore: revert to old logic for handlign wallet access
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Mar 1, 2024
1 parent 5543a63 commit 0fb4a79
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 32 deletions.
27 changes: 4 additions & 23 deletions commands/keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions commands/playwright-keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ module.exports = {
retries = 0;
await page.bringToFront();
await module.exports.waitUntilStable(page);
return { page, err: false };
return page

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (91% of all statements in
the enclosing function
have an explicit semicolon).
}
}
await sleep(200);
Expand All @@ -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.',
);
}
},
};
7 changes: 3 additions & 4 deletions tests/e2e/specs/keplr/keplr-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
Expand Down

0 comments on commit 0fb4a79

Please sign in to comment.