Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstracting Calls to Switching Extension in Keplr Helper Methods #13

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions commands/keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const keplr = {
await module.exports.goTo(permissionsUrl);
},
async switchToKeplrIfNotActive() {
if (await playwright.isCypressWindowActive()) {
if (playwright.isCypressWindowActive()) {
await playwright.switchToKeplrWindow();
switchBackToCypressWindow = true;
}
Expand Down Expand Up @@ -225,7 +225,10 @@ const keplr = {
}

await playwright.assignWindows();
await playwright.assignActiveTabName('keplr');
if (!playwright.isKeplrWindowActive()) {
await playwright.switchToKeplrWindow();
}
playwright.assignActiveTabName('keplr');
await module.exports.getExtensionDetails();
await module.exports.importWallet(
secretWordsOrPrivateKey,
Expand Down
10 changes: 5 additions & 5 deletions commands/playwright-keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ module.exports = {
keplrNotificationWindow() {
return keplrNotificationWindow;
},
async assignActiveTabName(tabName) {
assignActiveTabName(tabName) {
activeTabName = tabName;
return true;
},
async isKeplrWindowActive() {
isKeplrWindowActive() {
return activeTabName === 'keplr';
},
async isCypressWindowActive() {
isCypressWindowActive() {
Comment on lines +37 to +44
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check all references to these functions and remove the await if they're called with it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return activeTabName === 'cypress';
},
async switchToKeplrWindow() {
await keplrWindow.bringToFront();
await module.exports.assignActiveTabName('keplr');
module.exports.assignActiveTabName('keplr');
return true;
},
async switchToCypressWindow() {
if (mainWindow) {
await mainWindow.bringToFront();
await module.exports.assignActiveTabName('cypress');
module.exports.assignActiveTabName('cypress');
}
return true;
},
Expand Down
24 changes: 10 additions & 14 deletions tests/e2e/specs/keplr/keplr-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,19 @@ describe('Keplr', () => {
);
});
it(`should create a new wallet using 24 word phrase`, () => {
cy.switchToExtensionWindow().then(() => {
cy.setupWallet(
'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology',
'Test1234',
true,
).then(setupFinished => {
expect(setupFinished).to.be.true;
});
cy.setupWallet(
'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology',
'Test1234',
true,
).then(setupFinished => {
expect(setupFinished).to.be.true;
});
});
it(`should complete Keplr setup by importing the wallet using private key`, () => {
cy.switchToExtensionWindow().then(() => {
cy.setupWallet(
'A9C09B6E4AF70DE1F1B621CB1AA66CFD0B4AA977E4C18497C49132DD9E579485',
).then(setupFinished => {
expect(setupFinished).to.be.true;
});
cy.setupWallet(
'A9C09B6E4AF70DE1F1B621CB1AA66CFD0B4AA977E4C18497C49132DD9E579485',
).then(setupFinished => {
expect(setupFinished).to.be.true;
});
});
it(`should disconnect the wallet from all the connected DAPPs`, () => {
Expand Down
Loading