Skip to content

Commit

Permalink
Interaction for transaction rejection (#12)
Browse files Browse the repository at this point in the history
* feat: added logic for transaction rejection

* feat: added test for transaction rejection

* fix: typo in test name
  • Loading branch information
frazarshad authored Mar 4, 2024
1 parent f026bce commit 1081dc0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions commands/keplr.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ const keplr = {
return true;
},

async rejectTransaction() {
const notificationPage = await playwright.switchToKeplrNotification();
await notificationPage.close();
return true;
},

async initialSetup(
playwrightInstance,
{ secretWordsOrPrivateKey, password, newAccount },
Expand Down
1 change: 1 addition & 0 deletions plugins/keplr-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module.exports = (on, config) => {
acceptAccess: keplr.acceptAccess,
rejectAccess: keplr.rejectAccess,
confirmTransaction: keplr.confirmTransaction,
rejectTransaction: keplr.rejectTransaction,
disconnectWalletFromDapp: keplr.disconnectWalletFromDapp,
setupWallet: async ({ secretWordsOrPrivateKey, password, newAccount }) => {
await keplr.initialSetup(null, {
Expand Down
4 changes: 4 additions & 0 deletions support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ Cypress.Commands.add('confirmTransaction', () => {
return cy.task('confirmTransaction');
});

Cypress.Commands.add('rejectTransaction', () => {
return cy.task('rejectTransaction');
});

Cypress.Commands.add('isExtensionWindowActive', () => {
return cy.task('isExtensionWindowActive');
});
Expand Down
14 changes: 14 additions & 0 deletions tests/e2e/specs/keplr/keplr-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ describe('Keplr', () => {
expect(taskCompleted).to.be.true;
});
});
it(`should reject make an offer transaction`, () => {
const alertShown = cy.stub().as('alertShown');
cy.on('window:alert', alertShown);

cy.contains('Make an Offer').click();
cy.rejectTransaction().then(taskCompleted => {
expect(taskCompleted).to.be.true;
});

cy.get('@alertShown').should(
'have.been.calledOnceWith',
'Offer error: Error: Request rejected',
);
});
it(`should confirm make an offer transaction`, () => {
const alertShown = cy.stub().as('alertShown');
cy.on('window:alert', alertShown);
Expand Down

0 comments on commit 1081dc0

Please sign in to comment.