diff --git a/apps/explorer-e2e/src/integration/asset-page.feature b/apps/explorer-e2e/src/integration/asset-page.feature new file mode 100644 index 000000000..c46b2bc8f --- /dev/null +++ b/apps/explorer-e2e/src/integration/asset-page.feature @@ -0,0 +1,6 @@ +Feature: Asset Page + +Scenario: Navigate to Asset Page + Given I am on the homepage + When I navigate to the asset page + Then asset page is correctly displayed diff --git a/apps/explorer-e2e/src/support/pages/assets-page.js b/apps/explorer-e2e/src/support/pages/assets-page.js new file mode 100644 index 000000000..663b4b6b3 --- /dev/null +++ b/apps/explorer-e2e/src/support/pages/assets-page.js @@ -0,0 +1,9 @@ +import BasePage from './base-page'; + +export default class AssetsPage extends BasePage { + assetHeader = 'asset-header'; + + validateAssetsDisplayed() { + this.validateBlockDataDisplayed(this.assetHeader); + } +} diff --git a/apps/explorer-e2e/src/support/pages/base-page.js b/apps/explorer-e2e/src/support/pages/base-page.js index 1c5acf761..134ee2a05 100644 --- a/apps/explorer-e2e/src/support/pages/base-page.js +++ b/apps/explorer-e2e/src/support/pages/base-page.js @@ -8,4 +8,72 @@ export default class BasePage { marketsUrl = '/markets'; networkParametersUrl = '/network-parameters'; validatorsUrl = '/validators'; + blockExplorerHeader = 'explorer-header'; + searchField = 'search-input'; + + navigateToTxs() { + cy.get(`a[href='${this.transactionsUrl}']`).click(); + } + + navigateToBlocks() { + cy.get(`a[href='${this.blocksUrl}']`).click(); + } + + navigateToParties() { + cy.get(`a[href='${this.partiesUrl}']`).click(); + } + + navigateToAssets() { + cy.get(`a[href*='${this.assetsUrl}']`).click(); + } + + navigateToGenesis() { + cy.get(`a[href='${this.genesisUrl}']`).click(); + } + + navigateToGovernance() { + cy.get(`a[href='${this.governanceUrl}']`).click(); + } + + navigateToMarkets() { + cy.get(`a[href='${this.marketsUrl}']`).click(); + } + + navigateToNetworkParameters() { + cy.get(`a[href='${this.networkParametersUrl}']`).click(); + } + + navigateToValidators() { + cy.get(`a[href='${this.validatorsUrl}']`).click(); + } + + search(searchText) { + cy.getByTestId(this.searchField).type(searchText); + } + + validateSearchDisplayed() { + cy.getByTestId(this.blockExplorerHeader).should( + 'have.text', + 'Vega Block Explorer' + ); + cy.getByTestId(this.searchField).should('be.visible'); + } + + validateBlockDataDisplayed(headerTestId) { + cy.getByTestId(headerTestId).then(($assetHeaders) => { + const headersAmount = parseInt($assetHeaders.length); + + cy.wrap($assetHeaders).each(($header) => { + expect($header).to.not.be.empty; + }); + + cy.get('.language-json') + .each(($asset, index, $list) => { + expect($asset).to.not.be.empty; + }) + .then(($list) => { + expect($list).to.have.length(headersAmount); + }); + }); + } } diff --git a/apps/explorer-e2e/src/support/pages/genesis-page.js b/apps/explorer-e2e/src/support/pages/genesis-page.js new file mode 100644 index 000000000..9dcc7ab14 --- /dev/null +++ b/apps/explorer-e2e/src/support/pages/genesis-page.js @@ -0,0 +1,9 @@ +import BasePage from './base-page'; + +export default class GenesisPage extends BasePage { + GenesisHeader = 'genesis-header'; + + genesisFieldsDisplayed() { + this.validateBlockDataDisplayed(this.GenesisHeader); + } +} diff --git a/apps/explorer-e2e/src/support/pages/markets-page.js b/apps/explorer-e2e/src/support/pages/markets-page.js new file mode 100644 index 000000000..cf3680c68 --- /dev/null +++ b/apps/explorer-e2e/src/support/pages/markets-page.js @@ -0,0 +1,9 @@ +import BasePage from './base-page'; + +export default class MarketsPage extends BasePage { + marketHeaders = 'markets-header'; + + validateMarketDataDisplayed() { + this.validateBlockDataDisplayed(this.marketHeaders); + } +} diff --git a/apps/explorer-e2e/src/support/pages/network-parameters-page.js b/apps/explorer-e2e/src/support/pages/network-parameters-page.js new file mode 100644 index 000000000..faa2b0d32 --- /dev/null +++ b/apps/explorer-e2e/src/support/pages/network-parameters-page.js @@ -0,0 +1,14 @@ +import BasePage from './base-page'; + +export default class NetworkParametersPage extends BasePage { + networkParametersHeader = 'network-param-header'; + parameters = 'parameters'; + + verifyNetworkParametersDisplayed() { + cy.getByTestId(this.networkParametersHeader).should( + 'have.text', + 'NetworkParameters' + ); + cy.getByTestId(this.parameters).should('not.be.empty'); + } +} diff --git a/apps/explorer-e2e/src/support/pages/validators-page.js b/apps/explorer-e2e/src/support/pages/validators-page.js new file mode 100644 index 000000000..47129b2a0 --- /dev/null +++ b/apps/explorer-e2e/src/support/pages/validators-page.js @@ -0,0 +1,18 @@ +import BasePage from './base-page'; + +export default class ValidatorPage extends BasePage { + tendermintHeader = 'tendermint-header'; + vegaHeader = 'vega-header'; + tendermintData = 'tendermint-data'; + vegaData = 'vega-data'; + + validateValidatorsDisplayed() { + cy.getByTestId(this.tendermintHeader).should( + 'have.text', + 'Tendermint data' + ); + cy.getByTestId(this.tendermintData).should('not.be.empty'); + cy.getByTestId(this.vegaHeader).should('have.text', 'Vega data'); + cy.getByTestId(this.vegaData).should('not.be.empty'); + } +} diff --git a/apps/explorer-e2e/src/support/step_definitions/asset-page-step.js b/apps/explorer-e2e/src/support/step_definitions/asset-page-step.js new file mode 100644 index 000000000..4fda5268e --- /dev/null +++ b/apps/explorer-e2e/src/support/step_definitions/asset-page-step.js @@ -0,0 +1,12 @@ +import { Given, Then, When } from 'cypress-cucumber-preprocessor/steps'; + +import AssetsPage from '../pages/assets-page'; +const assetPage = new AssetsPage(); + +When('I navigate to the asset page', () => { + assetPage.navigateToAssets(); +}); + +Then('asset page is correctly displayed', () => { + assetPage.validateAssetsDisplayed(); +}); diff --git a/apps/explorer-e2e/src/support/step_definitions/common.step.js b/apps/explorer-e2e/src/support/step_definitions/common.step.js new file mode 100644 index 000000000..9ef918681 --- /dev/null +++ b/apps/explorer-e2e/src/support/step_definitions/common.step.js @@ -0,0 +1,5 @@ +import { Given, Then, When } from 'cypress-cucumber-preprocessor/steps'; + +Given('I am on the homepage', () => { + cy.visit('/'); +}); diff --git a/apps/explorer-e2e/src/support/step_definitions/home-page.step.js b/apps/explorer-e2e/src/support/step_definitions/home-page.step.js index 60c4bb50a..c7311e1db 100644 --- a/apps/explorer-e2e/src/support/step_definitions/home-page.step.js +++ b/apps/explorer-e2e/src/support/step_definitions/home-page.step.js @@ -1,5 +1 @@ import { Given, Then, When } from 'cypress-cucumber-preprocessor/steps'; - -Given('I go to the homepage', () => { - cy.visit('/'); -}); diff --git a/apps/explorer/src/app/contexts/websocket/tendermint-websocket-context.ts b/apps/explorer/src/app/contexts/websocket/tendermint-websocket-context.ts index 1551f71dc..8ee2f6400 100644 --- a/apps/explorer/src/app/contexts/websocket/tendermint-websocket-context.ts +++ b/apps/explorer/src/app/contexts/websocket/tendermint-websocket-context.ts @@ -1,5 +1,5 @@ -import React from "react"; -import { WebSocketHook } from "react-use-websocket/dist/lib/types"; +import React from 'react'; +import { WebSocketHook } from 'react-use-websocket/dist/lib/types'; export type WebsocketContextShape = WebSocketHook; @@ -9,7 +9,7 @@ export const TendermintWebsocketContext = export function useTendermintWebsocketContext() { const context = React.useContext(TendermintWebsocketContext); if (context === null) { - throw new Error("useWebsocket must be used within WebsocketContext"); + throw new Error('useWebsocket must be used within WebsocketContext'); } return context; } diff --git a/apps/explorer/src/app/routes/assets/index.tsx b/apps/explorer/src/app/routes/assets/index.tsx index ed0cedcc6..56001abd7 100644 --- a/apps/explorer/src/app/routes/assets/index.tsx +++ b/apps/explorer/src/app/routes/assets/index.tsx @@ -39,7 +39,7 @@ const Assets = () => {

Assets

{data?.assets.map((a) => ( -

+

{a.name} ({a.symbol})

diff --git a/apps/explorer/src/app/routes/genesis/index.tsx b/apps/explorer/src/app/routes/genesis/index.tsx index 41928f4c6..d573df14a 100644 --- a/apps/explorer/src/app/routes/genesis/index.tsx +++ b/apps/explorer/src/app/routes/genesis/index.tsx @@ -12,7 +12,7 @@ const Genesis = () => { if (!genesis?.result.genesis) return null; return (
-

Genesis

+

Genesis

); diff --git a/apps/explorer/src/app/routes/markets/index.tsx b/apps/explorer/src/app/routes/markets/index.tsx index 5b9ab37f7..bd79f0177 100644 --- a/apps/explorer/src/app/routes/markets/index.tsx +++ b/apps/explorer/src/app/routes/markets/index.tsx @@ -153,7 +153,7 @@ const Markets = () => {

Markets

{data.markets.map((m) => ( -

{m.name}

+

{m.name}

))} diff --git a/apps/explorer/src/app/routes/network-parameters/index.tsx b/apps/explorer/src/app/routes/network-parameters/index.tsx index 8855ab9d1..22689c61b 100644 --- a/apps/explorer/src/app/routes/network-parameters/index.tsx +++ b/apps/explorer/src/app/routes/network-parameters/index.tsx @@ -1,5 +1,5 @@ -import { gql, useQuery } from "@apollo/client"; -import { NetworkParametersQuery } from "./__generated__/NetworkParametersQuery"; +import { gql, useQuery } from '@apollo/client'; +import { NetworkParametersQuery } from './__generated__/NetworkParametersQuery'; export const NETWORK_PARAMETERS_QUERY = gql` query NetworkParametersQuery { @@ -14,8 +14,8 @@ const NetworkParameters = () => { const { data } = useQuery(NETWORK_PARAMETERS_QUERY); return (
-

NetworkParameters

-
{JSON.stringify(data, null, "  ")}
+

NetworkParameters

+
{JSON.stringify(data, null, '  ')}
); };