Skip to content

Commit

Permalink
improve gl3d uirevision test
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Jan 4, 2019
1 parent 4b8a05b commit b880717
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/jasmine/tests/plot_api_react_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1832,9 +1832,17 @@ describe('Test Plotly.react + interactions under uirevision:', function() {
});
}

// mocking panning/scrolling is brittle,
// mocking panning/scrolling with mouse events is brittle,
// this here is enough to to trigger the relayoutCallback
function _mouseup() {
var sceneLayout = gd._fullLayout.scene;
var cameraOld = sceneLayout.camera;
sceneLayout._scene.setCamera({
eye: {x: 2, y: 2, z: 2},
center: cameraOld.center,
up: cameraOld.up
});

var target = gd.querySelector('.svg-container .gl-container #scene canvas');
return new Promise(function(resolve) {
mouseEvent('mouseup', 200, 200, {element: target});
Expand All @@ -1844,6 +1852,18 @@ describe('Test Plotly.react + interactions under uirevision:', function() {

// should be same before & after 2nd react()
function _assertGUI(msg) {
var TOL = 2;

var eye = ((gd.layout.scene || {}).camera || {}).eye || {};
expect(eye.x).toBeCloseTo(2, TOL, msg);
expect(eye.y).toBeCloseTo(2, TOL, msg);
expect(eye.z).toBeCloseTo(2, TOL, msg);

var fullEye = gd._fullLayout.scene.camera.eye;
expect(fullEye.x).toBeCloseTo(2, TOL, msg);
expect(fullEye.y).toBeCloseTo(2, TOL, msg);
expect(fullEye.z).toBeCloseTo(2, TOL, msg);

var preGUI = gd._fullLayout._preGUI;
expect(preGUI['scene.camera']).toBe(null, msg);
}
Expand Down

0 comments on commit b880717

Please sign in to comment.