mempool/frontend/cypress/integration/testnet/testnet.spec.ts
Felipe Knorr Kuhn 9e46cde9b7
Updates to the e2e suite (#659)
* initial version of the update config script

* fix duplicated content

* update cypress ci settings

* add workflow to run e2e tests when pushing

* record cypress results to the dashboard

* pull the cypress record key and project id from the secrets

* add start-server-and-test to replace concurrently

* replace concurrently with start-server-and-test

* remove concurrently

* add new cypress target to record

* update cypress to 7.7.0

* add tests for signet

* add tests for testnet

* run tests on chrome and firefox

* update test matrix: add edge and run firefox on container

* fix copypasta

* update docker image for firefox

* fix task name again

* fix edge tests task name

* improve bisq tests

* update workflow config

* enable cypress debug logs

* add a manual trigger for the e2e tests

* add config:defaults target

* use more of the GHA options

* fix config command

* add cypress-fail-on-console-error

* upgrade cypress to v8.0.0

* add helper to wait for the loader skeleton to be gone

* use skeleton waiter on the tests

* remove manual test trigger

* fix tv test when only one mempool block is available

* add waiter for pagination

* add extra steps to debug firefox launch issue

* remove whoami step

* Revert "upgrade cypress to v8.0.0"

This reverts commit cb3ff7d906.

* remove userinfo debug step

* enable test retries in run mode

* update proxy config to reduce ECONNRESET errors

* add mock-socket dev dependency

* add helpers to mock websockets and detect page idleness

* stabilize mainnet tests

* fix tv mode test on Liquid

* add basic tests for the mainnet status page

* cleanup mainnet tests

* update bisq tests

* update signet tests

* update testnet tests

* add initial support for parameterized websocket mocks

* move testing dependencies to optionalDependencies

* comment out mempool size check until the live updates are fixed

* comment out tx regex test

* update fixture for the new difficulty adjustment component

* fix the assertions on the status page
2021-07-25 21:03:47 +03:00

124 lines
4.0 KiB
TypeScript

import { emitMempoolInfo } from "../../support/websocket";
describe('Testnet', () => {
beforeEach(() => {
cy.intercept('/api/block-height/*').as('block-height');
cy.intercept('/api/block/*').as('block');
cy.intercept('/api/block/*/txs/0').as('block-txs');
cy.intercept('/api/tx/*/outspends').as('tx-outspends');
});
it('loads the dashboard', () => {
cy.visit('/testnet');
cy.waitForSkeletonGone();
});
it('loads the dashboard with the skeleton blocks', () => {
cy.mockMempoolSocket();
cy.visit("/signet");
cy.get(':nth-child(1) > #bitcoin-block-0').should('be.visible');
cy.get(':nth-child(2) > #bitcoin-block-0').should('be.visible');
cy.get(':nth-child(3) > #bitcoin-block-0').should('be.visible');
cy.get('#mempool-block-0').should('be.visible');
cy.get('#mempool-block-1').should('be.visible');
cy.get('#mempool-block-2').should('be.visible');
emitMempoolInfo({
'params': {
loaded: true
}
});
cy.get(':nth-child(1) > #bitcoin-block-0').should('not.exist');
cy.get(':nth-child(2) > #bitcoin-block-0').should('not.exist');
cy.get(':nth-child(3) > #bitcoin-block-0').should('not.exist');
});
it('loads the blocks screen', () => {
cy.visit('/testnet');
cy.waitForSkeletonGone();
cy.get('li:nth-of-type(2) > a').click().then(() => {
cy.wait(1000);
});
});
it('loads the graphs screen', () => {
cy.visit('/testnet');
cy.waitForSkeletonGone();
cy.get('li:nth-of-type(3) > a').click().then(() => {
cy.wait(1000);
});
});
describe('tv mode', () => {
it('loads the tv screen - desktop', () => {
cy.viewport('macbook-16');
cy.visit('/testnet');
cy.waitForSkeletonGone();
cy.get('li:nth-of-type(4) > a').click().then(() => {
cy.wait(1000);
cy.get('.tv-only').should('not.exist');
});
});
it('loads the tv screen - mobile', () => {
cy.visit('/testnet');
cy.waitForSkeletonGone();
cy.get('li:nth-of-type(4) > a').click().then(() => {
cy.viewport('iphone-6');
cy.wait(1000);
cy.get('.tv-only').should('not.exist');
});
});
});
it('loads the api screen', () => {
cy.visit('/testnet');
cy.waitForSkeletonGone();
cy.get('li:nth-of-type(5) > a').click().then(() => {
cy.wait(1000);
});
});
describe('blocks', () => {
it('shows empty blocks properly', () => {
cy.visit('/testnet/block/0');
cy.waitForSkeletonGone();
cy.get('h2').invoke('text').should('equal', '1 transaction');
});
it('expands and collapses the block details', () => {
cy.visit('/testnet/block/0');
cy.waitForSkeletonGone();
cy.get('.btn.btn-outline-info').click().then(() => {
cy.get('#details').should('be.visible');
});
cy.get('.btn.btn-outline-info').click().then(() => {
cy.get('#details').should('not.be.visible');
});
});
it('shows blocks with no pagination', () => {
cy.visit('/testnet/block/000000000000002f8ce27716e74ecc7ad9f7b5101fed12d09e28bb721b9460ea');
cy.waitForSkeletonGone();
cy.get('h2').invoke('text').should('equal', '11 transactions');
cy.get('ul.pagination').first().children().should('have.length', 5);
});
it('supports pagination on the block screen', () => {
// 48 txs
cy.visit('/testnet/block/000000000000002ca3878ebd98b313a1c2d531f2e70a6575d232ca7564dea7a9');
cy.waitForSkeletonGone();
cy.get('.header-bg.box > a').invoke('text').then((text1) => {
cy.get('.active + li').first().click().then(() => {
cy.get('.header-bg.box > a').invoke('text').then((text2) => {
expect(text1).not.to.eq(text2);
});
});
});
});
});
});