From 288f075cacbcc083d2be86767584ea9ce9033374 Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Wed, 3 May 2023 11:23:17 +0100 Subject: [PATCH] test(governance): e2e tests updated to cypress 12 (#3582) --- .../src/fixtures/proposals/new-market.json | 2 +- .../integration/flow/proposal-details.cy.ts | 13 +- .../integration/flow/proposal-enacted.cy.ts | 14 +- .../src/integration/flow/proposal-flow.cy.ts | 1 + .../src/integration/flow/proposal-forms.cy.ts | 23 +- .../src/integration/flow/proposal-list.cy.ts | 6 +- .../src/integration/flow/rewards-flow.cy.ts | 17 +- .../src/integration/flow/staking-flow.cy.ts | 2 +- .../flow/token-association-flow.cy.ts | 197 ++++++++++++------ .../integration/flow/withdrawal-flow.cy.ts | 91 ++++---- .../src/support/governance.functions.ts | 5 +- .../src/support/wallet-teardown.functions.ts | 77 ++++--- 12 files changed, 281 insertions(+), 167 deletions(-) diff --git a/apps/governance-e2e/src/fixtures/proposals/new-market.json b/apps/governance-e2e/src/fixtures/proposals/new-market.json index d9875eabb..eb3368324 100644 --- a/apps/governance-e2e/src/fixtures/proposals/new-market.json +++ b/apps/governance-e2e/src/fixtures/proposals/new-market.json @@ -9,7 +9,7 @@ "name": "Token test market", "code": "Token.24h", "future": { - "settlementAsset": "fBTC", + "settlementAsset": "73174a6fb1d5802ba0ac7bd7ab79e0a3a4837b262de0a4e80815a55442692bd0", "quoteName": "fBTC", "dataSourceSpecForSettlementData": { "external": { 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 5e9de85ec..611568056 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts @@ -49,6 +49,7 @@ describe( }); beforeEach('visit proposals tab', function () { + cy.clearLocalStorage(); cy.reload(); waitForSpinner(); cy.connectVegaWallet(); @@ -217,9 +218,9 @@ describe( vegaWalletSetSpecifiedApprovalAmount('1000'); createRawProposal(); cy.get('@rawProposal').then((rawProposal) => { - getSubmittedProposalFromProposalList(rawProposal.rationale.title) - .as('submittedProposal') - .within(() => cy.get(viewProposalButton).click()); + getSubmittedProposalFromProposalList( + rawProposal.rationale.title + ).within(() => cy.get(viewProposalButton).click()); }); voteForProposal('for'); // 3001-VOTE-079 @@ -237,9 +238,9 @@ describe( ); navigateTo(navigation.proposals); cy.get('@rawProposal').then((rawProposal) => { - getSubmittedProposalFromProposalList(rawProposal.rationale.title) - .as('submittedProposal') - .within(() => cy.get(viewProposalButton).click()); + getSubmittedProposalFromProposalList( + rawProposal.rationale.title + ).within(() => cy.get(viewProposalButton).click()); }); cy.get(proposalVoteProgressForPercentage) .contains('100.00%') diff --git a/apps/governance-e2e/src/integration/flow/proposal-enacted.cy.ts b/apps/governance-e2e/src/integration/flow/proposal-enacted.cy.ts index 5f1fa01d9..293437d45 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-enacted.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-enacted.cy.ts @@ -16,6 +16,7 @@ import { import { ethereumWalletConnect } from '../../support/wallet-eth.functions'; import { vegaWalletSetSpecifiedApprovalAmount } from '../../support/wallet-teardown.functions'; +const proposalListItem = '[data-testid="proposals-list-item"]'; const closedProposals = '[data-testid="closed-proposals"]'; const proposalStatus = '[data-testid="proposal-status"]'; const viewProposalButton = '[data-testid="view-proposal-btn"]'; @@ -35,6 +36,7 @@ context( }); beforeEach('visit proposals', function () { + cy.clearLocalStorage(); cy.reload(); waitForSpinner(); cy.connectVegaWallet(); @@ -51,7 +53,8 @@ context( waitForSpinner(); cy.get(closedProposals).within(() => { cy.contains(proposalTitle) - .parentsUntil('[data-testid="proposals-list-item"]') + .parentsUntil(proposalListItem) + .last() .within(() => { cy.get(proposalStatus).should('have.text', 'Enacted '); cy.get(viewProposalButton).click(); @@ -78,7 +81,8 @@ context( waitForSpinner(); cy.get(openProposals).within(() => { cy.contains(proposalTitle) - .parentsUntil('[data-testid="proposals-list-item"]') + .parentsUntil(proposalListItem) + .last() .within(() => cy.get(viewProposalButton).click()); }); getProposalInformationFromTable('State') @@ -111,7 +115,8 @@ context( waitForSpinner(); cy.get(openProposals, { timeout: 6000 }).within(() => { cy.contains(proposalTitle) - .parentsUntil('[data-testid="proposals-list-item"]') + .parentsUntil(proposalListItem) + .last() .within(() => cy.get(viewProposalButton).click()); }); getProposalInformationFromTable('State') @@ -133,7 +138,8 @@ context( waitForSpinner(); cy.get(openProposals).within(() => { cy.contains(proposalTitle) - .parentsUntil('[data-testid="proposals-list-item"]') + .parentsUntil(proposalListItem) + .last() .within(() => cy.get(viewProposalButton).click()); }); getProposalInformationFromTable('State') diff --git a/apps/governance-e2e/src/integration/flow/proposal-flow.cy.ts b/apps/governance-e2e/src/integration/flow/proposal-flow.cy.ts index da5278d03..e810e63d4 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-flow.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-flow.cy.ts @@ -84,6 +84,7 @@ context( }); beforeEach('visit governance tab', function () { + cy.clearLocalStorage(); cy.reload(); waitForSpinner(); cy.connectVegaWallet(); diff --git a/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts b/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts index 557f6c31e..3855eaf24 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts @@ -76,6 +76,7 @@ context( }); beforeEach('visit governance tab', function () { + cy.clearLocalStorage(); cy.reload(); waitForSpinner(); cy.connectVegaWallet(); @@ -304,7 +305,10 @@ context( cy.get('dd').eq(0).should('have.text', 'Test market 1'); cy.get('dd').eq(1).should('have.text', 'TEST.24h'); cy.get('dd').eq(2).should('not.be.empty'); - cy.get('dd').eq(2).invoke('text').as('EnactedMarketId'); + cy.get('dd') + .eq(2) + .invoke('text') + .as('EnactedMarketId', { type: 'static' }); }); cy.get('@EnactedMarketId').then((marketId) => { cy.VegaWalletSubmitLiquidityProvision(String(marketId), '1'); @@ -322,6 +326,7 @@ context( cy.get('@EnactedMarketId').then((marketId) => { cy.contains(String(marketId)) .parentsUntil(proposalListItem) + .last() .within(() => { cy.getByTestId(viewProposalBtn).click(); }); @@ -375,16 +380,19 @@ context( cy.get(newProposalSubmitButton).should('be.visible').click(); // cannot submit a proposal with ERC20 address already in use cy.contains('Proposal rejected', proposalTimeout).should('be.visible'); - cy.getByTestId('dialog-content').within(() => { - cy.get('p').should( - 'have.text', - 'PROPOSAL_ERROR_ERC20_ADDRESS_ALREADY_IN_USE' - ); - }); + cy.getByTestId('dialog-content') + .last() + .within(() => { + cy.get('p').should( + 'have.text', + 'PROPOSAL_ERROR_ERC20_ADDRESS_ALREADY_IN_USE' + ); + }); closeDialog(); navigateTo(navigation.proposals); cy.contains(proposalTitle) .parentsUntil(proposalListItem) + .last() .within(() => { cy.getByTestId(viewProposalBtn).click(); }); @@ -422,6 +430,7 @@ context( cy.get(proposalType) .contains('Update asset') .parentsUntil(proposalListItem) + .last() .within(() => { cy.get(proposalDetails).should('contain.text', assetId); // 3001-VOTE-029 cy.getByTestId(viewProposalBtn).click(); diff --git a/apps/governance-e2e/src/integration/flow/proposal-list.cy.ts b/apps/governance-e2e/src/integration/flow/proposal-list.cy.ts index e6da93eaa..bbae98c34 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-list.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-list.cy.ts @@ -35,6 +35,7 @@ describe('Governance flow for proposal list', { tags: '@slow' }, function () { }); beforeEach('visit proposals tab', function () { + cy.clearLocalStorage(); cy.reload(); waitForSpinner(); cy.connectVegaWallet(); @@ -59,7 +60,10 @@ describe('Governance flow for proposal list', { tags: '@slow' }, function () { cy.get(openProposals).within(() => { cy.get(proposalClosingDate).first().should('contain.text', 'year'); cy.get(proposalClosingDate).should('contain.text', 'months'); - cy.get(proposalClosingDate).last().should('contain.text', 'days'); + cy.get(proposalClosingDate) + .last() + .invoke('text') + .should('match', /days|minutes/); }); }); diff --git a/apps/governance-e2e/src/integration/flow/rewards-flow.cy.ts b/apps/governance-e2e/src/integration/flow/rewards-flow.cy.ts index 2f33aadfa..be874a12e 100644 --- a/apps/governance-e2e/src/integration/flow/rewards-flow.cy.ts +++ b/apps/governance-e2e/src/integration/flow/rewards-flow.cy.ts @@ -25,9 +25,10 @@ const rewardsTimeOut = { timeout: 60000 }; context('rewards - flow', { tags: '@slow' }, function () { before('set up environment to allow rewards', function () { + cy.clearLocalStorage(); cy.visit('/'); waitForSpinner(); - depositAsset(vegaAssetAddress, '1000'); + depositAsset(vegaAssetAddress, '1000', 18); cy.validatorsSelfDelegate(); ethereumWalletConnect(); cy.connectVegaWallet(); @@ -56,7 +57,7 @@ context('rewards - flow', { tags: '@slow' }, function () { cy.getByTestId(rewardsTable) .first() .within(() => { - cy.getByTestId('asset').should('have.text', 'Vega'); + cy.getByTestId('asset', rewardsTimeOut).should('have.text', 'Vega'); cy.getByTestId('ACCOUNT_TYPE_GLOBAL_REWARD').should('have.text', '1'); cy.getByTestId('ACCOUNT_TYPE_FEES_INFRASTRUCTURE').should( 'have.text', @@ -93,13 +94,13 @@ context('rewards - flow', { tags: '@slow' }, function () { .within(() => { cy.get('h2').first().should('contain.text', 'EPOCH'); cy.getByTestId('individual-rewards-asset').should('have.text', 'Vega'); - cy.getByTestId('ACCOUNT_TYPE_GLOBAL_REWARD') - .should('contain.text', '0.1177') - .and('contain.text', '(11.7733%)'); + cy.getByTestId('ACCOUNT_TYPE_GLOBAL_REWARD', rewardsTimeOut) + .should('contain.text', '0.4415') + .and('contain.text', '(44.15%)'); cy.getByTestId('ACCOUNT_TYPE_FEES_INFRASTRUCTURE') - .should('contain.text', '0.0001') - .and('contain.text', '(11.7733%)'); - cy.getByTestId('total').should('have.text', '0.1179'); + .should('contain.text', '0.0004') + .and('contain.text', '(44.15%)'); + cy.getByTestId('total').should('have.text', '0.4419'); }); }); }); diff --git a/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts b/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts index 7722c6c8d..f7683bb31 100644 --- a/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts +++ b/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts @@ -66,7 +66,7 @@ context( beforeEach( 'teardown wallet & drill into a specific validator', function () { - cy.clearAllLocalStorage(); + cy.clearLocalStorage(); cy.reload(); waitForSpinner(); cy.connectVegaWallet(); diff --git a/apps/governance-e2e/src/integration/flow/token-association-flow.cy.ts b/apps/governance-e2e/src/integration/flow/token-association-flow.cy.ts index 9bb79171a..3eb6ce5d6 100644 --- a/apps/governance-e2e/src/integration/flow/token-association-flow.cy.ts +++ b/apps/governance-e2e/src/integration/flow/token-association-flow.cy.ts @@ -53,6 +53,7 @@ context( beforeEach( 'teardown wallet & drill into a specific validator', function () { + cy.clearLocalStorage(); cy.reload(); waitForSpinner(); cy.connectVegaWallet(); @@ -90,9 +91,14 @@ context( verifyEthWalletTotalAssociatedBalance('2.0'); - cy.get(vegaWallet).within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); - }); + cy.get(vegaWallet) + .first() + .within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 2.0 + ); + }); cy.get(vegaWalletUnstakedBalance, txTimeout).should('contain', 2.0); }); @@ -128,26 +134,38 @@ context( stakingPageAssociateTokens('1001', { approve: true }); verifyEthWalletAssociatedBalance('1,001.00'); verifyEthWalletTotalAssociatedBalance('1,001.00'); - cy.get(vegaWallet).within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - '1,001.00' - ); - }); + cy.get(vegaWallet) + .last() + .within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + '1,001.00' + ); + }); }); it('Able to disassociate a partial amount of tokens currently associated', function () { stakingPageAssociateTokens('2'); - cy.get(vegaWallet).within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); - }); + cy.get(vegaWallet) + .first() + .within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 2.0 + ); + }); cy.get('button').contains('Select a validator to nominate').click(); stakingPageDisassociateTokens('1'); verifyEthWalletAssociatedBalance('1.0'); - cy.get(vegaWallet).within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 1.0); - }); + cy.get(vegaWallet) + .first() + .within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 1.0 + ); + }); }); it('Able to disassociate all tokens - using max', function () { @@ -155,26 +173,40 @@ context( const warningText = 'Warning: Any tokens that have been nominated to a node will sacrifice rewards they are due for the current epoch. If you do not wish to sacrifice these, you should remove stake from a node at the end of an epoch before disassociation.'; stakingPageAssociateTokens('2'); - cy.get(vegaWallet).within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); - }); + cy.get(vegaWallet) + .first() + .within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 2.0 + ); + }); cy.get('button').contains('Select a validator to nominate').click(); cy.get(ethWalletDissociateButton).click(); cy.get(disassociationWarning).should('contain', warningText); stakingPageDisassociateAllTokens(); - cy.get(ethWalletContainer).within(() => { - cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should( - 'not.exist' - ); - }); - cy.get(ethWalletContainer).within(() => { - cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should( - 'not.exist' - ); - }); - cy.get(vegaWallet).within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 0.0); - }); + cy.get(ethWalletContainer) + .first() + .within(() => { + cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should( + 'not.exist' + ); + }); + cy.get(ethWalletContainer) + .first() + .within(() => { + cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should( + 'not.exist' + ); + }); + cy.get(vegaWallet) + .first() + .within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 0.0 + ); + }); }); it('Able to associate and disassociate vesting contract tokens', function () { @@ -200,9 +232,14 @@ context( cy.getByTestId('currency-title', txTimeout).should('have.length', 6); verifyEthWalletAssociatedBalance('2.0'); verifyEthWalletTotalAssociatedBalance('2.0'); - cy.get(vegaWallet).within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); - }); + cy.get(vegaWallet) + .first() + .within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 2.0 + ); + }); cy.get(vegaWalletUnstakedBalance, txTimeout).should('contain', 2.0); stakingPageDisassociateTokens('1', { type: 'contract', @@ -228,38 +265,61 @@ context( stakingPageAssociateTokens('21', { type: 'wallet' }); cy.get('button').contains('Select a validator to nominate').click(); stakingPageAssociateTokens('37', { type: 'contract' }); - cy.get(vestingContractSection).within(() => { - cy.get(associatedKey).should( - 'contain', - Cypress.env('vegaWalletPublicKeyShort') - ); - cy.get(associatedAmount, txTimeout).should('contain', 37); - }); - cy.get(vegaInWalletSection).within(() => { - cy.get(associatedKey).should( - 'contain', - Cypress.env('vegaWalletPublicKeyShort') - ); - cy.get(associatedAmount, txTimeout).should('contain', 21); - }); - cy.get(vegaWallet).within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 58); - }); + cy.get(vestingContractSection) + .first() + .within(() => { + cy.get(associatedKey).should( + 'contain', + Cypress.env('vegaWalletPublicKeyShort') + ); + cy.get(associatedAmount, txTimeout).should('contain', 37); + }); + cy.get(vegaInWalletSection) + .first() + .within(() => { + cy.get(associatedKey).should( + 'contain', + Cypress.env('vegaWalletPublicKeyShort') + ); + cy.get(associatedAmount, txTimeout).should('contain', 21); + }); + cy.get(vegaWallet) + .first() + .within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 58 + ); + }); stakingPageDisassociateTokens('6', { type: 'contract' }); - cy.get(vestingContractSection).within(() => { - cy.get(associatedAmount, txTimeout).should('contain', 31); - }); - cy.get(vegaWallet).within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 52); - }); + cy.get(vestingContractSection) + .first() + .within(() => { + cy.get(associatedAmount, txTimeout).should('contain', 31); + }); + cy.get(vegaWallet) + .first() + .within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 52 + ); + }); navigateTo(navigation.validators); stakingPageDisassociateTokens('9', { type: 'wallet' }); - cy.get(vegaInWalletSection).within(() => { - cy.get(associatedAmount, txTimeout).should('contain', 12); - }); - cy.get(vegaWallet).within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 43); - }); + cy.get(vegaInWalletSection) + .first() + .within(() => { + cy.get(associatedAmount, txTimeout).should('contain', 12); + }); + cy.get(vegaWallet) + .first() + .within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 43 + ); + }); }); it('Not able to associate more tokens than owned', function () { @@ -318,9 +378,14 @@ context( Cypress.env('vegaWalletPublicKey2') ); stakingPageAssociateTokens('2'); - cy.get(vegaWallet).within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); - }); + cy.get(vegaWallet) + .first() + .within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 2.0 + ); + }); cy.get(associateCompleteText).should( 'have.text', `Vega key ${Cypress.env( diff --git a/apps/governance-e2e/src/integration/flow/withdrawal-flow.cy.ts b/apps/governance-e2e/src/integration/flow/withdrawal-flow.cy.ts index ebd2f619b..733899622 100644 --- a/apps/governance-e2e/src/integration/flow/withdrawal-flow.cy.ts +++ b/apps/governance-e2e/src/integration/flow/withdrawal-flow.cy.ts @@ -4,10 +4,7 @@ import { waitForSpinner, } from '../../support/common.functions'; import { ethereumWalletConnect } from '../../support/wallet-eth.functions'; -import { - depositAsset, - vegaWalletTeardown, -} from '../../support/wallet-teardown.functions'; +import { depositAsset } from '../../support/wallet-teardown.functions'; const withdraw = 'withdraw'; const withdrawalForm = 'withdraw-form'; @@ -25,6 +22,13 @@ const withdrawalAmount = 'withdrawal-amount'; const withdrawalRecipient = 'withdrawal-recipient'; const withdrawFundsButton = 'withdraw-funds'; const completeWithdrawalButton = 'complete-withdrawal'; +const tableTxHash = '[col-id="txHash"]'; +const tableAssetSymbol = '[col-id="asset.symbol"]'; +const tableAmount = '[col-id="amount"]'; +const tableReceiverAddress = '[col-id="details.receiverAddress"]'; +const tableWithdrawnTimeStamp = '[col-id="withdrawnTimestamp"]'; +const tableWithdrawnStatus = '[col-id="status"]'; +const tableCreatedTimeStamp = '[col-id="createdTimestamp"]'; const usdtName = 'USDC (local)'; const usdcEthAddress = '0x1b8a1B6CBE5c93609b46D1829Cc7f3Cb8eeE23a0'; const usdcSymbol = 'tUSDC'; @@ -42,26 +46,23 @@ context( cy.visit('/'); // When running tests locally, will fail if run without restarting capsule cy.updateCapsuleMultiSig().then(() => { - depositAsset(usdcEthAddress, '100'); + ethereumWalletConnect(); + depositAsset(usdcEthAddress, '1000', 5); }); }); beforeEach('Navigate to withdrawal page', function () { + cy.clearLocalStorage(); cy.reload(); waitForSpinner(); navigateTo(navigation.withdraw); cy.connectVegaWallet(); ethereumWalletConnect(); - vegaWalletTeardown(); }); it('Able to open withdrawal form with vega wallet connected', function () { - // needs to reload page for withdrawal form to be displayed in ci - not reproducible outside of ci - cy.reload(); - waitForSpinner(); - ethereumWalletConnect(); cy.getByTestId(withdraw).should('be.visible').click(); - cy.getByTestId(withdrawalForm).within(() => { + cy.getByTestId(withdrawalForm, txTimeout).within(() => { cy.get('select').find('option').should('have.length.at.least', 2); cy.getByTestId(ethAddressInput).should('be.visible'); cy.getByTestId(amountInput).should('be.visible'); @@ -70,7 +71,7 @@ context( it('Unable to submit withdrawal with invalid fields', function () { cy.getByTestId(withdraw).should('be.visible').click(); - cy.getByTestId(withdrawalForm).within(() => { + cy.getByTestId(withdrawalForm, txTimeout).within(() => { cy.get('select').select(usdtSelectValue, { force: true }); cy.getByTestId(balanceAvailable, txTimeout).should('exist'); cy.getByTestId(submitWithdrawalButton).click(); @@ -94,7 +95,7 @@ context( it('Able to withdraw asset: -eth wallet connected -withdraw funds button', function () { // fill in withdrawal form cy.getByTestId(withdraw).should('be.visible').click(); - cy.getByTestId(withdrawalForm).within(() => { + cy.getByTestId(withdrawalForm, txTimeout).within(() => { cy.get('select').select(usdtSelectValue, { force: true }); cy.getByTestId(balanceAvailable, txTimeout).should('exist'); cy.getByTestId(withdrawalThreshold).should( @@ -102,7 +103,7 @@ context( '100,000.00000T' ); cy.getByTestId(delayTime).should('have.text', 'None'); - cy.getByTestId(amountInput).click().type('100'); + cy.getByTestId(amountInput).click().type('120'); cy.getByTestId(submitWithdrawalButton).click(); }); @@ -116,7 +117,7 @@ context( .should('have.attr', 'href') .and('contain', '/txs/'); cy.getByTestId(withdrawalAssetSymbol).should('have.text', usdcSymbol); - cy.getByTestId(withdrawalAmount).should('have.text', '100.00'); + cy.getByTestId(withdrawalAmount).should('have.text', '120.00'); cy.getByTestId(withdrawalRecipient) .should('have.text', truncatedWithdrawalEthAddress) .and('have.attr', 'href') @@ -128,26 +129,20 @@ context( 'Withdraw asset complete' ); cy.getByTestId(dialogClose).click(); - - // need to reload page to see withdrawal history complete - cy.reload(); - waitForAssetsDisplayed(usdtName); - // withdrawal history for complete withdrawal displayed - cy.get('[col-id="txHash"]', txTimeout) - .should('have.length.above', 1) - .eq(1) + cy.get(tableWithdrawnStatus) + .eq(1, txTimeout) + .should('have.text', 'Completed') .parent() .within(() => { - cy.get('[col-id="asset.symbol"]').should('have.text', usdcSymbol); - cy.get('[col-id="amount"]').should('have.text', '100.00'); - cy.get('[col-id="details.receiverAddress"]') + cy.get(tableAssetSymbol).should('have.text', usdcSymbol); + cy.get(tableAmount).should('have.text', '120.00'); + cy.get(tableReceiverAddress) .find('a') .should('have.attr', 'href') .and('contain', 'https://sepolia.etherscan.io/address/'); - cy.get('[col-id="withdrawnTimestamp"]').should('not.be.empty'); - cy.get('[col-id="status"]').should('have.text', 'Completed'); - cy.get('[col-id="txHash"]') + cy.get(tableWithdrawnTimeStamp).should('not.be.empty'); + cy.get(tableTxHash) .find('a') .should('have.attr', 'href') .and('contain', 'https://sepolia.etherscan.io/tx/'); @@ -155,16 +150,16 @@ context( }); // Skipping because of bug #1857 - it.skip('Able to withdraw asset: -eth wallet not connected', function () { + it('Able to withdraw asset: -eth wallet not connected', function () { const ethWalletAddress = Cypress.env('ethWalletPublicKey'); cy.reload(); waitForAssetsDisplayed(usdtName); // fill in withdrawal form cy.getByTestId(withdraw).should('be.visible').click(); - cy.getByTestId(withdrawalForm).within(() => { + cy.getByTestId(withdrawalForm, txTimeout).within(() => { cy.get('select').select(usdtSelectValue, { force: true }); cy.getByTestId(ethAddressInput).should('be.empty'); - cy.getByTestId(amountInput).click().type('100'); + cy.getByTestId(amountInput).click().type('110'); cy.getByTestId(submitWithdrawalButton).click(); // Need eth address to submit withdrawal @@ -180,20 +175,20 @@ context( 'Transaction complete' ); cy.getByTestId(dialogClose).click(); - - cy.getByTestId(completeWithdrawalButton) - .eq(0) - .parent() + cy.get(tableTxHash) + .eq(1) + .should('have.text', 'Complete withdrawal') .parent() .within(() => { - cy.get('[col-id="asset.symbol"]').should('have.text', usdcSymbol); - cy.get('[col-id="amount"]').should('have.text', '100.00'); - cy.get('[col-id="details.receiverAddress"]') + cy.get(tableAssetSymbol).should('have.text', usdcSymbol); + cy.get(tableAmount).should('have.text', '110.00'); + cy.get(tableReceiverAddress) .find('a') .should('have.attr', 'href') .and('contain', 'https://sepolia.etherscan.io/address/'); - cy.get('[col-id="createdTimestamp"]').should('not.be.empty'); + cy.get(tableCreatedTimeStamp).should('not.be.empty'); cy.getByTestId(completeWithdrawalButton).click(); + // Unable to complete withdrawal in Capsule }); }); @@ -202,26 +197,28 @@ context( const expectedErrorTxt = `You are connected in a view only state for public key: ${vegaWalletPubKey}. In order to send transactions you must connect to a real wallet.`; // Disconnect vega wallet - cy.getByTestId('manage-vega-wallet').click(); + cy.getByTestId('manage-vega-wallet').last().click(); cy.getByTestId('disconnect').click(); cy.connectPublicKey(vegaWalletPubKey); cy.getByTestId(withdraw).should('be.visible').click(); - cy.getByTestId(withdrawalForm).within(() => { + cy.getByTestId(withdrawalForm, txTimeout).within(() => { cy.get('select').select(usdtSelectValue, { force: true }); cy.getByTestId(balanceAvailable, txTimeout).should('exist'); cy.getByTestId(amountInput).click().type('100'); cy.getByTestId(submitWithdrawalButton).click(); }); - cy.getByTestId('dialog-content').within(() => { - cy.get('h1').should('have.text', 'Transaction failed'); - cy.getByTestId('Error').should('have.text', expectedErrorTxt); - }); + cy.getByTestId('dialog-content') + .last() + .within(() => { + cy.get('h1').should('have.text', 'Transaction failed'); + cy.getByTestId('Error').should('have.text', expectedErrorTxt); + }); }); function waitForAssetsDisplayed(expectedAsset: string) { - cy.contains(expectedAsset, txTimeout).should('be.visible'); + cy.getByTestId('currency-title').should('contain.text', expectedAsset); } } ); diff --git a/apps/governance-e2e/src/support/governance.functions.ts b/apps/governance-e2e/src/support/governance.functions.ts index 318d53cdf..d3634c062 100644 --- a/apps/governance-e2e/src/support/governance.functions.ts +++ b/apps/governance-e2e/src/support/governance.functions.ts @@ -90,6 +90,7 @@ export function getSubmittedProposalFromProposalList(proposalTitle: string) { export function getProposalIdFromList(proposalTitle: string) { cy.contains(proposalTitle) .parentsUntil(proposalListItem) + .last() .within(() => { cy.get(proposalDetails) .invoke('text') @@ -133,7 +134,7 @@ export function waitForProposalSync() { // before proposal appears in the list - so rather than hard coded wait - we just wait on the // delegation checks that are performed on the governance page. - cy.intercept('POST', '/query', (req) => { + cy.intercept('POST', '/graphql', (req) => { if (req.body.operationName === 'Delegations') { req.alias = 'proposalDelegationsCompletion'; } @@ -143,7 +144,7 @@ export function waitForProposalSync() { cy.wait(['@proposalDelegationsCompletion', '@proposalDelegationsCompletion']); // Turn off this intercept from here on in - cy.intercept('POST', '/query', (req) => { + cy.intercept('POST', '/graphql', (req) => { if (req.body.operationName === 'Delegations') { req.continue(); } diff --git a/apps/governance-e2e/src/support/wallet-teardown.functions.ts b/apps/governance-e2e/src/support/wallet-teardown.functions.ts index 1560c2233..5c80fca9a 100644 --- a/apps/governance-e2e/src/support/wallet-teardown.functions.ts +++ b/apps/governance-e2e/src/support/wallet-teardown.functions.ts @@ -35,18 +35,25 @@ const stakingBridgeContract = new StakingBridge( ); const vestingContract = new TokenVesting(vegaTokenContractAddress, signer); -export async function depositAsset(assetEthAddress: string, amount: string) { +export async function depositAsset( + assetEthAddress: string, + amount: string, + decimalPlaces: number +) { // Approve asset const faucet = new TokenFaucetable(assetEthAddress, signer); - cy.wrap(faucet.approve(Erc20BridgeAddress, amount + '0'.repeat(19)), { - timeout: transactionTimeout, - log: false, - }).then(() => { + cy.wrap( + faucet.approve(Erc20BridgeAddress, amount + '0'.repeat(decimalPlaces + 1)), + { + timeout: transactionTimeout, + log: false, + } + ).then(() => { const collateralBridge = new CollateralBridge(Erc20BridgeAddress, signer); cy.wrap( collateralBridge.deposit_asset( assetEthAddress, - amount + '0'.repeat(18), + amount + '0'.repeat(decimalPlaces), '0x' + vegaWalletPubKey ), { timeout: transactionTimeout, log: false } @@ -102,27 +109,49 @@ async function vegaWalletTeardownStaking(stakingBridgeContract: StakingBridge) { cy.highlight('Tearing down staking tokens from vega wallet if present'); cy.wrap( stakingBridgeContract.stake_balance(ethWalletPubKey, vegaWalletPubKey), - { timeout: transactionTimeout, log: false } + { timeout: transactionTimeout } ).then((stakeBalance) => { if (Number(stakeBalance) != 0) { - cy.get('[data-testid="vega-wallet-balance-unstaked"]:visible').within( - () => { - cy.get(associatedAmountInWallet) - .invoke('text') - .then(($walletAmount) => { - cy.wrap( - stakingBridgeContract.remove_stake( - String(stakeBalance), - vegaWalletPubKey - ), - { timeout: transactionTimeout, log: false } - ); - cy.get(associatedAmountInWallet, { + cy.get(vegaWalletContainer).within(() => { + cy.getByTestId('currency-value') + .first() + .invoke('text') + .then(($associatedAmount) => { + cy.wrap( + stakingBridgeContract.remove_stake( + String(stakeBalance), + vegaWalletPubKey + ), + { timeout: transactionTimeout } + ); + cy.wrap( + vestingContract.stake_balance(ethWalletPubKey, vegaWalletPubKey), + { timeout: transactionTimeout, - }).should('not.have.text', $walletAmount); + log: false, + } + ).then((vestingAmount) => { + if (Number(vestingAmount) != 0) { + cy.contains('Associated', { + timeout: transactionTimeout, + }) + .parent() + .parent() + .within(() => { + cy.getByTestId('currency-value', { + timeout: transactionTimeout, + }) + .should('have.length', 1) + .invoke('text') + .as('displayedAmount'); + cy.get('@displayedAmount', { + timeout: transactionTimeout, + }).should('not.eq', $associatedAmount); + }); + } }); - } - ); + }); + }); } }); } @@ -136,7 +165,7 @@ async function vegaWalletTeardownVesting(vestingContract: TokenVesting) { if (Number(vestingAmount) != 0) { cy.wrap( vestingContract.remove_stake(String(vestingAmount), vegaWalletPubKey), - { timeout: transactionTimeout, log: false } + { timeout: transactionTimeout } ); } });