chore: [console-lite] - fix failling int tests (#857)

Co-authored-by: maciek <maciek@vegaprotocol.io>
This commit is contained in:
macqbat 2022-07-25 17:15:26 +02:00 committed by GitHub
parent b7f08def47
commit c2b61251c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 100 additions and 2 deletions

View File

@ -1,6 +1,14 @@
import { aliasQuery } from '@vegaprotocol/cypress';
import { generateSimpleMarkets } from '../support/mocks/generate-markets';
import { generateFilters } from '../support/mocks/generate-filters';
describe('market list', () => {
describe('simple url', () => {
beforeEach(() => {
cy.mockGQL((req) => {
aliasQuery(req, 'SimpleMarkets', generateSimpleMarkets());
aliasQuery(req, 'MarketFilters', generateFilters());
});
cy.visit('/markets');
});
@ -51,15 +59,21 @@ describe('market list', () => {
});
describe('url params should select filters', () => {
beforeEach(() => {
cy.mockGQL((req) => {
aliasQuery(req, 'SimpleMarkets', generateSimpleMarkets());
aliasQuery(req, 'MarketFilters', generateFilters());
});
});
it('suspended status', () => {
cy.visit('/markets/Suspended');
cy.getByTestId('state-trigger').should('have.text', 'Suspended');
});
it('last asset (if exists)', () => {
cy.intercept('POST', '/query').as('Filters');
cy.visit('/markets');
cy.wait('@Filters').then((filters) => {
cy.wait('@MarketFilters').then((filters) => {
if (filters?.response?.body?.data?.markets?.length) {
const asset =
filters.response.body.data.markets[0].tradableInstrument.instrument

View File

@ -0,0 +1,84 @@
export const generateFilters = () => {
return {
markets: [
{
tradableInstrument: {
instrument: {
product: {
__typename: 'Future',
settlementAsset: { symbol: 'fDAI', __typename: 'Asset' },
},
__typename: 'Instrument',
},
__typename: 'TradableInstrument',
},
__typename: 'Market',
},
{
tradableInstrument: {
instrument: {
product: {
__typename: 'Future',
settlementAsset: { symbol: 'fBTC', __typename: 'Asset' },
},
__typename: 'Instrument',
},
__typename: 'TradableInstrument',
},
__typename: 'Market',
},
{
tradableInstrument: {
instrument: {
product: {
__typename: 'Future',
settlementAsset: { symbol: 'fDAI', __typename: 'Asset' },
},
__typename: 'Instrument',
},
__typename: 'TradableInstrument',
},
__typename: 'Market',
},
{
tradableInstrument: {
instrument: {
product: {
__typename: 'Future',
settlementAsset: { symbol: 'fDAI', __typename: 'Asset' },
},
__typename: 'Instrument',
},
__typename: 'TradableInstrument',
},
__typename: 'Market',
},
{
tradableInstrument: {
instrument: {
product: {
__typename: 'Future',
settlementAsset: { symbol: 'fUSDC', __typename: 'Asset' },
},
__typename: 'Instrument',
},
__typename: 'TradableInstrument',
},
__typename: 'Market',
},
{
tradableInstrument: {
instrument: {
product: {
__typename: 'Future',
settlementAsset: { symbol: 'fEURO', __typename: 'Asset' },
},
__typename: 'Instrument',
},
__typename: 'TradableInstrument',
},
__typename: 'Market',
},
],
};
};