Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix/ui-tests
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/test_and_release.yml
#	docker/Dockerfile
#	package-lock.json
#	package.json
#	test/e2e/test.js
  • Loading branch information
pshenmic committed May 3, 2024
2 parents f27da3c + b66dd8e commit ac7f7b1
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 54 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ jobs:
- name: Run ESLinter
run: npm run lint

- name: Use https instead of git protocol fo git
run: git config --global url."https://".insteadOf git://

- name: Build project
run: npm run build

- name: Run tests
run: npm run test

Expand Down Expand Up @@ -81,6 +87,9 @@ jobs:
const [, major, minor] = tag.match(/^v([0-9]+)\.([0-9]+)/);
return (tag.includes('dev') ? `${major}.${minor}-dev` : 'latest');
- name: Use https instead of git protocol fo git
run: git config --global url."https://".insteadOf git://

- name: Publish NPM package
uses: JS-DevTools/npm-publish@v1
with:
Expand All @@ -101,7 +110,7 @@ jobs:
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v1
with:
version: v0.6.1
version: v0.7.0
install: true
driver-opts: image=moby/buildkit:buildx-stable-1

Expand Down
20 changes: 14 additions & 6 deletions lib/test/service-ctl/InsightUIOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class InsightUIOptions extends NodeJsServiceOptions {
cacheNodeModules: false,
};

const configFile = this.getConfigPath();
const configPath = this.getConfigPath();

const defaultContainerOptions = {
image: 'dashpay/insight',
Expand All @@ -41,9 +41,6 @@ class InsightUIOptions extends NodeJsServiceOptions {
'/insight/bin/dashcore-node',
'start',
],
volumes: [...InsightUIOptions.defaultCustomOptions.container.volumes,
`${configFile}:/insight/dashcore-node.json`,
],
};

const defaultOptions = defaultServiceOptions;
Expand All @@ -55,7 +52,11 @@ class InsightUIOptions extends NodeJsServiceOptions {
...customOptions,
);

this.saveConfig(configFile, options);
options.container.volumes.push(
`${configPath}:/insight/dashcore-node.json`,
);

this.saveConfig(configPath, options);

