From 80f7a08765c61b706c627404b05f23b77c27bb13 Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Tue, 22 Aug 2023 16:15:33 +0100 Subject: [PATCH] test(governance): vote error test (#4588) --- .../integration/flow/proposal-details.cy.ts | 28 +++++++++++++++++++ .../src/support/staking.functions.ts | 5 ++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts b/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts index cef462d61..13b7e19bb 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts @@ -361,6 +361,34 @@ describe( stakingPageDisassociateAllTokens(); }); + it('Error message should be displayed if error returned from wallet when voting', function () { + const errorMsg = + 'Application error: party has already submitted the maximum number of transactions of this type per epoch (3)'; + + createRawProposal(); + cy.get('@rawProposal').then((rawProposal) => { + getProposalFromTitle(rawProposal.rationale.title).within(() => + cy.getByTestId(viewProposalButton).click() + ); + cy.intercept('POST', '/api/v2/requests', { + jsonrpc: '2.0', + error: { + code: 2001, + message: 'Application error', + data: 'party has already submitted the maximum number of transactions of this type per epoch (3)', + }, + id: '-PK5EGmErnjLhAmzMeclC', + }); + cy.contains('Vote breakdown').should('be.visible', { timeout: 10000 }); + cy.getByTestId('vote-buttons').contains('for').click(); + cy.getByTestId('dialog-title').should( + 'have.text', + 'Transaction failed' + ); + cy.getByTestId('Error').should('have.text', errorMsg); + }); + }); + it('Able to see successor market details with new and updated values', function () { cy.createMarket(); cy.reload(); diff --git a/apps/governance-e2e/src/support/staking.functions.ts b/apps/governance-e2e/src/support/staking.functions.ts index 4f99e0964..cd198783d 100644 --- a/apps/governance-e2e/src/support/staking.functions.ts +++ b/apps/governance-e2e/src/support/staking.functions.ts @@ -183,9 +183,8 @@ export function clickOnValidatorFromList( cy.get(`[row-id="${validatorNumber}"]`) .should('be.visible') .first() - .within(() => { - cy.get(stakeValidatorListName).click(); - }); + .as('validatorOnList'); + cy.get('@validatorOnList').click(); } }