diff --git a/apps/explorer-e2e/src/support/commands.ts b/apps/explorer-e2e/src/support/commands.ts index 310f1fa0e..c6a821e12 100644 --- a/apps/explorer-e2e/src/support/commands.ts +++ b/apps/explorer-e2e/src/support/commands.ts @@ -13,6 +13,7 @@ declare namespace Cypress { // eslint-disable-next-line @typescript-eslint/no-unused-vars interface Chainable { login(email: string, password: string): void; + getByTestId(selector: string): Chainable>; } } // @@ -31,3 +32,6 @@ Cypress.Commands.add('login', (email, password) => { // // -- This will overwrite an existing command -- // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) +Cypress.Commands.add('getByTestId', (selector, ...args) => { + return cy.get(`[data-testid=${selector}]`, ...args); +}); diff --git a/apps/explorer-e2e/src/support/pages/base-page.js b/apps/explorer-e2e/src/support/pages/base-page.js new file mode 100644 index 000000000..1c5acf761 --- /dev/null +++ b/apps/explorer-e2e/src/support/pages/base-page.js @@ -0,0 +1,11 @@ +export default class BasePage { + transactionsUrl = '/tsx'; + blocksUrl = '/blocks'; + partiesUrl = '/parties'; + assetsUrl = '/assets'; + genesisUrl = '/genesis'; + governanceUrl = '/governance'; + marketsUrl = '/markets'; + networkParametersUrl = '/network-parameters'; + validatorsUrl = '/validators'; +} diff --git a/apps/explorer-e2e/src/support/pages/blocks-page.js b/apps/explorer-e2e/src/support/pages/blocks-page.js new file mode 100644 index 000000000..f8ee84de2 --- /dev/null +++ b/apps/explorer-e2e/src/support/pages/blocks-page.js @@ -0,0 +1,25 @@ +import BasePage from './base-page'; + +export default class BlocksPage extends BasePage { + blocksFrmHeader = 'blocks-frm-header'; + blocksStreamedHeader = 'blocks-streamed-header'; + blockHeight = 'block-height'; + blockchainBlocks = 'blockchain-blocks'; + streamedBlocks = 'streamed-blocks'; + + validateBlocksPageDisplayed() { + cy.getByTestId(this.blocksFrmHeader).should( + 'have.text', + 'Blocks from blockchain' + ); + cy.getByTestId(this.blocksStreamedHeader).should( + 'have.text', + 'Blocks streamed in' + ); + cy.getByTestId(this.blockHeight) + .should('contain.text', 'Height: ') + .and('have.length.greaterThan', 10); + cy.getByTestId(this.blockchainBlocks).should('not.be.empty'); + cy.getByTestId(this.streamedBlocks).should('not.be.empty'); + } +} diff --git a/apps/explorer-e2e/src/support/pages/home-page.js b/apps/explorer-e2e/src/support/pages/home-page.js new file mode 100644 index 000000000..12fc1b14d --- /dev/null +++ b/apps/explorer-e2e/src/support/pages/home-page.js @@ -0,0 +1,3 @@ +import BasePage from './base-page'; + +export default class HomePage extends BasePage {} diff --git a/apps/explorer-e2e/src/support/pages/transactions-page.js b/apps/explorer-e2e/src/support/pages/transactions-page.js new file mode 100644 index 000000000..0b03e9baf --- /dev/null +++ b/apps/explorer-e2e/src/support/pages/transactions-page.js @@ -0,0 +1,11 @@ +import BasePage from './base-page'; + +export default class TransactionsPage extends BasePage { + unconfirmedTransactions = 'unconfirmed-txs'; + + validateUnconfirmedTxsNumDisplayed() { + cy.getByTestId(this.unconfirmedTransactions) + .should('contain.text', 'Number: ') + .and('have.length.above', 8); + } +} diff --git a/apps/explorer/src/app/components/search/index.tsx b/apps/explorer/src/app/components/search/index.tsx index e7ee3ebf8..d1d9d8066 100644 --- a/apps/explorer/src/app/components/search/index.tsx +++ b/apps/explorer/src/app/components/search/index.tsx @@ -91,10 +91,15 @@ const Search = () => { const { search, onChange } = useGuess(); return (
-

Vega Block Explorer

+

Vega Block Explorer

- onChange(e)} /> + onChange(e)} + />
);