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

Single Screen Interaction, Approve Button Fix and Code Cleanup #9

Merged
merged 6 commits into from
Mar 4, 2024
Merged
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;
frazarshad marked this conversation as resolved.
Show resolved Hide resolved
},
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
Loading