Test/fix trading tests (#1139)

This commit is contained in:
Joe Tsang 2022-08-25 09:01:20 +01:00 committed by GitHub
parent 465db69da8
commit 750c421ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 83 additions and 55 deletions

View File

@ -1,4 +1,4 @@
# App configuration variables
NX_VEGA_ENV=TESTNET
CYPRESS_VEGA_ENV=TESTNET
NX_VEGA_REST=https://api.n11.testnet.vega.xyz
NX_VEGA_REST=https://api.n10.testnet.vega.xyz

View File

@ -1,6 +1,6 @@
const textToCheck = Cypress.env('VEGA_ENV');
// breaking changes fail
describe.skip('stats', () => {
describe('stats', () => {
beforeEach(() => cy.visit('/'));
it('should display header based on environment name', () => {

View File

@ -9,7 +9,7 @@ describe('deposit form validation', () => {
cy.mockWeb3Provider();
cy.mockGQL((req) => {
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
aliasQuery(req, 'DepositPage', generateDepositPage());
aliasQuery(req, 'AssetsConnection', generateDepositPage());
});
cy.visit('/portfolio/deposit');
@ -17,7 +17,7 @@ describe('deposit form validation', () => {
cy.getByTestId(connectEthWalletBtn).click();
cy.getByTestId('web3-connector-MetaMask').click();
cy.wait('@DepositPage');
cy.wait('@AssetsConnection');
cy.contains('Deposit');
});

View File

@ -28,7 +28,7 @@ describe('accounts', () => {
.should('be.visible')
.get(tradingAccountRowId)
.find('[col-id="type"]')
.should('have.text', 'ACCOUNT_TYPE_GENERAL');
.should('have.text', 'General');
cy.getByTestId('tab-accounts')
.should('be.visible')

View File

@ -18,6 +18,7 @@ export const generateDealTicketQuery = (
tradableInstrument: {
__typename: 'TradableInstrument',
instrument: {
id: 'tBTC TEST',
__typename: 'Instrument',
product: {
__typename: 'Future',

View File

@ -6,30 +6,39 @@ export const generateDepositPage = (
override?: PartialDeep<any>
) => {
const defaultResult = {
assets: [
{
id: 'asset-0',
symbol: 'AST0',
name: 'Asset 0',
decimals: 5,
source: {
__typename: 'ERC20',
contractAddress: '0x5E4b9aDA947130Fc320a144cd22bC1641e5c9d81',
assetsConnection: {
edges: [
{
node: {
id: 'asset-0',
symbol: 'AST0',
name: 'Asset 0',
decimals: 5,
source: {
__typename: 'ERC20',
contractAddress: '0x5E4b9aDA947130Fc320a144cd22bC1641e5c9d81',
},
__typename: 'Asset',
},
__typename: 'AssetEdge',
},
__typename: 'Asset',
},
{
id: 'asset-1',
symbol: 'AST1',
name: 'Asset 1',
decimals: 5,
source: {
__typename: 'ERC20',
contractAddress: '0x444b9aDA947130Fc320a144cd22bC1641e5c9d81',
{
node: {
id: 'asset-1',
symbol: 'AST1',
name: 'Asset 1',
decimals: 5,
source: {
__typename: 'ERC20',
contractAddress: '0x444b9aDA947130Fc320a144cd22bC1641e5c9d81',
},
__typename: 'Asset',
},
__typename: 'AssetEdge',
},
__typename: 'Asset',
},
],
],
__typename: 'AssetsConnection',
},
};
return merge(defaultResult, override);

View File

@ -84,6 +84,15 @@ export const generateMarketList = (
positionDecimalPlaces: 0,
state: MarketState.STATE_SUSPENDED,
tradingMode: MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
fees: {
factors: {
makerFee: '0.0002',
infrastructureFee: '0.0005',
liquidityFee: '0.001',
__typename: 'FeeFactors',
},
__typename: 'Fees',
},
data: {
market: {
id: '34d95e10faa00c21d19d382d6d7e6fc9722a96985369f0caec041b0f44b775ed',
@ -94,6 +103,7 @@ export const generateMarketList = (
bestBidPrice: '17065127',
bestOfferPrice: '17017654',
markPrice: '8441',
trigger: AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY,
indicativeVolume: '249',
__typename: 'MarketData',
},

View File

@ -38,6 +38,7 @@ export const generateMarket = (override?: PartialDeep<Market>): Market => {
},
tradableInstrument: {
instrument: {
id: 'BTCUSD.MF21',
name: 'BTCUSD Monthly',
code: 'BTCUSD.MF21',
metadata: {

View File

@ -1,5 +1,5 @@
import merge from 'lodash/merge';
import { MarketTradingMode } from '@vegaprotocol/types';
import { MarketState, MarketTradingMode } from '@vegaprotocol/types';
import type { DeepPartial } from 'react-hook-form';
export interface MarketsLanding_markets_marketTimestamps {
@ -11,6 +11,7 @@ export interface MarketsLanding_markets {
__typename: 'Market';
id: string;
tradingMode: MarketTradingMode;
state: MarketState;
marketTimestamps: MarketsLanding_markets_marketTimestamps;
}
@ -26,6 +27,7 @@ export const generateMarketsLanding = (
{
id: 'market-0',
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS,
state: MarketState.STATE_ACTIVE,
marketTimestamps: {
__typename: 'MarketTimestamps',
open: '1',
@ -35,6 +37,7 @@ export const generateMarketsLanding = (
{
id: 'market-1',
tradingMode: MarketTradingMode.TRADING_MODE_OPENING_AUCTION,
state: MarketState.STATE_SUSPENDED,
marketTimestamps: {
__typename: 'MarketTimestamps',
open: '2',

View File

@ -30,30 +30,38 @@ export const generateWithdrawPageQuery = (
],
__typename: 'Party',
},
assets: [
{
id: 'asset-0',
symbol: 'AST0',
name: 'Asset 0',
decimals: 5,
source: {
__typename: 'ERC20',
contractAddress: '0x5E4b9aDA947130Fc320a144cd22bC1641e5c9d81',
assetsConnection: {
edges: [
{
node: {
id: 'asset-0',
symbol: 'AST0',
name: 'Asset 0',
decimals: 5,
source: {
__typename: 'ERC20',
contractAddress: '0x5E4b9aDA947130Fc320a144cd22bC1641e5c9d81',
},
__typename: 'Asset',
},
__typename: 'AssetEdge',
},
__typename: 'Asset',
},
{
id: 'asset-1',
symbol: 'AST1',
name: 'Asset 1',
decimals: 5,
source: {
__typename: 'ERC20',
contractAddress: '0x444b9aDA947130Fc320a144cd22bC1641e5c9d81',
{
node: {
id: 'asset-1',
symbol: 'AST1',
name: 'Asset 1',
decimals: 5,
source: {
__typename: 'ERC20',
contractAddress: '0x444b9aDA947130Fc320a144cd22bC1641e5c9d81',
},
__typename: 'Asset',
},
__typename: 'AssetEdge',
},
__typename: 'Asset',
},
],
],
},
};
return merge(defaultResult, override);

View File

@ -12,10 +12,6 @@ declare global {
export function addMockGQLCommand() {
Cypress.Commands.add('mockGQL', (handler: RouteHandler) => {
cy.intercept(
'POST',
'https://api.n11.testnet.vega.xyz/graphql',
handler
).as('GQL');
cy.intercept('POST', '**/graphql', handler).as('GQL');
});
}