From a9df2f425db5a6838045bdb022f4796694a27c9e Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Thu, 23 Jun 2022 22:56:12 +0100 Subject: [PATCH] test: additional test for sorted orders (#613) --- .../src/integration/trading-orders.ts | 17 +++++++++- .../src/support/mocks/generate-orders.ts | 32 +++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/apps/trading-e2e/src/integration/trading-orders.ts b/apps/trading-e2e/src/integration/trading-orders.ts index 22bed6fcc..88ffd9b5e 100644 --- a/apps/trading-e2e/src/integration/trading-orders.ts +++ b/apps/trading-e2e/src/integration/trading-orders.ts @@ -19,12 +19,14 @@ describe('orders', () => { const orderTimeInForce = 'timeInForce'; const orderCreatedAt = 'createdAt'; - it('renders orders', () => { + beforeEach(() => { cy.getByTestId('Orders').click(); cy.getByTestId('tab-orders').contains('Please connect Vega wallet'); connectVegaWallet(); + }); + it('renders orders', () => { cy.getByTestId('tab-orders').should('be.visible'); cy.getByTestId('tab-orders') @@ -68,4 +70,17 @@ describe('orders', () => { cy.wrap($dateTime).invoke('text').should('not.be.empty'); }); }); + + it('orders are sorted by most recent order', () => { + const expectedOrderList = ['TSLA.QM21', 'BTCUSD.MF21', 'AAVEDAI.MF21']; + + cy.getByTestId('tab-orders') + .get(`[col-id='${orderSymbol}']`) + .should('have.length.at.least', 3) + .each(($symbol, index) => { + if (index != 0) { + cy.wrap($symbol).should('have.text', expectedOrderList[index - 1]); + } + }); + }); }); diff --git a/apps/trading-e2e/src/support/mocks/generate-orders.ts b/apps/trading-e2e/src/support/mocks/generate-orders.ts index 7f54fd796..e65220da1 100644 --- a/apps/trading-e2e/src/support/mocks/generate-orders.ts +++ b/apps/trading-e2e/src/support/mocks/generate-orders.ts @@ -33,7 +33,7 @@ export const generateOrders = (override?: PartialDeep): Orders => { remaining: '0', price: '20000000', timeInForce: OrderTimeInForce.GTC, - createdAt: new Date().toISOString(), + createdAt: new Date(2020, 1, 1).toISOString(), updatedAt: null, expiresAt: null, rejectionReason: null, @@ -59,13 +59,41 @@ export const generateOrders = (override?: PartialDeep): Orders => { status: OrderStatus.Filled, side: Side.Buy, remaining: '0', - price: '0', + price: '100', timeInForce: OrderTimeInForce.GTC, createdAt: new Date().toISOString(), updatedAt: null, expiresAt: null, rejectionReason: null, }, + { + __typename: 'Order', + id: '4e93702990712c41f6995fcbbd94f60bb372ad12d64dfa7d96d205c49f790336', + market: { + __typename: 'Market', + id: 'c6f4337b31ed57a961969c3ba10297b369d01b9e75a4cbb96db4fc62886444e6', + name: 'BTCUSD Monthly (30 Jun 2022)', + decimalPlaces: 5, + tradableInstrument: { + __typename: 'TradableInstrument', + instrument: { + __typename: 'Instrument', + code: 'BTCUSD.MF21', + }, + }, + }, + size: '1', + type: OrderType.Limit, + status: OrderStatus.Filled, + side: Side.Buy, + remaining: '0', + price: '20000', + timeInForce: OrderTimeInForce.GTC, + createdAt: new Date(2022, 5, 10).toISOString(), + updatedAt: null, + expiresAt: null, + rejectionReason: null, + }, ]; const defaultResult = {