@@ -16,6 +16,7 @@ var delay = require('../assets/delay');
1616var  doubleClick  =  require ( '../assets/double_click' ) ; 
1717var  failTest  =  require ( '../assets/fail_test' ) ; 
1818var  touchEvent  =  require ( '../assets/touch_event' ) ; 
19+ var  negateIf  =  require ( '../assets/negate_if' ) ; 
1920
2021var  customAssertions  =  require ( '../assets/custom_assertions' ) ; 
2122var  assertHoverLabelStyle  =  customAssertions . assertHoverLabelStyle ; 
@@ -1750,6 +1751,48 @@ describe('hover info', function() {
17501751            . catch ( failTest ) 
17511752            . then ( done ) ; 
17521753        } ) ; 
1754+ 
1755+         it ( 'hovermode:y common label should shift and clip text start into graph div' ,  function ( done )  { 
1756+             function  _assert ( msg ,  exp )  { 
1757+                 return  function ( )  { 
1758+                     var  label  =  d3 . select ( 'g.axistext' ) ; 
1759+                     if ( label . node ( ) )  { 
1760+                         var  ltext  =  label . select ( 'text' ) ; 
1761+                         expect ( ltext . text ( ) ) . toBe ( exp . txt ,  'common label text| '  +  msg ) ; 
1762+                         expect ( ltext . attr ( 'x' ) ) . toBeWithin ( exp . ltx ,  5 ,  'common label text x| '  +  msg ) ; 
1763+ 
1764+                         negateIf ( exp . clip ,  expect ( ltext . attr ( 'clip-path' ) ) ) . toBe ( null ,  'text clip url| '  +  msg ) ; 
1765+ 
1766+                         var  fullLayout  =  gd . _fullLayout ; 
1767+                         var  clipId  =  'clip'  +  fullLayout . _uid  +  'commonlabely' ; 
1768+                         var  clipPath  =  d3 . select ( '#'  +  clipId ) ; 
1769+                         negateIf ( exp . clip ,  expect ( clipPath . node ( ) ) ) . toBe ( null ,  'text clip path|'  +  msg ) ; 
1770+                     }  else  { 
1771+                         fail ( 'fail to generate common hover label' ) ; 
1772+                     } 
1773+                 } ; 
1774+             } 
1775+ 
1776+             function  _hoverWayLong ( )  {  return  _hover ( gd ,  135 ,  100 ) ;  } 
1777+ 
1778+             function  _hoverA ( )  {  return  _hover ( gd ,  135 ,  20 ) ;  } 
1779+ 
1780+             Plotly . plot ( gd ,  [ { 
1781+                 type : 'bar' , 
1782+                 orientation : 'h' , 
1783+                 y : [ 'Looong label' ,  'Loooooger label' ,  'Waay loooong label' ,  'a' ] , 
1784+                 x : [ 2 ,  5 ,  10 ,  2 ] 
1785+             } ] ,  { 
1786+                 width : 400 , 
1787+                 height : 400 
1788+             } ) 
1789+             . then ( _hoverWayLong ) 
1790+             . then ( _assert ( 'on way long label' ,  { txt : 'Waay loooong label' ,  clip : true ,  ltx : 38 } ) ) 
1791+             . then ( _hoverA ) 
1792+             . then ( _assert ( 'on "a" label' ,  { txt : 'a' ,  clip : false ,  ltx : - 9 } ) ) 
1793+             . catch ( failTest ) 
1794+             . then ( done ) ; 
1795+         } ) ; 
17531796    } ) ; 
17541797
17551798    describe ( 'hovertemplate' ,  function ( )  { 
0 commit comments