From 0b33ed4299986f8ecfd49a868729243aa6b708de Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Mon, 26 Jun 2023 10:21:13 +0100 Subject: [PATCH] test(governance): 3802 multisig error test (#4169) --- .../src/fixtures/mocks/previous-epoch.ts | 63 +++++++++++++++++++ .../src/integration/view/validators.cy.ts | 19 ++++++ .../src/integration/view/wallet-vega.cy.ts | 34 +++++----- 3 files changed, 96 insertions(+), 20 deletions(-) create mode 100644 apps/governance-e2e/src/fixtures/mocks/previous-epoch.ts diff --git a/apps/governance-e2e/src/fixtures/mocks/previous-epoch.ts b/apps/governance-e2e/src/fixtures/mocks/previous-epoch.ts new file mode 100644 index 000000000..f6a54ff9a --- /dev/null +++ b/apps/governance-e2e/src/fixtures/mocks/previous-epoch.ts @@ -0,0 +1,63 @@ +export const previousEpochData = { + epoch: { + id: '7611', + validatorsConnection: { + edges: [ + { + node: { + id: 'cd96782bc0ad5679869cf69fe7838a92212da7f53b4a214bed68067117494122', + stakedTotal: '3154229668720612941799', + rewardScore: { + rawValidatorScore: '0.2', + performanceScore: '1', + multisigScore: '0', + validatorScore: '0.2', + normalisedScore: '0.2007216887087119', + validatorStatus: 'VALIDATOR_NODE_STATUS_TENDERMINT', + __typename: 'RewardScore', + }, + rankingScore: { + status: 'VALIDATOR_NODE_STATUS_TENDERMINT', + previousStatus: 'VALIDATOR_NODE_STATUS_TENDERMINT', + rankingScore: '0.211713765544955625', + stakeScore: '0.2016321576618625', + performanceScore: '1', + votingPower: '2007', + __typename: 'RankingScore', + }, + __typename: 'Node', + }, + __typename: 'NodeEdge', + }, + { + node: { + id: '887d936f797a47032eceb572a13b69b581d3b1fa595a7d021a3e3cf2a5d2acfd', + stakedTotal: '3151161904761904764551', + rewardScore: { + rawValidatorScore: '0.2', + performanceScore: '1', + multisigScore: '1', + validatorScore: '0.2', + normalisedScore: '0.2007216887087119', + validatorStatus: 'VALIDATOR_NODE_STATUS_TENDERMINT', + __typename: 'RewardScore', + }, + rankingScore: { + status: 'VALIDATOR_NODE_STATUS_TENDERMINT', + previousStatus: 'VALIDATOR_NODE_STATUS_TENDERMINT', + rankingScore: '0.211507855409133255', + stakeScore: '0.2014360527706031', + performanceScore: '1', + votingPower: '2007', + __typename: 'RankingScore', + }, + __typename: 'Node', + }, + __typename: 'NodeEdge', + }, + ], + __typename: 'NodesConnection', + }, + __typename: 'Epoch', + }, +}; diff --git a/apps/governance-e2e/src/integration/view/validators.cy.ts b/apps/governance-e2e/src/integration/view/validators.cy.ts index 25dcabd14..8f8ecdf9b 100644 --- a/apps/governance-e2e/src/integration/view/validators.cy.ts +++ b/apps/governance-e2e/src/integration/view/validators.cy.ts @@ -1,5 +1,6 @@ /// +import { aliasGQLQuery } from '@vegaprotocol/cypress'; import { navigation, verifyPageHeader, @@ -9,6 +10,7 @@ import { clickOnValidatorFromList, waitForBeginningOfEpoch, } from '../../support/staking.functions'; +import { previousEpochData } from '../../fixtures/mocks/previous-epoch'; const guideLink = '[data-testid="staking-guide-link"]'; const validatorTitle = '[data-testid="validator-node-title"]'; @@ -30,6 +32,7 @@ const normalisedVotingPowerToolTip = '[data-testid="normalised-voting-power-tooltip"]'; const performancePenaltyToolTip = '[data-testid="performance-penalty-tooltip"]'; const overstakedPenaltyToolTip = '[data-testid="overstaked-penalty-tooltip"]'; +const multisigPenaltyToolTip = '[data-testid="multisig-error-tooltip"]'; const epochCountDown = '[data-testid="epoch-countdown"]'; const stakeNumberRegex = /^\d{1,3}(,\d{3})*(\.\d+)?$/; @@ -151,6 +154,22 @@ context('Validators Page - verify elements on page', function () { cy.wrap($pendingStake).should('contain.text', '0.00'); }); }); + + it('Should be able to see multisig error', function () { + cy.mockGQL((req) => { + aliasGQLQuery(req, 'PreviousEpoch', previousEpochData); + }); + waitForBeginningOfEpoch(); + cy.getByTestId('total-penalty').first().realHover(); + cy.get(multisigPenaltyToolTip) + .invoke('text') + .should('contain', 'Multisig penalty: 100%'); + + cy.getByTestId('total-penalty').eq(1).realHover(); + cy.get(multisigPenaltyToolTip) + .invoke('text') + .should('contain', 'Multisig penalty: 100%'); + }); } ); diff --git a/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts b/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts index 1a67a6472..d09479021 100644 --- a/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts +++ b/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts @@ -282,33 +282,33 @@ context( // 2002-SINC-016 describe('Vega wallet with assets', function () { const assets = [ + { + id: '816af99af60d684502a40824758f6b5377e6af48e50a9ee8ef478ecb879ea8bc', + name: 'USDC (fake)', + symbol: 'fUSDC', + amount: '1000000', + expectedAmount: 10.0, + }, { id: '8566db7257222b5b7ef2886394ad28b938b28680a54a169bbc795027b89d6665', name: 'DAI (fake)', symbol: 'fDAI', amount: '200000', - expectedAmount: '2.00', + expectedAmount: 2.0, }, { id: '73174a6fb1d5802ba0ac7bd7ab79e0a3a4837b262de0a4e80815a55442692bd0', name: 'BTC (fake)', symbol: 'fBTC', amount: '600000', - expectedAmount: '6.00', + expectedAmount: 6.0, }, { id: 'e02d4c15d790d1d2dffaf2dcd1cf06a1fe656656cf4ed18c8ce99f9e83643567', name: 'EURO (fake)', symbol: 'fEURO', amount: '800000', - expectedAmount: '8.00', - }, - { - id: '816af99af60d684502a40824758f6b5377e6af48e50a9ee8ef478ecb879ea8bc', - name: 'USDC (fake)', - symbol: 'fUSDC', - amount: '1000000', - expectedAmount: '10.00', + expectedAmount: 8.0, }, ]; @@ -319,12 +319,6 @@ context( cy.reload(); waitForSpinner(); cy.connectVegaWallet(); - cy.get(walletContainer).within(() => { - cy.getByTestId('currency-title', txTimeout).should( - 'have.length.at.least', - 5 - ); - }); }); for (const { name, symbol, expectedAmount } of assets) { @@ -338,10 +332,10 @@ context( .contains(name) .parent() .siblings() - .invoke('text') - .should('have.length.at.least', 4) - .then(parseFloat) - .should('be.gte', parseFloat(expectedAmount)); + .then((elementAmount) => { + const displayedAmount = parseFloat(elementAmount.text()); + expect(displayedAmount).be.gte(expectedAmount); + }); cy.get(vegaWalletCurrencyTitle) .contains(name)