@@ -10,6 +10,7 @@ var mockCircular = require('@mocks/sankey_circular.json');
1010var mockCircularLarge = require ( '@mocks/sankey_circular_large.json' ) ;
1111var mockXY = require ( '@mocks/sankey_x_y.json' ) ;
1212var Sankey = require ( '@src/traces/sankey' ) ;
13+ var Registry = require ( '@src/registry' ) ;
1314
1415var createGraphDiv = require ( '../assets/create_graph_div' ) ;
1516var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
@@ -608,6 +609,48 @@ describe('sankey tests', function() {
608609 . catch ( failTest )
609610 . then ( done ) ;
610611 } ) ;
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+ } ) ;
611654 } ) ;
612655
613656 describe ( 'Test hover/click interactions:' , function ( ) {
0 commit comments