Skip to content

Commit

Permalink
refactor: changed args for setupWallet
Browse files Browse the repository at this point in the history
  • Loading branch information
frazarshad committed Mar 8, 2024
1 parent 7d67904 commit 58b7a5a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 26 deletions.
28 changes: 15 additions & 13 deletions support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,22 +410,24 @@ Cypress.Commands.add(
);

// Keplr Commands
Cypress.Commands.add(
'setupWallet',
(
secretWordsOrPrivateKey = 'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology',
Cypress.Commands.add('setupWallet', (args = {}) => {
const {
secretWords,
privateKey,
password = 'Test1234',
newAccount = false,
walletName = 'My Wallet',
) => {
return cy.task('setupWallet', {
secretWordsOrPrivateKey,
password,
newAccount,
walletName,
});
},
);
} = args;
return cy.task('setupWallet', {
secretWordsOrPrivateKey:
secretWords ||
privateKey ||
'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology',
password,
newAccount,
walletName,
});
});

Cypress.Commands.add('acceptAccess', () => {
return cy.task('acceptAccess');
Expand Down
18 changes: 18 additions & 0 deletions support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,5 +505,23 @@ declare namespace Cypress {
viewportWidth: number,
viewportHeight: number,
): Chainable<Subject>;
/**
* Generic method to setup wallet (works for keplr only)
* @example
* cy.setupWallet();
* cy.setupWallet({
* secretWords: 'test test test test test test test test test test test junk',
* password: 'Password123',
* });
*/
setupWallet(
args: {
secretWords?: String;
privateKey?: String;
password?: String;
newAccount?: Boolean;
walletName?: String;
}
): Chainable<Subject>;
}
}
26 changes: 13 additions & 13 deletions tests/e2e/specs/keplr/keplr-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ describe('Keplr', () => {
);
});
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 => {
cy.setupWallet({
secretWords:
'orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology',
password: 'Test1234',
newAccount: true,
walletName: 'My Wallet 2',
}).then(setupFinished => {
expect(setupFinished).to.be.true;
});
});
it(`should complete Keplr setup by importing the wallet using private key`, () => {
cy.setupWallet(
'A9C09B6E4AF70DE1F1B621CB1AA66CFD0B4AA977E4C18497C49132DD9E579485',
null,
false,
'My wallet 3',
).then(setupFinished => {
cy.setupWallet({
privateKey:
'A9C09B6E4AF70DE1F1B621CB1AA66CFD0B4AA977E4C18497C49132DD9E579485',
walletName: 'My wallet 3',
}).then(setupFinished => {
expect(setupFinished).to.be.true;
});
});
Expand Down Expand Up @@ -119,4 +119,4 @@ describe('Keplr', () => {
});
});
});
});
});

0 comments on commit 58b7a5a

Please sign in to comment.