From 3a3b5cbc9ab82d75d768315da5d7fa7a604bd9e7 Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Wed, 31 Aug 2022 07:03:56 +0100 Subject: [PATCH] test: trading fills tab on accounts (#1168) --- ...tfolio-fills.cy.ts => trading-fills.cy.ts} | 130 ++++++++++-------- 1 file changed, 73 insertions(+), 57 deletions(-) rename apps/trading-e2e/src/integration/{portfolio-fills.cy.ts => trading-fills.cy.ts} (61%) diff --git a/apps/trading-e2e/src/integration/portfolio-fills.cy.ts b/apps/trading-e2e/src/integration/trading-fills.cy.ts similarity index 61% rename from apps/trading-e2e/src/integration/portfolio-fills.cy.ts rename to apps/trading-e2e/src/integration/trading-fills.cy.ts index e52d20767..9c78895e6 100644 --- a/apps/trading-e2e/src/integration/portfolio-fills.cy.ts +++ b/apps/trading-e2e/src/integration/trading-fills.cy.ts @@ -1,76 +1,92 @@ import { aliasQuery } from '@vegaprotocol/cypress'; import { generateFill, generateFills } from '../support/mocks/generate-fills'; import { Side } from '@vegaprotocol/types'; +import { MarketState } from '@vegaprotocol/types'; import { connectVegaWallet } from '../support/vega-wallet'; +import { mockTradingPage } from '../support/trading'; import { generateNetworkParameters } from '../support/mocks/generate-network-parameters'; +const fills = [ + generateFill({ + buyer: { + id: Cypress.env('VEGA_PUBLIC_KEY'), + }, + }), + generateFill({ + id: '1', + seller: { + id: Cypress.env('VEGA_PUBLIC_KEY'), + }, + aggressor: Side.SIDE_SELL, + buyerFee: { + infrastructureFee: '5000', + }, + market: { + name: 'Apples Daily v3', + positionDecimalPlaces: 2, + }, + }), + generateFill({ + id: '2', + seller: { + id: Cypress.env('VEGA_PUBLIC_KEY'), + }, + aggressor: Side.SIDE_BUY, + }), + generateFill({ + id: '3', + aggressor: Side.SIDE_SELL, + market: { + name: 'ETHBTC Quarterly (30 Jun 2022)', + }, + buyer: { + id: Cypress.env('VEGA_PUBLIC_KEY'), + }, + }), +]; +const result = generateFills({ + party: { + tradesConnection: { + edges: fills.map((f, i) => { + return { + __typename: 'TradeEdge', + node: f, + cursor: i.toString(), + }; + }), + }, + }, +}); + describe('fills', () => { - before(() => { - const fills = [ - generateFill({ - buyer: { - id: Cypress.env('VEGA_PUBLIC_KEY'), - }, - }), - generateFill({ - id: '1', - seller: { - id: Cypress.env('VEGA_PUBLIC_KEY'), - }, - aggressor: Side.SIDE_SELL, - buyerFee: { - infrastructureFee: '5000', - }, - market: { - name: 'Apples Daily v3', - positionDecimalPlaces: 2, - }, - }), - generateFill({ - id: '2', - seller: { - id: Cypress.env('VEGA_PUBLIC_KEY'), - }, - aggressor: Side.SIDE_BUY, - }), - generateFill({ - id: '3', - aggressor: Side.SIDE_SELL, - market: { - name: 'ETHBTC Quarterly (30 Jun 2022)', - }, - buyer: { - id: Cypress.env('VEGA_PUBLIC_KEY'), - }, - }), - ]; - const result = generateFills({ - party: { - tradesConnection: { - edges: fills.map((f, i) => { - return { - __typename: 'TradeEdge', - node: f, - cursor: i.toString(), - }; - }), - }, - }, - }); + beforeEach(() => { cy.mockGQL((req) => { aliasQuery(req, 'Fills', result); aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters()); }); - cy.visit('/portfolio'); - cy.get('main[data-testid="portfolio"]').should('exist'); }); - it('renders fills', () => { + it('renders fills on portfolio page', () => { + cy.visit('/portfolio'); + cy.get('main[data-testid="portfolio"]').should('exist'); cy.getByTestId('Fills').click(); cy.getByTestId('tab-fills').contains('Connect your Vega wallet'); - connectVegaWallet(); + validateFillsDisplayed(); + }); + it('renders fills on trading tab', () => { + cy.mockGQL((req) => { + mockTradingPage(req, MarketState.STATE_ACTIVE); + }); + cy.visit('/markets/market-0'); + cy.getByTestId('Fills').click(); + cy.getByTestId('tab-fills').contains('Please connect Vega wallet'); + connectVegaWallet(); + validateFillsDisplayed(); + }); + + function validateFillsDisplayed() { cy.getByTestId('tab-fills').should('be.visible'); cy.getByTestId('tab-fills') @@ -118,5 +134,5 @@ describe('fills', () => { cy.wrap($tradeDateTime).invoke('text').should('match', dateTimeRegex); } }); - }); + } });