return options;
}
Expand All @@ -71,14 +72,21 @@ class InsightUIOptions extends NodeJsServiceOptions {

// noinspection JSMethodCanBeStatic
getConfigPath() {
if (this.configPath) {
return this.configPath;
}

let tempDir = os.tmpdir();
if (os.platform() === 'darwin') {
// Default temp dir on mac is like '/var/folders/...'
// docker doesn't allow to share files there without changing 'File sharing' settings
tempDir = '/tmp';
}
const tmpPath = fs.mkdtempSync(path.join(tempDir, 'js-evo-ctl-insight-'));
return path.join(tmpPath, 'bitcore-node-dash.json');

this.configPath = path.join(tmpPath, 'bitcore-node-dash.json');

return this.configPath;
}

// noinspection JSMethodCanBeStatic
Expand Down
39 changes: 13 additions & 26 deletions lib/test/startInsightUI.js → lib/test/startInsightNode.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
const { merge } = require('lodash');

const startDashCore = require('@dashevo/dp-services-ctl/lib/services/dashCore/startDashCore');
const startInsightUi = require('./service-ctl/startInsightUI');

async function remove(services) {
const insightDeps = [
services.dashCore,
];
await Promise.all(insightDeps.map(instance => instance.remove()));
}
const startInsightUI = require('./service-ctl/startInsightUI');

/**
* @typedef InsightUI
Expand All @@ -24,8 +17,8 @@ async function remove(services) {
* @param {object} [options]
* @returns {Promise<InsightUI>}
*/
async function startInsightUI(options) {
const instances = await startInsightUi.many(1, options);
async function startInsightNode(options) {
const instances = await startInsightNode.many(1, options);
return instances[0];
}

Expand All @@ -36,7 +29,7 @@ async function startInsightUI(options) {
* @param {object} [options]
* @returns {Promise<InsightUI[]>}
*/
startInsightUI.many = async function many(number, options = {}) {
startInsightNode.many = async function many(number, options = {}) {
if (number < 1) {
throw new Error('Invalid number of instances');
}
Expand All @@ -45,10 +38,7 @@ startInsightUI.many = async function many(number, options = {}) {
}


const dashCoreInstancesPromise = startDashCore.many(number, options.dashCore);
const [dashCoreInstances] = await Promise.all([
dashCoreInstancesPromise,
]);
const dashCoreInstances = await startDashCore.many(number, options.dashCore);

const instances = [];

Expand Down Expand Up @@ -78,25 +68,22 @@ startInsightUI.many = async function many(number, options = {}) {
});


const insightUIPromise = await startInsightUI(insightUIOptions);

const [insightUi] = await Promise.all([
insightUIPromise,
]);

const insightUI = await startInsightUI(insightUIOptions);

const instance = {
insightUi,
insightUI,
dashCore,
async clean() {
await remove(instance);
await dashCore.remove();
await insightUI.remove();

const newServices = await startInsightUI(options);
const newServices = await startInsightNode(options);

Object.assign(instance, newServices);
},
async remove() {
await remove(instance);
await dashCore.remove();
await insightUI.remove();
},
};

Expand All @@ -106,4 +93,4 @@ startInsightUI.many = async function many(number, options = {}) {
return instances;
};

module.exports = startInsightUI;
module.exports = startInsightNode;
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@dashevo/insight-ui",
"description": "An open-source frontend for the Insight API. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the Dash network and build your own services with it.",
"version": "3.1.2",
"version": "4.0.6",
"repository": "git://github.com/dashevo/insight-ui.git",
"contributors": [
{
Expand Down Expand Up @@ -59,10 +59,10 @@
"eslint-plugin-import": "^2.13.0",
"grunt": "~0.4.2",
"grunt-angular-gettext": "^0.2.15",
"grunt-cli": "~1.3.2",
"grunt-cli": "~1.4.3",
"grunt-contrib-concat": "~1.0.1",
"grunt-contrib-jshint": "~2.0.0",
"grunt-contrib-uglify": "~4.0.0",
"grunt-contrib-uglify": "~5.2.0",
"grunt-contrib-watch": "~1.1.0",
"grunt-css": "~0.5.4",
"grunt-macreload": "*",
Expand Down
5 changes: 2 additions & 3 deletions public/js/angularjs-all.min.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions public/js/main.min.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions public/js/vendors.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/src/js/services/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ angular.module('insight.address')
return {
test: function (addressStr) {

return /^[XxYy][1-9A-Za-z][^OIl]{20,40}/.test(addressStr);
return /^[Xy789][1-9A-Za-z][^OIl]{20,40}/.test(addressStr);
}
};
});
13 changes: 7 additions & 6 deletions public/src/js/translations.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test/e2e/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ exports.config = {
defaultTimeoutInterval: 250000,
},
specs: ['test.js'],

multiCapabilities: [
{
browserName: 'firefox',
Expand Down
6 changes: 5 additions & 1 deletion test/e2e/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const StatusPage = require('../../lib/test/pages/StatusPage');
const BlockPage = require('../../lib/test/pages/BlockPage');

describe('basic UI tests', () => {
let insightNode;

let url;
let browser;
let blockHash;
Expand Down Expand Up @@ -37,7 +39,6 @@ describe('basic UI tests', () => {
expect(title).equal('Home | Insight');
});


it('should be able to open status page', async () => {
await topPanel.openStatusPage();
await wait(10000); // time to complete sync
Expand Down Expand Up @@ -126,10 +127,13 @@ describe('basic UI tests', () => {
topPanel = new TopPanel(browser);

topPanel.search(blockIdToSearch);

await wait(5000);
blockPage = new BlockPage(browser);

const currentUrl = await browser.getCurrentUrl();
expect(currentUrl).equal(`${url}block/${blockHash}`);

const blockId = (await blockPage.getBlockId()).replace('Block #', '');
expect(blockId).equal(blockIdToSearch);
blockHash = await blockPage.getBlockHash();
Expand Down

0 comments on commit ac7f7b1

Please sign in to comment.