From 460ff68a527f42a61267c59edd3af7595bbe0660 Mon Sep 17 00:00:00 2001 From: Felipe Knorr Kuhn <100320+knorrium@users.noreply.github.com> Date: Wed, 6 Jul 2022 10:00:32 -0700 Subject: [PATCH 1/2] Add test locators to the mining dashboard elements --- .../app/components/block/block.component.html | 4 ++-- .../blockchain-blocks.component.html | 20 ++++++++--------- .../hashrate-chart.component.html | 12 +++++----- .../hashrate-chart-pools.component.html | 10 ++++----- .../mempool-blocks.component.html | 14 ++++++------ .../mining-dashboard.component.html | 14 ++++++------ .../pool-ranking/pool-ranking.component.html | 22 +++++++++---------- 7 files changed, 48 insertions(+), 48 deletions(-) diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index 1216ecc30..77544dccd 100644 --- a/frontend/src/app/components/block/block.component.html +++ b/frontend/src/app/components/block/block.component.html @@ -113,13 +113,13 @@ Miner - {{ block.extras.pool.name }} - {{ block.extras.pool.name }} diff --git a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html index d41d34b81..f1d2cca6d 100644 --- a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html +++ b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.html @@ -1,31 +1,31 @@
-
- +   -
+
-
+
~{{ block?.extras?.medianFee | number:feeRounding }} sat/vB
-
+
{{ block?.extras?.feeRange[1] | number:feeRounding }} - {{ block?.extras?.feeRange[block?.extras?.feeRange.length - 1] | number:feeRounding }} sat/vB
-
+
-
-
+
+
{{ i }} transaction {{ i }} transactions
-
+
diff --git a/frontend/src/app/components/hashrate-chart/hashrate-chart.component.html b/frontend/src/app/components/hashrate-chart/hashrate-chart.component.html index 46be9e2d2..9e013a45c 100644 --- a/frontend/src/app/components/hashrate-chart/hashrate-chart.component.html +++ b/frontend/src/app/components/hashrate-chart/hashrate-chart.component.html @@ -28,22 +28,22 @@
diff --git a/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.html b/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.html index 51f6abafc..1d9e63716 100644 --- a/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.html +++ b/frontend/src/app/components/hashrates-chart-pools/hashrate-chart-pools.component.html @@ -10,19 +10,19 @@
diff --git a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.html b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.html index ecb8163c1..77ca95b2f 100644 --- a/frontend/src/app/components/mempool-blocks/mempool-blocks.component.html +++ b/frontend/src/app/components/mempool-blocks/mempool-blocks.component.html @@ -2,26 +2,26 @@
-
+
 
