From 95c1526aa3cb9ab00011a4c26b4560a473d3ef86 Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Fri, 26 Aug 2022 14:16:28 +0100 Subject: [PATCH] Test/994 additional market info (#1172) * test: additional market info tests * chore: fix intermittent failing tests * chore: change wait logic for asserting node --- .../src/integration/node-switcher.cy.js | 25 +++++----- .../token-e2e/src/support/common.functions.js | 2 +- .../src/integration/market-info.cy.ts | 46 +++++++++++++++++-- .../mocks/generate-market-info-query.ts | 19 ++++++++ .../src/support/mocks/generate-market.ts | 4 ++ 5 files changed, 80 insertions(+), 16 deletions(-) diff --git a/apps/explorer-e2e/src/integration/node-switcher.cy.js b/apps/explorer-e2e/src/integration/node-switcher.cy.js index b55db5d04..5aeb3fa75 100644 --- a/apps/explorer-e2e/src/integration/node-switcher.cy.js +++ b/apps/explorer-e2e/src/integration/node-switcher.cy.js @@ -10,14 +10,12 @@ context('Node switcher', function () { }).as('nodeData'); cy.visit('/'); cy.wait('@nodeData'); + cy.getByTestId('git-network-data').within(() => { + cy.getByTestId('link').should('be.visible').click(); + }); }); describe('form validations and responses', function () { - beforeEach('open node selector', function () { - cy.getByTestId('git-network-data').within(() => { - cy.getByTestId('link').click(); - }); - }); it('node data is displayed', function () { cy.getByTestId('node-row').should('have.length.at.least', 2); @@ -28,10 +26,13 @@ context('Node switcher', function () { .should('exist') .and('have.attr', 'aria-checked', 'true'); cy.get('label').should('have.text', Cypress.env('networkQueryUrl')); - cy.contains('-').should('not.exist'); + cy.getByTestId('ssl-cell').should('have.text', 'Checking'); + cy.getByTestId('ssl-cell', { timeout: 6000 }).should( + 'not.have.text', + 'Checking' + ); cy.getByTestId('response-time-cell').should('contain.text', 'ms'); cy.getByTestId('block-cell').should('not.be.empty'); - cy.getByTestId('ssl-cell').should('not.be.empty'); }); }); @@ -58,15 +59,15 @@ context('Node switcher', function () { cy.get('input').clear().type('https://n03.s.vega.xyz/query'); cy.getByTestId('link').click(); }); - cy.getByTestId('ssl-cell').should('contain.text', 'Yes'); + cy.getByTestId('ssl-cell', { timeout: 6000 }).should( + 'contain.text', + 'Yes' + ); validateNodeError(errorTypeTxt, nodeErrorTxt); }); function validateNodeError(errortype, errorMsg) { - cy.getByTestId(nodeErrorType, { timeout: 10000 }).should( - 'have.text', - errortype - ); + cy.getByTestId(nodeErrorType).should('have.text', errortype); cy.getByTestId(nodeErrorMsg).should('have.text', errorMsg); } }); diff --git a/apps/token-e2e/src/support/common.functions.js b/apps/token-e2e/src/support/common.functions.js index 3d670d7bb..443528a60 100644 --- a/apps/token-e2e/src/support/common.functions.js +++ b/apps/token-e2e/src/support/common.functions.js @@ -18,7 +18,7 @@ const navigation = { }; Cypress.Commands.add('navigate_to', (page) => { - return cy.get(navigation.section).within(() => { + return cy.get(navigation.section, { timeout: 10000 }).within(() => { cy.get(navigation[page]).click(); }); }); diff --git a/apps/trading-e2e/src/integration/market-info.cy.ts b/apps/trading-e2e/src/integration/market-info.cy.ts index 8fe877126..73c4f5f9b 100644 --- a/apps/trading-e2e/src/integration/market-info.cy.ts +++ b/apps/trading-e2e/src/integration/market-info.cy.ts @@ -21,17 +21,28 @@ describe('market info is displayed', () => { validateMarketDataRow(0, 'Maker Fee', '0.02%'); validateMarketDataRow(1, 'Infrastructure Fee', '0.05%'); validateMarketDataRow(2, 'Liquidity Fee', '1.00%'); + validateMarketDataRow(3, 'Total Fees', '1.04%'); + }); + it('market price', () => { + cy.getByTestId(marketTitle).contains('Market price').click(); + validateMarketDataRow(0, 'Mark Price', '57.49'); + validateMarketDataRow(1, 'Best Bid Price', '6,817.65'); + validateMarketDataRow(2, 'Best Offer Price', '6,817.69'); }); it('market volume displayed', () => { cy.getByTestId(marketTitle).contains('Market volume').click(); validateMarketDataRow(0, '24 Hour Volume', '-'); validateMarketDataRow(1, 'Open Interest', '0'); + validateMarketDataRow(2, 'Best Bid Volume', '5'); + validateMarketDataRow(3, 'Best Offer Volume', '1'); + validateMarketDataRow(4, 'Best Static Bid Volume', '5'); + validateMarketDataRow(5, 'Best Static Offer Volume', '1'); }); - it('market price', () => { - cy.getByTestId(marketTitle).contains('Market price').click(); - validateMarketDataRow(0, 'Mark Price', '57.49'); + it('insurance pool displayed', () => { + cy.getByTestId(marketTitle).contains('Insurance pool').click(); + validateMarketDataRow(0, 'Balance', '0'); }); it('key details displayed', () => { @@ -99,6 +110,14 @@ describe('market info is displayed', () => { validateMarketDataRow(2, 'Auction Extension Secs', '600'); }); + it('price monitoring bound displayed', () => { + cy.getByTestId(marketTitle).contains('Price monitoring bound 1').click(); + + validateMarketDataRow(0, 'Min Valid Price', '6,547.01'); + validateMarketDataRow(1, 'Max Valid Price', '7,973.23'); + validateMarketDataRow(2, 'Reference Price', '7,226.25'); + }); + it('liquidity monitoring parameters displayed', () => { cy.getByTestId(marketTitle) .contains('Liquidity monitoring parameters') @@ -109,6 +128,27 @@ describe('market info is displayed', () => { validateMarketDataRow(2, 'Scaling Factor', '10'); }); + it('oracle displayed', () => { + cy.getByTestId(marketTitle).contains('Oracle').click(); + + validateMarketDataRow(0, 'Settlement Price Property', 'prices.BTC.value'); + validateMarketDataRow( + 1, + 'Trading Termination Property', + 'termination.BTC.value' + ); + validateMarketDataRow( + 2, + 'Price Oracle', + 'f028fe5ea7de3890962a05a7163fdde562629af649ed81b8c8902fafb6eef04f' + ); + validateMarketDataRow( + 3, + 'Termination Oracle', + 'f028fe5ea7de3890962a05a7163fdde562629af649ed81b8c8902fafb6eef04f' + ); + }); + afterEach('close toggle', () => { cy.get('[data-state="open"]').find('button').click(); }); diff --git a/apps/trading-e2e/src/support/mocks/generate-market-info-query.ts b/apps/trading-e2e/src/support/mocks/generate-market-info-query.ts index 502c00da1..926fc4120 100644 --- a/apps/trading-e2e/src/support/mocks/generate-market-info-query.ts +++ b/apps/trading-e2e/src/support/mocks/generate-market-info-query.ts @@ -1,6 +1,7 @@ import type { MarketInfoQuery } from '@vegaprotocol/deal-ticket'; import { AccountType, + AuctionTrigger, MarketState, MarketTradingMode, } from '@vegaprotocol/types'; @@ -82,6 +83,23 @@ export const generateMarketInfoQuery = ( bestStaticBidVolume: '5', bestStaticOfferVolume: '1', openInterest: '0', + bestBidPrice: '681765', + bestOfferPrice: '681769', + trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED, + priceMonitoringBounds: [ + { + minValidPrice: '654701', + maxValidPrice: '797323', + trigger: { + horizonSecs: 43200, + probability: 0.9999999, + auctionExtensionSecs: 600, + __typename: 'PriceMonitoringTrigger', + }, + referencePrice: '722625', + __typename: 'PriceMonitoringBounds', + }, + ], }, liquidityMonitoringParameters: { triggeringRatio: 0, @@ -92,6 +110,7 @@ export const generateMarketInfoQuery = ( }, __typename: 'LiquidityMonitoringParameters', }, + candles: [], tradableInstrument: { __typename: 'TradableInstrument', instrument: { diff --git a/apps/trading-e2e/src/support/mocks/generate-market.ts b/apps/trading-e2e/src/support/mocks/generate-market.ts index 64974d680..322bd3be4 100644 --- a/apps/trading-e2e/src/support/mocks/generate-market.ts +++ b/apps/trading-e2e/src/support/mocks/generate-market.ts @@ -53,6 +53,10 @@ export const generateMarket = (override?: PartialDeep): Market => { __typename: 'InstrumentMetadata', }, product: { + oracleSpecForTradingTermination: { + id: 'd253c16c6a17ab88e098479635c611ab503582a1079752d1a49ac15f656f7e7b', + __typename: 'OracleSpec', + }, quoteName: 'BTCUSD Monthly', settlementAsset: { id: '000',