@@ -111,6 +111,7 @@ describe('update menus defaults', function() {
111111 expect ( layoutOut . updatemenus [ 0 ] . buttons [ 0 ] ) . toEqual ( {
112112 method : 'relayout' ,
113113 args : [ 'title' , 'Hello World' ] ,
114+ execute : true ,
114115 label : '' ,
115116 _index : 1
116117 } ) ;
@@ -135,6 +136,7 @@ describe('update menus defaults', function() {
135136 expect ( layoutOut . updatemenus [ 0 ] . buttons [ 0 ] ) . toEqual ( {
136137 method : 'relayout' ,
137138 args : [ 'title' , 'Hello World' ] ,
139+ execute : true ,
138140 label : '' ,
139141 _index : 1
140142 } ) ;
@@ -156,11 +158,13 @@ describe('update menus defaults', function() {
156158 expect ( layoutOut . updatemenus [ 0 ] . buttons [ 0 ] ) . toEqual ( {
157159 method : 'skip' ,
158160 label : '' ,
161+ execute : true ,
159162 _index : 0
160163 } , {
161164 method : 'skip' ,
162165 args : [ 'title' , 'Hello World' ] ,
163166 label : '' ,
167+ execute : true ,
164168 _index : 1
165169 } ) ;
166170 } ) ;
@@ -444,6 +448,32 @@ describe('update menus interactions', function() {
444448 } ) ;
445449 } ) ;
446450
451+ it ( 'should execute the API command when execute = true' , function ( done ) {
452+ expect ( gd . data [ 0 ] . line . color ) . toEqual ( 'blue' ) ;
453+
454+ click ( selectHeader ( 0 ) ) . then ( function ( ) {
455+ return click ( selectButton ( 2 ) ) ;
456+ } ) . then ( function ( ) {
457+ // Has been changed:
458+ expect ( gd . data [ 0 ] . line . color ) . toEqual ( 'green' ) ;
459+ } ) . catch ( fail ) . then ( done ) ;
460+ } ) ;
461+
462+ it ( 'should not execute the API command when execute = false' , function ( done ) {
463+ // This test is identical to the one above, except that it disables
464+ // the command by setting execute = false first:
465+ expect ( gd . data [ 0 ] . line . color ) . toEqual ( 'blue' ) ;
466+
467+ Plotly . relayout ( gd , 'updatemenus[0].buttons[2].execute' , false ) . then ( function ( ) {
468+ return click ( selectHeader ( 0 ) ) ;
469+ } ) . then ( function ( ) {
470+ return click ( selectButton ( 2 ) ) ;
471+ } ) . then ( function ( ) {
472+ // Is unchanged:
473+ expect ( gd . data [ 0 ] . line . color ) . toEqual ( 'blue' ) ;
474+ } ) . catch ( fail ) . then ( done ) ;
475+ } ) ;
476+
447477 it ( 'should emit an event on button click' , function ( done ) {
448478 var clickCnt = 0 ;
449479 var data = [ ] ;
0 commit comments