2022-06-10 19:00:02 +00:00
|
|
|
import { MarketState } from '@vegaprotocol/types';
|
|
|
|
import { mockTradingPage } from '../support/trading';
|
|
|
|
import { connectVegaWallet } from '../support/vega-wallet';
|
|
|
|
|
2022-09-02 09:04:38 +00:00
|
|
|
before(() => {
|
2022-06-20 15:16:47 +00:00
|
|
|
cy.mockGQL((req) => {
|
2022-08-22 22:50:13 +00:00
|
|
|
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
2022-06-20 15:16:47 +00:00
|
|
|
});
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.visit('/markets/market-0');
|
2022-09-02 09:04:38 +00:00
|
|
|
cy.getByTestId('Orders').click();
|
|
|
|
cy.getByTestId('tab-orders').contains('Please connect Vega wallet');
|
|
|
|
|
|
|
|
connectVegaWallet();
|
2022-06-10 19:00:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('orders', () => {
|
|
|
|
const orderSymbol = 'market.tradableInstrument.instrument.code';
|
|
|
|
const orderSize = 'size';
|
|
|
|
const orderType = 'type';
|
|
|
|
const orderStatus = 'status';
|
|
|
|
const orderRemaining = 'remaining';
|
|
|
|
const orderPrice = 'price';
|
|
|
|
const orderTimeInForce = 'timeInForce';
|
|
|
|
const orderCreatedAt = 'createdAt';
|
2022-09-02 09:04:38 +00:00
|
|
|
const cancelOrderBtn = 'cancel';
|
|
|
|
const editOrderBtn = 'edit';
|
2022-06-10 19:00:02 +00:00
|
|
|
|
2022-06-23 21:56:12 +00:00
|
|
|
it('renders orders', () => {
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.getByTestId('tab-orders').should('be.visible');
|
|
|
|
|
2022-07-18 10:54:02 +00:00
|
|
|
cy.getByTestId('tab-orders').within(() => {
|
|
|
|
cy.get(`[col-id='${orderSymbol}']`).each(($symbol) => {
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.wrap($symbol).invoke('text').should('not.be.empty');
|
|
|
|
});
|
2022-07-18 10:54:02 +00:00
|
|
|
|
|
|
|
cy.get(`[col-id='${orderSize}']`).each(($size) => {
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.wrap($size).invoke('text').should('not.be.empty');
|
|
|
|
});
|
2022-07-18 10:54:02 +00:00
|
|
|
|
|
|
|
cy.get(`[col-id='${orderType}']`).each(($type) => {
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.wrap($type).invoke('text').should('not.be.empty');
|
|
|
|
});
|
2022-07-18 10:54:02 +00:00
|
|
|
|
|
|
|
cy.get(`[col-id='${orderStatus}']`).each(($status) => {
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.wrap($status).invoke('text').should('not.be.empty');
|
|
|
|
});
|
2022-07-18 10:54:02 +00:00
|
|
|
|
|
|
|
cy.get(`[col-id='${orderRemaining}']`).each(($remaining) => {
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.wrap($remaining).invoke('text').should('not.be.empty');
|
|
|
|
});
|
2022-07-18 10:54:02 +00:00
|
|
|
|
|
|
|
cy.get(`[col-id='${orderPrice}']`).each(($price) => {
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.wrap($price).invoke('text').should('not.be.empty');
|
|
|
|
});
|
2022-07-18 10:54:02 +00:00
|
|
|
|
|
|
|
cy.get(`[col-id='${orderTimeInForce}']`).each(($timeInForce) => {
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.wrap($timeInForce).invoke('text').should('not.be.empty');
|
|
|
|
});
|
2022-07-18 10:54:02 +00:00
|
|
|
|
|
|
|
cy.get(`[col-id='${orderCreatedAt}']`).each(($dateTime) => {
|
2022-06-10 19:00:02 +00:00
|
|
|
cy.wrap($dateTime).invoke('text').should('not.be.empty');
|
|
|
|
});
|
2022-07-18 10:54:02 +00:00
|
|
|
|
2022-09-02 09:04:38 +00:00
|
|
|
cy.getByTestId(cancelOrderBtn)
|
2022-07-18 10:54:02 +00:00
|
|
|
.should('be.visible')
|
|
|
|
.and('have.length.at.least', 1);
|
2022-08-11 10:26:26 +00:00
|
|
|
|
2022-09-02 09:04:38 +00:00
|
|
|
cy.getByTestId(editOrderBtn)
|
2022-08-11 10:26:26 +00:00
|
|
|
.should('be.visible')
|
|
|
|
.and('have.length.at.least', 1);
|
2022-07-18 10:54:02 +00:00
|
|
|
});
|
2022-06-10 19:00:02 +00:00
|
|
|
});
|
2022-06-23 21:56:12 +00:00
|
|
|
|
2022-09-02 09:04:38 +00:00
|
|
|
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');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-06-23 21:56:12 +00:00
|
|
|
it('orders are sorted by most recent order', () => {
|
2022-07-18 10:54:02 +00:00
|
|
|
const expectedOrderList = [
|
2022-07-21 13:25:37 +00:00
|
|
|
'AAVEDAI.MF21',
|
2022-07-18 10:54:02 +00:00
|
|
|
'TSLA.QM21',
|
|
|
|
'BTCUSD.MF21',
|
2022-07-21 13:25:37 +00:00
|
|
|
'UNIDAI.MF21',
|
2022-09-02 09:04:38 +00:00
|
|
|
'UNIDAI.MF21',
|
2022-07-18 10:54:02 +00:00
|
|
|
];
|
2022-06-23 21:56:12 +00:00
|
|
|
|
|
|
|
cy.getByTestId('tab-orders')
|
|
|
|
.get(`[col-id='${orderSymbol}']`)
|
2022-09-02 09:04:38 +00:00
|
|
|
.should('have.length.at.least', 4)
|
2022-06-23 21:56:12 +00:00
|
|
|
.each(($symbol, index) => {
|
|
|
|
if (index != 0) {
|
|
|
|
cy.wrap($symbol).should('have.text', expectedOrderList[index - 1]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2022-06-10 19:00:02 +00:00
|
|
|
});
|