Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better tests #3

Merged
merged 12 commits into from
Dec 31, 2017
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ install:
- npm install

script:
- docker exec -it emscripten ./node_modules/.bin/lerna run start --stream
- npm test
- docker exec -it emscripten npm run start
- npm travis_test

after_script:
before_cache:
- if [ ! -f ${CACHE_FILE_EMSCRIPTEN} ]; then docker save trzeci/emscripten:sdk-incoming-64bit | gzip > ${CACHE_FILE_EMSCRIPTEN}; fi
- if [ ! -f ${CACHE_FILE_PUPPETEER} ]; then docker save zenato/puppeteer | gzip > ${CACHE_FILE_PUPPETEER}; fi
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
"lerna": "^2.5.1"
},
"scripts": {
"start": "lerna run start",
"start": "lerna run start ${PACKAGE:+--scope=@jpmorganchase/${PACKAGE}}",
"puppeteer": "docker run -it --rm --shm-size=2g -u root -e WRITE_TESTS=${WRITE_TESTS} -v $(pwd):/src -w /src/packages/${PACKAGE} zenato/puppeteer ./node_modules/.bin/jest --runInBand",
"postinstall": "lerna bootstrap --hoist",
"test": "docker run -it --rm -u root -v $(pwd):/src -w /src zenato/puppeteer ./node_modules/.bin/lerna run test",
"write_tests": "docker run -it --rm -u root -e WRITE_TESTS=1 -v $(pwd):/src -w /src zenato/puppeteer ./node_modules/.bin/lerna run test"
"test": "npm run test_perspective && npm run test_viewer && npm run test_hypergrid && npm run test_highcharts",
"test_perspective": "PACKAGE=perspective npm run puppeteer",
"test_viewer": "PACKAGE=perspective-viewer npm run puppeteer",
"test_hypergrid": "PACKAGE=perspective-viewer-hypergrid npm run puppeteer",
"test_highcharts": "PACKAGE=perspective-viewer-highcharts npm run puppeteer",
"write_tests": "WRITE_TESTS=1 npm run test",
"travis_test": "docker run -it --rm --shm-size=2g -u root -e WRITE_TESTS=${WRITE_TESTS} -v $(pwd):/src -w /src/ zenato/puppeteer ./node_modules/.bin/lerna run test"
}
}
22 changes: 13 additions & 9 deletions packages/perspective-common/common.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@

const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

const plugins = []

if (!process.env.PSP_NO_MINIFY) {
plugins.push(new UglifyJSPlugin({
sourceMap: true,
uglifyOptions: {
sourceMap: true,
ecma: 5
}
}));
}

