import { CHART_VIZ_CONTAINER_SELECTOR , visitDynamicWidget } from '../../../../src/testing/selectors' ; import { SECOND_IN_MS } from '../../../../src/utils/time' ; const root = '/tests' ; const VIEWPORT_HEIGHT = 500 ; const VIEWPORT_WIDTH = 500 ; const TIME_FOR_GESTURE_TO_COMPLETE = 0.1 * SECOND_IN_MS ; it ( 'moves viewport when gestures are applied' , ( ) => { const START = new Date ( 2000 , 0 , 0 ) ; const END = new Date ( 2000 , 0 , 2 ) ; const OLD_X_AXIS_TICK = 'Fri 31' ; visitDynamicWidget ( cy , { componentTag : 'sc-bar-chart' , viewportStart : START , viewportEnd : END , gestures : true , } ) ; cy . waitForChart ( ) ; cy . contains ( OLD_X_AXIS_TICK ) . should ( 'be.visible' ) ; cy . get ( CHART_VIZ_CONTAINER_SELECTOR ) . dblclick ( 'center' ) ; cy . get ( CHART_VIZ_CONTAINER_SELECTOR ) . dblclick ( 'center' ) ; cy . get ( CHART_VIZ_CONTAINER_SELECTOR ) . dblclick ( 'center' ) ; cy . contains ( OLD_X_AXIS_TICK ) . should ( 'not.exist' ) ; } ) ; it ( 'does not move viewport when gestures are not applied' , ( ) => { const START = new Date ( 2000 , 0 , 0 ) ; const END = new Date ( 2000 , 0 , 2 ) ; const OLD_X_AXIS_TICK = 'Fri 31' ; visitDynamicWidget ( cy , { componentTag : 'sc-bar-chart' , viewportStart : START , viewportEnd : END , gestures : false , } ) ; cy . waitForChart ( ) ; cy . contains ( OLD_X_AXIS_TICK ) . should ( 'exist' ) ; cy . get ( CHART_VIZ_CONTAINER_SELECTOR ) . dblclick ( 'center' ) ; cy . contains ( OLD_X_AXIS_TICK ) . should ( 'be.visible' ) ; } ) ; it ( 'adjusts y range as data in the view changes' , ( ) => { cy . viewport ( VIEWPORT_WIDTH , VIEWPORT_HEIGHT ) ; cy . visit ( `${ root }/chart/y-range?componentTag=sc-bar-chart` ) ; const EXISTING_Y_VALUE = '18,000' ; cy . waitForChart ( ) ; cy . contains ( EXISTING_Y_VALUE ) . should ( 'exist' ) ; cy . get ( CHART_VIZ_CONTAINER_SELECTOR ) . dblclick ( 'center' ) ; cy . get ( CHART_VIZ_CONTAINER_SELECTOR ) . dblclick ( 'center' ) ; cy . wait ( TIME_FOR_GESTURE_TO_COMPLETE ) ; cy . contains ( EXISTING_Y_VALUE ) . should ( 'not.exist' ) ; } ) ;