-
+
~{{ projectedBlock.medianFee | number:feeRounding }} sat/vB
-
+
{{ projectedBlock.feeRange[0] | number:feeRounding }} - {{ projectedBlock.feeRange[projectedBlock.feeRange.length - 1] | number:feeRounding }} sat/vB
- +
-
+
{{ i }} transaction {{ i }} transactions
-
+
@@ -30,7 +30,7 @@
-
+
() {{ i }} blocks
diff --git a/frontend/src/app/components/mining-dashboard/mining-dashboard.component.html b/frontend/src/app/components/mining-dashboard/mining-dashboard.component.html index b0ec46ac5..64b39649b 100644 --- a/frontend/src/app/components/mining-dashboard/mining-dashboard.component.html +++ b/frontend/src/app/components/mining-dashboard/mining-dashboard.component.html @@ -7,7 +7,7 @@
- Reward stats  + Reward stats  (144 blocks)
@@ -22,15 +22,15 @@
Difficulty Adjustment
- +
@@ -39,7 +39,7 @@
@@ -54,7 +54,7 @@   - +
@@ -68,7 +68,7 @@   - +
diff --git a/frontend/src/app/components/pool-ranking/pool-ranking.component.html b/frontend/src/app/components/pool-ranking/pool-ranking.component.html index a4027dfa2..b6a90a491 100644 --- a/frontend/src/app/components/pool-ranking/pool-ranking.component.html +++ b/frontend/src/app/components/pool-ranking/pool-ranking.component.html @@ -40,34 +40,34 @@ *ngIf="!widget && (miningStatsObservable$ | async) as stats">
@@ -95,7 +95,7 @@ Empty blocks - + {{ pool.rank }} From 9d832f9bfc302311bc853833a0aa6e0968b03663 Mon Sep 17 00:00:00 2001 From: Felipe Knorr Kuhn <100320+knorrium@users.noreply.github.com> Date: Wed, 6 Jul 2022 10:01:05 -0700 Subject: [PATCH 2/2] Add initial mining dashboard tests --- frontend/cypress/e2e/mainnet/mining.spec.ts | 171 ++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 frontend/cypress/e2e/mainnet/mining.spec.ts diff --git a/frontend/cypress/e2e/mainnet/mining.spec.ts b/frontend/cypress/e2e/mainnet/mining.spec.ts new file mode 100644 index 000000000..5c60f3a8c --- /dev/null +++ b/frontend/cypress/e2e/mainnet/mining.spec.ts @@ -0,0 +1,171 @@ +const baseModule = Cypress.env("BASE_MODULE"); + +describe('Mainnet - Mining Features', () => { + beforeEach(() => { + //https://github.com/cypress-io/cypress/issues/14459 + if (Cypress.browser.family === 'chromium') { + Cypress.automation('remote:debugger:protocol', { + command: 'Network.enable', + params: {} + }); + Cypress.automation('remote:debugger:protocol', { + command: 'Network.setCacheDisabled', + params: { cacheDisabled: true } + }); + } + }); + + if (baseModule === 'mempool') { + + describe('Miner page', () => { + beforeEach(() => { + cy.intercept('/api/v1/mining/pool/**').as('pool'); + cy.intercept('/api/v1/mining/hashrate/pools/**').as('hashrate'); + cy.intercept('/api/tx/**').as('tx'); + cy.intercept('/api/v1/outpends/**').as('outspends'); + }); + it('loads the mining pool page from the dashboard', () => { + cy.visit('/mining'); + cy.waitForSkeletonGone(); + cy.get('[data-cy="bitcoin-block-0-pool"]').click().then(() => { + cy.waitForSkeletonGone(); + cy.wait('@pool'); + cy.url().should('match', /\/mining\/pool\/(\w+)/); + }); + }); + + it('loads the mining pool page from the blocks page', () => { + cy.visit('/mining'); + cy.waitForSkeletonGone(); + cy.get('[data-cy="bitcoin-block-0-height"]').click().then(() => { + cy.waitForSkeletonGone(); + cy.get('[data-cy="block-details-miner-badge"]').click().then(() => { + cy.waitForSkeletonGone(); + cy.wait('@pool'); + cy.url().should('match', /\/mining\/pool\/(\w+)/); + }); + }); + }); + }); + + describe('Mining Dashboard Landing page widgets', () => { + + beforeEach(() => { + cy.visit('/mining'); + cy.waitForSkeletonGone(); + }); + + it('shows the mempool blocks', () => { + cy.get('[data-cy="mempool-block-0-fees"]').invoke('text').should('match', /~(.*) sat\/vB/); + cy.get('[data-cy="mempool-block-0-fee-span"]').invoke('text').should('match', /(.*) - (.*) sat\/vB/); + cy.get('[data-cy="mempool-block-0-total-fees"]').invoke('text').should('match', /(.*) BTC/); + cy.get('[data-cy="mempool-block-0-transaction-count"]').invoke('text').should('match', /(.*) transactions/); + cy.get('[data-cy="mempool-block-0-time"]').invoke('text').should('match', /In ~(.*) minutes/); + }); + + it('shows the mined blocks', () => { + cy.get('[data-cy="bitcoin-block-0-height"]').invoke('text').should('match', /(\d)/); + cy.get('[data-cy="bitcoin-block-0-fees"]').invoke('text').should('match', /~(.*) sat\/vB/); + cy.get('[data-cy="bitcoin-block-0-fee-span"]').invoke('text').should('match', /(.*) - (.*) sat\/vB/); + cy.get('[data-cy="bitcoin-block-0-total-fees"]').invoke('text').should('match', /(.*) BTC/); + cy.get('[data-cy="bitcoin-block-0-transactions"]').invoke('text').should('match', /(.*) transactions/); + cy.get('[data-cy="bitcoin-block-0-time"]').invoke('text').should('match', /((.*) ago|Just now)/); + cy.get('[data-cy="bitcoin-block-0-pool"]').invoke('text').should('match', /(\w)/); + }); + + it('shows the reward stats for the last 144 blocks', () => { + cy.get('[data-cy="reward-stats"]'); + }); + + it('shows the difficulty adjustment stats', () => { + cy.get('[data-cy="difficulty-adjustment"]'); + }); + + it('shows the latest blocks', () => { + cy.get('[data-cy="latest-blocks"]'); + }); + + it('shows the pools pie chart', () => { + cy.get('[data-cy="pool-distribution"]'); + }); + + it('shows the hashrate graph', () => { + cy.get('[data-cy="hashrate-graph"]'); + }); + it('shows the latest blocks', () => { + cy.get('[data-cy="latest-blocks"]'); + }); + + it('shows the latest adjustments', () => { + cy.get('[data-cy="difficulty-adjustments-table"]'); + }); + }); + + describe.only('mining graphs', () => { + describe('pools ranking', () => { + it('loads the graph', () => { + cy.visit('/graphs/mining/pools'); + cy.waitForSkeletonGone(); + cy.waitForPageIdle(); + cy.get('.spinner-border').should('not.exist'); + }); + }); + + describe('pools dominance', () => { + it('loads the graph', () => { + cy.visit('/graphs/mining/pools-dominance'); + cy.waitForSkeletonGone(); + cy.waitForPageIdle(); + cy.get('.spinner-border').should('not.exist'); + }); + }); + + describe('hashrate & difficulty', () => { + it('loads the graph', () => { + cy.visit('/graphs/mining/hashrate-difficulty'); + cy.waitForSkeletonGone(); + cy.waitForPageIdle(); + cy.get('.spinner-border').should('not.exist'); + }); + }); + + describe('block fee rates', () => { + it('loads the graph', () => { + cy.visit('/graphs/mining/block-fee-rates'); + cy.waitForSkeletonGone(); + cy.waitForPageIdle(); + cy.get('.spinner-border').should('not.exist'); + }); + }); + + describe('block fees', () => { + it('loads the graph', () => { + cy.visit('/graphs/mining/block-fees'); + cy.waitForSkeletonGone(); + cy.waitForPageIdle(); + cy.get('.spinner-border').should('not.exist'); + }); + }); + + describe('block rewards', () => { + it('loads the graph', () => { + cy.visit('/graphs/mining/block-rewards'); + cy.waitForSkeletonGone(); + cy.waitForPageIdle(); + cy.get('.spinner-border').should('not.exist'); + }); + }); + + describe('block sizes and weights', () => { + it('loads the graph', () => { + cy.visit('/graphs/mining/block-sizes-weights'); + cy.waitForSkeletonGone(); + cy.waitForPageIdle(); + cy.get('.spinner-border').should('not.exist'); + }); + }); + }); + } else { + it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`); + } +});