Skip to content

Commit c25d57b

Browse files
authored
Merge pull request #1213 from plotly/fix-mapbox-image-test
Fix mapbox image tests
2 parents 18a836d + 4206375 commit c25d57b

11 files changed

+19
-23
lines changed

tasks/pretest.js

-19
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ var common = require('./util/common');
55

66
// main
77
makeCredentialsFile();
8-
makeSetPlotConfigFile();
98
makeTestImageFolders();
109
makeRequireJSFixture();
1110

@@ -20,24 +19,6 @@ function makeCredentialsFile() {
2019
logger('make build/credentials.json');
2120
}
2221

23-
// Create a 'set plot config' file,
24-
// to be included in the image test index
25-
function makeSetPlotConfigFile() {
26-
var setPlotConfig = [
27-
'\'use strict\';',
28-
'',
29-
'/* global Plotly:false */',
30-
'',
31-
'Plotly.setPlotConfig({',
32-
' mapboxAccessToken: \'' + constants.mapboxAccessToken + '\'',
33-
'});',
34-
''
35-
].join('\n');
36-
37-
common.writeFile(constants.pathToSetPlotConfig, setPlotConfig);
38-
logger('make build/set_plot_config.js');
39-
}
40-
4122
// Make artifact folders for image tests
4223
function makeTestImageFolders() {
4324

tasks/util/constants.js

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ module.exports = {
7373
// more info: https://www.mapbox.com/help/define-access-token/
7474
mapboxAccessToken: 'pk.eyJ1IjoiZXRwaW5hcmQiLCJhIjoiY2luMHIzdHE0MGFxNXVubTRxczZ2YmUxaCJ9.hwWZful0U2CQxit4ItNsiQ',
7575
pathToCredentials: path.join(pathToBuild, 'credentials.json'),
76-
pathToSetPlotConfig: path.join(pathToBuild, 'set_plot_config.js'),
7776

7877
testContainerImage: 'plotly/testbed:latest',
7978
testContainerName: process.env.PLOTLYJS_TEST_CONTAINER_NAME || 'imagetest',

tasks/util/container_commands.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ var constants = require('./constants');
33
var containerCommands = {
44
cdHome: 'cd ' + constants.testContainerHome,
55
cpIndex: 'cp -f test/image/index.html ../server_app/index.html',
6-
restart: 'supervisorctl restart nw1',
6+
injectEnv: [
7+
'sed -i',
8+
's/process.env.PLOTLY_MAPBOX_DEFAULT_ACCESS_TOKEN/\\\'' + constants.mapboxAccessToken + '\\\'/',
9+
'../server_app/main.js'
10+
].join(' '),
11+
restart: 'supervisorctl restart nw1'
712
};
813

914
containerCommands.ping = [
@@ -14,6 +19,7 @@ containerCommands.ping = [
1419

1520
containerCommands.setup = [
1621
containerCommands.cpIndex,
22+
containerCommands.injectEnv,
1723
containerCommands.restart,
1824
'sleep 1',
1925
containerCommands.ping,

test/image/baselines/mapbox_0.png

7 Bytes
Loading
-2.72 KB
Loading
-3 Bytes
Loading
-2.79 KB
Loading

test/image/baselines/mapbox_fill.png

-587 Bytes
Loading
-336 Bytes
Loading

test/image/compare_pixels_test.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ var mockList = getMockList(pattern);
5353
var isInQueue = (process.argv[3] === '--queue');
5454
var isCI = process.env.CIRCLECI;
5555

56+
5657
if(mockList.length === 0) {
5758
throw new Error('No mocks found with pattern ' + pattern);
5859
}
@@ -252,7 +253,8 @@ function comparePixels(mockName, cb) {
252253
function onEqualityCheck(err, isEqual) {
253254
if(err) {
254255
common.touch(imagePaths.diff);
255-
return console.error(err, mockName);
256+
console.error(err);
257+
return;
256258
}
257259
if(isEqual) {
258260
fs.unlinkSync(imagePaths.diff);
@@ -261,7 +263,16 @@ function comparePixels(mockName, cb) {
261263
cb(isEqual, mockName);
262264
}
263265

266+
// 525 means a plotly.js error
267+
function onResponse(response) {
268+
if(+response.statusCode === 525) {
269+
console.error('plotly.js error while generating', mockName);
270+
cb(false, mockName);
271+
}
272+
}
273+
264274
request(requestOpts)
275+
.on('response', onResponse)
265276
.pipe(saveImageStream)
266277
.on('close', checkImage);
267278
}

test/image/index.html

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<script type="text/javascript" src="../plotly.js/dist/extras/mathjax/MathJax.js?config=TeX-AMS-MML_SVG"></script>
66
<script type="text/javascript" src="../plotly.js/build/plotly.js" charset="utf-8"></script>
77
<script type="text/javascript" src="../plotly.js/dist/plotly-geo-assets.js" charset="utf-8"></script>
8-
<script type="text/javascript" src="../plotly.js/build/set_plot_config.js"></script>
98
<script type="text/javascript" src="./main.js"></script>
109
</body>
1110
</html>

0 commit comments

Comments
 (0)