Skip to content

Commit

Permalink
fix: fixed implementation of waitAndClickByText to perform exact matc…
Browse files Browse the repository at this point in the history
…hing
  • Loading branch information
frazarshad committed Mar 1, 2024
1 parent e48a42b commit d3be1b9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
20 changes: 15 additions & 5 deletions commands/keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const keplr = {
};
},

async importWallet(secretWords, password, newAccount) {
async importWallet(secretWordsOrPrivateKey, password, newAccount) {
await playwright.waitAndClickByText(
newAccount
? onboardingElements.createWalletButton
Expand All @@ -56,10 +56,16 @@ const keplr = {
await playwright.keplrWindow(),
));

if (secretWords.includes(' ')) {
await module.exports.importWalletWithPhrase(secretWords, password);
if (secretWordsOrPrivateKey.includes(' ')) {
await module.exports.importWalletWithPhrase(
secretWordsOrPrivateKey,
password,
);
} else {
await module.exports.importWalletWithPrivateKey(secretWords, password);
await module.exports.importWalletWithPrivateKey(
secretWordsOrPrivateKey,
password,
);
}

await playwright.waitAndType(
Expand Down Expand Up @@ -128,7 +134,11 @@ const keplr = {
);
},
async importWalletWithPrivateKey(privateKey) {
await playwright.clickByText(onboardingElements.phrasePrivateKey);
await playwright.waitAndClickByText(
onboardingElements.phrasePrivateKey,
await playwright.keplrWindow(),
true,
);

await playwright.waitAndTypeByLocator(
onboardingElements.textAreaSelector,
Expand Down
12 changes: 5 additions & 7 deletions commands/playwright-keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,9 @@ module.exports = {
return keplrNotificationWindow;
},

async clickByText(text, page = keplrWindow) {
await page.click(`text="${text}"`);
},

async waitAndClickByText(text, page = keplrWindow) {
async waitAndClickByText(text, page = keplrWindow, exact = false) {
await module.exports.waitForByText(text, page);
const element = `:is(:text-is("${text}"), :text("${text}"))`;
const element = `:is(:text-is("${text}")${exact ? '' : `, :text("${text}")`})`;
await page.click(element);
await module.exports.waitUntilStable();
},
Expand Down Expand Up @@ -362,7 +358,9 @@ module.exports = {
const keplrExtensionData = (await module.exports.getExtensionsData()).keplr;
const browserContext = await browser.contexts()[0];
keplrRegistrationWindow = await browserContext.newPage();
await keplrRegistrationWindow.goto(`chrome-extension://${keplrExtensionData.id}/register.html`);
await keplrRegistrationWindow.goto(
`chrome-extension://${keplrExtensionData.id}/register.html`,
);
return true;
},
async switchToKeplrNotification() {
Expand Down

0 comments on commit d3be1b9

Please sign in to comment.