From 3e8d646edd07ee6b4b11c355e102454570a0463b Mon Sep 17 00:00:00 2001 From: Felipe Knorr Kuhn <100320+knorrium@users.noreply.github.com> Date: Tue, 17 Aug 2021 12:03:03 -0700 Subject: [PATCH 1/5] Fix update-config script to parse string values --- frontend/update-config.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/update-config.js b/frontend/update-config.js index 4f5a0e8bc..92facefa1 100644 --- a/frontend/update-config.js +++ b/frontend/update-config.js @@ -5,7 +5,7 @@ const GENERATED_CONFIG_FILE_NAME = 'generated-config.js'; let settings = []; let configContent = {}; -const packageSettings = ['GIT_COMMIT_HASH', 'PACKAGE_JSON_VERSION']; //These will be handled by generate-config +const packageSettings = ['GIT_COMMIT_HASH', 'PACKAGE_JSON_VERSION']; //These will be handled by generate-config var args = process.argv.slice(2); @@ -19,8 +19,10 @@ function addSetting(key, value) { function normalizedValue(value) { if (Number(value)) { value = Number(value); - } else if ((value === 'true') || (value !== 'true')) { + } else if ((value === 'true') || (value === 'false')) { value = !!JSON.parse(String(value).toLowerCase()); + } else { + value = String(value).toLowerCase(); } return value; } From ed06e3c49190e4061445ab1fa8188af5cd603978 Mon Sep 17 00:00:00 2001 From: Felipe Knorr Kuhn <100320+knorrium@users.noreply.github.com> Date: Tue, 17 Aug 2021 13:00:46 -0700 Subject: [PATCH 2/5] Add a new JS-based dev proxy for the new split up sites --- frontend/proxy.conf.js | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 frontend/proxy.conf.js diff --git a/frontend/proxy.conf.js b/frontend/proxy.conf.js new file mode 100644 index 000000000..4869935ff --- /dev/null +++ b/frontend/proxy.conf.js @@ -0,0 +1,64 @@ +const fs = require('fs'); + +let PROXY_CONFIG; +let configContent; + +const CONFIG_FILE_NAME = 'mempool-frontend-config.json'; + +try { + const rawConfig = fs.readFileSync(CONFIG_FILE_NAME); + configContent = JSON.parse(rawConfig); + console.log(`${CONFIG_FILE_NAME} file found, using provided config`); +} catch (e) { + console.log(e); + if (e.code !== 'ENOENT') { + throw new Error(e); + } else { + console.log(`${CONFIG_FILE_NAME} file not found, using default config`); + + } +} + +PROXY_CONFIG = [ + { + context: ['*', + '/api/**', '!/api/v1/ws', + '!/bisq', '!/bisq/**', '!/bisq/', + '!/liquid', '!/liquid/**', '!/liquid/', + '/testnet/api/**', '/signet/api/**' + ], + target: "https://mempool.space", + ws: true, + secure: false, + changeOrigin: true + }, + { + context: ['/api/v1/ws'], + target: "https://mempool.space", + ws: true, + secure: false, + changeOrigin: true, + }, + { + context: ['/api/bisq**', '/bisq/api/**'], + target: "https://bisq.markets", + pathRewrite: { + "^/api/bisq/": "/bisq/api" + }, + ws: true, + secure: false, + changeOrigin: true + }, + { + context: ['/api/liquid**', '/liquid/api/**'], + target: "https://liquid.network", + pathRewrite: { + "^/api/liquid/": "/liquid/api" + }, + ws: true, + secure: false, + changeOrigin: true + } +]; + +module.exports = PROXY_CONFIG; From 648d59631b740d105c158159bfdbe7257c09e059 Mon Sep 17 00:00:00 2001 From: Felipe Knorr Kuhn <100320+knorrium@users.noreply.github.com> Date: Tue, 17 Aug 2021 13:01:04 -0700 Subject: [PATCH 3/5] Update local-prod target to use the new JS dev proxy --- frontend/angular.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/angular.json b/frontend/angular.json index 287d0ccaf..c5b6776be 100644 --- a/frontend/angular.json +++ b/frontend/angular.json @@ -200,7 +200,7 @@ "verbose": true }, "local-prod": { - "proxyConfig": "proxy.prod.conf.json", + "proxyConfig": "proxy.conf.js", "disableHostCheck": true, "host": "0.0.0.0", "verbose": false From 250ea09c7ecc887b4e32faab5ff6ce778bf39f55 Mon Sep 17 00:00:00 2001 From: Felipe Knorr Kuhn <100320+knorrium@users.noreply.github.com> Date: Tue, 17 Aug 2021 13:01:36 -0700 Subject: [PATCH 4/5] Run generate config before running e2e tests locally --- frontend/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/package.json b/frontend/package.json index 60430a08e..1ff64b484 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -37,7 +37,7 @@ "build-mempool.js": "tsc | browserify -p tinyify ./node_modules/@mempool/mempool.js/lib/index.js --standalone mempoolJS > ./dist/mempool/browser/en-US/mempool.js", "test": "ng test", "lint": "ng lint", - "e2e": "ng e2e", + "e2e": "npm run generate-config && ng e2e", "e2e:ci": "npm run cypress:run:ci", "config:defaults": "node update-config.js TESTNET_ENABLED=true SIGNET_ENABLED=true LIQUID_ENABLED=true BISQ_ENABLED=true ITEMS_PER_PAGE=25 && npm run generate-config", "dev:ssr": "npm run generate-config && ng run mempool:serve-ssr", From 901cee903c38b84df24045726cde5a080f1b91b8 Mon Sep 17 00:00:00 2001 From: Felipe Knorr Kuhn <100320+knorrium@users.noreply.github.com> Date: Tue, 17 Aug 2021 13:02:24 -0700 Subject: [PATCH 5/5] Update bisq tests to use the menu navigation --- .../cypress/integration/bisq/bisq.spec.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/frontend/cypress/integration/bisq/bisq.spec.ts b/frontend/cypress/integration/bisq/bisq.spec.ts index 47632b23d..2ba604153 100644 --- a/frontend/cypress/integration/bisq/bisq.spec.ts +++ b/frontend/cypress/integration/bisq/bisq.spec.ts @@ -62,20 +62,26 @@ describe('Bisq', () => { it('shows blocks pagination with 5 pages (desktop)', () => { cy.viewport(760, 800); - cy.visit('/bisq/blocks'); + cy.visit('/bisq'); cy.waitForSkeletonGone(); - cy.get('tbody tr').should('have.length', 10); - // 5 pages + 4 buttons = 9 buttons - cy.get('.pagination-container ul.pagination').first().children().should('have.length', 9); + cy.get('li:nth-of-type(3) > a').click().then(() => { + cy.waitForSkeletonGone(); + cy.get('tbody tr').should('have.length', 10); + // 5 pages + 4 buttons = 9 buttons + cy.get('.pagination-container ul.pagination').first().children().should('have.length', 9); + }); }); it('shows blocks pagination with 3 pages (mobile)', () => { cy.viewport(669, 800); - cy.visit('/bisq/blocks'); + cy.visit('/bisq'); 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); + cy.get('li:nth-of-type(3) > a').click().then(() => { + 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); + }); }); });