diff --git a/support/commands.js b/support/commands.js index d8399b5b4..3179a0ea8 100644 --- a/support/commands.js +++ b/support/commands.js @@ -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'); diff --git a/support/index.d.ts b/support/index.d.ts index 820a9dcae..4cf9717ae 100644 --- a/support/index.d.ts +++ b/support/index.d.ts @@ -505,5 +505,23 @@ declare namespace Cypress { viewportWidth: number, viewportHeight: number, ): Chainable; + /** + * 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; } } diff --git a/tests/e2e/specs/keplr/keplr-spec.js b/tests/e2e/specs/keplr/keplr-spec.js index 8015d853e..a2f9b1791 100644 --- a/tests/e2e/specs/keplr/keplr-spec.js +++ b/tests/e2e/specs/keplr/keplr-spec.js @@ -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; }); }); @@ -119,4 +119,4 @@ describe('Keplr', () => { }); }); }); -}); \ No newline at end of file +});