Test/294 orders list (#301)
* Order mocks generated * Tests passing with orders
This commit is contained in:
parent
29cd7dd2e4
commit
448e0ec78f
@ -28,3 +28,9 @@ Feature: Markets page
|
|||||||
And I connect to Vega Wallet
|
And I connect to Vega Wallet
|
||||||
When I click on positions tab
|
When I click on positions tab
|
||||||
Then positions are displayed
|
Then positions are displayed
|
||||||
|
|
||||||
|
Scenario: Placed orders displayed
|
||||||
|
Given I am on the trading page for an active market
|
||||||
|
And I connect to Vega Wallet
|
||||||
|
When I click on orders tab
|
||||||
|
Then placed orders are displayed
|
||||||
|
79
apps/trading-e2e/src/support/mocks/generate-orders.ts
Normal file
79
apps/trading-e2e/src/support/mocks/generate-orders.ts
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
import merge from 'lodash/merge';
|
||||||
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
import type { Orders, Orders_party_orders } from '@vegaprotocol/order-list';
|
||||||
|
import {
|
||||||
|
OrderStatus,
|
||||||
|
OrderTimeInForce,
|
||||||
|
OrderType,
|
||||||
|
Side,
|
||||||
|
} from '@vegaprotocol/types';
|
||||||
|
|
||||||
|
export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
|
||||||
|
const orders: Orders_party_orders[] = [
|
||||||
|
{
|
||||||
|
__typename: 'Order',
|
||||||
|
id: '066468C06549101DAF7BC51099E1412A0067DC08C246B7D8013C9D0CBF1E8EE7',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: 'c9f5acd348796011c075077e4d58d9b7f1689b7c1c8e030a5e886b83aa96923d',
|
||||||
|
name: 'AAVEDAI Monthly (30 Jun 2022)',
|
||||||
|
decimalPlaces: 5,
|
||||||
|
tradableInstrument: {
|
||||||
|
__typename: 'TradableInstrument',
|
||||||
|
instrument: {
|
||||||
|
__typename: 'Instrument',
|
||||||
|
code: 'AAVEDAI.MF21',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
size: '10',
|
||||||
|
type: OrderType.Limit,
|
||||||
|
status: OrderStatus.Filled,
|
||||||
|
side: Side.Buy,
|
||||||
|
remaining: '0',
|
||||||
|
price: '20000000',
|
||||||
|
timeInForce: OrderTimeInForce.GTC,
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
updatedAt: null,
|
||||||
|
expiresAt: null,
|
||||||
|
rejectionReason: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: 'Order',
|
||||||
|
id: '48DB6767E4E4E0F649C5A13ABFADE39F8451C27DA828DAF14B7A1E8E5EBDAD99',
|
||||||
|
market: {
|
||||||
|
__typename: 'Market',
|
||||||
|
id: '5a4b0b9e9c0629f0315ec56fcb7bd444b0c6e4da5ec7677719d502626658a376',
|
||||||
|
name: 'Tesla Quarterly (30 Jun 2022)',
|
||||||
|
decimalPlaces: 5,
|
||||||
|
tradableInstrument: {
|
||||||
|
__typename: 'TradableInstrument',
|
||||||
|
instrument: {
|
||||||
|
__typename: 'Instrument',
|
||||||
|
code: 'TSLA.QM21',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
size: '1',
|
||||||
|
type: OrderType.Limit,
|
||||||
|
status: OrderStatus.Filled,
|
||||||
|
side: Side.Buy,
|
||||||
|
remaining: '0',
|
||||||
|
price: '0',
|
||||||
|
timeInForce: OrderTimeInForce.GTC,
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
updatedAt: null,
|
||||||
|
expiresAt: null,
|
||||||
|
rejectionReason: null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const defaultResult = {
|
||||||
|
party: {
|
||||||
|
id: Cypress.env('vegaPublicKey'),
|
||||||
|
orders,
|
||||||
|
__typename: 'Party',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return merge(defaultResult, override);
|
||||||
|
};
|
@ -1,18 +1,20 @@
|
|||||||
import { Given, Then } from 'cypress-cucumber-preprocessor/steps';
|
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps';
|
||||||
import { hasOperationName } from '..';
|
import { hasOperationName } from '..';
|
||||||
import { MarketState } from '@vegaprotocol/types';
|
import { MarketState } from '@vegaprotocol/types';
|
||||||
import TradesList from '../trading-windows/trades-list';
|
|
||||||
import TradingPage from '../pages/trading-page';
|
|
||||||
import { generateChart } from '../mocks/generate-chart';
|
import { generateChart } from '../mocks/generate-chart';
|
||||||
import { generateCandles } from '../mocks/generate-candles';
|
import { generateCandles } from '../mocks/generate-candles';
|
||||||
import { generateTrades } from '../mocks/generate-trades';
|
import { generateTrades } from '../mocks/generate-trades';
|
||||||
import { generateDealTicketQuery } from '../mocks/generate-deal-ticket-query';
|
import { generateDealTicketQuery } from '../mocks/generate-deal-ticket-query';
|
||||||
import { generateMarket } from '../mocks/generate-market';
|
import { generateMarket } from '../mocks/generate-market';
|
||||||
|
import { generateOrders } from '../mocks/generate-orders';
|
||||||
import { generatePositions } from '../mocks/generate-positions';
|
import { generatePositions } from '../mocks/generate-positions';
|
||||||
|
import TradesList from '../trading-windows/trades-list';
|
||||||
|
import TradingPage from '../pages/trading-page';
|
||||||
|
import OrderList from '../trading-windows/orders-list';
|
||||||
|
|
||||||
const tradesList = new TradesList();
|
const tradesList = new TradesList();
|
||||||
const tradingPage = new TradingPage();
|
const tradingPage = new TradingPage();
|
||||||
/* eslint-enable @nrwl/nx/enforce-module-boundaries */
|
const ordersList = new OrderList();
|
||||||
|
|
||||||
const mockMarket = (state: MarketState) => {
|
const mockMarket = (state: MarketState) => {
|
||||||
cy.mockGQL('Market', (req) => {
|
cy.mockGQL('Market', (req) => {
|
||||||
@ -28,6 +30,12 @@ const mockMarket = (state: MarketState) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasOperationName(req, 'Orders')) {
|
||||||
|
req.reply({
|
||||||
|
body: { data: generateOrders() },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (hasOperationName(req, 'Positions')) {
|
if (hasOperationName(req, 'Positions')) {
|
||||||
req.reply({
|
req.reply({
|
||||||
body: { data: generatePositions() },
|
body: { data: generatePositions() },
|
||||||
@ -76,6 +84,10 @@ Given('I am on the trading page for a suspended market', () => {
|
|||||||
cy.contains('Market: SUSPENDED MARKET');
|
cy.contains('Market: SUSPENDED MARKET');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
When('I click on orders tab', () => {
|
||||||
|
tradingPage.clickOnOrdersTab();
|
||||||
|
});
|
||||||
|
|
||||||
Then('trading page for {string} market is displayed', (marketType) => {
|
Then('trading page for {string} market is displayed', (marketType) => {
|
||||||
switch (marketType) {
|
switch (marketType) {
|
||||||
case 'active':
|
case 'active':
|
||||||
@ -92,3 +104,7 @@ Then('trading page for {string} market is displayed', (marketType) => {
|
|||||||
tradingPage.clickOnTradesTab();
|
tradingPage.clickOnTradesTab();
|
||||||
tradesList.verifyTradesListDisplayed();
|
tradesList.verifyTradesListDisplayed();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Then('placed orders are displayed', () => {
|
||||||
|
ordersList.verifyOrdersDisplayed();
|
||||||
|
});
|
||||||
|
37
apps/trading-e2e/src/support/trading-windows/orders-list.ts
Normal file
37
apps/trading-e2e/src/support/trading-windows/orders-list.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
export default class OrdersList {
|
||||||
|
orderSymbol = 'market.tradableInstrument.instrument.code';
|
||||||
|
orderSize = 'size';
|
||||||
|
orderType = 'type';
|
||||||
|
orderStatus = 'status';
|
||||||
|
orderRemaining = 'remaining';
|
||||||
|
orderPrice = 'price';
|
||||||
|
orderTimeInForce = 'timeInForce';
|
||||||
|
orderCreatedAt = 'createdAt';
|
||||||
|
|
||||||
|
verifyOrdersDisplayed() {
|
||||||
|
cy.get(`[col-id='${this.orderSymbol}']`).each(($symbol) => {
|
||||||
|
cy.wrap($symbol).invoke('text').should('not.be.empty');
|
||||||
|
});
|
||||||
|
cy.get(`[col-id='${this.orderSize}']`).each(($size) => {
|
||||||
|
cy.wrap($size).invoke('text').should('not.be.empty');
|
||||||
|
});
|
||||||
|
cy.get(`[col-id='${this.orderType}']`).each(($type) => {
|
||||||
|
cy.wrap($type).invoke('text').should('not.be.empty');
|
||||||
|
});
|
||||||
|
cy.get(`[col-id='${this.orderStatus}']`).each(($status) => {
|
||||||
|
cy.wrap($status).invoke('text').should('not.be.empty');
|
||||||
|
});
|
||||||
|
cy.get(`[col-id='${this.orderRemaining}']`).each(($remaining) => {
|
||||||
|
cy.wrap($remaining).invoke('text').should('not.be.empty');
|
||||||
|
});
|
||||||
|
cy.get(`[col-id='${this.orderPrice}']`).each(($price) => {
|
||||||
|
cy.wrap($price).invoke('text').should('not.be.empty');
|
||||||
|
});
|
||||||
|
cy.get(`[col-id='${this.orderTimeInForce}']`).each(($timeInForce) => {
|
||||||
|
cy.wrap($timeInForce).invoke('text').should('not.be.empty');
|
||||||
|
});
|
||||||
|
cy.get(`[col-id='${this.orderCreatedAt}']`).each(($dateTime) => {
|
||||||
|
cy.wrap($dateTime).invoke('text').should('not.be.empty');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,2 +1,3 @@
|
|||||||
export * from './lib/order-list';
|
export * from './lib/order-list';
|
||||||
export * from './lib/order-list-container';
|
export * from './lib/order-list-container';
|
||||||
|
export * from './lib/__generated__/Orders';
|
||||||
|
Loading…
Reference in New Issue
Block a user