Merge pull request #726 from knorrium/update_devproxy

Update test infra to add initial support for the new multi-site setup.
This commit is contained in:
softsimon 2021-08-17 23:52:21 +03:00 committed by GitHub
commit 83c3d901c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 84 additions and 12 deletions

View File

@ -200,7 +200,7 @@
"verbose": true "verbose": true
}, },
"local-prod": { "local-prod": {
"proxyConfig": "proxy.prod.conf.json", "proxyConfig": "proxy.conf.js",
"disableHostCheck": true, "disableHostCheck": true,
"host": "0.0.0.0", "host": "0.0.0.0",
"verbose": false "verbose": false

View File

@ -62,20 +62,26 @@ describe('Bisq', () => {
it('shows blocks pagination with 5 pages (desktop)', () => { it('shows blocks pagination with 5 pages (desktop)', () => {
cy.viewport(760, 800); cy.viewport(760, 800);
cy.visit('/bisq/blocks'); cy.visit('/bisq');
cy.waitForSkeletonGone(); cy.waitForSkeletonGone();
cy.get('tbody tr').should('have.length', 10); cy.get('li:nth-of-type(3) > a').click().then(() => {
// 5 pages + 4 buttons = 9 buttons cy.waitForSkeletonGone();
cy.get('.pagination-container ul.pagination').first().children().should('have.length', 9); 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)', () => { it('shows blocks pagination with 3 pages (mobile)', () => {
cy.viewport(669, 800); cy.viewport(669, 800);
cy.visit('/bisq/blocks'); cy.visit('/bisq');
cy.waitForSkeletonGone(); cy.waitForSkeletonGone();
cy.get('tbody tr').should('have.length', 10); cy.get('li:nth-of-type(3) > a').click().then(() => {
// 3 pages + 4 buttons = 7 buttons cy.waitForSkeletonGone();
cy.get('.pagination-container ul.pagination').first().children().should('have.length', 7); 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);
});
}); });
}); });

View File

@ -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", "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", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",
"e2e": "ng e2e", "e2e": "npm run generate-config && ng e2e",
"e2e:ci": "npm run cypress:run:ci", "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", "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", "dev:ssr": "npm run generate-config && ng run mempool:serve-ssr",

64
frontend/proxy.conf.js Normal file
View File

@ -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;

View File

@ -5,7 +5,7 @@ const GENERATED_CONFIG_FILE_NAME = 'generated-config.js';
let settings = []; let settings = [];
let configContent = {}; 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); var args = process.argv.slice(2);
@ -19,8 +19,10 @@ function addSetting(key, value) {
function normalizedValue(value) { function normalizedValue(value) {
if (Number(value)) { if (Number(value)) {
value = Number(value); value = Number(value);
} else if ((value === 'true') || (value !== 'true')) { } else if ((value === 'true') || (value === 'false')) {
value = !!JSON.parse(String(value).toLowerCase()); value = !!JSON.parse(String(value).toLowerCase());
} else {
value = String(value).toLowerCase();
} }
return value; return value;
} }