From 4756ae597a11947ce56b2a2b19d7cc48ae67016b Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Thu, 18 Aug 2022 11:44:07 +0100 Subject: [PATCH] test: test for market conditions tool tip (#1054) * test: test for market conditions tool tip * fix: failing to click market dropdown --- .../trading-e2e/src/integration/markets.cy.ts | 47 ++++++++++++++++++- apps/trading-e2e/src/support/index.ts | 1 + .../src/support/mocks/generate-market.ts | 11 +++-- apps/trading-e2e/tsconfig.json | 2 +- .../trading-mode-tooltip.tsx | 6 +-- 5 files changed, 58 insertions(+), 9 deletions(-) diff --git a/apps/trading-e2e/src/integration/markets.cy.ts b/apps/trading-e2e/src/integration/markets.cy.ts index fa1c92f50..6be9f5b64 100644 --- a/apps/trading-e2e/src/integration/markets.cy.ts +++ b/apps/trading-e2e/src/integration/markets.cy.ts @@ -9,7 +9,7 @@ describe('markets table', () => { aliasQuery(req, 'MarketList', generateMarketList()); }); cy.visit('/'); - cy.wait('@MarketList'); + cy.wait('@MarketList', { timeout: 5000 }); }); it('renders markets correctly', () => { @@ -38,7 +38,7 @@ describe('markets table', () => { }); openMarketDropDown(); - cy.getByTestId('market-link-market-0').click(); + cy.getByTestId('market-link-market-0').should('be.visible').click(); cy.wait('@Market'); cy.contains('ACTIVE MARKET'); @@ -46,6 +46,49 @@ describe('markets table', () => { verifyMarketSummaryDisplayed(); }); + it('Auction conditions are displayed', () => { + const toolTipLabel = 'tooltip-label'; + const toolTipValue = 'tooltip-value'; + const auctionToolTipLabels = [ + 'Auction start', + 'Est auction end', + 'Target liquidity', + 'Current liquidity', + 'Est uncrossing price', + 'Est uncrossing vol', + ]; + + cy.mockGQL((req) => { + mockTradingPage(req, MarketState.Active); + }); + + cy.visit('/markets/market-0'); + cy.wait('@Market'); + + cy.getByTestId('trading-mode').eq(0).realHover(); + cy.getByTestId('tooltip-market-info').within(() => { + cy.get('span') + .eq(0) + .should( + 'contain.text', + 'This market is in auction until it reaches sufficient liquidity.' + ); + cy.getByTestId('link') + .should('have.attr', 'href') + .and( + 'include', + 'https://docs.fairground.vega.xyz/docs/trading-questions/#auctions-what-is-a-liquidity-monitoring-auction' + ); + }); + + for (let i = 0; i < 6; i++) { + cy.getByTestId(toolTipLabel) + .eq(i) + .should('have.text', auctionToolTipLabels[i]); + cy.getByTestId(toolTipValue).eq(i).should('not.be.empty'); + } + }); + function openMarketDropDown() { cy.getByTestId('dialog-close').click(); cy.getByTestId('popover-trigger').click(); diff --git a/apps/trading-e2e/src/support/index.ts b/apps/trading-e2e/src/support/index.ts index 4a49c7d38..27c1b1c02 100644 --- a/apps/trading-e2e/src/support/index.ts +++ b/apps/trading-e2e/src/support/index.ts @@ -1 +1,2 @@ import '@vegaprotocol/cypress'; +import 'cypress-real-events/support'; diff --git a/apps/trading-e2e/src/support/mocks/generate-market.ts b/apps/trading-e2e/src/support/mocks/generate-market.ts index 91a9d4b79..b9e7f6339 100644 --- a/apps/trading-e2e/src/support/mocks/generate-market.ts +++ b/apps/trading-e2e/src/support/mocks/generate-market.ts @@ -13,7 +13,7 @@ export const generateMarket = (override?: PartialDeep): Market => { market: { id: 'market-0', name: 'ACTIVE MARKET', - tradingMode: MarketTradingMode.Continuous, + tradingMode: MarketTradingMode.MonitoringAuction, state: MarketState.Active, decimalPlaces: 5, positionDecimalPlaces: 0, @@ -22,13 +22,18 @@ export const generateMarket = (override?: PartialDeep): Market => { id: '10cd0a793ad2887b340940337fa6d97a212e0e517fe8e9eab2b5ef3a38633f35', __typename: 'Market', }, + auctionStart: '2022-08-12T11:13:47.611014117Z', + auctionEnd: '2022-08-16T09:08:23.611014117Z', markPrice: '13739109', - indicativeVolume: '0', + indicativeVolume: '2316', + indicativePrice: '88470230', + suppliedStake: '79481836527', + targetStake: '97284519014', bestBidVolume: '244', bestOfferVolume: '100', bestStaticBidVolume: '482', bestStaticOfferVolume: '2188', - trigger: AuctionTrigger.Unspecified, + trigger: AuctionTrigger.Liquidity, __typename: 'MarketData', }, tradableInstrument: { diff --git a/apps/trading-e2e/tsconfig.json b/apps/trading-e2e/tsconfig.json index 117dbb681..35bbbfd52 100644 --- a/apps/trading-e2e/tsconfig.json +++ b/apps/trading-e2e/tsconfig.json @@ -5,7 +5,7 @@ "sourceMap": false, "outDir": "../../dist/out-tsc", "allowJs": true, - "types": ["cypress", "node"], + "types": ["cypress", "node", "cypress-real-events"], "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, diff --git a/apps/trading/components/trading-mode-tooltip/trading-mode-tooltip.tsx b/apps/trading/components/trading-mode-tooltip/trading-mode-tooltip.tsx index ecbbdd32b..3112be7c5 100644 --- a/apps/trading/components/trading-mode-tooltip/trading-mode-tooltip.tsx +++ b/apps/trading/components/trading-mode-tooltip/trading-mode-tooltip.tsx @@ -23,8 +23,8 @@ const MarketDataGrid = ({ grid }: MarketDataGridProps) => { ({ label, value, isEstimate }, index) => value && (
- {label} - + {label} + {isEstimate && {'~'}} {value} @@ -150,7 +150,7 @@ export const TradingModeTooltip = ({ market }: TradingModeTooltipProps) => { case AuctionTrigger.Liquidity: { return ( <> -

+

{t( 'This market is in auction until it reaches sufficient liquidity.'