@@ -10,6 +10,7 @@ var mockCircular = require('@mocks/sankey_circular.json');
10
10
var mockCircularLarge = require ( '@mocks/sankey_circular_large.json' ) ;
11
11
var mockXY = require ( '@mocks/sankey_x_y.json' ) ;
12
12
var Sankey = require ( '@src/traces/sankey' ) ;
13
+ var Registry = require ( '@src/registry' ) ;
13
14
14
15
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
15
16
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
@@ -608,6 +609,48 @@ describe('sankey tests', function() {
608
609
. catch ( failTest )
609
610
. then ( done ) ;
610
611
} ) ;
612
+
613
+ [ '0' , '1' ] . forEach ( function ( finalUIRevision ) {
614
+ it ( 'on Plotly.react, it preserves the groups depending on layout.uirevision' , function ( done ) {
615
+ var uirevisions = [ '0' , finalUIRevision ] ;
616
+
617
+ var mockCopy = Lib . extendDeep ( { } , mockCircular ) ;
618
+ mockCopy . layout . uirevision = uirevisions [ 0 ] ;
619
+
620
+ Plotly . plot ( gd , mockCopy )
621
+ . then ( function ( ) {
622
+ // Create a group via guiRestyle
623
+ return Registry . call ( '_guiRestyle' , gd , 'node.groups' , [ [ [ 0 , 1 ] ] ] ) ;
624
+ } )
625
+ . then ( function ( ) {
626
+ // Check that the nodes are grouped
627
+ expect ( gd . _fullData [ 0 ] . node . groups ) . toEqual ( [ [ 0 , 1 ] ] ) ;
628
+
629
+ // Change color of nodes
630
+ mockCopy = Lib . extendDeep ( { } , mockCircular ) ;
631
+ mockCopy . data [ 0 ] . node . color = 'orange' ;
632
+ mockCopy . layout . uirevision = uirevisions [ 1 ] ;
633
+ return Plotly . react ( gd , mockCopy ) ;
634
+ } )
635
+ . then ( function ( ) {
636
+ if ( uirevisions [ 0 ] === uirevisions [ 1 ] ) {
637
+ // If uirevision is the same, the groups should stay the same
638
+ expect ( gd . _fullData [ 0 ] . node . groups ) . toEqual (
639
+ [ [ 0 , 1 ] ] ,
640
+ 'should stay the same because uirevision did not change'
641
+ ) ;
642
+ } else {
643
+ // If uirevision changed, the groups should be empty as in the figure obj
644
+ expect ( gd . _fullData [ 0 ] . node . groups ) . toEqual (
645
+ [ ] ,
646
+ 'should go back to its default because uirevision changed'
647
+ ) ;
648
+ }
649
+ } )
650
+ . catch ( failTest )
651
+ . then ( done ) ;
652
+ } ) ;
653
+ } ) ;
611
654
} ) ;
612
655
613
656
describe ( 'Test hover/click interactions:' , function ( ) {
0 commit comments