vega-frontend-monorepo/apps/trading-e2e/src/integration/markets.cy.ts
m.ray 0523b56e39
feat: market list mega dropdown (rich popover) (#889)
* feat: use MarketList query only

* fix: remove Market.ts from index

* feat: 30 refactor dialog, market list, change query

* feat: #30 add indicativeVolume, total fees, tooltip, large dialog, tooltip accepts html description

* fix: #30 total fees display in tooltip

* fix: #30 toggle title on dialog open

* fix: #30 fix order, price, high, low utils

* fix: #30 fix test for market utils

* feat: #30 add popover with markets to select

* feat: #30 storybook popover

* feat: #30 remove border on trigger and add some other classes

* fix:  #30 fix format check with format:write

* feat: #30 add tooltip on taker fee

* feat: #30 add tooltip on taker fee

* fix: #30 format on select market list

* fix: #30 remove unknown cast in test mock data

* fix: #30 show markets where you have open positions

* fix: #30 double check if open positions

* fix: #30 dialog has only small/large sizes

* feat: #30 add border on trigger and change padding and no wrap

* fix: #30 if fees or factors are not found

* fix: #30 remove markets.cy tests as markets page is now gone

* fix #30 remove view full market list test

* fix: #30 add rotating arrow on market title

* fix: #30 add ease-in-out on popover

* fix: #30 add ease-in-out on popover

* fix: #30 align select a market table

* fix: #30 select a market title

* fix: #30 select a market title

* fix: #30 fix any validateDOMnesting issues

* fix: #30 show loading market data

* fix: #30 add list of header columns

* fix: #30 add list of header columns

* fix: #30 small refactoring after review

* fix: #30 update bold undreline class names

* fix: #30 add large-mobile size

* feat: #30 refactor select markets tables to render array of columns

* fix: #30 remove size from select market dialog

* fix: #30 add extra file for columns

* fix: #30 update formtting

* fix: #30 make sure popup closes on same market navigation

* fix: rename market-utils, add calcCandle methods, store market id on select

* fix: useMemo ondata and marketPositionData + orderbook stories fix

* feat: #30 add open volume positions

* fix: add market summary back

* fix: update formatting

* fix: use currentcolor on arrow

* fix: create all markets page

* fix: add overflow-y auto

* fix: enlarge select market to get started dialog

* fix: revert markets container

* fix: use query to fix flickering on position markets

* fix: edit unordered list in tooltips

* fix: fix tooltip table

* fix: fix home.cy.ts

* chore: skip /markets tests
2022-08-11 12:56:35 +01:00

95 lines
2.9 KiB
TypeScript

import { aliasQuery } from '@vegaprotocol/cypress';
import { MarketState } from '@vegaprotocol/types';
import { generateMarkets } from '../support/mocks/generate-markets';
import { mockTradingPage } from '../support/trading';
describe('markets table', () => {
beforeEach(() => {
cy.mockGQL((req) => {
aliasQuery(req, 'Markets', generateMarkets());
});
cy.visit('/markets');
});
it.skip('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',
'Trading mode',
'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.skip('can select an active market', () => {
cy.wait('@Markets');
cy.get('.ag-root-wrapper').should('be.visible');
cy.mockGQL((req) => {
mockTradingPage(req, MarketState.Active);
});
// click on market
cy.get('[role="gridcell"][col-id=data]').should('be.visible');
cy.get('[role="gridcell"][col-id=name]').contains('ACTIVE MARKET').click();
cy.wait('@Market');
cy.contains('ACTIVE MARKET');
cy.url().should('include', '/markets/market-0');
verifyMarketSummaryDisplayed();
});
function verifyMarketSummaryDisplayed() {
const marketSummaryBlock = 'market-summary';
const percentageValue = 'price-change-percentage';
const priceChangeValue = 'price-change';
const tradingVolume = 'trading-volume';
const tradingMode = 'trading-mode';
cy.getByTestId(marketSummaryBlock).within(() => {
cy.contains('Change (24h)');
cy.getByTestId(percentageValue).should('not.be.empty');
cy.getByTestId(priceChangeValue).should('not.be.empty');
cy.contains('Volume');
cy.getByTestId(tradingVolume).should('not.be.empty');
cy.contains('Trading mode');
cy.getByTestId(tradingMode).should('not.be.empty');
});
}
});