From a01e48d508380f4d400793386ab206888a20244d Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Tue, 6 Jun 2023 12:12:59 +0100 Subject: [PATCH] chore(governance): nightly e2e test fixes (#4038) --- .github/workflows/cypress-run.yml | 2 +- .../integration/flow/proposal-details.cy.ts | 2 - .../integration/flow/proposal-enacted.cy.ts | 2 + .../src/integration/flow/proposal-forms.cy.ts | 26 ++- .../src/integration/flow/proposal-list.cy.ts | 7 +- .../src/integration/flow/rewards-flow.cy.ts | 14 +- .../src/integration/flow/staking-flow.cy.ts | 3 + .../flow/token-association-flow.cy.ts | 150 +++++------------- .../src/support/common.functions.ts | 26 +++ .../src/support/governance.functions.ts | 38 ++--- .../src/support/staking.functions.ts | 4 +- .../src/support/wallet-teardown.functions.ts | 59 +++---- 12 files changed, 157 insertions(+), 176 deletions(-) diff --git a/.github/workflows/cypress-run.yml b/.github/workflows/cypress-run.yml index abe346284..31039e427 100644 --- a/.github/workflows/cypress-run.yml +++ b/.github/workflows/cypress-run.yml @@ -20,7 +20,7 @@ jobs: project: ${{ fromJSON(inputs.projects) }} name: ${{ matrix.project }} runs-on: self-hosted-runner - timeout-minutes: 60 + timeout-minutes: 100 steps: # Checks if skip cache was requested - name: Set skip-nx-cache flag 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 c0ebdd4fa..995288645 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts @@ -103,8 +103,6 @@ describe( it('Newly created freeform proposal details - shows proposed and closing dates', function () { const proposalTitle = generateFreeFormProposalTitle(); const proposalTimeStamp = createTenDigitUnixTimeStampForSpecifiedDays(3); - // const currentDate = new Date(createTenDigitUnixTimeStampForSpecifiedDays(0) * 1000) - // const proposedDate = new Date(currentDate.getTime() + 60000) submitUniqueRawProposal({ proposalTitle: proposalTitle, 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 022dbf90d..b03a33056 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-enacted.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-enacted.cy.ts @@ -14,6 +14,7 @@ import { createUpdateNetworkProposalTxBody, createFreeFormProposalTxBody, } from '../../support/proposal.functions'; +import { ensureSpecifiedUnstakedTokensAreAssociated } from '../../support/staking.functions'; import { ethereumWalletConnect } from '../../support/wallet-eth.functions'; import { vegaWalletSetSpecifiedApprovalAmount } from '../../support/wallet-teardown.functions'; @@ -43,6 +44,7 @@ context( waitForSpinner(); cy.connectVegaWallet(); ethereumWalletConnect(); + ensureSpecifiedUnstakedTokensAreAssociated('1'); navigateTo(navigation.proposals); }); 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 6cbabacf9..a649fe862 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts @@ -1,5 +1,6 @@ import { closeDialog, + dissociateFromSecondWalletKey, navigateTo, navigation, turnTelemetryOff, @@ -15,7 +16,11 @@ import { governanceProposalType, voteForProposal, } from '../../support/governance.functions'; -import { ensureSpecifiedUnstakedTokensAreAssociated } from '../../support/staking.functions'; +import { + ensureSpecifiedUnstakedTokensAreAssociated, + stakingPageAssociateTokens, + stakingPageDisassociateAllTokens, +} from '../../support/staking.functions'; import { ethereumWalletConnect } from '../../support/wallet-eth.functions'; import { vegaWalletSetSpecifiedApprovalAmount, @@ -197,6 +202,9 @@ context( // 3003-PMAN-001 it('Able to submit valid new market proposal', function () { + // Wait needed for test to pass in CI because of report name discrepancy when time passes + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(5000); goToMakeNewProposal(governanceProposalType.NEW_MARKET); cy.get(newProposalTitle).type('Test new market proposal'); cy.get(newProposalDescription).type('E2E test for proposals'); @@ -248,6 +256,9 @@ context( // Will fail if run after 'Able to submit update market proposal and vote for proposal' // 3002-PROP-022 it('Unable to submit update market proposal without equity-like share in the market', function () { + cy.get('[data-testid="manage-vega-wallet"]:visible').click(); + cy.get('[data-testid="select-keypair-button"]').eq(0).click(); // switch to second wallet pub key + stakingPageAssociateTokens('1'); goToMakeNewProposal(governanceProposalType.UPDATE_MARKET); cy.get(newProposalTitle).type('Test update market proposal - rejected'); cy.get(newProposalDescription).type('E2E test for proposals'); @@ -269,7 +280,11 @@ context( cy.get(newProposalSubmitButton).should('be.visible').click(); cy.contains('Proposal rejected', proposalTimeout).should('be.visible'); validateDialogContentMsg('PROPOSAL_ERROR_INSUFFICIENT_EQUITY_LIKE_SHARE'); - ensureSpecifiedUnstakedTokensAreAssociated('1'); + closeDialog(); + ethereumWalletConnect(); + stakingPageDisassociateAllTokens(); + cy.get('[data-testid="manage-vega-wallet"]:visible').click(); + cy.get('[data-testid="select-keypair-button"]').eq(0).click(); }); // 3002-PROP-020 @@ -525,6 +540,13 @@ context( }); }); + after('Disassociate from second wallet key if present', function () { + cy.reload(); + waitForSpinner(); + ethereumWalletConnect(); + dissociateFromSecondWalletKey(); + }); + function validateDialogContentMsg(expectedMsg: string) { cy.getByTestId('dialog-content') .last() 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 4a47ebfdc..a2e2153e4 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-list.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-list.cy.ts @@ -86,11 +86,12 @@ describe('Governance flow for proposal list', { tags: '@slow' }, function () { }); it('Newly created proposals list - shows title and portion of summary', function () { - const proposalPath = '/proposals/new-market-raw.json'; - const enactmentTimestamp = createTenDigitUnixTimeStampForSpecifiedDays(3); + const proposalPath = 'src/fixtures/proposals/new-market-raw.json'; + const proposalTimestamp = createTenDigitUnixTimeStampForSpecifiedDays(3); submitUniqueRawProposal({ proposalBody: proposalPath, - enactmentTimestamp: enactmentTimestamp, + enactmentTimestamp: proposalTimestamp, + closingTimestamp: proposalTimestamp, }); // 3001-VOTE-052 // 3001-VOTE-008 // 3001-VOTE-034 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 a8aee38be..939a700ff 100644 --- a/apps/governance-e2e/src/integration/flow/rewards-flow.cy.ts +++ b/apps/governance-e2e/src/integration/flow/rewards-flow.cy.ts @@ -20,8 +20,10 @@ const vegaAssetAddress = '0x67175Da1D5e966e40D11c4B2519392B2058373de'; const vegaWalletUnstakedBalance = '[data-testid="vega-wallet-balance-unstaked"]'; const rewardsTable = 'epoch-total-rewards-table'; +const rewardsStartEpoch = 380; // Use 30 running locally +const rewardsEndEpoch = 500; // Change to 200 running locally const txTimeout = Cypress.env('txTimeout'); -const rewardsTimeOut = { timeout: 60000 }; +const rewardsTimeOut = { timeout: 5 * 60 * 1000 }; context('rewards - flow', { tags: '@slow' }, function () { before('set up environment to allow rewards', function () { @@ -29,18 +31,22 @@ context('rewards - flow', { tags: '@slow' }, function () { turnTelemetryOff(); cy.visit('/'); waitForSpinner(); - depositAsset(vegaAssetAddress, '1000', 18); ethereumWalletConnect(); cy.connectVegaWallet(); + depositAsset(vegaAssetAddress, '1000', 18); + cy.getByTestId('currency-title', txTimeout).should( + 'contain.text', + 'Collateral' + ); vegaWalletTeardown(); cy.associateTokensToVegaWallet('6000'); - cy.VegaWalletTopUpRewardsPool(30, 200); - navigateTo(navigation.validators); + cy.VegaWalletTopUpRewardsPool(rewardsStartEpoch, rewardsEndEpoch); cy.get(vegaWalletUnstakedBalance, txTimeout).should( 'contain', '6,000.0', txTimeout ); + navigateTo(navigation.validators); clickOnValidatorFromList(0); stakingValidatorPageAddStake('3000'); closeStakingDialog(); 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 f3aee5c79..dfa8b01bd 100644 --- a/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts +++ b/apps/governance-e2e/src/integration/flow/staking-flow.cy.ts @@ -109,6 +109,7 @@ context( cy.getByTestId(userStake, epochTimeout) .first() .should('have.text', '2.00'); + waitForBeginningOfEpoch(); cy.getByTestId('total-stake').first().realHover(); cy.getByTestId('staked-by-user-tooltip') .first() @@ -379,6 +380,7 @@ context( }); it('Disassociating some tokens - prioritizes unstaked tokens', function () { + vegaWalletSetSpecifiedApprovalAmount('1000'); stakingPageAssociateTokens('3'); verifyUnstakedBalance(3.0); cy.get('button').contains('Select a validator to nominate').click(); @@ -485,6 +487,7 @@ context( }); afterEach('Teardown Wallet', function () { + navigateTo(navigation.home); vegaWalletTeardown(); }); 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 3727ca52f..9c95d90cc 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 @@ -24,7 +24,6 @@ const ethWalletContainer = '[data-testid="ethereum-wallet"]'; const vegaWalletAssociatedBalance = '[data-testid="currency-value"]'; const vegaWalletUnstakedBalance = '[data-testid="vega-wallet-balance-unstaked"]'; -const currencyTitle = '[data-testid="currency-title"]:visible'; const txTimeout = Cypress.env('txTimeout'); const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); const ethWalletAssociateButton = '[data-testid="associate-btn"]:visible'; @@ -39,7 +38,7 @@ const associatedKey = '[data-testid="associated-key"]'; const associatedAmount = '[data-testid="associated-amount"]'; const associateCompleteText = '[data-testid="transaction-complete-body"]'; const disassociationWarning = '[data-testid="disassociation-warning"]'; -const vegaWallet = '[data-testid="vega-wallet"]'; +const vegaWallet = 'aside [data-testid="vega-wallet"]'; context( 'Token association flow - with eth and vega wallets connected', @@ -79,27 +78,15 @@ context( //0005-ETXN-003 //0005-ETXN-005 stakingPageAssociateTokens('2', { skipConfirmation: true }); - - cy.get(currencyTitle, txTimeout).should('have.length.above', 4); validateWalletCurrency('Associated', '0.00'); validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Total associated after pending', '2.00'); - cy.get(currencyTitle, txTimeout).should('have.length.at.least', 6); - // 0005-ETXN-002 verifyEthWalletAssociatedBalance('2.0'); - verifyEthWalletTotalAssociatedBalance('2.0'); - - cy.get(vegaWallet) - .first() - .within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - 2.0 - ); - }); - + cy.get(vegaWallet).within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); + }); cy.get(vegaWalletUnstakedBalance, txTimeout).should('contain', 2.0); }); @@ -114,12 +101,11 @@ context( verifyEthWalletAssociatedBalance('2.0'); verifyEthWalletTotalAssociatedBalance('6,002.00'); cy.get('button').contains('Select a validator to nominate').click(); + cy.getByTestId('epoch-countdown').should('be.visible'); stakingPageDisassociateTokens('2'); - cy.get(currencyTitle, txTimeout).should('have.length.above', 4); validateWalletCurrency('Associated', '2.00'); validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Total associated after pending', '0.00'); - cy.get(currencyTitle, txTimeout).should('have.length.at.least', 6); cy.get( '[data-testid="eth-wallet-associated-balances"]:visible', txTimeout @@ -132,38 +118,26 @@ context( stakingPageAssociateTokens('1001', { approve: true }); verifyEthWalletAssociatedBalance('1,001.00'); verifyEthWalletTotalAssociatedBalance('7,001.00'); - cy.get(vegaWallet) - .last() - .within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - '1,001.00' - ); - }); + cy.get(vegaWallet).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) - .first() - .within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - 2.0 - ); - }); - + cy.get(vegaWallet).within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); + }); cy.get('button').contains('Select a validator to nominate').click(); + cy.getByTestId('epoch-countdown').should('be.visible'); stakingPageDisassociateTokens('1'); verifyEthWalletAssociatedBalance('1.0'); - cy.get(vegaWallet) - .first() - .within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - 1.0 - ); - }); + cy.get(vegaWallet).within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 1.0); + }); }); it('Able to disassociate all tokens - using max', function () { @@ -171,15 +145,11 @@ 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) - .first() - .within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - 2.0 - ); - }); + cy.get(vegaWallet).within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); + }); cy.get('button').contains('Select a validator to nominate').click(); + cy.getByTestId('epoch-countdown').should('be.visible'); cy.get(ethWalletDissociateButton).click(); cy.get(disassociationWarning).should('contain', warningText); stakingPageDisassociateAllTokens(); @@ -197,14 +167,9 @@ context( 'not.exist' ); }); - cy.get(vegaWallet) - .first() - .within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - 0.0 - ); - }); + cy.get(vegaWallet).within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 0.0); + }); }); it('Able to associate and disassociate vesting contract tokens', function () { @@ -219,32 +184,22 @@ context( type: 'contract', skipConfirmation: true, }); - - cy.get(currencyTitle, txTimeout).should('have.length.above', 4); validateWalletCurrency('Associated', '0.00'); validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Total associated after pending', '2.00'); - cy.get(currencyTitle, txTimeout).should('have.length.at.least', 6); verifyEthWalletAssociatedBalance('2.0'); verifyEthWalletTotalAssociatedBalance('2.0'); - cy.get(vegaWallet) - .first() - .within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - 2.0 - ); - }); + cy.get(vegaWallet).within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); + }); cy.get(vegaWalletUnstakedBalance, txTimeout).should('contain', 2.0); stakingPageDisassociateTokens('1', { type: 'contract', skipConfirmation: true, }); - cy.get(currencyTitle, txTimeout).should('have.length.above', 4); validateWalletCurrency('Associated', '2.00'); validateWalletCurrency('Pending association', '1.00'); validateWalletCurrency('Total associated after pending', '1.00'); - cy.get(currencyTitle, txTimeout).should('have.length.at.least', 6); verifyEthWalletAssociatedBalance('1.0'); verifyEthWalletTotalAssociatedBalance('1.0'); }); @@ -256,6 +211,7 @@ context( // 1004-ASSO-022 stakingPageAssociateTokens('21', { type: 'wallet' }); cy.get('button').contains('Select a validator to nominate').click(); + cy.getByTestId('epoch-countdown').should('be.visible'); stakingPageAssociateTokens('37', { type: 'contract' }); cy.get(vestingContractSection) .first() @@ -275,28 +231,18 @@ context( ); cy.get(associatedAmount, txTimeout).should('contain', 21); }); - cy.get(vegaWallet) - .first() - .within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - 58 - ); - }); + cy.get(vegaWallet).within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 58); + }); stakingPageDisassociateTokens('6', { type: 'contract' }); cy.get(vestingContractSection) .first() .within(() => { cy.get(associatedAmount, txTimeout).should('contain', 31); }); - cy.get(vegaWallet) - .first() - .within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - 52 - ); - }); + cy.get(vegaWallet).within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 52); + }); navigateTo(navigation.validators); stakingPageDisassociateTokens('9', { type: 'wallet' }); cy.get(vegaInWalletSection) @@ -304,14 +250,9 @@ context( .within(() => { cy.get(associatedAmount, txTimeout).should('contain', 12); }); - cy.get(vegaWallet) - .first() - .within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - 43 - ); - }); + cy.get(vegaWallet).within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 43); + }); }); it('Not able to associate more tokens than owned', function () { @@ -328,11 +269,9 @@ context( // 1004-ASSO-004 it('Pending association outside of app is shown', function () { vegaWalletAssociate('2'); - cy.get(currencyTitle, txTimeout).should('have.length.above', 4); validateWalletCurrency('Associated', '0.00'); validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Total associated after pending', '2.00'); - cy.get(currencyTitle, txTimeout).should('have.length.at.least', 6); validateWalletCurrency('Associated', '2.00'); }); @@ -341,11 +280,9 @@ context( cy.wrap(validateWalletCurrency('Associated', '2.00')).then(() => { vegaWalletDisassociate('2'); }); - cy.get(currencyTitle, txTimeout).should('have.length.above', 4); validateWalletCurrency('Associated', '2.00'); validateWalletCurrency('Pending association', '2.00'); validateWalletCurrency('Total associated after pending', '0.00'); - cy.get(currencyTitle, txTimeout).should('have.length.at.least', 6); validateWalletCurrency('Associated', '0.00'); }); @@ -364,14 +301,9 @@ context( Cypress.env('vegaWalletPublicKey2') ); stakingPageAssociateTokens('2'); - cy.get(vegaWallet) - .first() - .within(() => { - cy.get(vegaWalletAssociatedBalance, txTimeout).should( - 'contain', - 2.0 - ); - }); + cy.get(vegaWallet).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/support/common.functions.ts b/apps/governance-e2e/src/support/common.functions.ts index 94a5e3afb..39fc20f6b 100644 --- a/apps/governance-e2e/src/support/common.functions.ts +++ b/apps/governance-e2e/src/support/common.functions.ts @@ -1,8 +1,11 @@ +import { stakingPageDisassociateAllTokens } from './staking.functions'; + const tokenDropDown = 'state-trigger'; const txTimeout = Cypress.env('txTimeout'); export enum navigation { section = 'nav', + home = '[href="/"]', vesting = '[href="/token/redeem"]', validators = '[href="/validators"]', rewards = '[href="/rewards"]', @@ -18,6 +21,7 @@ export function convertTokenValueToNumber(subject: string) { } const topLevelRoutes = [ + navigation.home, navigation.proposals, navigation.validators, navigation.rewards, @@ -97,3 +101,25 @@ export function turnTelemetryOff() { win.localStorage.setItem('vega_telemetry_on', 'false') ); } + +export function dissociateFromSecondWalletKey() { + const secondWalletKey = Cypress.env('vegaWalletPublicKey2Short'); + cy.getByTestId('vega-in-wallet') + .first() + .within(() => { + cy.getByTestId('eth-wallet-associated-balances') + .last() + .within(() => { + cy.getByTestId('associated-key') + .invoke('text') + .as('associatedPubKey'); + }); + }); + cy.get('@associatedPubKey').then((associatedPubKey) => { + if (associatedPubKey == secondWalletKey) { + cy.get('[data-testid="manage-vega-wallet"]:visible').click(); + cy.get('[data-testid="select-keypair-button"]').eq(0).click(); + stakingPageDisassociateAllTokens(); + } + }); +} diff --git a/apps/governance-e2e/src/support/governance.functions.ts b/apps/governance-e2e/src/support/governance.functions.ts index 5809a1e39..dcd7dd7eb 100644 --- a/apps/governance-e2e/src/support/governance.functions.ts +++ b/apps/governance-e2e/src/support/governance.functions.ts @@ -59,29 +59,29 @@ export function submitUniqueRawProposal(proposalFields: { submit?: boolean; }) { goToMakeNewProposal(governanceProposalType.RAW); - let proposalBodyPath = '/proposals/raw.json'; + let proposalBodyPath = 'src/fixtures/proposals/raw.json'; if (proposalFields.proposalBody) { proposalBodyPath = proposalFields.proposalBody; } cy.readFile(proposalBodyPath).then((rawProposal) => { - if (!proposalFields.proposalBody) { - if (proposalFields.proposalTitle) { - rawProposal.rationale.title = proposalFields.proposalTitle; - cy.wrap(proposalFields.proposalTitle).as('proposalTitle'); - } - if (proposalFields.proposalDescription) { - rawProposal.rationale.description = proposalFields.proposalDescription; - } - if (proposalFields.closingTimestamp) { - rawProposal.terms.closingTimestamp = proposalFields.closingTimestamp; - } else { - const minTimeStamp = createTenDigitUnixTimeStampForSpecifiedDays(2); - rawProposal.terms.closingTimestamp = minTimeStamp; - } - if (proposalFields.enactmentTimestamp) { - rawProposal.terms.enactmentTimestamp = - proposalFields.enactmentTimestamp; - } + if (proposalFields.proposalTitle) { + rawProposal.rationale.title = proposalFields.proposalTitle; + cy.wrap(proposalFields.proposalTitle).as('proposalTitle'); + } + if (proposalFields.proposalDescription) { + rawProposal.rationale.description = proposalFields.proposalDescription; + } + if (proposalFields.closingTimestamp) { + rawProposal.terms.closingTimestamp = proposalFields.closingTimestamp; + } else if ( + !proposalFields.closingTimestamp && + !proposalFields.proposalBody + ) { + const minTimeStamp = createTenDigitUnixTimeStampForSpecifiedDays(2); + rawProposal.terms.closingTimestamp = minTimeStamp; + } + if (proposalFields.enactmentTimestamp) { + rawProposal.terms.enactmentTimestamp = proposalFields.enactmentTimestamp; } const proposalPayload = JSON.stringify(rawProposal); diff --git a/apps/governance-e2e/src/support/staking.functions.ts b/apps/governance-e2e/src/support/staking.functions.ts index c016a37e0..c7b88e5af 100644 --- a/apps/governance-e2e/src/support/staking.functions.ts +++ b/apps/governance-e2e/src/support/staking.functions.ts @@ -236,8 +236,8 @@ export function validateWalletCurrency( currencyTitle: string, expectedAmount: string ) { - cy.get("[data-testid='currency-title']") - .contains(currencyTitle) + cy.get("[data-testid='currency-title']", txTimeout) + .contains(currencyTitle, txTimeout) .parent() .parent() .within(() => { diff --git a/apps/governance-e2e/src/support/wallet-teardown.functions.ts b/apps/governance-e2e/src/support/wallet-teardown.functions.ts index 13883849a..1753958ce 100644 --- a/apps/governance-e2e/src/support/wallet-teardown.functions.ts +++ b/apps/governance-e2e/src/support/wallet-teardown.functions.ts @@ -19,7 +19,7 @@ const ethStakingBridgeContractAddress = Cypress.env( ); const ethProviderUrl = Cypress.env('ethProviderUrl'); const getAccount = (number = 0) => `m/44'/60'/0'/0/${number}`; -const transactionTimeout = 100000; +const transactionTimeout = { timeout: 100000, log: false }; const Erc20BridgeAddress = '0x9708FF7510D4A7B9541e1699d15b53Ecb1AFDc54'; const provider = new ethers.providers.JsonRpcProvider({ url: ethProviderUrl }); @@ -43,10 +43,7 @@ export async function depositAsset( const faucet = new Token(assetEthAddress, signer); cy.wrap( faucet.approve(Erc20BridgeAddress, amount + '0'.repeat(decimalPlaces + 1)), - { - timeout: transactionTimeout, - log: false, - } + transactionTimeout ).then(() => { const collateralBridge = new CollateralBridge(Erc20BridgeAddress, signer); cy.wrap( @@ -55,7 +52,7 @@ export async function depositAsset( amount + '0'.repeat(decimalPlaces), '0x' + vegaWalletPubKey ), - { timeout: transactionTimeout, log: false } + transactionTimeout ); }); } @@ -79,13 +76,13 @@ export async function vegaWalletTeardown() { } }); cy.get(vegaWalletContainer).within(() => { - cy.get(associatedAmountInWallet, { - timeout: transactionTimeout, - }) - .should('have.length', 1, { timeout: transactionTimeout }) - .contains('0.00', { - timeout: transactionTimeout, - }); + cy.get(associatedAmountInWallet, transactionTimeout).should( + 'have.length', + 1 + ); + cy.get(associatedAmountInWallet) + .first(transactionTimeout) + .should('have.text', '0.00'); }); }); } @@ -109,7 +106,7 @@ 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 } + transactionTimeout ).then((stakeBalance) => { if (Number(stakeBalance) != 0) { cy.get(vegaWalletContainer).within(() => { @@ -122,31 +119,25 @@ async function vegaWalletTeardownStaking(stakingBridgeContract: StakingBridge) { String(stakeBalance), vegaWalletPubKey ), - { timeout: transactionTimeout } + transactionTimeout ); cy.wrap( vestingContract.stake_balance(ethWalletPubKey, vegaWalletPubKey), - { - timeout: transactionTimeout, - log: false, - } + transactionTimeout ).then((vestingAmount) => { if (Number(vestingAmount) != 0) { - cy.contains('Associated', { - timeout: transactionTimeout, - }) + cy.contains('Associated', transactionTimeout) .parent() .parent() .within(() => { - cy.getByTestId('currency-value', { - timeout: transactionTimeout, - }) - .should('have.length', 1) + cy.getByTestId('currency-value', transactionTimeout) + .first() .invoke('text') .as('displayedAmount'); - cy.get('@displayedAmount', { - timeout: transactionTimeout, - }).should('not.eq', $associatedAmount); + cy.get('@displayedAmount', transactionTimeout).should( + 'not.eq', + $associatedAmount + ); }); } }); @@ -158,14 +149,14 @@ async function vegaWalletTeardownStaking(stakingBridgeContract: StakingBridge) { async function vegaWalletTeardownVesting(vestingContract: TokenVesting) { cy.highlight('Tearing down vesting tokens from vega wallet if present'); - cy.wrap(vestingContract.stake_balance(ethWalletPubKey, vegaWalletPubKey), { - timeout: transactionTimeout, - log: false, - }).then((vestingAmount) => { + cy.wrap( + vestingContract.stake_balance(ethWalletPubKey, vegaWalletPubKey), + transactionTimeout + ).then((vestingAmount) => { if (Number(vestingAmount) != 0) { cy.wrap( vestingContract.remove_stake(String(vestingAmount), vegaWalletPubKey), - { timeout: transactionTimeout } + transactionTimeout ); } });