Skip to content

Fix mapbox image tests #1213

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

Merged
merged 3 commits into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions tasks/pretest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var common = require('./util/common');

// main
makeCredentialsFile();
makeSetPlotConfigFile();
makeTestImageFolders();
makeRequireJSFixture();

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

// Create a 'set plot config' file,
// to be included in the image test index
function makeSetPlotConfigFile() {
var setPlotConfig = [
'\'use strict\';',
'',
'/* global Plotly:false */',
'',
'Plotly.setPlotConfig({',
' mapboxAccessToken: \'' + constants.mapboxAccessToken + '\'',
'});',
''
].join('\n');

common.writeFile(constants.pathToSetPlotConfig, setPlotConfig);
logger('make build/set_plot_config.js');
}

// Make artifact folders for image tests
function makeTestImageFolders() {

Expand Down
1 change: 0 additions & 1 deletion tasks/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ module.exports = {
// more info: https://www.mapbox.com/help/define-access-token/
mapboxAccessToken: 'pk.eyJ1IjoiZXRwaW5hcmQiLCJhIjoiY2luMHIzdHE0MGFxNXVubTRxczZ2YmUxaCJ9.hwWZful0U2CQxit4ItNsiQ',
pathToCredentials: path.join(pathToBuild, 'credentials.json'),
pathToSetPlotConfig: path.join(pathToBuild, 'set_plot_config.js'),

testContainerImage: 'plotly/testbed:latest',
testContainerName: process.env.PLOTLYJS_TEST_CONTAINER_NAME || 'imagetest',
Expand Down
8 changes: 7 additions & 1 deletion tasks/util/container_commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ var constants = require('./constants');
var containerCommands = {
cdHome: 'cd ' + constants.testContainerHome,
cpIndex: 'cp -f test/image/index.html ../server_app/index.html',
restart: 'supervisorctl restart nw1',
injectEnv: [
'sed -i',
's/process.env.PLOTLY_MAPBOX_DEFAULT_ACCESS_TOKEN/\\\'' + constants.mapboxAccessToken + '\\\'/',
'../server_app/main.js'
].join(' '),
restart: 'supervisorctl restart nw1'
};

containerCommands.ping = [
Expand All @@ -14,6 +19,7 @@ containerCommands.ping = [

containerCommands.setup = [
containerCommands.cpIndex,
containerCommands.injectEnv,
containerCommands.restart,
'sleep 1',
containerCommands.ping,
Expand Down
Binary file modified test/image/baselines/mapbox_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_angles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_bubbles-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_custom-style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_fill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/mapbox_layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion test/image/compare_pixels_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var mockList = getMockList(pattern);
var isInQueue = (process.argv[3] === '--queue');
var isCI = process.env.CIRCLECI;


if(mockList.length === 0) {
throw new Error('No mocks found with pattern ' + pattern);
}
Expand Down Expand Up @@ -252,7 +253,8 @@ function comparePixels(mockName, cb) {
function onEqualityCheck(err, isEqual) {
if(err) {
common.touch(imagePaths.diff);
return console.error(err, mockName);
console.error(err);
return;
}
if(isEqual) {
fs.unlinkSync(imagePaths.diff);
Expand All @@ -261,7 +263,16 @@ function comparePixels(mockName, cb) {
cb(isEqual, mockName);
}

// 525 means a plotly.js error
function onResponse(response) {
if(+response.statusCode === 525) {
console.error('plotly.js error while generating', mockName);
cb(false, mockName);
}
}

request(requestOpts)
.on('response', onResponse)
.pipe(saveImageStream)
.on('close', checkImage);
}
1 change: 0 additions & 1 deletion test/image/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<script type="text/javascript" src="../plotly.js/dist/extras/mathjax/MathJax.js?config=TeX-AMS-MML_SVG"></script>
<script type="text/javascript" src="../plotly.js/build/plotly.js" charset="utf-8"></script>
<script type="text/javascript" src="../plotly.js/dist/plotly-geo-assets.js" charset="utf-8"></script>
<script type="text/javascript" src="../plotly.js/build/set_plot_config.js"></script>
<script type="text/javascript" src="./main.js"></script>
</body>
</html>