test: add test for partially filled order view (#1218)
This commit is contained in:
parent
9e8d34cf9a
commit
72ce253102
@ -2,11 +2,15 @@ import { MarketState } from '@vegaprotocol/types';
|
||||
import { mockTradingPage } from '../support/trading';
|
||||
import { connectVegaWallet } from '../support/vega-wallet';
|
||||
|
||||
beforeEach(() => {
|
||||
before(() => {
|
||||
cy.mockGQL((req) => {
|
||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
||||
});
|
||||
cy.visit('/markets/market-0');
|
||||
cy.getByTestId('Orders').click();
|
||||
cy.getByTestId('tab-orders').contains('Please connect Vega wallet');
|
||||
|
||||
connectVegaWallet();
|
||||
});
|
||||
|
||||
describe('orders', () => {
|
||||
@ -18,13 +22,8 @@ describe('orders', () => {
|
||||
const orderPrice = 'price';
|
||||
const orderTimeInForce = 'timeInForce';
|
||||
const orderCreatedAt = 'createdAt';
|
||||
|
||||
beforeEach(() => {
|
||||
cy.getByTestId('Orders').click();
|
||||
cy.getByTestId('tab-orders').contains('Please connect Vega wallet');
|
||||
|
||||
connectVegaWallet();
|
||||
});
|
||||
const cancelOrderBtn = 'cancel';
|
||||
const editOrderBtn = 'edit';
|
||||
|
||||
it('renders orders', () => {
|
||||
cy.getByTestId('tab-orders').should('be.visible');
|
||||
@ -62,27 +61,41 @@ describe('orders', () => {
|
||||
cy.wrap($dateTime).invoke('text').should('not.be.empty');
|
||||
});
|
||||
|
||||
cy.getByTestId('cancel')
|
||||
cy.getByTestId(cancelOrderBtn)
|
||||
.should('be.visible')
|
||||
.and('have.length.at.least', 1);
|
||||
|
||||
cy.getByTestId('edit')
|
||||
cy.getByTestId(editOrderBtn)
|
||||
.should('be.visible')
|
||||
.and('have.length.at.least', 1);
|
||||
});
|
||||
});
|
||||
|
||||
it('partially filled orders should not show close/edit buttons', () => {
|
||||
cy.getByTestId('tab-orders').should('be.visible');
|
||||
cy.get('[row-index="4"]').within(() => {
|
||||
cy.get(`[col-id='${orderStatus}']`).should(
|
||||
'have.text',
|
||||
'PartiallyFilled'
|
||||
);
|
||||
cy.get(`[col-id='${orderRemaining}']`).should('have.text', '7/10');
|
||||
cy.getByTestId(cancelOrderBtn).should('not.exist');
|
||||
cy.getByTestId(editOrderBtn).should('not.exist');
|
||||
});
|
||||
});
|
||||
|
||||
it('orders are sorted by most recent order', () => {
|
||||
const expectedOrderList = [
|
||||
'AAVEDAI.MF21',
|
||||
'TSLA.QM21',
|
||||
'BTCUSD.MF21',
|
||||
'UNIDAI.MF21',
|
||||
'UNIDAI.MF21',
|
||||
];
|
||||
|
||||
cy.getByTestId('tab-orders')
|
||||
.get(`[col-id='${orderSymbol}']`)
|
||||
.should('have.length.at.least', 3)
|
||||
.should('have.length.at.least', 4)
|
||||
.each(($symbol, index) => {
|
||||
if (index != 0) {
|
||||
cy.wrap($symbol).should('have.text', expectedOrderList[index - 1]);
|
||||
|
@ -133,6 +133,36 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
|
||||
expiresAt: null,
|
||||
rejectionReason: null,
|
||||
},
|
||||
{
|
||||
__typename: 'Order',
|
||||
id: '94aead3ca92dc932efcb503631b03a410e2a5d4606cae6083e2406dc38e52f78',
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
id: 'a316fa51dab97d76a1472c2f22906f4e461728e04355096788165d5b13999ed5',
|
||||
name: 'UNIDAI Monthly (30 Jun 2022)',
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 0,
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
id: '',
|
||||
__typename: 'Instrument',
|
||||
code: 'UNIDAI.MF21',
|
||||
},
|
||||
},
|
||||
},
|
||||
size: '10',
|
||||
type: OrderType.TYPE_LIMIT,
|
||||
status: OrderStatus.STATUS_PARTIALLY_FILLED,
|
||||
side: Side.SIDE_SELL,
|
||||
remaining: '3',
|
||||
price: '100000',
|
||||
timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC,
|
||||
createdAt: new Date(2020, 1, 27).toISOString(),
|
||||
updatedAt: null,
|
||||
expiresAt: null,
|
||||
rejectionReason: null,
|
||||
},
|
||||
];
|
||||
|
||||
const defaultResult: Orders = {
|
||||
|
Loading…
Reference in New Issue
Block a user