Skip to content

Commit

Permalink
Single Screen Interaction, Approve Button Fix and Code Cleanup (#9)
Browse files Browse the repository at this point in the history
* chore: organize code in playwright.keplr.js and remove not used states

* chore: resolve merge conflicts with dev branch

* chore: using a consistent and more intention revealing name for a helper function

* chore: adding a test case for validating the switchToExtensionWindow function

* chore: change selector for Approve button on connecting with wallet UI

* chore: addressing PR comments
  • Loading branch information
rabi-siddique authored Mar 4, 2024
1 parent fcbd07f commit f026bce
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 221 deletions.
46 changes: 36 additions & 10 deletions commands/keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,72 @@ const {

let extensionId;
let extensionVersion;
let registrationUrl;
let permissionsUrl;
let switchBackToCypressWindow;

const keplr = {
async resetState() {
log('Resetting state of keplr');
extensionId = undefined;
extensionVersion = undefined;
registrationUrl = undefined;
permissionsUrl = undefined;
},
extensionId: () => {
return extensionId;
},
extensionUrls: () => {
return {
extensionImportAccountUrl,
registrationUrl,
permissionsUrl,
};
},

async goTo(url) {
await Promise.all([
playwright.keplrWindow().waitForNavigation(),
playwright.keplrWindow().goto(url),
]);
await playwright.waitUntilStable();
},
async goToRegistration() {
await module.exports.goTo(registrationUrl);
},
async goToPermissions() {
await module.exports.goTo(permissionsUrl);
},
async switchToKeplrIfNotActive() {
if (await playwright.isCypressWindowActive()) {
await playwright.switchToKeplrWindow();
switchBackToCypressWindow = true;
}
return switchBackToCypressWindow;
},
async getExtensionDetails() {
const keplrExtensionData = (await playwright.getExtensionsData()).keplr;

extensionId = keplrExtensionData.id;
extensionVersion = keplrExtensionData.version;
registrationUrl = `chrome-extension://${extensionId}/register.html`;
permissionsUrl = `chrome-extension://${extensionId}/popup.html#/setting/security/permission`;

return {
extensionId,
extensionVersion,
registrationUrl,
permissionsUrl,
};
},
async disconnectWalletFromDapp() {
await module.exports.goToPermissions();
await playwright.waitAndClickByText(
'Disconnect All',
playwright.keplrPermissionWindow(),
playwright.keplrWindow(),
);
return true;
},
async importWallet(secretWordsOrPrivateKey, password, newAccount) {
await module.exports.goToRegistration();
await playwright.waitAndClickByText(
newAccount
? onboardingElements.createWalletButton
Expand Down Expand Up @@ -79,7 +110,7 @@ const keplr = {
onboardingElements.walletName,
);

const passwordFieldExists = await playwright.doesElementExist(
const passwordFieldExists = await playwright.waitForAndCheckElementExistence(
onboardingElements.passwordInput,
);

Expand Down Expand Up @@ -112,12 +143,7 @@ const keplr = {
await playwright.keplrWindow(),
);

await playwright.waitAndClick(
onboardingElements.finishButton,
await playwright.keplrWindow(),
{ dontWait: true },
);

await playwright.switchToCypressWindow();
return true;
},
async importWalletWithPhrase(secretWords) {
Expand Down
1 change: 1 addition & 0 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ const metamask = {
return true;
},
async disconnectWalletFromDapp() {
await playwright.switchToKeplrWindow();
await switchToMetamaskIfNotActive();
await playwright.waitAndClick(mainPageElements.optionsMenu.button);
await playwright.waitAndClick(
Expand Down
Loading

0 comments on commit f026bce

Please sign in to comment.