@@ -6,6 +6,7 @@ var interactConstants = require('@src/constants/interactions');
66var createGraphDiv = require ( '../assets/create_graph_div' ) ;
77var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
88var mouseEvent = require ( '../assets/mouse_event' ) ;
9+ var Plots = require ( '@src/plots/plots' ) ;
910
1011describe ( 'editable titles' , function ( ) {
1112 'use strict' ;
@@ -45,6 +46,24 @@ describe('editable titles', function() {
4546 return promise ;
4647 }
4748
49+ function editTitle ( letter , attr , text ) {
50+ return new Promise ( function ( resolve ) {
51+ gd . once ( 'plotly_relayout' , function ( eventData ) {
52+ expect ( eventData [ attr ] ) . toEqual ( text , [ letter , attr , eventData ] ) ;
53+ setTimeout ( resolve , 10 ) ;
54+ } ) ;
55+
56+ var textNode = document . querySelector ( '.' + letter + 'title' ) ;
57+ textNode . dispatchEvent ( new window . MouseEvent ( 'click' ) ) ;
58+
59+ var editNode = document . querySelector ( '.plugin-editable.editable' ) ;
60+ editNode . dispatchEvent ( new window . FocusEvent ( 'focus' ) ) ;
61+ editNode . textContent = text ;
62+ editNode . dispatchEvent ( new window . FocusEvent ( 'focus' ) ) ;
63+ editNode . dispatchEvent ( new window . FocusEvent ( 'blur' ) ) ;
64+ } ) ;
65+ }
66+
4867 it ( 'shows default titles semi-opaque with no hover effects' , function ( done ) {
4968 Plotly . plot ( gd , data , { } , { editable : true } )
5069 . then ( function ( ) {
@@ -84,11 +103,13 @@ describe('editable titles', function() {
84103 title : ''
85104 } , { editable : true } )
86105 . then ( function ( ) {
87- return Plotly . relayout ( gd , {
88- 'xaxis.title' : 'XXX' ,
89- 'yaxis.title' : 'YYY' ,
90- 'title' : 'TTT'
91- } ) ;
106+ return editTitle ( 'x' , 'xaxis.title' , 'XXX' ) ;
107+ } )
108+ . then ( function ( ) {
109+ return editTitle ( 'y' , 'yaxis.title' , 'YYY' ) ;
110+ } )
111+ . then ( function ( ) {
112+ return editTitle ( 'g' , 'title' , 'TTT' ) ;
92113 } )
93114 . then ( function ( ) {
94115 return Promise . all ( [
0 commit comments