test: additional test for sorted orders (#613)

This commit is contained in:
Joe Tsang 2022-06-23 22:56:12 +01:00 committed by GitHub
parent 8978cbed9f
commit a9df2f425d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 3 deletions

View File

@ -19,12 +19,14 @@ describe('orders', () => {
const orderTimeInForce = 'timeInForce'; const orderTimeInForce = 'timeInForce';
const orderCreatedAt = 'createdAt'; const orderCreatedAt = 'createdAt';
it('renders orders', () => { beforeEach(() => {
cy.getByTestId('Orders').click(); cy.getByTestId('Orders').click();
cy.getByTestId('tab-orders').contains('Please connect Vega wallet'); cy.getByTestId('tab-orders').contains('Please connect Vega wallet');
connectVegaWallet(); connectVegaWallet();
});
it('renders orders', () => {
cy.getByTestId('tab-orders').should('be.visible'); cy.getByTestId('tab-orders').should('be.visible');
cy.getByTestId('tab-orders') cy.getByTestId('tab-orders')
@ -68,4 +70,17 @@ describe('orders', () => {
cy.wrap($dateTime).invoke('text').should('not.be.empty'); 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]);
}
});
});
}); });

View File

@ -33,7 +33,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
remaining: '0', remaining: '0',
price: '20000000', price: '20000000',
timeInForce: OrderTimeInForce.GTC, timeInForce: OrderTimeInForce.GTC,
createdAt: new Date().toISOString(), createdAt: new Date(2020, 1, 1).toISOString(),
updatedAt: null, updatedAt: null,
expiresAt: null, expiresAt: null,
rejectionReason: null, rejectionReason: null,
@ -59,13 +59,41 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
status: OrderStatus.Filled, status: OrderStatus.Filled,
side: Side.Buy, side: Side.Buy,
remaining: '0', remaining: '0',
price: '0', price: '100',
timeInForce: OrderTimeInForce.GTC, timeInForce: OrderTimeInForce.GTC,
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
updatedAt: null, updatedAt: null,
expiresAt: null, expiresAt: null,
rejectionReason: 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 = { const defaultResult = {