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

Initial setup to integrate Keplr with Synpress #1

Merged
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
146 changes: 146 additions & 0 deletions commands/keplr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
const log = require('debug')('synpress:keplr');
const playwright = require('./playwright-keplr');
const { onboardingElements } = require('../pages/keplr/first-time-flow-page');
const {
notificationPageElements,
} = require('../pages/keplr/notification-page');

let extensionId;
let extensionVersion;

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

async getExtensionDetails() {
const keplrExtensionData = (await playwright.getExtensionsData()).keplr;

extensionId = keplrExtensionData.id;
extensionVersion = keplrExtensionData.version;

return {
extensionId,
extensionVersion,
};
},

async importWallet(secretWords, password) {
await playwright.waitAndClickByText(
onboardingElements.createWalletButton,
await playwright.keplrWindow(),
);
await playwright.waitAndClickByText(
onboardingElements.importRecoveryPhraseButton,
await playwright.keplrWindow(),
);
await playwright.waitAndClickByText(
onboardingElements.useRecoveryPhraseButton,
await playwright.keplrWindow(),
);
await playwright.waitAndClickByText(
onboardingElements.phraseCount24,
await playwright.keplrWindow(),
);

for (const [index, word] of secretWords.split(' ').entries()) {
await playwright.waitAndTypeByLocator(
onboardingElements.textAreaSelector,
word,
index,
);
}

await playwright.waitAndClick(
onboardingElements.submitPhraseButton,
await playwright.keplrWindow(),
);

await playwright.waitAndType(
onboardingElements.walletInput,
onboardingElements.walletName,
);
await playwright.waitAndType(onboardingElements.passwordInput, password);
await playwright.waitAndType(
onboardingElements.confirmPasswordInput,
password,
);

await playwright.waitAndClick(
onboardingElements.submitWalletDataButton,
await playwright.keplrWindow(),
{ number: 1 },
);

await playwright.waitForByText(
onboardingElements.phraseSelectChain,
await playwright.keplrWindow(),
);

await playwright.waitAndClick(
onboardingElements.submitChainButton,
await playwright.keplrWindow(),
);

await playwright.waitForByText(
onboardingElements.phraseAccountCreated,
await playwright.keplrWindow(),
);

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

return true;
},

async acceptAccess() {
const notificationPage = await playwright.switchToKeplrNotification();
await playwright.waitAndClick(
notificationPageElements.approveButton,
notificationPage,
{ waitForEvent: 'close' },
);
return true;
},

async confirmTransaction() {
const notificationPage = await playwright.switchToKeplrNotification();
await playwright.waitAndClick(
notificationPageElements.approveButton,
notificationPage,
{ waitForEvent: 'close' },
);
return true;
},

async initialSetup(
playwrightInstance,
{ secretWordsOrPrivateKey, password },
) {
if (playwrightInstance) {
await playwright.init(playwrightInstance);
} else {
await playwright.init();
}

await playwright.assignWindows();
await playwright.assignActiveTabName('keplr');
await module.exports.getExtensionDetails();
await module.exports.importWallet(secretWordsOrPrivateKey, password);
},
};

module.exports = keplr;
2 changes: 1 addition & 1 deletion commands/metamask.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const log = require('debug')('synpress:metamask');
const playwright = require('./playwright');
const playwright = require('./playwright-metamask');
const sleep = require('util').promisify(setTimeout);

const {
Expand Down
Loading