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
50 changes: 40 additions & 10 deletions commands/keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,76 @@ const {

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

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) {
const keplrWindow = playwright.keplrWindow();
const currentUrl = await keplrWindow.url();
if (!currentUrl.includes('registr')) {
frazarshad marked this conversation as resolved.
Show resolved Hide resolved
await module.exports.goToRegistration();
}

await playwright.waitAndClickByText(
newAccount
? onboardingElements.createWalletButton
Expand Down Expand Up @@ -79,7 +114,7 @@ const keplr = {
onboardingElements.walletName,
);

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

Expand Down Expand Up @@ -112,12 +147,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
Loading
Loading