Skip to content

Commit

Permalink
feature: adding behavior in import wallet flow to select a chain when…
Browse files Browse the repository at this point in the history
… importing/creating wallet
  • Loading branch information
rabi-siddique committed Mar 6, 2024
1 parent 4665470 commit c4bf858
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
20 changes: 16 additions & 4 deletions commands/keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ const keplr = {
await playwright.keplrWindow(),
);

await playwright.waitAndClick(
onboardingElements.submitChainButton,
await playwright.keplrWindow(),
);
await module.exports.handleSelectChain();

await playwright.waitForByText(
onboardingElements.phraseAccountCreated,
Expand All @@ -170,6 +167,21 @@ const keplr = {

return true;
},
async handleSelectChain() {
const chainNameExists = await playwright.waitForAndCheckElementExistence(onboardingElements.chainNameSelector);

if (chainNameExists) {
await playwright.waitAndClickByText(onboardingElements.chainName, playwright.keplrWindow());
await playwright.waitAndClick(onboardingElements.submitChainButton, playwright.keplrWindow());
const importButtonExists = await playwright.waitForAndCheckElementExistence(onboardingElements.importButtonSelector);

if (importButtonExists) {
await playwright.waitAndClick(onboardingElements.importButtonSelector, playwright.keplrWindow());
}
} else {
await playwright.waitAndClick(onboardingElements.submitChainButton, playwright.keplrWindow());
}
},
async importWalletWithPhrase(secretWords) {
await playwright.waitAndClickByText(
onboardingElements.phraseCount24,
Expand Down
1 change: 1 addition & 0 deletions commands/playwright-keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ module.exports = {
page = keplrWindow,
) {
try {
await module.exports.waitUntilStable(page);
await page.waitForSelector(selector, { timeout });
return true;
} catch (error) {
Expand Down
6 changes: 6 additions & 0 deletions pages/keplr/first-time-flow-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ const phraseAccountCreated = 'Account Created!';
const finishButton = 'button[type="button"]';
const textAreaSelector = 'textbox';
const submitPhraseButton = 'button[type="submit"]';
const chainName = 'Agoric local'
const chainNameSelector = 'text=Agoric local'
const importButtonSelector = 'button:has-text("Import")'

module.exports.onboardingElements = {
existingWalletButton,
createWalletButton,
importRecoveryPhraseButton,
useRecoveryPhraseButton,
chainNameSelector,
importButtonSelector,
phraseCount24,
phrasePrivateKey,
walletInput,
Expand All @@ -32,4 +37,5 @@ module.exports.onboardingElements = {
finishButton,
textAreaSelector,
submitPhraseButton,
chainName
};
22 changes: 11 additions & 11 deletions tests/e2e/specs/keplr/keplr-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@

describe('Keplr', () => {
context('Test commands', () => {
it(`should create a new wallet using 24 word phrase`, () => {
cy.setupWallet(
'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology',
'Test1234',
true,
'My Wallet 2',
).then(setupFinished => {
it(`should complete Keplr setup by importing an existing wallet using 24 word phrase`, () => {
cy.setupWallet().then(setupFinished => {
expect(setupFinished).to.be.true;
});
cy.visit('/');
});
it(`should reject connection with wallet`, () => {
cy.visit('/');
const alertShown = cy.stub().as('alertShown');
cy.on('window:alert', alertShown);

Expand Down Expand Up @@ -60,8 +55,13 @@ describe('Keplr', () => {
'Offer accepted',
);
});
it(`should complete Keplr setup by importing an existing wallet using 24 word phrase`, () => {
cy.setupWallet().then(setupFinished => {
it(`should create a new wallet using 24 word phrase`, () => {
cy.setupWallet(
'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology',
'Test1234',
true,
'My Wallet 2',
).then(setupFinished => {
expect(setupFinished).to.be.true;
});
});
Expand Down Expand Up @@ -105,4 +105,4 @@ describe('Keplr', () => {
});
});
});
});
});

0 comments on commit c4bf858

Please sign in to comment.