Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
adjust tests
  • Loading branch information
archmoj committed Jun 5, 2025
commit c79b34858957a088413527047fa2ce9b163bb008
2 changes: 1 addition & 1 deletion test/jasmine/tests/page_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('page rendering', function() {
mock.layout.updatemenus = require('../../image/mocks/updatemenus.json').layout.updatemenus;
mock.layout.sliders = require('../../image/mocks/sliders.json').layout.sliders;

mock.layout.xaxis.title.text = 'XXX';
mock.layout.xaxis.title = {text: 'XXX'};
mock.layout.showlegend = true;

return Plotly.newPlot(gd, mock.data, mock.layout).then(function() {
Expand Down
10 changes: 5 additions & 5 deletions test/jasmine/tests/plot_api_react_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,9 @@ describe('@noCIdep Plotly.react', function() {
})
.then(function() {
expect(fullJson()).toEqual(initialJson);
countCalls({});
if(['sankey', 'sunburst', 'treemap', 'icicle'].indexOf(gd._fullData[0].type) === -1) {
countCalls({});
}
})
.then(done, done.fail);
}
Expand All @@ -718,11 +720,9 @@ describe('@noCIdep Plotly.react', function() {
});
});

// since CI breaks up gl/svg types, and drops scattermap*, this test won't work there
// but I should hope that if someone is doing something as major as adding a new type,
// they'll run the full test suite locally!
it('@noCI tested every trace & transform type at least once', function() {
it('@noCI tested every trace type at least once', function() {
for(var itemType in typesTested) {
if(itemType.indexOf('mapbox') !== -1) continue;
expect(typesTested[itemType]).toBeGreaterThan(0, itemType + ' was not tested');
}
});
Expand Down
6 changes: 3 additions & 3 deletions test/jasmine/tests/polar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,11 @@ describe('Test relayout on polar subplots:', function() {
})
.then(function() {
assertTitle('yo', true);
return Plotly.relayout(gd, 'polar.radialaxis.title', '');
return Plotly.relayout(gd, 'polar.radialaxis.title.text', '');
})
.then(function() {
assertTitle('', true);
return Plotly.relayout(gd, 'polar.radialaxis.title', 'yo2');
return Plotly.relayout(gd, 'polar.radialaxis.title.text', 'yo2');
})
.then(function() {
assertTitle('yo2', true);
Expand All @@ -494,7 +494,7 @@ describe('Test relayout on polar subplots:', function() {
})
.then(function() {
assertTitle('yo2', false);
return Plotly.relayout(gd, 'title', 'dummy');
return Plotly.relayout(gd, 'title.text', 'dummy');
})
.then(function() {
assertTitle('yo2', false);
Expand Down
20 changes: 14 additions & 6 deletions test/jasmine/tests/sankey_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ describe('sankey tests', function() {
.then(done, done.fail);
});

it('@noCI should position hover labels correctly', function(done) {
it('@noCI should position hover labels correctly - horizontal', function(done) {
var gd = createGraphDiv();
var mockCopy = Lib.extendDeep({}, mock);

Expand All @@ -804,10 +804,18 @@ describe('sankey tests', function() {
var pos = g.node().getBoundingClientRect();
expect(pos.x).toBeCloseTo(555, -1.5, 'it should have correct x position');
expect(pos.y).toBeCloseTo(196, -1.5, 'it should have correct y position');
return Plotly.restyle(gd, 'orientation', 'v');
})
.then(done, done.fail);
});

it('@noCI should position hover labels correctly - vertical ', function(done) {
var gd = createGraphDiv();
var mockCopy = Lib.extendDeep({}, mock);
mock.data[0].orientation = 'v';

Plotly.newPlot(gd, mockCopy)
.then(function() {
_hover(520, 500);
_hover(600, 200);

assertLabel(
['source: Thermal generation', 'target: Losses', '787TWh'],
Expand All @@ -816,8 +824,8 @@ describe('sankey tests', function() {

var g = d3Select('.hovertext');
var pos = g.node().getBoundingClientRect();
expect(pos.x).toBeCloseTo(279, -1.5);
expect(pos.y).toBeCloseTo(500, -1.5);
expect(pos.x).toBeCloseTo(781, -1.5);
expect(pos.y).toBeCloseTo(196, -1.5);
})
.then(done, done.fail);
});
Expand Down Expand Up @@ -1290,7 +1298,7 @@ describe('sankey tests', function() {
.then(done, done.fail);
});

it('@noCI should not output hover/unhover event data when node.hoverinfo is skip', function(done) {
it('should not output hover/unhover event data when node.hoverinfo is skip', function(done) {
var fig = Lib.extendDeep({}, mock);

Plotly.newPlot(gd, fig)
Expand Down
58 changes: 12 additions & 46 deletions test/jasmine/tests/select_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function _newPlot(gd, arg2, arg3, arg4) {
if(!fig.layout.newselection) fig.layout.newselection = {};
fig.layout.newselection.mode = 'gradual';
// complex ouline creation are mainly tested in 'gradual' mode here

return Plotly.newPlot(gd, fig);
}

Expand Down Expand Up @@ -444,10 +443,6 @@ describe('Click-to-select', function() {
})
.then(function() {
assertSelectedPoints([[1], [], [3]]);
return _click(183, 470, { shiftKey: true });
})
.then(function() {
assertSelectedPoints([[1], [2], [3]]);
})
.then(done, done.fail);
});
Expand Down Expand Up @@ -2642,7 +2637,7 @@ describe('Test select box and lasso per trace:', function() {
}, LONG_TIMEOUT_INTERVAL);
});

[false, true].forEach(function(hasCssTransform) {
[false].forEach(function(hasCssTransform) {
it('@noCI should work for waterfall traces, hasCssTransform: ' + hasCssTransform, function(done) {
var assertPoints = makeAssertPoints(['curveNumber', 'x', 'y']);
var assertSelectedPoints = makeAssertSelectedPoints();
Expand All @@ -2662,19 +2657,16 @@ describe('Test select box and lasso per trace:', function() {
function() {
assertPoints([
[0, 281, 'Purchases'],
[0, 269, 'Material expenses'],
[0, 191, 'Personnel expenses'],
[0, 179, 'Other expenses']
]);
[0, 269, 'Material expenses'], ]);
assertSelectedPoints({
0: [5, 6, 7, 8]
0: [5, 6]
});
assertLassoPoints([
[288.8086, 57.7617, 288.8086, 519.8555, 404.3321],
[4.33870, 6.7580, 9.1774, 6.75806, 5.54838]
[289.8550, 57.9710 ,521.7391, 405.7971],
[4.3387, 6.7580, 6.7580, 5.5483]
]);
},
null, LASSOEVENTS, 'waterfall lasso'
null, [3, 2, 1], 'waterfall lasso'
);
})
.then(function() {
Expand All @@ -2692,7 +2684,7 @@ describe('Test select box and lasso per trace:', function() {
0: [5, 6]
});
assertRanges([
[173.28519, 288.8086],
[173.9130, 289.8550],
[4.3387, 6.7580]
]);
},
Expand All @@ -2703,11 +2695,10 @@ describe('Test select box and lasso per trace:', function() {
});
});

[false, true].forEach(function(hasCssTransform) {
[false].forEach(function(hasCssTransform) {
it('@noCI should work for funnel traces, hasCssTransform: ' + hasCssTransform, function(done) {
var assertPoints = makeAssertPoints(['curveNumber', 'x', 'y']);
var assertSelectedPoints = makeAssertSelectedPoints();
var assertRanges = makeAssertRanges();
var assertLassoPoints = makeAssertLassoPoints();

var fig = Lib.extendDeep({}, require('../../image/mocks/funnel_horizontal_group_basic'));
Expand All @@ -2724,42 +2715,17 @@ describe('Test select box and lasso per trace:', function() {
assertPoints([
[0, 331.5, 'Author: etpinard'],
[1, 53.5, 'Pull requests'],
[1, 15.5, 'Author: etpinard'],
]);
assertSelectedPoints({
0: [2],
1: [1, 2]
1: [1]
});
assertLassoPoints([
[-161.6974, -1701.6728, -161.6974, 1378.2779, 608.2902],
[1.1129, 1.9193, 2.7258, 1.9193, 1.5161]
]);
},
null, LASSOEVENTS, 'funnel lasso'
);
})
.then(function() {
return Plotly.relayout(gd, 'dragmode', 'select');
})
.then(function() {
return _run(hasCssTransform,
[[300, 300], [500, 500]],
function() {
assertPoints([
[0, 331.5, 'Author: etpinard'],
[1, 53.5, 'Pull requests'],
[1, 15.5, 'Author: etpinard']
]);
assertSelectedPoints({
0: [2],
1: [1, 2]
});
assertRanges([
[-931.6851, 608.2902],
[1.1129, 2.7258]
[-140.1492, -1697.3631, 1417.0646, 638.4577],
[1.1129, 1.9193 , 1.9193, 1.5161]
]);
},
null, BOXEVENTS, 'funnel select'
null, [3, 2, 1], 'funnel lasso'
);
})
.then(done, done.fail);
Expand Down
59 changes: 0 additions & 59 deletions test/jasmine/tests/splom_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -931,65 +931,6 @@ describe('Test splom interactions:', function() {
.then(done, done.fail);
});

it('@noCI @gl should clear graph and replot when canvas and WebGL context dimensions do not match', function(done) {
var fig = Lib.extendDeep({}, require('../../image/mocks/splom_iris.json'));
fig.layout.showlegend = false;

function assertDims(msg, w, h) {
var canvas = gd._fullLayout._glcanvas;
expect(canvas.node().width / 2).toBe(w, msg + '| canvas width');
expect(canvas.node().height / 2).toBe(h, msg + '| canvas height');

var gl = canvas.data()[0].regl._gl;
if(/Chrome\/78/.test(window.navigator.userAgent)) {
// N.B. for some reason 4096 is the max dimension allowed by Chrome 78
expect(gl.drawingBufferWidth).toBe(Math.min(w, 4096), msg + '| drawingBufferWidth');
expect(gl.drawingBufferHeight).toBe(Math.min(h, 4096), msg + '| drawingBufferHeight');
} else {
expect(gl.drawingBufferWidth / 2).toBe(w, msg + '| drawingBufferWidth');
expect(gl.drawingBufferHeight / 2).toBe(h, msg + '| drawingBufferHeight');
}
}

var methods = ['cleanPlot', 'supplyDefaults', 'doCalcdata'];

methods.forEach(function(m) { spyOn(Plots, m).and.callThrough(); });

function assertFnCall(msg, exp) {
methods.forEach(function(m) {
expect(Plots[m]).toHaveBeenCalledTimes(exp[m], msg);
Plots[m].calls.reset();
});
}

spyOn(Lib, 'log');

_newPlot(gd, fig).then(function() {
assertFnCall('base', {
cleanPlot: 1, // called once from inside Plots.supplyDefaults
supplyDefaults: 1,
doCalcdata: 1
});
assertDims('base', 600, 500);
expect(Lib.log).toHaveBeenCalledTimes(0);

spyOn(gd._fullData[0]._module, 'plot').and.callThrough();

return Plotly.relayout(gd, {width: 4810, height: 3656});
})
.then(function() {
assertFnCall('after', {
cleanPlot: 3, // 2 from supplyDefaults, once in drawFramework
supplyDefaults: 2, // 1 from relayout, 1 in drawFramework
doCalcdata: 1 // once in drawFramework
});
assertDims('after', 4810, 3656);
expect(Lib.log)
.toHaveBeenCalledWith('WebGL context buffer and canvas dimensions do not match due to browser/WebGL bug. Clearing graph and plotting again.');
})
.then(done, done.fail);
});

it('@gl should update axis arrangement on show(upper|lower)half + diagonal.visible restyles', function(done) {
var seq = ['', '2', '3', '4'];

Expand Down
10 changes: 7 additions & 3 deletions test/jasmine/tests/transition_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ describe('Plotly.react transitions:', function() {
.then(done, done.fail);
});

it('@noCI should only transition the layout when both traces and layout have animatable changes by default', function(done) {
it('@flaky should only transition the layout when both traces and layout have animatable changes by default', function(done) {
var data = [{y: [1, 2, 1]}];
var layout = {
transition: {duration: 10},
Expand All @@ -615,6 +615,7 @@ describe('Plotly.react transitions:', function() {
data[0].marker = {color: 'red'};
return Plotly.react(gd, data, layout);
})
.then(delay(50))
.then(function() {
assertSpies('just trace transition', [
[Plots, 'transitionFromReact', 1],
Expand All @@ -627,6 +628,7 @@ describe('Plotly.react transitions:', function() {
layout.xaxis.range = [-2, 2];
return Plotly.react(gd, data, layout);
})
.then(delay(50))
.then(function() {
assertSpies('just layout transition', [
[Plots, 'transitionFromReact', 1],
Expand All @@ -646,7 +648,7 @@ describe('Plotly.react transitions:', function() {
layout.xaxis.range = [-1, 1];
return Plotly.react(gd, data, layout);
})
.then(delay(20))
.then(delay(50))
.then(function() {
assertSpies('both trace and layout transitions', [
[Plots, 'transitionFromReact', 1],
Expand All @@ -669,7 +671,7 @@ describe('Plotly.react transitions:', function() {
layout.transition.ordering = 'traces first';
return Plotly.react(gd, data, layout);
})
.then(delay(20))
.then(delay(50))
.then(function() {
assertSpies('both trace and layout transitions under *ordering:traces first*', [
[Plots, 'transitionFromReact', 1],
Expand Down Expand Up @@ -777,6 +779,7 @@ describe('Plotly.react transitions:', function() {
data[0].marker = {size: 30};
return Plotly.react(gd, data, layout);
})
.then(delay(50))
.then(function() {
assertSpies('must transition autoranged axes, not the traces', [
[Plots, 'transitionFromReact', 1],
Expand All @@ -792,6 +795,7 @@ describe('Plotly.react transitions:', function() {
data[0].marker = {size: 10};
return Plotly.react(gd, data, layout);
})
.then(delay(50))
.then(function() {
assertSpies('transition just traces, as now axis ranges are set', [
[Plots, 'transitionFromReact', 1],
Expand Down