From 79cf8163bea08f9456759883ec8b89ede1cf4d68 Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Thu, 3 Aug 2023 09:54:51 +0100 Subject: [PATCH] chore(governance): add e2e test for successor market (#4471) --- .../fixtures/proposals/successor-market.json | 107 ++++++++++++++++++ .../src/integration/flow/proposal-forms.cy.ts | 90 ++++++++++++++- .../src/support/common.functions.ts | 2 +- 3 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 apps/governance-e2e/src/fixtures/proposals/successor-market.json diff --git a/apps/governance-e2e/src/fixtures/proposals/successor-market.json b/apps/governance-e2e/src/fixtures/proposals/successor-market.json new file mode 100644 index 000000000..853a5b94c --- /dev/null +++ b/apps/governance-e2e/src/fixtures/proposals/successor-market.json @@ -0,0 +1,107 @@ +{ + "changes": { + "decimalPlaces": "5", + "positionDecimalPlaces": "5", + "linearSlippageFactor": "0.001", + "quadraticSlippageFactor": "0", + "lpPriceRange": "10", + "instrument": { + "name": "Token test market", + "code": "Token.24h", + "future": { + "settlementAsset": "816af99af60d684502a40824758f6b5377e6af48e50a9ee8ef478ecb879ea8bc", + "quoteName": "fUSDC", + "dataSourceSpecForSettlementData": { + "external": { + "oracle": { + "signers": [ + { + "pubKey": { + "key": "70d14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680" + } + } + ], + "filters": [ + { + "key": { + "name": "prices.BTC.value", + "type": "TYPE_INTEGER", + "numberDecimalPlaces": "0" + }, + "conditions": [ + { + "operator": "OPERATOR_GREATER_THAN", + "value": "0" + } + ] + } + ] + } + } + }, + "dataSourceSpecForTradingTermination": { + "external": { + "oracle": { + "signers": [ + { + "pubKey": { + "key": "70d14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680" + } + } + ], + "filters": [ + { + "key": { + "name": "trading.terminated.ETH5", + "type": "TYPE_BOOLEAN" + }, + "conditions": [ + { + "operator": "OPERATOR_EQUALS", + "value": "true" + } + ] + } + ] + } + } + }, + "dataSourceSpecBinding": { + "settlementDataProperty": "prices.BTC.value", + "tradingTerminationProperty": "trading.terminated.ETH5" + } + } + }, + "metadata": ["sector:food", "sector:materials", "source:docs.vega.xyz"], + "priceMonitoringParameters": { + "triggers": [ + { + "horizon": "43200", + "probability": "0.9999999", + "auctionExtension": "600" + } + ] + }, + "liquidityMonitoringParameters": { + "targetStakeParameters": { + "timeWindow": "3600", + "scalingFactor": 10 + }, + "triggeringRatio": "0.7", + "auctionExtension": "1" + }, + "logNormal": { + "tau": 0.0001140771161, + "riskAversionParameter": 0.001, + "params": { + "mu": 0, + "r": 0.016, + "sigma": 0.8 + } + }, + "successor": { + "parentMarketId": "", + "insurancePoolFraction": "0.75" + } + } +} 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 49dd849f4..7a7157101 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-forms.cy.ts @@ -220,7 +220,7 @@ context( function () { const proposalTitle = 'Test new market proposal'; goToMakeNewProposal(governanceProposalType.NEW_MARKET); - cy.getByTestId(newProposalTitle).type('Test new market proposal'); + cy.getByTestId(newProposalTitle).type(proposalTitle); cy.getByTestId(newProposalDescription).type('E2E test for proposals'); cy.fixture('/proposals/new-market').then((newMarketProposal) => { const newMarketPayload = JSON.stringify(newMarketProposal); @@ -606,6 +606,94 @@ context( }); }); + it('able to submit successor market proposal', function () { + const proposalTitle = 'Test successor market proposal'; + + cy.createMarket(); + cy.reload(); + waitForSpinner(); + cy.getByTestId('closed-proposals').within(() => { + cy.contains('Add Lorem Ipsum market') + .parentsUntil(proposalListItem) + .last() + .within(() => { + cy.getByTestId(viewProposalBtn).click(); + }); + }); + getProposalInformationFromTable('ID').invoke('text').as('parentMarketId'); + goToMakeNewProposal(governanceProposalType.NEW_MARKET); + cy.getByTestId(newProposalTitle).type(proposalTitle); + cy.getByTestId(newProposalDescription).type( + 'E2E test for successor market' + ); + cy.fixture('/proposals/successor-market').then((newMarketProposal) => { + newMarketProposal.changes.successor.parentMarketId = + this.parentMarketId; + const newMarketPayload = JSON.stringify(newMarketProposal); + cy.getByTestId(newProposalTerms).type(newMarketPayload, { + parseSpecialCharSequences: false, + delay: 2, + }); + }); + cy.getByTestId(proposalDownloadBtn) + .should('be.visible') + .click() + .then(() => { + cy.wrap( + getDownloadedProposalJsonPath('vega-new-market-proposal-') + ).then((filePath) => { + goToMakeNewProposal(governanceProposalType.RAW); + submitUniqueRawProposal({ proposalBody: filePath }); + }); + }); + navigateTo(navigation.proposals); + getProposalFromTitle(proposalTitle).within(() => { + // 3003-PMAN-008 + cy.getByTestId('proposal-successor-info') + .should('have.text', 'Successor market to: TEST.24h') + .find('a') + .should('have.attr', 'href') + .and('contain', this.parentMarketId); + cy.getByTestId('view-proposal-btn').click(); + }); + // #3003-PMAN-010 + cy.getByTestId(proposalJsonToggle).click(); + cy.get('.language-json').within(() => { + cy.get('.hljs-attr').should('contain.text', 'parentMarketId'); + cy.get('.hljs-string').should('contain.text', this.parentMarketId); + cy.get('.hljs-attr').should('contain.text', 'insurancePoolFraction'); + cy.get('.hljs-string').should('contain.text', '0.75'); + }); + cy.getByTestId('proposal-market-data').within(() => { + cy.getByTestId('proposal-market-data-toggle').click(); + cy.contains('Key details').click(); + // 3003-PMAN-009 + getMarketProposalDetailsFromTable('Parent Market ID').should( + 'have.text', + this.parentMarketId + ); + getMarketProposalDetailsFromTable('Insurance Pool Fraction').should( + 'have.text', + '0.75' + ); + getMarketProposalDetailsFromTable('Trading Mode').should( + 'have.text', + 'No trading' + ); + }); + // 3003-PMAN-011 + cy.contains('Parent Market ID').realHover(); + cy.getByTestId('tooltip-content').should( + 'contain.text', + 'The ID of the market this market succeeds.' + ); + cy.contains('Insurance Pool Fraction').realHover(); + cy.getByTestId('tooltip-content').should( + 'contain.text', + 'The fraction of the insurance pool balance that is carried over from the parent market to the successor.' + ); + }); + after('Disassociate from second wallet key if present', function () { cy.reload(); waitForSpinner(); diff --git a/apps/governance-e2e/src/support/common.functions.ts b/apps/governance-e2e/src/support/common.functions.ts index 35d27771a..c440176de 100644 --- a/apps/governance-e2e/src/support/common.functions.ts +++ b/apps/governance-e2e/src/support/common.functions.ts @@ -107,7 +107,7 @@ export function dissociateFromSecondWalletKey() { cy.getByTestId('vega-in-wallet') .first() .within(() => { - cy.getByTestId('eth-wallet-associated-balances') + cy.getByTestId('eth-wallet-associated-balances', txTimeout) .last() .within(() => { cy.getByTestId('associated-key')