2022-06-20 15:16:47 +00:00
|
|
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
2022-06-10 19:00:02 +00:00
|
|
|
import { MarketState } from '@vegaprotocol/types';
|
|
|
|
import { generateMarkets } from '../support/mocks/generate-markets';
|
|
|
|
import { mockTradingPage } from '../support/trading';
|
|
|
|
|
|
|
|
describe('markets table', () => {
|
|
|
|
beforeEach(() => {
|
2022-06-20 15:16:47 +00:00
|
|
|
cy.mockGQL((req) => {
|
|
|
|
aliasQuery(req, 'Markets', generateMarkets());
|
2022-06-10 19:00:02 +00:00
|
|
|
});
|
|
|
|
cy.visit('/markets');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders correctly', () => {
|
|
|
|
const marketRowHeaderClassname = 'div > span.ag-header-cell-text';
|
|
|
|
const marketRowNameColumn = 'tradableInstrument.instrument.code';
|
|
|
|
const marketRowSymbolColumn =
|
|
|
|
'tradableInstrument.instrument.product.settlementAsset.symbol';
|
|
|
|
const marketRowPrices = 'flash-cell';
|
|
|
|
const marketRowDescription = 'name';
|
|
|
|
|
|
|
|
cy.wait('@Markets');
|
|
|
|
cy.get('.ag-root-wrapper').should('be.visible');
|
|
|
|
|
|
|
|
const expectedMarketHeaders = [
|
|
|
|
'Market',
|
|
|
|
'Settlement asset',
|
|
|
|
'State',
|
|
|
|
'Best bid',
|
|
|
|
'Best offer',
|
|
|
|
'Mark price',
|
|
|
|
'Description',
|
|
|
|
];
|
|
|
|
|
|
|
|
for (let index = 0; index < expectedMarketHeaders.length; index++) {
|
|
|
|
cy.get(marketRowHeaderClassname).should(
|
|
|
|
'contain.text',
|
|
|
|
expectedMarketHeaders[index]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
cy.get(`[col-id='${marketRowNameColumn}']`).each(($marketName) => {
|
|
|
|
cy.wrap($marketName).should('not.be.empty');
|
|
|
|
});
|
|
|
|
|
|
|
|
cy.get(`[col-id='${marketRowSymbolColumn}']`).each(($marketSymbol) => {
|
|
|
|
cy.wrap($marketSymbol).should('not.be.empty');
|
|
|
|
});
|
|
|
|
|
|
|
|
cy.getByTestId(marketRowPrices).each(($price) => {
|
|
|
|
cy.wrap($price).should('not.be.empty').and('contain.text', '.');
|
|
|
|
});
|
|
|
|
|
|
|
|
cy.get(`[col-id='${marketRowDescription}']`).each(($marketDescription) => {
|
|
|
|
cy.wrap($marketDescription).should('not.be.empty');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can select an active market', () => {
|
|
|
|
cy.wait('@Markets');
|
|
|
|
cy.get('.ag-root-wrapper').should('be.visible');
|
|
|
|
|
2022-06-20 15:16:47 +00:00
|
|
|
cy.mockGQL((req) => {
|
|
|
|
mockTradingPage(req, MarketState.Active);
|
|
|
|
});
|
2022-06-10 19:00:02 +00:00
|
|
|
|
|
|
|
// click on active market
|
|
|
|
cy.get('[role="gridcell"][col-id=data]').should('be.visible');
|
|
|
|
cy.get('[role="gridcell"][col-id=data]').contains('Active').click();
|
|
|
|
|
|
|
|
cy.wait('@Market');
|
|
|
|
cy.contains('ACTIVE MARKET');
|
|
|
|
cy.url().should('include', '/markets/market-0');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can select a suspended market', () => {
|
|
|
|
cy.wait('@Markets');
|
|
|
|
cy.get('.ag-root-wrapper').should('be.visible');
|
|
|
|
|
2022-06-20 15:16:47 +00:00
|
|
|
cy.mockGQL((req) => {
|
|
|
|
mockTradingPage(req, MarketState.Suspended);
|
|
|
|
});
|
2022-06-10 19:00:02 +00:00
|
|
|
|
|
|
|
// click on active market
|
|
|
|
cy.get('[role="gridcell"][col-id=data]').should('be.visible');
|
|
|
|
cy.get('[role="gridcell"][col-id=data]').contains('Suspended').click();
|
|
|
|
|
|
|
|
cy.wait('@Market');
|
|
|
|
cy.contains('SUSPENDED MARKET');
|
|
|
|
cy.url().should('include', '/markets/market-1');
|
|
|
|
});
|
|
|
|
});
|