vega-frontend-monorepo/apps/trading-e2e/src/integration/markets.cy.ts

147 lines
4.7 KiB
TypeScript
Raw Normal View History

import { MarketState } from '@vegaprotocol/types';
import { mockTradingPage } from '../support/trading';
describe('markets table', () => {
beforeEach(() => {
cy.mockGQL((req) => {
mockTradingPage(req, MarketState.STATE_ACTIVE);
});
});
it('renders markets correctly', () => {
cy.visit('/');
cy.wait('@MarketList');
cy.get('[data-testid^="market-link-"]')
.should('not.be.empty')
.and('have.attr', 'href');
cy.getByTestId('price').invoke('text').should('not.be.empty');
cy.getByTestId('settlement-asset').should('not.be.empty');
cy.getByTestId('price-change-percentage').should('not.be.empty');
cy.getByTestId('price-change').should('not.be.empty');
cy.getByTestId('sparkline-svg').should('be.visible');
});
it('renders market list drop down', () => {
cy.visit('/');
cy.wait('@MarketList');
openMarketDropDown();
cy.getByTestId('price').invoke('text').should('not.be.empty');
cy.getByTestId('trading-mode').should('not.be.empty');
cy.getByTestId('taker-fee').should('contain.text', '%');
cy.getByTestId('market-volume').should('not.be.empty');
cy.getByTestId('market-name').should('not.be.empty');
});
it('Able to select market from dropdown', () => {
cy.visit('/');
cy.wait('@MarketList');
openMarketDropDown();
cy.getByTestId('market-link-market-0').should('be.visible').click();
cy.wait('@Market');
cy.contains('ACTIVE MARKET');
cy.url().should('include', '/markets/market-0');
fix: filter rejected markets, order when suspended, remove market state from header, show continuous trading (#761) * fix: #603 filter out rejected markets & dialog lg width * fix: #609 show trading mode Continuous Trading and hide market state * fix: #656 modify order validation to trade when suspended * fix: #656 fix use order validation tests * fix: #656 format volume no * fix: format volume with positionDecimalPlaces * fix: tests don't need to be async * fix: md:w-[720px] to prevent dialog overflow * fix: add market state translations * fix: imprt type validation props * Update libs/orders/src/lib/order-hooks/use-order-validation.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update libs/orders/src/lib/order-hooks/use-order-validation.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update libs/orders/src/lib/order-hooks/use-order-validation.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update libs/orders/src/lib/order-hooks/use-order-validation.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update libs/orders/src/lib/order-hooks/use-order-validation.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update libs/orders/src/lib/order-hooks/use-order-validation.spec.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update apps/trading/pages/markets/__generated__/Market.ts Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * fix: fix warning messages based on feedback * fix: capitalize trading mode * fix: capitalize trading mode * fix: remove line 72 on markets.cy.ts * fix: don't show trigger if unspecified * fix: format last price and shrink 0 on warning icon * fix: order sizes must be whole numbers for this market and input warning size 20 * fix: order sizes must be whole numbers for this market and input warning size 20 * fix: format market list * fix: remove market state check from markets.cy.ts * fix: remove market state check from markets.cy.ts * fix: remove market state check from markets.cy.ts * Revert "fix: remove market state check from markets.cy.ts" This reverts commit c9ab55c98a7373342bb4d2d4699fd2c9e726e96e. * Revert "fix: remove market state check from markets.cy.ts" This reverts commit be60e56d8a944ab2c2240ac2683f22fc7cc76bad. * fix: fix markets.cy.ts failing * fix: fix markets.cy.ts failing * fix: fix markets.cy.ts failing * fix: remove extra test from markets.cy.ts * fix: update extra test from markets.cy.ts * fix: update extra test from markets.cy.ts Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com>
2022-07-16 13:31:47 +00:00
verifyMarketSummaryDisplayed();
});
it('Able to open and sort full market list - market page', () => {
const ExpectedSortedMarkets = [
'AAPL.MF21',
'BTCUSD.MF21',
'ETHBTC.QM21',
'SOLUSD',
];
cy.visit('/');
cy.wait('@MarketList');
cy.getByTestId('link').should('have.attr', 'href', '/markets').click();
cy.url().should('eq', Cypress.config('baseUrl') + '/markets');
cy.contains('AAPL.MF21').should('be.visible');
cy.contains('Market').click(); // sort by market name
for (let i = 0; i < ExpectedSortedMarkets.length; i++) {
cy.get(`[row-index=${i}]`)
.find('[col-id="tradableInstrument.instrument.code"]')
.should('have.text', ExpectedSortedMarkets[i]);
}
});
it('Settlement expiry is displayed', () => {
cy.visit('/markets/market-0');
cy.wait('@Market');
cy.getByTestId('trading-expiry')
.should('have.text', 'Not time-based')
.realHover();
cy.getByTestId('expiry-tool-tip').should(
'contain.text',
'This market expires when triggered by its oracle, not on a set date.'
);
cy.getByTestId('link')
.should('have.attr', 'href')
.and('include', 'https://explorer.fairground.wtf/');
});
it('Auction conditions are displayed', () => {
const toolTipLabel = 'tooltip-label';
const toolTipValue = 'tooltip-value';
const auctionToolTipLabels = [
'Auction start',
'Est auction end',
'Target liquidity',
'Current liquidity',
'Est uncrossing price',
'Est uncrossing vol',
];
cy.visit('/markets/market-0');
cy.wait('@Market');
cy.getByTestId('trading-mode').eq(0).realHover();
cy.getByTestId('tooltip-market-info').within(() => {
cy.get('span')
.eq(0)
.should(
'contain.text',
'This market is in auction until it reaches sufficient liquidity.'
);
cy.getByTestId('link')
.should('have.attr', 'href')
.and(
'include',
'https://docs.fairground.vega.xyz/docs/trading-questions/#auctions-what-is-a-liquidity-monitoring-auction'
);
});
for (let i = 0; i < 6; i++) {
cy.getByTestId(toolTipLabel)
.eq(i)
.should('have.text', auctionToolTipLabels[i]);
cy.getByTestId(toolTipValue).eq(i).should('not.be.empty');
}
});
function openMarketDropDown() {
cy.getByTestId('dialog-close').click();
cy.getByTestId('popover-trigger').click();
cy.contains('Loading market data...').should('not.exist');
}
fix: filter rejected markets, order when suspended, remove market state from header, show continuous trading (#761) * fix: #603 filter out rejected markets & dialog lg width * fix: #609 show trading mode Continuous Trading and hide market state * fix: #656 modify order validation to trade when suspended * fix: #656 fix use order validation tests * fix: #656 format volume no * fix: format volume with positionDecimalPlaces * fix: tests don't need to be async * fix: md:w-[720px] to prevent dialog overflow * fix: add market state translations * fix: imprt type validation props * Update libs/orders/src/lib/order-hooks/use-order-validation.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update libs/orders/src/lib/order-hooks/use-order-validation.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update libs/orders/src/lib/order-hooks/use-order-validation.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update libs/orders/src/lib/order-hooks/use-order-validation.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update libs/orders/src/lib/order-hooks/use-order-validation.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update libs/orders/src/lib/order-hooks/use-order-validation.spec.tsx Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * Update apps/trading/pages/markets/__generated__/Market.ts Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com> * fix: fix warning messages based on feedback * fix: capitalize trading mode * fix: capitalize trading mode * fix: remove line 72 on markets.cy.ts * fix: don't show trigger if unspecified * fix: format last price and shrink 0 on warning icon * fix: order sizes must be whole numbers for this market and input warning size 20 * fix: order sizes must be whole numbers for this market and input warning size 20 * fix: format market list * fix: remove market state check from markets.cy.ts * fix: remove market state check from markets.cy.ts * fix: remove market state check from markets.cy.ts * Revert "fix: remove market state check from markets.cy.ts" This reverts commit c9ab55c98a7373342bb4d2d4699fd2c9e726e96e. * Revert "fix: remove market state check from markets.cy.ts" This reverts commit be60e56d8a944ab2c2240ac2683f22fc7cc76bad. * fix: fix markets.cy.ts failing * fix: fix markets.cy.ts failing * fix: fix markets.cy.ts failing * fix: remove extra test from markets.cy.ts * fix: update extra test from markets.cy.ts * fix: update extra test from markets.cy.ts Co-authored-by: candida-d <62548908+candida-d@users.noreply.github.com>
2022-07-16 13:31:47 +00:00
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');
cy.getByTestId('mark-price').should('not.be.empty');
});
}
});