Skip to content
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
4 changes: 3 additions & 1 deletion src/snapshot/cloneplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module.exports = function clonePlot(graphObj, options) {
var oldLayout = graphObj.layout;
var newData = extendDeep([], oldData);
var newLayout = extendDeep({}, oldLayout, cloneLayoutOverride(options.tileClass));
var context = graphObj._context || {};

if(options.width) newLayout.width = options.width;
if(options.height) newLayout.height = options.height;
Expand Down Expand Up @@ -153,7 +154,8 @@ module.exports = function clonePlot(graphObj, options) {
options.plotGlPixelRatio,
displaylogo: options.displaylogo || false,
showLink: options.showLink || false,
showTips: options.showTips || false
showTips: options.showTips || false,
mapboxAccessToken: context.mapboxAccessToken
}
};

Expand Down
73 changes: 73 additions & 0 deletions test/jasmine/tests/mapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,5 +964,78 @@ describe('@noCI, mapbox plots', function() {
}, MOUSE_DELAY);
});
}
});

describe('@noCI, mapbox toImage', function() {
var MINIMUM_LENGTH = 1e5;

var gd;

beforeEach(function() {
gd = createGraphDiv();
});

afterEach(function() {
Plotly.purge(gd);
Plotly.setPlotConfig({ mapboxAccessToken: null });
destroyGraphDiv();
});

it('should generate image data with global credentials', function(done) {
Plotly.setPlotConfig({
mapboxAccessToken: MAPBOX_ACCESS_TOKEN
});

Plotly.newPlot(gd, [{
type: 'scattermapbox',
lon: [0, 10, 20],
lat: [-10, 10, -10]
}])
.then(function() {
return Plotly.toImage(gd);
})
.then(function(imgData) {
expect(imgData.length).toBeGreaterThan(MINIMUM_LENGTH);
})
.catch(failTest)
.then(done);
}, LONG_TIMEOUT_INTERVAL);

it('should generate image data with config credentials', function(done) {
Plotly.newPlot(gd, [{
type: 'scattermapbox',
lon: [0, 10, 20],
lat: [-10, 10, -10]
}], {}, {
mapboxAccessToken: MAPBOX_ACCESS_TOKEN
})
.then(function() {
return Plotly.toImage(gd);
})
.then(function(imgData) {
expect(imgData.length).toBeGreaterThan(MINIMUM_LENGTH);
})
.catch(failTest)
.then(done);
}, LONG_TIMEOUT_INTERVAL);

it('should generate image data with layout credentials', function(done) {
Plotly.newPlot(gd, [{
type: 'scattermapbox',
lon: [0, 10, 20],
lat: [-10, 10, -10]
}], {
mapbox: {
accesstoken: MAPBOX_ACCESS_TOKEN
}
})
.then(function() {
return Plotly.toImage(gd);
})
.then(function(imgData) {
expect(imgData.length).toBeGreaterThan(MINIMUM_LENGTH);
})
.catch(failTest)
.then(done);
}, LONG_TIMEOUT_INTERVAL);
});
13 changes: 8 additions & 5 deletions test/jasmine/tests/scattermapbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ function move(fromX, fromY, toX, toY, delay) {
});
}

Plotly.setPlotConfig({
mapboxAccessToken: require('@build/credentials.json').MAPBOX_ACCESS_TOKEN
});


describe('scattermapbox defaults', function() {
'use strict';

Expand Down Expand Up @@ -341,6 +336,10 @@ describe('@noCI scattermapbox hover', function() {
beforeAll(function(done) {
jasmine.addMatchers(customMatchers);

Plotly.setPlotConfig({
mapboxAccessToken: require('@build/credentials.json').MAPBOX_ACCESS_TOKEN
});

gd = createGraphDiv();

var data = [{
Expand Down Expand Up @@ -520,6 +519,10 @@ describe('@noCI Test plotly events on a scattermapbox plot:', function() {
beforeAll(function(done) {
jasmine.addMatchers(customMatchers);

Plotly.setPlotConfig({
mapboxAccessToken: require('@build/credentials.json').MAPBOX_ACCESS_TOKEN
});

gd = createGraphDiv();
mockCopy = Lib.extendDeep({}, mock);

Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/snapshot_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ describe('Plotly.Snapshot', function() {
displaylogo: false,
showLink: false,
showTips: false,
setBackground: 'opaque'
setBackground: 'opaque',
mapboxAccessToken: undefined
};

var themeTile = Plotly.Snapshot.clone(dummyGraphObj, themeOptions);
Expand Down