module.exports = function() {
return {
plugins: [
new UglifyJSPlugin({
sourceMap: true,
uglifyOptions: {
sourceMap: true,
ecma: 5
}
})
],
plugins: plugins,
devtool: 'source-map',
node: {
fs: "empty"
Expand Down
10 changes: 5 additions & 5 deletions packages/perspective-viewer-highcharts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"highcharts": "webpack --config src/config/highcharts.plugin.config.js",
"start": "npm run highcharts && npm run compile_test",
"compile_test": "cp test/html/* build",
"test": "jest 2>&1",
"test": "jest --runInBand 2>&1",
"clean": "find build -mindepth 1 -delete"
},
"jest": {
Expand All @@ -36,7 +36,8 @@
"highcharts": "5.0.14",
"highcharts-grouped-categories": "1.1.2",
"highcharts-more": "^0.1.2",
"highcharts-heatmap": "^0.1.2"
"highcharts-heatmap": "^0.1.2",
"@jpmorganchase/perspective-common": "^0.0.0"
},
"devDependencies": {
"@jpmorganchase/perspective": "^0.0.0",
Expand All @@ -48,14 +49,13 @@
"babel-plugin-transform-es2015-for-of": "^6.23.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.0",
"chart.js": "^2.7.1",
"css-loader": "^0.28.7",
"jest": "^22.0.4",
"html-loader": "^0.5.1",
"less": "^2.7.2",
"less-loader": "^4.0.5",
"style-loader": "^0.18.2",
"uglifyjs-webpack-plugin": "^0.4.6",
"webpack": "^3.5.6",
"@jpmorganchase/perspective-common": "^0.0.0"
"webpack": "^3.5.6"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<html>
<head>

<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
<script src="perspective.view.js"></script>
<script src="highcharts.plugin.js"></script>

Expand Down
41 changes: 41 additions & 0 deletions packages/perspective-viewer-highcharts/test/html/line.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!--

Copyright (c) 2017, the Perspective Authors.

This file is part of the Perspective library, distributed under the terms of
the Apache License 2.0. The full license can be found in the LICENSE file.

-->

<!DOCTYPE html>
<html>
<head>

<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
<script src="perspective.view.js"></script>
<script src="highcharts.plugin.js"></script>

<link rel='stylesheet' href="demo.css">

</head>
<body>

<perspective-viewer
view='line'
columns='["Order Date", "Profit"]'>

</perspective-viewer>

<script>

var xhr = new XMLHttpRequest();
xhr.open('GET', 'superstore.csv', true);
xhr.onload = function () {
document.getElementsByTagName('perspective-viewer')[0].load(xhr.response);
}
xhr.send(null);

</script>

</body>
</html>
41 changes: 41 additions & 0 deletions packages/perspective-viewer-highcharts/test/html/scatter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!--

Copyright (c) 2017, the Perspective Authors.

This file is part of the Perspective library, distributed under the terms of
the Apache License 2.0. The full license can be found in the LICENSE file.

-->

<!DOCTYPE html>
<html>
<head>

<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
<script src="perspective.view.js"></script>
<script src="highcharts.plugin.js"></script>

<link rel='stylesheet' href="demo.css">

</head>
<body>

<perspective-viewer
view='scatter'
columns='["Sales","Profit"]'>

</perspective-viewer>

<script>

var xhr = new XMLHttpRequest();
xhr.open('GET', 'superstore.csv', true);
xhr.onload = function () {
document.getElementsByTagName('perspective-viewer')[0].load(xhr.response);
}
xhr.send(null);

</script>

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@
*
*/

var Jasmine = require('jasmine');
var jasmine = new Jasmine();
const utils = require('@jpmorganchase/perspective-viewer/test/js/utils.js');

jasmine.configureDefaultReporter({
showColors: true
});
const simple_tests = require('@jpmorganchase/perspective-viewer/test/js/simple_tests.js');


utils.with_server({}, () => {

describe.page("bar.html", () => {

jasmine.execute(['./build/test_node.js']);
simple_tests.default();

});

});
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,17 @@
*
*/

require('@jpmorganchase/perspective-viewer/test/js/superstore.spec.js');
const utils = require('@jpmorganchase/perspective-viewer/test/js/utils.js');

const simple_tests = require('@jpmorganchase/perspective-viewer/test/js/simple_tests.js');


utils.with_server({}, () => {

describe.page("line.html", () => {

simple_tests.default();

});

});
23 changes: 23 additions & 0 deletions packages/perspective-viewer-highcharts/test/js/scatter.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

const utils = require('@jpmorganchase/perspective-viewer/test/js/utils.js');

const simple_tests = require('@jpmorganchase/perspective-viewer/test/js/simple_tests.js');


utils.with_server({}, () => {

describe.page("scatter.html", () => {

simple_tests.default();

});

});
40 changes: 32 additions & 8 deletions packages/perspective-viewer-highcharts/test/results/results.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
{
"shows a grid without any settings applied.": "9880a0fc261c00dc0a210eeeba7d06f6",
"pivots by a row.": "4711f455d5c9d5d3bc8c177b92da725f",
"pivots by two rows.": "53f0c27ba47a5df2974c30289fe02a78",
"pivots by a row and a column.": "8546e4942f755673794abce6d584b6b6",
"pivots by two rows and two columns.": "ff17b69cef7bfc90ec21b56729a4256f",
"sorts by a numeric column.": "375062fbd50e09afa7b6df7e6b4a3a5f",
"sorts by an alpha column.": "2643e0b5787b6e8e85f122b1713d01cd",
"displays visible columns.": "1da296527f149393be8f3f99e34b3e4a"
"superstore.html/shows a grid without any settings applied.": "9880a0fc261c00dc0a210eeeba7d06f6",
"superstore.html/pivots by a row.": "4711f455d5c9d5d3bc8c177b92da725f",
"superstore.html/pivots by two rows.": "0a70147319e8178982268bd4aa47e2f5",
"superstore.html/pivots by a row and a column.": "8546e4942f755673794abce6d584b6b6",
"superstore.html/pivots by two rows and two columns.": "fb32e990fef5a727d2cf4c32b39ff123",
"superstore.html/sorts by a numeric column.": "375062fbd50e09afa7b6df7e6b4a3a5f",
"superstore.html/sorts by an alpha column.": "2643e0b5787b6e8e85f122b1713d01cd",
"superstore.html/displays visible columns.": "1da296527f149393be8f3f99e34b3e4a",
"scatter.html/shows a grid without any settings applied.": "352854b8fa9466ddf9f884462f1fcfbf",
"scatter.html/pivots by a row.": "d747a811424247f2e82fbd1f3e4b102d",
"scatter.html/pivots by two rows.": "327f10b204fc30b4f09a3c78b0fb0789",
"scatter.html/pivots by a row and a column.": "aefd420b9568e75b2e4aa28fa48e78b2",
"scatter.html/pivots by two rows and two columns.": "5f32d38e1d95c92f29578d18ebd6f917",
"scatter.html/sorts by a numeric column.": "a5cea557d54498d931272f9aba20cb38",
"scatter.html/sorts by an alpha column.": "bcf36f6eaaa17eada7c284e6257cf6a7",
"scatter.html/displays visible columns.": "7f4568381b35950da01a23b7a13fa216",
"bar.html/shows a grid without any settings applied.": "fa9f33409c8409155b403c30e97b9397",
"bar.html/pivots by a row.": "667024057e32ac7dcff85f714e991345",
"bar.html/pivots by two rows.": "38985a461a70412e91ba04ed08630f56",
"bar.html/pivots by a row and a column.": "d3c12fafa6aa6e48a65fb772633db007",
"bar.html/pivots by two rows and two columns.": "62d79c966449d7baeb024991038dbce9",
"bar.html/sorts by a numeric column.": "89ca3dd689ac395e44e77520845055f4",
"bar.html/sorts by an alpha column.": "9116319b7b31aed9beba0632e474ddf0",
"line.html/shows a grid without any settings applied.": "5c7d75d2872635968019ef08bc505ff3",
"line.html/pivots by a row.": "a5c448c1f00f22657dae1ce3e059b075",
"line.html/pivots by two rows.": "1944115018252f8dceb03f84fab2ebf4",
"line.html/pivots by a row and a column.": "79c490c3f843b24af104b6681685b82f",
"line.html/pivots by two rows and two columns.": "76b7c6b1c0854e3fc295fb4ad2bc8e86",
"line.html/sorts by a numeric column.": "604f906365754839e95d0c7f01f15241",
"line.html/sorts by an alpha column.": "a9cf05d78de91c435055049ed538d1ad",
"line.html/displays visible columns.": "010890a5ebf5e4bd32557191a6b11c27",
"bar.html/displays visible columns.": "a5662668dffce69048d1823052a83ab6"
}
5 changes: 2 additions & 3 deletions packages/perspective-viewer-hypergrid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"hypergrid": "webpack --config src/config/hypergrid.plugin.config.js",
"start": "npm run hypergrid && npm run compile_test",
"compile_test": "cp test/html/* build",
"test": "jest 2>&1",
"test": "jest --runInBand 2>&1",
"clean": "find build -mindepth 1 -delete"
},
"jest": {
Expand All @@ -34,6 +34,7 @@
"babel-runtime": "^6.26.0",
"fin-hypergrid": "2.0.2",
"underscore": "^1.8.3",
"babel-polyfill": "^6.26.0",
"@jpmorganchase/perspective-common": "^0.0.0"
},
"devDependencies": {
Expand All @@ -45,9 +46,7 @@
"babel-loader": "^7.1.2",
"babel-plugin-transform-es2015-for-of": "^6.23.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"chart.js": "^2.7.1",
"css-loader": "^0.28.7",
"html-loader": "^0.5.1",
"http-server": "^0.10.0",
Expand Down
22 changes: 10 additions & 12 deletions packages/perspective-viewer-hypergrid/src/js/hypergrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,40 +189,38 @@ function setPSP(payload) {
}

for (i = 0; i < this.schema.length; i++) {
let props = this.grid.getColumnProperties(i);
if (this.schema[i].type === 'number' || this.schema[i].type === 'float') {
this.grid.behavior.setColumnProperties(i, {
Object.assign(props, {
halign: 'right',
columnHeaderHalign: 'right',
format: 'FinanceFloat'
});
} else if (this.schema[i].type === 'integer') {
this.grid.behavior.setColumnProperties(i, {
Object.assign(props, {
halign: 'right',
columnHeaderHalign: 'right',
format: 'FinanceInteger'
});
} else if (this.schema[i].type === 'date') {
this.grid.behavior.setColumnProperties(i, {
Object.assign(props, {
format: 'FinanceDate'
});
}
}

// restore column widths;
for (let c = 0; c < this.grid.getColumnCount(); c++) {
let header = this.grid.getColumnProperties(c).header;
// restore column widths;
let header = props.header;
let name = header.split("|")
name = name[name.length - 1];
if (header in widths) {
this.grid.setColumnWidth(c, widths[header]);
props.width = widths[header];
} else if (name in widths) {
this.grid.setColumnWidth(c, widths[name]);
props.width = widths[name];
} else {
this.grid.setColumnWidth(c, 50);
props.width = 50;
}
let props = this.grid.getColumnProperties(c);
props.columnAutosizing = true;
this.grid.setColumnProperties(c, props);
this.grid.behavior.setColumnProperties(i, props);
}
}
this.grid.canvas.dispatchEvent(new CustomEvent('fin-hypergrid-data-loaded', { detail: { grid: this.grid } }));
Expand Down
Loading