Windshaft-cartodb/test/acceptance/analysis/regressions-test.js

117 lines
4.3 KiB
JavaScript
Raw Normal View History

'use strict';
require('../../support/test-helper');
var assert = require('../../support/assert');
var TestClient = require('../../support/test-client');
2019-10-22 01:07:24 +08:00
describe('analysis-layers regressions', function () {
it('should return a complete list of nodes from analysis', function (done) {
var mapConfig = {
2019-10-22 01:07:24 +08:00
version: '1.5.0',
layers: [
{
2019-10-22 01:07:24 +08:00
type: 'cartodb',
options: {
cartocss: TestClient.CARTOCSS.POINTS,
cartocss_version: '2.1.1',
interactivity: [],
source: {
id: 'a4'
}
}
},
{
2019-10-22 01:07:24 +08:00
type: 'cartodb',
options: {
cartocss: TestClient.CARTOCSS.POINTS,
cartocss_version: '2.1.0',
interactivity: [],
source: {
id: 'b1'
}
}
}
],
2019-10-22 01:07:24 +08:00
dataviews: {
'74493a30-4679-4b72-a60c-b6f808b57c98': {
type: 'histogram',
source: {
id: 'b0'
},
2019-10-22 01:07:24 +08:00
options: {
column: 'customer_value',
bins: 10
}
}
},
2019-10-22 01:07:24 +08:00
analyses: [
{
2019-10-22 01:07:24 +08:00
id: 'a4',
type: 'point-in-polygon',
params: {
polygons_source: {
id: 'a3',
type: 'buffer',
params: {
source: {
id: 'a2',
type: 'centroid',
params: {
source: {
id: 'b1',
type: 'kmeans',
params: {
source: {
id: 'b0',
type: 'source',
params: {
query: 'SELECT * FROM populated_places_simple_reduced'
}
},
2019-10-22 01:07:24 +08:00
clusters: 5
}
},
2019-10-22 01:07:24 +08:00
category_column: 'cluster_no'
}
},
2019-10-22 01:07:24 +08:00
radius: 200000
}
},
2019-10-22 01:07:24 +08:00
points_source: {
id: 'customer_home_locations',
type: 'source',
params: {
query: 'SELECT * FROM populated_places_simple_reduced'
}
}
}
}
]
};
var testClient = new TestClient(mapConfig, 1234);
2019-10-22 01:07:24 +08:00
testClient.getLayergroup(function (err, layergroupResult) {
assert.ok(!err, err);
assert.ok(layergroupResult);
assert.ok(layergroupResult.metadata);
var analyses = layergroupResult.metadata.analyses;
assert.ok(analyses);
assert.strictEqual(analyses.length, 1);
var expectedIds = ['customer_home_locations', 'b0', 'b1', 'a2', 'a3', 'a4'];
2019-10-22 01:07:24 +08:00
expectedIds.forEach(function (expectedId) {
assert.ok(
analyses[0].nodes.hasOwnProperty(expectedId),
'Missing "' + expectedId + '" from node list.'
);
});
assert.strictEqual(Object.keys(analyses[0].nodes).length, expectedIds.length, Object.keys(analyses[0].nodes));
testClient.drain(done);
});
});
});