diff --git a/frontend/cypress/integration/bisq/bisq.spec.ts b/frontend/cypress/integration/bisq/bisq.spec.ts index 761770ac8..0271ca775 100644 --- a/frontend/cypress/integration/bisq/bisq.spec.ts +++ b/frontend/cypress/integration/bisq/bisq.spec.ts @@ -1,8 +1,8 @@ describe('Bisq', () => { - let baseModule; + const baseModule = Cypress.env("BASE_MODULE"); + const basePath = (baseModule === 'bisq') ? '' : '/bisq'; + beforeEach(() => { - baseModule = (Cypress.env('BASE_MODULE') && Cypress.env('BASE_MODULE') === 'bisq') ? '' : '/bisq'; - cy.intercept('/sockjs-node/info*').as('socket'); cy.intercept('/bisq/api/markets/hloc?market=btc_usd&interval=day').as('hloc'); cy.intercept('/bisq/api/markets/ticker').as('ticker'); @@ -23,15 +23,15 @@ describe('Bisq', () => { }); }); - if (Cypress.env("BASE_MODULE") === '' || Cypress.env("BASE_MODULE") !== 'liquid') { + if (baseModule === 'mempool' || baseModule === 'bisq') { it('loads the dashboard', () => { - cy.visit(`${baseModule}`); + cy.visit(`${basePath}`); cy.waitForSkeletonGone(); }); it('loads the transactions screen', () => { - cy.visit(`${baseModule}`); + cy.visit(`${basePath}`); cy.waitForSkeletonGone(); cy.get('li:nth-of-type(2) > a').click().then(() => { cy.get('.table > tr').should('have.length', 50); @@ -39,7 +39,7 @@ describe('Bisq', () => { }); it('loads the blocks screen', () => { - cy.visit(`${baseModule}`); + cy.visit(`${basePath}`); cy.waitForSkeletonGone(); cy.get('li:nth-of-type(3) > a').click().then(() => { cy.wait('@blocks'); @@ -48,7 +48,7 @@ describe('Bisq', () => { }); it('loads the stats screen', () => { - cy.visit(`${baseModule}`); + cy.visit(`${basePath}`); cy.waitForSkeletonGone(); cy.get('li:nth-of-type(4) > a').click().then(() => { cy.wait('@stats'); @@ -56,7 +56,7 @@ describe('Bisq', () => { }); it('loads the api screen', () => { - cy.visit(`${baseModule}`); + cy.visit(`${basePath}`); cy.waitForSkeletonGone(); cy.get('li:nth-of-type(5) > a').click().then(() => { cy.get('.card').should('have.length.at.least', 1); @@ -67,7 +67,7 @@ describe('Bisq', () => { it('shows blocks pagination with 5 pages (desktop)', () => { cy.viewport(760, 800); - cy.visit(`${baseModule}/blocks`); + cy.visit(`${basePath}/blocks`); cy.waitForSkeletonGone(); cy.get('tbody tr').should('have.length', 10); // 5 pages + 4 buttons = 9 buttons @@ -76,13 +76,13 @@ describe('Bisq', () => { it('shows blocks pagination with 3 pages (mobile)', () => { cy.viewport(669, 800); - cy.visit(`${baseModule}/blocks`); + cy.visit(`${basePath}/blocks`); cy.waitForSkeletonGone(); cy.get('tbody tr').should('have.length', 10); // 3 pages + 4 buttons = 7 buttons cy.get('.pagination-container ul.pagination').first().children().should('have.length', 7); }); } else { - it.skip("Tests cannot be run on the selected BASE_MODULE"); + it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`); } }); diff --git a/frontend/cypress/integration/liquid/liquid.spec.ts b/frontend/cypress/integration/liquid/liquid.spec.ts index 26c032860..44aca078e 100644 --- a/frontend/cypress/integration/liquid/liquid.spec.ts +++ b/frontend/cypress/integration/liquid/liquid.spec.ts @@ -1,8 +1,8 @@ describe('Liquid', () => { - let baseModule; - beforeEach(() => { - baseModule = (Cypress.env('BASE_MODULE') && Cypress.env('BASE_MODULE') === 'liquid') ? '' : '/liquid'; + const baseModule = Cypress.env("BASE_MODULE"); + const basePath = (baseModule === 'liquid') ? '' : '/liquid'; + beforeEach(() => { cy.intercept('/liquid/api/block/**').as('block'); cy.intercept('/liquid/api/blocks/').as('blocks'); cy.intercept('/liquid/api/tx/**/outspends').as('outspends'); @@ -16,30 +16,30 @@ describe('Liquid', () => { }); }); - if (Cypress.env("BASE_MODULE") === '' || Cypress.env("BASE_MODULE") !== 'bisq') { + if (baseModule === 'mempool' || baseModule === 'liquid') { it('loads the dashboard', () => { - cy.visit(`${baseModule}`); + cy.visit(`${basePath}`); cy.waitForSkeletonGone(); }); it('loads the blocks page', () => { - cy.visit(`${baseModule}/blocks`); + cy.visit(`${basePath}/blocks`); cy.waitForSkeletonGone(); }); it('loads a specific block page', () => { - cy.visit(`${baseModule}/block/7e1369a23a5ab861e7bdede2aadcccae4ea873ffd9caf11c7c5541eb5bcdff54`); + cy.visit(`${basePath}/block/7e1369a23a5ab861e7bdede2aadcccae4ea873ffd9caf11c7c5541eb5bcdff54`); cy.waitForSkeletonGone(); }); it('loads the graphs page', () => { - cy.visit(`${baseModule}/graphs`); + cy.visit(`${basePath}/graphs`); cy.waitForSkeletonGone(); }); it('loads the tv page - desktop', () => { - cy.visit(`${baseModule}`); + cy.visit(`${basePath}`); cy.waitForSkeletonGone(); cy.get('li:nth-of-type(3) > a').click().then(() => { cy.wait(1000); @@ -47,7 +47,7 @@ describe('Liquid', () => { }); it('loads the graphs page - mobile', () => { - cy.visit(`${baseModule}`) + cy.visit(`${basePath}`) cy.waitForSkeletonGone(); cy.get('li:nth-of-type(3) > a').click().then(() => { cy.viewport('iphone-6'); @@ -58,13 +58,13 @@ describe('Liquid', () => { describe('assets', () => { it('shows the assets screen', () => { - cy.visit(`${baseModule}/assets`); + cy.visit(`${basePath}/assets`); cy.waitForSkeletonGone(); cy.get('table tr').should('have.length.at.least', 5); }); it('allows searching assets', () => { - cy.visit(`${baseModule}/assets`); + cy.visit(`${basePath}/assets`); cy.waitForSkeletonGone(); cy.get('.container-xl input').click().type('Liquid Bitcoin').then(() => { cy.get('table tr').should('have.length', 1); @@ -72,7 +72,7 @@ describe('Liquid', () => { }); it('shows a specific asset ID', () => { - cy.visit(`${baseModule}/assets`); + cy.visit(`${basePath}/assets`); cy.waitForSkeletonGone(); cy.get('.container-xl input').click().type('Liquid AUD').then(() => { cy.get('table tr td:nth-of-type(1) a').click(); @@ -84,27 +84,27 @@ describe('Liquid', () => { describe('unblinded TX', () => { it('should not show an unblinding error message for regular txs', () => { - cy.visit(`${baseModule}/tx/82a479043ec3841e0d3f829afc8df4f0e2bbd675a13f013ea611b2fde0027d45`); + cy.visit(`${basePath}/tx/82a479043ec3841e0d3f829afc8df4f0e2bbd675a13f013ea611b2fde0027d45`); cy.waitForSkeletonGone(); cy.get('.error-unblinded' ).should('not.exist'); }); it('show unblinded TX', () => { - cy.visit(`${baseModule}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=100000,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,0ab9f70650f16b1db8dfada05237f7d0d65191c3a13183da8a2ddddfbde9a2ad,fd98b2edc5530d76acd553f206a431f4c1fab27e10e290ad719582af878e98fc,2364760,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,90c7a43b15b905bca045ca42a01271cfe71d2efe3133f4197792c24505cb32ed,12eb5959d9293b8842e7dd8bc9aa9639fd3fd031c5de3ba911adeca94eb57a3a`); + cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=100000,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,0ab9f70650f16b1db8dfada05237f7d0d65191c3a13183da8a2ddddfbde9a2ad,fd98b2edc5530d76acd553f206a431f4c1fab27e10e290ad719582af878e98fc,2364760,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,90c7a43b15b905bca045ca42a01271cfe71d2efe3133f4197792c24505cb32ed,12eb5959d9293b8842e7dd8bc9aa9639fd3fd031c5de3ba911adeca94eb57a3a`); cy.waitForSkeletonGone(); cy.get('#table-tx-vin tr').should('have.class', 'assetBox'); cy.get('#table-tx-vout tr').should('have.class', 'assetBox'); }); it('show empty unblinded TX', () => { - cy.visit(`${baseModule}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=`); + cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=`); cy.waitForSkeletonGone(); cy.get('#table-tx-vin tr').should('have.class', ''); cy.get('#table-tx-vout tr').should('have.class', ''); }); it('show invalid unblinded TX hex', () => { - cy.visit(`${baseModule}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=123`); + cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=123`); cy.waitForSkeletonGone(); cy.get('#table-tx-vin tr').should('have.class', ''); cy.get('#table-tx-vout tr').should('have.class', ''); @@ -112,36 +112,36 @@ describe('Liquid', () => { }); it('show first unblinded vout', () => { - cy.visit(`${baseModule}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=100000,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,0ab9f70650f16b1db8dfada05237f7d0d65191c3a13183da8a2ddddfbde9a2ad,fd98b2edc5530d76acd553f206a431f4c1fab27e10e290ad719582af878e98fc`); + cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=100000,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,0ab9f70650f16b1db8dfada05237f7d0d65191c3a13183da8a2ddddfbde9a2ad,fd98b2edc5530d76acd553f206a431f4c1fab27e10e290ad719582af878e98fc`); cy.waitForSkeletonGone(); cy.get('#table-tx-vout tr:first-child()').should('have.class', 'assetBox'); }); it('show second unblinded vout', () => { - cy.visit(`${baseModule}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=2364760,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,90c7a43b15b905bca045ca42a01271cfe71d2efe3133f4197792c24505cb32ed,12eb5959d9293b8842e7dd8bc9aa9639fd3fd031c5de3ba911adeca94eb57a3a`); + cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=2364760,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,90c7a43b15b905bca045ca42a01271cfe71d2efe3133f4197792c24505cb32ed,12eb5959d9293b8842e7dd8bc9aa9639fd3fd031c5de3ba911adeca94eb57a3a`); cy.get('#table-tx-vout tr').should('have.class', 'assetBox'); }); it('show invalid error unblinded TX', () => { - cy.visit(`${baseModule}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=100000,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,0ab9f70650f16b1db8dfada05237f7d0d65191c3a13183da8a2ddddfbde9a2ad,fd98b2edc5530d76acd553f206a431f4c1fab27e10e290ad719582af878e98fc,2364760,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,90c7a43b15b905bca045ca42a01271cfe71d2efe3133f4197792c24505cb32ed,12eb5959d9293b8842e7dd8bc9aa9639fd3fd031c5de3ba911adeca94eb57a3c`); + cy.visit(`${basePath}/tx/f2f41c0850e8e7e3f1af233161fd596662e67c11ef10ed15943884186fbb7f46#blinded=100000,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,0ab9f70650f16b1db8dfada05237f7d0d65191c3a13183da8a2ddddfbde9a2ad,fd98b2edc5530d76acd553f206a431f4c1fab27e10e290ad719582af878e98fc,2364760,6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d,90c7a43b15b905bca045ca42a01271cfe71d2efe3133f4197792c24505cb32ed,12eb5959d9293b8842e7dd8bc9aa9639fd3fd031c5de3ba911adeca94eb57a3c`); cy.waitForSkeletonGone(); cy.get('#table-tx-vout tr').should('have.class', 'assetBox'); cy.get('.error-unblinded' ).contains('Error: Invalid blinding data.'); }); it('shows asset peg in/out and burn transactions', () => { - cy.visit(`${baseModule}/asset/6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d`); + cy.visit(`${basePath}/asset/6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d`); cy.waitForSkeletonGone(); cy.get('#table-tx-vout tr').not('.assetBox'); cy.get('#table-tx-vin tr').not('.assetBox'); }); it('prevents regressing issue #644', () => { - cy.visit(`${baseModule}/tx/393b890966f305e7c440fcfb12a13f51a7a9011cc59ff5f14f6f93214261bd82`); + cy.visit(`${basePath}/tx/393b890966f305e7c440fcfb12a13f51a7a9011cc59ff5f14f6f93214261bd82`); cy.waitForSkeletonGone(); }); }); } else { - it.skip("Tests cannot be run on the selected BASE_MODULE"); + it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`); } }); diff --git a/frontend/cypress/integration/mainnet/mainnet.spec.ts b/frontend/cypress/integration/mainnet/mainnet.spec.ts index 5839f4f51..f700c00d9 100644 --- a/frontend/cypress/integration/mainnet/mainnet.spec.ts +++ b/frontend/cypress/integration/mainnet/mainnet.spec.ts @@ -1,5 +1,7 @@ import { emitMempoolInfo, dropWebSocket } from "../../support/websocket"; +const baseModule = Cypress.env("BASE_MODULE"); + describe('Mainnet', () => { beforeEach(() => { //cy.intercept('/sockjs-node/info*').as('socket'); @@ -20,7 +22,7 @@ describe('Mainnet', () => { }); }); - if (Cypress.env("BASE_MODULE") === '' || Cypress.env("BASE_MODULE") === 'mempool') { + if (baseModule === 'mempool') { it('loads the status screen', () => { cy.visit('/status'); @@ -281,7 +283,7 @@ describe('Mainnet', () => { }); }); - it.only('loads the tv screen - mobile', () => { + it('loads the tv screen - mobile', () => { cy.viewport('iphone-6'); cy.visit('/tv'); cy.waitForSkeletonGone(); @@ -363,6 +365,6 @@ describe('Mainnet', () => { }); }); } else { - it.skip("Tests cannot be run on the selected BASE_MODULE"); + it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`); } }); diff --git a/frontend/cypress/integration/signet/signet.spec.ts b/frontend/cypress/integration/signet/signet.spec.ts index e10c5563d..ec2a0a852 100644 --- a/frontend/cypress/integration/signet/signet.spec.ts +++ b/frontend/cypress/integration/signet/signet.spec.ts @@ -1,5 +1,7 @@ import { emitMempoolInfo } from "../../support/websocket"; +const baseModule = Cypress.env("BASE_MODULE"); + describe('Signet', () => { beforeEach(() => { cy.intercept('/api/block-height/*').as('block-height'); @@ -9,7 +11,7 @@ describe('Signet', () => { }); - if (Cypress.env("BASE_MODULE") === '' || Cypress.env("BASE_MODULE") === 'mempool') { + if (baseModule === 'mempool') { it('loads the dashboard', () => { cy.visit('/signet'); cy.waitForSkeletonGone(); @@ -126,6 +128,6 @@ describe('Signet', () => { }); }); } else { - it.skip("Tests cannot be run on the selected BASE_MODULE"); + it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`); } }); diff --git a/frontend/cypress/integration/testnet/testnet.spec.ts b/frontend/cypress/integration/testnet/testnet.spec.ts index d82a4d435..6e406c087 100644 --- a/frontend/cypress/integration/testnet/testnet.spec.ts +++ b/frontend/cypress/integration/testnet/testnet.spec.ts @@ -1,5 +1,7 @@ import { confirmAddress, emitMempoolInfo, sendWsMock, showNewTx, startTrackingAddress } from "../../support/websocket"; +const baseModule = Cypress.env("BASE_MODULE"); + describe('Testnet', () => { beforeEach(() => { cy.intercept('/api/block-height/*').as('block-height'); @@ -8,7 +10,7 @@ describe('Testnet', () => { cy.intercept('/api/tx/*/outspends').as('tx-outspends'); }); - if (Cypress.env("BASE_MODULE") === '' || Cypress.env("BASE_MODULE") === 'mempool') { + if (baseModule === 'mempool') { it('loads the dashboard', () => { cy.visit('/testnet'); @@ -123,6 +125,6 @@ describe('Testnet', () => { }); }); } else { - it.skip("Tests cannot be run on the selected BASE_MODULE"); + it.skip(`Tests cannot be run on the selected BASE_MODULE ${baseModule}`); } }); diff --git a/frontend/cypress/plugins/index.js b/frontend/cypress/plugins/index.js index 1ee7c778d..1ae86fa18 100644 --- a/frontend/cypress/plugins/index.js +++ b/frontend/cypress/plugins/index.js @@ -1 +1,14 @@ -module.exports = (on, config) => {} +const fs = require('fs'); + +const CONFIG_FILE = 'mempool-frontend-config.json'; + +module.exports = (on, config) => { + if (fs.existsSync(CONFIG_FILE)) { + let contents = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8')); + console.log(contents); + config.env.BASE_MODULE = contents.BASE_MODULE; + } else { + config.env.BASE_MODULE = 'mempool'; + } + return config; +} diff --git a/frontend/cypress/support/commands.ts b/frontend/cypress/support/commands.ts index ea5e88996..4d165e409 100644 --- a/frontend/cypress/support/commands.ts +++ b/frontend/cypress/support/commands.ts @@ -56,6 +56,13 @@ const codes = { ArrowDown: 40 } +Cypress.Commands.add("getBaseModule", () => { + return cy.task("getBaseModule").then((baseModule) => { + console.log(baseModule); + return baseModule; + }); +}); + Cypress.Commands.add('waitForSkeletonGone', () => { cy.waitUntil(() => { return Cypress.$('.skeleton-loader').length === 0; diff --git a/frontend/proxy.conf.js b/frontend/proxy.conf.js index 65aa0df65..88ad4040b 100644 --- a/frontend/proxy.conf.js +++ b/frontend/proxy.conf.js @@ -68,7 +68,7 @@ if (configContent && configContent.BASE_MODULE == "liquid") { changeOrigin: true, }); } else { - PROXY_CONFIG.push( { + PROXY_CONFIG.push({ context: ['/resources/pools.json', '/resources/assets.json', '/resources/assets.minimal.json'], target: "https://mempool.space", secure: false,