Test/994 additional market info (#1172)

* test: additional market info tests

* chore: fix intermittent failing tests

* chore: change wait logic for asserting node
This commit is contained in:
Joe Tsang 2022-08-26 14:16:28 +01:00 committed by GitHub
parent 0539cb5ed0
commit 95c1526aa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 80 additions and 16 deletions

View File

@ -10,14 +10,12 @@ context('Node switcher', function () {
}).as('nodeData');
cy.visit('/');
cy.wait('@nodeData');
cy.getByTestId('git-network-data').within(() => {
cy.getByTestId('link').should('be.visible').click();
});
});
describe('form validations and responses', function () {
beforeEach('open node selector', function () {
cy.getByTestId('git-network-data').within(() => {
cy.getByTestId('link').click();
});
});
it('node data is displayed', function () {
cy.getByTestId('node-row').should('have.length.at.least', 2);
@ -28,10 +26,13 @@ context('Node switcher', function () {
.should('exist')
.and('have.attr', 'aria-checked', 'true');
cy.get('label').should('have.text', Cypress.env('networkQueryUrl'));
cy.contains('-').should('not.exist');
cy.getByTestId('ssl-cell').should('have.text', 'Checking');
cy.getByTestId('ssl-cell', { timeout: 6000 }).should(
'not.have.text',
'Checking'
);
cy.getByTestId('response-time-cell').should('contain.text', 'ms');
cy.getByTestId('block-cell').should('not.be.empty');
cy.getByTestId('ssl-cell').should('not.be.empty');
});
});
@ -58,15 +59,15 @@ context('Node switcher', function () {
cy.get('input').clear().type('https://n03.s.vega.xyz/query');
cy.getByTestId('link').click();
});
cy.getByTestId('ssl-cell').should('contain.text', 'Yes');
cy.getByTestId('ssl-cell', { timeout: 6000 }).should(
'contain.text',
'Yes'
);
validateNodeError(errorTypeTxt, nodeErrorTxt);
});
function validateNodeError(errortype, errorMsg) {
cy.getByTestId(nodeErrorType, { timeout: 10000 }).should(
'have.text',
errortype
);
cy.getByTestId(nodeErrorType).should('have.text', errortype);
cy.getByTestId(nodeErrorMsg).should('have.text', errorMsg);
}
});

View File

@ -18,7 +18,7 @@ const navigation = {
};
Cypress.Commands.add('navigate_to', (page) => {
return cy.get(navigation.section).within(() => {
return cy.get(navigation.section, { timeout: 10000 }).within(() => {
cy.get(navigation[page]).click();
});
});

View File

@ -21,17 +21,28 @@ describe('market info is displayed', () => {
validateMarketDataRow(0, 'Maker Fee', '0.02%');
validateMarketDataRow(1, 'Infrastructure Fee', '0.05%');
validateMarketDataRow(2, 'Liquidity Fee', '1.00%');
validateMarketDataRow(3, 'Total Fees', '1.04%');
});
it('market price', () => {
cy.getByTestId(marketTitle).contains('Market price').click();
validateMarketDataRow(0, 'Mark Price', '57.49');
validateMarketDataRow(1, 'Best Bid Price', '6,817.65');
validateMarketDataRow(2, 'Best Offer Price', '6,817.69');
});
it('market volume displayed', () => {
cy.getByTestId(marketTitle).contains('Market volume').click();
validateMarketDataRow(0, '24 Hour Volume', '-');
validateMarketDataRow(1, 'Open Interest', '0');
validateMarketDataRow(2, 'Best Bid Volume', '5');
validateMarketDataRow(3, 'Best Offer Volume', '1');
validateMarketDataRow(4, 'Best Static Bid Volume', '5');
validateMarketDataRow(5, 'Best Static Offer Volume', '1');
});
it('market price', () => {
cy.getByTestId(marketTitle).contains('Market price').click();
validateMarketDataRow(0, 'Mark Price', '57.49');
it('insurance pool displayed', () => {
cy.getByTestId(marketTitle).contains('Insurance pool').click();
validateMarketDataRow(0, 'Balance', '0');
});
it('key details displayed', () => {
@ -99,6 +110,14 @@ describe('market info is displayed', () => {
validateMarketDataRow(2, 'Auction Extension Secs', '600');
});
it('price monitoring bound displayed', () => {
cy.getByTestId(marketTitle).contains('Price monitoring bound 1').click();
validateMarketDataRow(0, 'Min Valid Price', '6,547.01');
validateMarketDataRow(1, 'Max Valid Price', '7,973.23');
validateMarketDataRow(2, 'Reference Price', '7,226.25');
});
it('liquidity monitoring parameters displayed', () => {
cy.getByTestId(marketTitle)
.contains('Liquidity monitoring parameters')
@ -109,6 +128,27 @@ describe('market info is displayed', () => {
validateMarketDataRow(2, 'Scaling Factor', '10');
});
it('oracle displayed', () => {
cy.getByTestId(marketTitle).contains('Oracle').click();
validateMarketDataRow(0, 'Settlement Price Property', 'prices.BTC.value');
validateMarketDataRow(
1,
'Trading Termination Property',
'termination.BTC.value'
);
validateMarketDataRow(
2,
'Price Oracle',
'f028fe5ea7de3890962a05a7163fdde562629af649ed81b8c8902fafb6eef04f'
);
validateMarketDataRow(
3,
'Termination Oracle',
'f028fe5ea7de3890962a05a7163fdde562629af649ed81b8c8902fafb6eef04f'
);
});
afterEach('close toggle', () => {
cy.get('[data-state="open"]').find('button').click();
});

View File

@ -1,6 +1,7 @@
import type { MarketInfoQuery } from '@vegaprotocol/deal-ticket';
import {
AccountType,
AuctionTrigger,
MarketState,
MarketTradingMode,
} from '@vegaprotocol/types';
@ -82,6 +83,23 @@ export const generateMarketInfoQuery = (
bestStaticBidVolume: '5',
bestStaticOfferVolume: '1',
openInterest: '0',
bestBidPrice: '681765',
bestOfferPrice: '681769',
trigger: AuctionTrigger.AUCTION_TRIGGER_UNSPECIFIED,
priceMonitoringBounds: [
{
minValidPrice: '654701',
maxValidPrice: '797323',
trigger: {
horizonSecs: 43200,
probability: 0.9999999,
auctionExtensionSecs: 600,
__typename: 'PriceMonitoringTrigger',
},
referencePrice: '722625',
__typename: 'PriceMonitoringBounds',
},
],
},
liquidityMonitoringParameters: {
triggeringRatio: 0,
@ -92,6 +110,7 @@ export const generateMarketInfoQuery = (
},
__typename: 'LiquidityMonitoringParameters',
},
candles: [],
tradableInstrument: {
__typename: 'TradableInstrument',
instrument: {

View File

@ -53,6 +53,10 @@ export const generateMarket = (override?: PartialDeep<Market>): Market => {
__typename: 'InstrumentMetadata',
},
product: {
oracleSpecForTradingTermination: {
id: 'd253c16c6a17ab88e098479635c611ab503582a1079752d1a49ac15f656f7e7b',
__typename: 'OracleSpec',
},
quoteName: 'BTCUSD Monthly',
settlementAsset: {
id: '000',