chore: fix chainId mock (#1777)
* chore: fix chainId popup * chore: cleanup
This commit is contained in:
parent
a6576132b1
commit
ab760eee58
@ -1,7 +1,3 @@
|
|||||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
|
||||||
import { generateAssets } from '../support/mocks/generate-assets';
|
|
||||||
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
|
|
||||||
|
|
||||||
const connectEthWalletBtn = 'connect-eth-wallet-btn';
|
const connectEthWalletBtn = 'connect-eth-wallet-btn';
|
||||||
const assetSelectField = 'select[name="asset"]';
|
const assetSelectField = 'select[name="asset"]';
|
||||||
const toAddressField = 'input[name="to"]';
|
const toAddressField = 'input[name="to"]';
|
||||||
@ -12,10 +8,7 @@ describe('deposit form validation', { tags: '@smoke' }, () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.mockWeb3Provider();
|
cy.mockWeb3Provider();
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
|
|
||||||
aliasQuery(req, 'Assets', generateAssets());
|
|
||||||
});
|
|
||||||
cy.visit('/portfolio/deposit');
|
cy.visit('/portfolio/deposit');
|
||||||
|
|
||||||
// Deposit page requires connection Ethereum wallet first
|
// Deposit page requires connection Ethereum wallet first
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||||
import { connectVegaWallet } from '../support/vega-wallet';
|
import { connectVegaWallet } from '../support/vega-wallet';
|
||||||
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
|
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
|
||||||
import { generateChainId } from '../support/mocks/generate-chain-id';
|
|
||||||
|
|
||||||
describe('vega wallet', { tags: '@smoke' }, () => {
|
describe('vega wallet', { tags: '@smoke' }, () => {
|
||||||
const connectVegaBtn = 'connect-vega-wallet';
|
const connectVegaBtn = 'connect-vega-wallet';
|
||||||
@ -13,9 +12,7 @@ describe('vega wallet', { tags: '@smoke' }, () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// Using portfolio page as it requires vega wallet connection
|
// Using portfolio page as it requires vega wallet connection
|
||||||
cy.visit('/portfolio');
|
cy.visit('/portfolio');
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
aliasQuery(req, 'ChainId', generateChainId());
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
cy.get('main[data-testid="portfolio"]').should('exist');
|
cy.get('main[data-testid="portfolio"]').should('exist');
|
||||||
});
|
});
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||||
import { MarketState } from '@vegaprotocol/types';
|
|
||||||
import { mockTradingPage } from '../support/trading';
|
|
||||||
|
|
||||||
describe('home', { tags: '@regression' }, () => {
|
describe('home', { tags: '@regression' }, () => {
|
||||||
const selectMarketOverlay = 'select-market-list';
|
const selectMarketOverlay = 'select-market-list';
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { MarketState, MarketTradingModeMapping } from '@vegaprotocol/types';
|
import { MarketState, MarketTradingModeMapping } from '@vegaprotocol/types';
|
||||||
import { mockTradingPage } from '../support/trading';
|
|
||||||
import { connectVegaWallet } from '../support/vega-wallet';
|
import { connectVegaWallet } from '../support/vega-wallet';
|
||||||
|
|
||||||
const marketInfoBtn = 'Info';
|
const marketInfoBtn = 'Info';
|
||||||
@ -10,9 +9,7 @@ const externalLink = 'external-link';
|
|||||||
|
|
||||||
describe('market info is displayed', { tags: '@smoke' }, () => {
|
describe('market info is displayed', { tags: '@smoke' }, () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.wait('@Market');
|
cy.wait('@Market');
|
||||||
@ -221,9 +218,7 @@ describe('market states', { tags: '@smoke' }, function () {
|
|||||||
states.forEach((marketState) => {
|
states.forEach((marketState) => {
|
||||||
describe(marketState, function () {
|
describe(marketState, function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage(marketState);
|
||||||
mockTradingPage(req, marketState);
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.wait('@Market');
|
cy.wait('@Market');
|
||||||
|
@ -3,7 +3,6 @@ import {
|
|||||||
MarketState,
|
MarketState,
|
||||||
MarketTradingMode,
|
MarketTradingMode,
|
||||||
} from '@vegaprotocol/types';
|
} from '@vegaprotocol/types';
|
||||||
import { mockTradingPage } from '../support/trading';
|
|
||||||
|
|
||||||
const marketSummaryBlock = 'header-summary';
|
const marketSummaryBlock = 'header-summary';
|
||||||
const marketExpiry = 'market-expiry';
|
const marketExpiry = 'market-expiry';
|
||||||
@ -19,14 +18,11 @@ const itemValue = 'item-value';
|
|||||||
|
|
||||||
describe('Market trading page', () => {
|
describe('Market trading page', () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage(
|
||||||
mockTradingPage(
|
MarketState.STATE_ACTIVE,
|
||||||
req,
|
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
|
||||||
MarketState.STATE_ACTIVE,
|
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
|
||||||
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
|
);
|
||||||
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
|
|
||||||
);
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.wait('@MarketData');
|
cy.wait('@MarketData');
|
||||||
|
@ -3,18 +3,14 @@ import {
|
|||||||
MarketState,
|
MarketState,
|
||||||
MarketTradingMode,
|
MarketTradingMode,
|
||||||
} from '@vegaprotocol/types';
|
} from '@vegaprotocol/types';
|
||||||
import { mockTradingPage } from '../support/trading';
|
|
||||||
|
|
||||||
describe('markets table', { tags: '@smoke' }, () => {
|
describe('markets table', { tags: '@smoke' }, () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage(
|
||||||
mockTradingPage(
|
MarketState.STATE_ACTIVE,
|
||||||
req,
|
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
|
||||||
MarketState.STATE_ACTIVE,
|
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
|
||||||
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
|
);
|
||||||
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
|
|
||||||
);
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
cy.wait('@Market');
|
cy.wait('@Market');
|
||||||
|
@ -1,15 +1,8 @@
|
|||||||
import { MarketState } from '@vegaprotocol/types';
|
|
||||||
import { mockTradingPage } from '../support/trading';
|
|
||||||
import { connectVegaWallet } from '../support/vega-wallet';
|
import { connectVegaWallet } from '../support/vega-wallet';
|
||||||
import { connectEthereumWallet } from '../support/ethereum-wallet';
|
import { connectEthereumWallet } from '../support/ethereum-wallet';
|
||||||
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
|
|
||||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
|
|
||||||
});
|
|
||||||
cy.mockWeb3Provider();
|
cy.mockWeb3Provider();
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
|
@ -3,7 +3,6 @@ import {
|
|||||||
MarketTradingMode,
|
MarketTradingMode,
|
||||||
AuctionTrigger,
|
AuctionTrigger,
|
||||||
} from '@vegaprotocol/types';
|
} from '@vegaprotocol/types';
|
||||||
import { mockTradingPage } from '../support/trading';
|
|
||||||
import { connectVegaWallet } from '../support/vega-wallet';
|
import { connectVegaWallet } from '../support/vega-wallet';
|
||||||
|
|
||||||
const orderSizeField = 'order-size';
|
const orderSizeField = 'order-size';
|
||||||
@ -123,9 +122,7 @@ const testOrder = (order: Order, expected?: Partial<Order>) => {
|
|||||||
describe('must submit order', { tags: '@smoke' }, () => {
|
describe('must submit order', { tags: '@smoke' }, () => {
|
||||||
// 7002-SORD-039
|
// 7002-SORD-039
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.wait('@Market');
|
cy.wait('@Market');
|
||||||
@ -205,9 +202,7 @@ describe('must submit order', { tags: '@smoke' }, () => {
|
|||||||
|
|
||||||
describe('deal ticket validation', { tags: '@smoke' }, () => {
|
describe('deal ticket validation', { tags: '@smoke' }, () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.wait('@Market');
|
cy.wait('@Market');
|
||||||
});
|
});
|
||||||
@ -260,9 +255,7 @@ describe('deal ticket validation', { tags: '@smoke' }, () => {
|
|||||||
|
|
||||||
describe('deal ticket size validation', { tags: '@smoke' }, function () {
|
describe('deal ticket size validation', { tags: '@smoke' }, function () {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.wait('@Market');
|
cy.wait('@Market');
|
||||||
connectVegaWallet();
|
connectVegaWallet();
|
||||||
@ -289,9 +282,7 @@ describe('deal ticket size validation', { tags: '@smoke' }, function () {
|
|||||||
|
|
||||||
describe('limit order validations', { tags: '@smoke' }, () => {
|
describe('limit order validations', { tags: '@smoke' }, () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.wait('@Market');
|
cy.wait('@Market');
|
||||||
cy.getByTestId(toggleLimit).click();
|
cy.getByTestId(toggleLimit).click();
|
||||||
@ -345,9 +336,7 @@ describe('limit order validations', { tags: '@smoke' }, () => {
|
|||||||
|
|
||||||
describe('market order validations', { tags: '@smoke' }, () => {
|
describe('market order validations', { tags: '@smoke' }, () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.wait('@Market');
|
cy.wait('@Market');
|
||||||
cy.getByTestId(toggleMarket).click();
|
cy.getByTestId(toggleMarket).click();
|
||||||
@ -398,14 +387,11 @@ describe('market order validations', { tags: '@smoke' }, () => {
|
|||||||
|
|
||||||
describe('suspended market validation', { tags: '@regression' }, () => {
|
describe('suspended market validation', { tags: '@regression' }, () => {
|
||||||
before(() => {
|
before(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage(
|
||||||
mockTradingPage(
|
MarketState.STATE_SUSPENDED,
|
||||||
req,
|
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
|
||||||
MarketState.STATE_SUSPENDED,
|
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
|
||||||
MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
|
);
|
||||||
AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY
|
|
||||||
);
|
|
||||||
});
|
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.wait('@Market');
|
cy.wait('@Market');
|
||||||
connectVegaWallet();
|
connectVegaWallet();
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||||
import { generateFills } from '../support/mocks/generate-fills';
|
import { generateFills } from '../support/mocks/generate-fills';
|
||||||
import { MarketState } from '@vegaprotocol/types';
|
|
||||||
import { connectVegaWallet } from '../support/vega-wallet';
|
import { connectVegaWallet } from '../support/vega-wallet';
|
||||||
import { mockTradingPage } from '../support/trading';
|
|
||||||
|
|
||||||
describe('fills', { tags: '@regression' }, () => {
|
describe('fills', { tags: '@regression' }, () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
cy.mockTradingPage();
|
||||||
cy.mockGQL((req) => {
|
cy.mockGQL((req) => {
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
aliasQuery(req, 'Fills', generateFills());
|
aliasQuery(req, 'Fills', generateFills());
|
||||||
});
|
});
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
@ -23,9 +21,7 @@ describe('fills', { tags: '@regression' }, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('renders fills on trading tab', () => {
|
it('renders fills on trading tab', () => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.getByTestId('Fills').click();
|
cy.getByTestId('Fills').click();
|
||||||
cy.getByTestId('tab-fills').contains('Please connect Vega wallet');
|
cy.getByTestId('tab-fills').contains('Please connect Vega wallet');
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
import {
|
import { OrderRejectionReason, OrderStatus } from '@vegaprotocol/types';
|
||||||
MarketState,
|
|
||||||
OrderRejectionReason,
|
|
||||||
OrderStatus,
|
|
||||||
} from '@vegaprotocol/types';
|
|
||||||
import { mockTradingPage } from '../support/trading';
|
|
||||||
import { connectVegaWallet } from '../support/vega-wallet';
|
import { connectVegaWallet } from '../support/vega-wallet';
|
||||||
import {
|
import {
|
||||||
updateOrder,
|
updateOrder,
|
||||||
@ -25,9 +20,7 @@ describe('orders list', { tags: '@smoke' }, () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
const subscriptionMocks = getSubscriptionMocks();
|
const subscriptionMocks = getSubscriptionMocks();
|
||||||
cy.spy(subscriptionMocks, 'OrderSub');
|
cy.spy(subscriptionMocks, 'OrderSub');
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription(subscriptionMocks);
|
cy.mockGQLSubscription(subscriptionMocks);
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.getByTestId('Orders').click();
|
cy.getByTestId('Orders').click();
|
||||||
@ -132,9 +125,7 @@ describe('subscribe orders', { tags: '@smoke' }, () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
const subscriptionMocks = getSubscriptionMocks();
|
const subscriptionMocks = getSubscriptionMocks();
|
||||||
cy.spy(subscriptionMocks, 'OrderSub');
|
cy.spy(subscriptionMocks, 'OrderSub');
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription(subscriptionMocks);
|
cy.mockGQLSubscription(subscriptionMocks);
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
cy.getByTestId('Orders').click();
|
cy.getByTestId('Orders').click();
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
import { MarketState } from '@vegaprotocol/types';
|
|
||||||
import { mockTradingPage } from '../support/trading';
|
|
||||||
import { connectVegaWallet } from '../support/vega-wallet';
|
import { connectVegaWallet } from '../support/vega-wallet';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
import { MarketState } from '@vegaprotocol/types';
|
|
||||||
import { mockTradingPage } from '../support/trading';
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
cy.visit('/markets/market-0');
|
cy.visit('/markets/market-0');
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
|
||||||
import { connectEthereumWallet } from '../support/ethereum-wallet';
|
import { connectEthereumWallet } from '../support/ethereum-wallet';
|
||||||
import { generateChainId } from '../support/mocks/generate-chain-id';
|
|
||||||
import { generateAccounts } from '../support/mocks/generate-accounts';
|
|
||||||
import { generateAssets } from '../support/mocks/generate-assets';
|
|
||||||
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
|
|
||||||
import { generateWithdrawals } from '../support/mocks/generate-withdrawals';
|
|
||||||
import { connectVegaWallet } from '../support/vega-wallet';
|
import { connectVegaWallet } from '../support/vega-wallet';
|
||||||
|
|
||||||
describe('withdraw', { tags: '@smoke' }, () => {
|
describe('withdraw', { tags: '@smoke' }, () => {
|
||||||
@ -20,13 +14,7 @@ describe('withdraw', { tags: '@smoke' }, () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.mockWeb3Provider();
|
cy.mockWeb3Provider();
|
||||||
cy.mockGQL((req) => {
|
cy.mockTradingPage();
|
||||||
aliasQuery(req, 'ChainId', generateChainId());
|
|
||||||
aliasQuery(req, 'Withdrawals', generateWithdrawals());
|
|
||||||
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
|
|
||||||
aliasQuery(req, 'Assets', generateAssets());
|
|
||||||
aliasQuery(req, 'Accounts', generateAccounts());
|
|
||||||
});
|
|
||||||
cy.mockGQLSubscription();
|
cy.mockGQLSubscription();
|
||||||
|
|
||||||
cy.visit('/portfolio');
|
cy.visit('/portfolio');
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
import '@vegaprotocol/cypress';
|
import '@vegaprotocol/cypress';
|
||||||
import 'cypress-real-events/support';
|
import 'cypress-real-events/support';
|
||||||
import registerCypressGrep from 'cypress-grep';
|
import registerCypressGrep from 'cypress-grep';
|
||||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
import { addMockTradingPage } from './trading';
|
||||||
import { generateChainId } from './mocks/generate-chain-id';
|
|
||||||
registerCypressGrep();
|
registerCypressGrep();
|
||||||
|
addMockTradingPage();
|
||||||
before(() => {
|
|
||||||
// Mock chainId fetch which happens on every page wallet connection
|
|
||||||
cy.mockGQL((req) => {
|
|
||||||
aliasQuery(req, 'ChainId', generateChainId());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
17
apps/trading-e2e/src/support/mocks/generate-statistics.ts
Normal file
17
apps/trading-e2e/src/support/mocks/generate-statistics.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import type { StatisticsQuery } from '@vegaprotocol/environment';
|
||||||
|
import merge from 'lodash/merge';
|
||||||
|
import type { PartialDeep } from 'type-fest';
|
||||||
|
|
||||||
|
export const generateStatistics = (
|
||||||
|
override?: PartialDeep<StatisticsQuery>
|
||||||
|
): StatisticsQuery => {
|
||||||
|
const defaultResult = {
|
||||||
|
statistics: {
|
||||||
|
__typename: 'Statistics',
|
||||||
|
chainId: 'test-chain-id',
|
||||||
|
blockHeight: '11',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return merge(defaultResult, override);
|
||||||
|
};
|
@ -1,13 +1,11 @@
|
|||||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||||
import type {
|
import type { MarketTradingMode, AuctionTrigger } from '@vegaprotocol/types';
|
||||||
MarketState,
|
import { MarketState } from '@vegaprotocol/types';
|
||||||
MarketTradingMode,
|
|
||||||
AuctionTrigger,
|
|
||||||
} from '@vegaprotocol/types';
|
|
||||||
import type { CyHttpMessages } from 'cypress/types/net-stubbing';
|
import type { CyHttpMessages } from 'cypress/types/net-stubbing';
|
||||||
import { generateAccounts } from './mocks/generate-accounts';
|
import { generateAccounts } from './mocks/generate-accounts';
|
||||||
import { generateAsset, generateAssets } from './mocks/generate-assets';
|
import { generateAsset, generateAssets } from './mocks/generate-assets';
|
||||||
import { generateCandles } from './mocks/generate-candles';
|
import { generateCandles } from './mocks/generate-candles';
|
||||||
|
import { generateChainId } from './mocks/generate-chain-id';
|
||||||
import { generateChart } from './mocks/generate-chart';
|
import { generateChart } from './mocks/generate-chart';
|
||||||
import { generateDealTicketQuery } from './mocks/generate-deal-ticket-query';
|
import { generateDealTicketQuery } from './mocks/generate-deal-ticket-query';
|
||||||
import { generateMarket, generateMarketData } from './mocks/generate-market';
|
import { generateMarket, generateMarketData } from './mocks/generate-market';
|
||||||
@ -18,16 +16,21 @@ import {
|
|||||||
generateMarketsData,
|
generateMarketsData,
|
||||||
generateMarketsCandles,
|
generateMarketsCandles,
|
||||||
} from './mocks/generate-markets';
|
} from './mocks/generate-markets';
|
||||||
|
import { generateNetworkParameters } from './mocks/generate-network-parameters';
|
||||||
import { generateOrders } from './mocks/generate-orders';
|
import { generateOrders } from './mocks/generate-orders';
|
||||||
import { generateMargins, generatePositions } from './mocks/generate-positions';
|
import { generateMargins, generatePositions } from './mocks/generate-positions';
|
||||||
|
import { generateStatistics } from './mocks/generate-statistics';
|
||||||
import { generateTrades } from './mocks/generate-trades';
|
import { generateTrades } from './mocks/generate-trades';
|
||||||
|
import { generateWithdrawals } from './mocks/generate-withdrawals';
|
||||||
|
|
||||||
export const mockTradingPage = (
|
const mockTradingPage = (
|
||||||
req: CyHttpMessages.IncomingHttpRequest,
|
req: CyHttpMessages.IncomingHttpRequest,
|
||||||
state: MarketState,
|
state: MarketState = MarketState.STATE_ACTIVE,
|
||||||
tradingMode?: MarketTradingMode,
|
tradingMode?: MarketTradingMode,
|
||||||
trigger?: AuctionTrigger
|
trigger?: AuctionTrigger
|
||||||
) => {
|
) => {
|
||||||
|
aliasQuery(req, 'ChainId', generateChainId());
|
||||||
|
aliasQuery(req, 'Statistics', generateStatistics());
|
||||||
aliasQuery(
|
aliasQuery(
|
||||||
req,
|
req,
|
||||||
'Market',
|
'Market',
|
||||||
@ -91,4 +94,30 @@ export const mockTradingPage = (
|
|||||||
aliasQuery(req, 'Trades', generateTrades());
|
aliasQuery(req, 'Trades', generateTrades());
|
||||||
aliasQuery(req, 'Chart', generateChart());
|
aliasQuery(req, 'Chart', generateChart());
|
||||||
aliasQuery(req, 'Candles', generateCandles());
|
aliasQuery(req, 'Candles', generateCandles());
|
||||||
|
aliasQuery(req, 'Withdrawals', generateWithdrawals());
|
||||||
|
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
|
||||||
|
};
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||||
|
namespace Cypress {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
interface Chainable<Subject> {
|
||||||
|
mockTradingPage(
|
||||||
|
state?: MarketState,
|
||||||
|
tradingMode?: MarketTradingMode,
|
||||||
|
trigger?: AuctionTrigger
|
||||||
|
): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const addMockTradingPage = () => {
|
||||||
|
Cypress.Commands.add(
|
||||||
|
'mockTradingPage',
|
||||||
|
(state = MarketState.STATE_ACTIVE, tradingMode, trigger) => {
|
||||||
|
cy.mockGQL((req) => {
|
||||||
|
mockTradingPage(req, state, tradingMode, trigger);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
@ -6,3 +6,6 @@ export * from './hooks';
|
|||||||
|
|
||||||
// Types
|
// Types
|
||||||
export * from './types';
|
export * from './types';
|
||||||
|
|
||||||
|
// Utils
|
||||||
|
export * from './utils/__generated__/Node';
|
||||||
|
Loading…
Reference in New Issue
Block a user