import { elementsOverlap } from '../../helpers/rules' ; import { TIMELINE_ROW_RENDERERS_DISABLE_ALL_BTN , TIMELINE_ROW_RENDERERS_MODAL_CLOSE_BUTTON , TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX , TIMELINE_ROW_RENDERERS_SEARCHBOX , TIMELINE_SHOW_ROW_RENDERERS_GEAR , TIMELINE_ROW_RENDERERS_SURICATA_SIGNATURE , TIMELINE_ROW_RENDERERS_SURICATA_SIGNATURE_TOOLTIP , TIMELINE_ROW_RENDERERS_SURICATA_LINK_TOOLTIP , } from '../../screens/timeline' ; import { cleanKibana } from '../../tasks/common' ; import { loginAndWaitForPage } from '../../tasks/login' ; import { openTimelineUsingToggle } from '../../tasks/security_main' ; import { populateTimeline } from '../../tasks/timeline' ; import { HOSTS_URL } from '../../urls/navigation' ; describe ( 'Row renderers' , ( ) => { beforeEach ( ( ) => { cleanKibana ( ) ; loginAndWaitForPage ( HOSTS_URL ) ; openTimelineUsingToggle ( ) ; populateTimeline ( ) ; cy . get ( TIMELINE_SHOW_ROW_RENDERERS_GEAR ) . should ( 'exist' ) ; cy . get ( TIMELINE_SHOW_ROW_RENDERERS_GEAR ) . first ( ) . click ( { force : true } ) ; } ) ; afterEach ( ( ) => { cy . get ( TIMELINE_ROW_RENDERERS_MODAL_CLOSE_BUTTON ) . click ( { force : true } ) ; } ) ; it ( 'Row renderers should be enabled by default' , ( ) => { cy . get ( TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX ) . should ( 'exist' ) ; cy . get ( TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX ) . should ( 'be.checked' ) ; } ) ; it ( 'Selected renderer can be disabled and enabled' , ( ) => { cy . get ( TIMELINE_ROW_RENDERERS_SEARCHBOX ) . should ( 'exist' ) ; cy . get ( TIMELINE_ROW_RENDERERS_SEARCHBOX ) . type ( 'flow' ) ; cy . intercept ( 'PATCH' , '/api/timeline' ) . as ( 'updateTimeline' ) ; cy . get ( TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX ) . first ( ) . uncheck ( ) ; cy . wait ( '@updateTimeline' ) . then ( ( interception ) => { expect ( interception . request . body . timeline . excludedRowRendererIds ) . to . contain ( 'netflow' ) ; } ) ; cy . get ( TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX ) . first ( ) . check ( ) ; cy . wait ( '@updateTimeline' ) . then ( ( interception ) => { expect ( interception . request . body . timeline . excludedRowRendererIds ) . not . to . contain ( 'netflow' ) ; } ) ; } ) ; it ( 'Selected renderer can be disabled with one click' , ( ) => { cy . get ( TIMELINE_ROW_RENDERERS_DISABLE_ALL_BTN ) . should ( 'exist' ) ; cy . get ( TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX ) . should ( 'be.checked' ) ; cy . intercept ( 'PATCH' , '/api/timeline' ) . as ( 'updateTimeline' ) ; cy . root ( ) . pipe ( ( $el ) => { $el . find ( TIMELINE_ROW_RENDERERS_DISABLE_ALL_BTN ) . trigger ( 'click' ) ; return $el . find ( TIMELINE_ROW_RENDERERS_MODAL_ITEMS_CHECKBOX ) . first ( ) ; } ) . should ( 'not.be.checked' ) ; cy . wait ( '@updateTimeline' ) . its ( 'response.statusCode' ) . should ( 'eq' , 200 ) ; } ) ; describe ( 'Suricata' , ( ) => { it ( 'Signature tooltips do not overlap' , ( ) => { cy . get ( TIMELINE_ROW_RENDERERS_SURICATA_SIGNATURE ) . parents ( '.euiPopover__anchor' ) . trigger ( 'mouseover' ) ; cy . get ( TIMELINE_ROW_RENDERERS_SURICATA_LINK_TOOLTIP ) . then ( ( $googleLinkTooltip ) => { cy . get ( TIMELINE_ROW_RENDERERS_SURICATA_SIGNATURE_TOOLTIP ) . then ( ( $signatureTooltip ) => { expect ( elementsOverlap ( $googleLinkTooltip , $signatureTooltip ) , 'tooltips do not overlap' ) . to . equal ( false ) ; } ) ; } ) ; } ) ; } ) ; } ) ;