diff --git a/apps/simple-trading-app-e2e/src/integration/market-list.test.ts b/apps/simple-trading-app-e2e/src/integration/market-list.test.ts index 7b314d2b0..8e43f8283 100644 --- a/apps/simple-trading-app-e2e/src/integration/market-list.test.ts +++ b/apps/simple-trading-app-e2e/src/integration/market-list.test.ts @@ -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 diff --git a/apps/simple-trading-app-e2e/src/support/mocks/generate-filters.ts b/apps/simple-trading-app-e2e/src/support/mocks/generate-filters.ts new file mode 100644 index 000000000..23adeb745 --- /dev/null +++ b/apps/simple-trading-app-e2e/src/support/mocks/generate-filters.ts @@ -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', + }, + ], + }; +};