Skip to content

Join duplicated tests for sunburst, icicle and treemap #5757

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 1 commit into from
Jun 22, 2021
Merged
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
134 changes: 33 additions & 101 deletions test/jasmine/tests/plot_api_react_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2048,109 +2048,41 @@ describe('Plotly.react and uirevision attributes', function() {
_run(fig, editComponents, checkInitial, checkEdited).then(done);
});

it('preserves sunburst level changes', function(done) {
function assertLevel(msg, exp) {
expect(gd._fullData[0].level).toBe(exp, msg);
}

Plotly.react(gd, [{
type: 'sunburst',
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'],
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve'],
uirevision: 1
}])
.then(function() {
assertLevel('no set level at start', undefined);
})
.then(function() {
var nodeSeth = d3Select('.slice:nth-child(2)').node();
mouseEvent('click', 0, 0, {element: nodeSeth});
})
.then(function() {
assertLevel('after clicking on Seth sector', 'Seth');
})
.then(function() {
return Plotly.react(gd, [{
type: 'sunburst',
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura', 'Joe'],
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve', 'Seth'],
uirevision: 1
}]);
})
.then(function() {
assertLevel('after reacting with new data, but with same uirevision', 'Seth');
})
.then(done, done.fail);
});

it('preserves treemap level changes', function(done) {
function assertLevel(msg, exp) {
expect(gd._fullData[0].level).toBe(exp, msg);
}

Plotly.react(gd, [{
type: 'treemap',
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'],
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve'],
uirevision: 1
}])
.then(function() {
assertLevel('no set level at start', undefined);
})
.then(function() {
var nodeSeth = d3Select('.slice:nth-child(2)').node();
mouseEvent('click', 0, 0, {element: nodeSeth});
})
.then(function() {
assertLevel('after clicking on Seth sector', 'Seth');
})
.then(function() {
return Plotly.react(gd, [{
type: 'treemap',
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura', 'Joe'],
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve', 'Seth'],
uirevision: 1
}]);
})
.then(function() {
assertLevel('after reacting with new data, but with same uirevision', 'Seth');
})
.then(done, done.fail);
});

it('preserves icicle level changes', function(done) {
function assertLevel(msg, exp) {
expect(gd._fullData[0].level).toBe(exp, msg);
}
['sunburst', 'icicle', 'treemap'].forEach(function(type) {
it('preserves ' + type + ' level changes', function(done) {
function assertLevel(msg, exp) {
expect(gd._fullData[0].level).toBe(exp, msg);
}

Plotly.react(gd, [{
type: 'icicle',
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'],
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve'],
uirevision: 1
}])
.then(function() {
assertLevel('no set level at start', undefined);
})
.then(function() {
var nodeSeth = d3Select('.slice:nth-child(2)').node();
mouseEvent('click', 0, 0, {element: nodeSeth});
})
.then(function() {
assertLevel('after clicking on Seth sector', 'Seth');
})
.then(function() {
return Plotly.react(gd, [{
type: 'icicle',
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura', 'Joe'],
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve', 'Seth'],
Plotly.react(gd, [{
type: type,
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'],
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve'],
uirevision: 1
}]);
})
.then(function() {
assertLevel('after reacting with new data, but with same uirevision', 'Seth');
})
.then(done, done.fail);
}])
.then(function() {
assertLevel('no set level at start', undefined);
})
.then(function() {
var nodeSeth = d3Select('.slice:nth-child(2)').node();
mouseEvent('click', 0, 0, {element: nodeSeth});
})
.then(function() {
assertLevel('after clicking on Seth sector', 'Seth');
})
.then(function() {
return Plotly.react(gd, [{
type: type,
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura', 'Joe'],
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve', 'Seth'],
uirevision: 1
}]);
})
.then(function() {
assertLevel('after reacting with new data, but with same uirevision', 'Seth');
})
.then(done, done.fail);
});
});
});

Expand Down