Skip to content

Add check for failed binding comparison #1176

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 5 commits into from
Nov 21, 2016
Merged
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
46 changes: 46 additions & 0 deletions test/jasmine/tests/updatemenus_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,52 @@ describe('update menus interactions', function() {
});
});

it('should update correctly on failed binding comparisons', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well, right @rreusser ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, a full end to end test of the specific failing case. Thanks! 👍

To elaborate, the specific difficulty is knowing when to dive into array contents. It's a little unpleasant since… do you do a deep comparison? Limit the deep comparison to when there aren't 1000 elements?

To limit the intelligence (which correlates with bugginess), my solution was to only compare arrays if they're length 1. I think that's a reasonable compromise since overall there are quite a few tests here (though this case was missed, obv 😞 )


// See https://github.com/plotly/plotly.js/issues/1169
// for more info.

var data = [{
y: [1, 2, 3],
visible: true
}, {
y: [2, 3, 1],
visible: false
}, {
y: [3, 1, 2],
visible: false
}];

var layout = {
updatemenus: [{
buttons: [{
label: 'a',
method: 'restyle',
args: ['visible', [true, false, false]]
}, {
label: 'b',
method: 'restyle',
args: ['visible', [false, true, false]]
}, {
label: 'c',
method: 'restyle',
args: ['visible', [false, false, true]]
}]
}]
};

Plotly.newPlot(gd, data, layout).then(function() {
return click(selectHeader(0));
})
.then(function() {
return click(selectButton(1));
})
.then(function() {
assertActive(gd, [1]);
})
.then(done);
});

it('should change color on mouse over', function(done) {
var INDEX_0 = 2,
INDEX_1 = gd.layout.updatemenus[1].active;
Expand Down