import { getNewRule } from '../../objects/rule' ; import { ROLES } from '../../../common/test' ; import { expandFirstAlertActions , waitForAlertsIndexToBeCreated , waitForAlertsPanelToBeLoaded , } from '../../tasks/alerts' ; import { createCustomRuleActivated } from '../../tasks/api_calls/rules' ; import { cleanKibana } from '../../tasks/common' ; import { waitForAlertsToPopulate } from '../../tasks/create_new_rule' ; import { login , loginAndWaitForPage , waitForPageWithoutDateRange } from '../../tasks/login' ; import { refreshPage } from '../../tasks/security_header' ; import { ALERTS_URL } from '../../urls/navigation' ; import { ATTACH_ALERT_TO_CASE_BUTTON } from '../../screens/alerts' ; const loadDetectionsPage = ( role ) => { waitForPageWithoutDateRange ( ALERTS_URL , role ) ; waitForAlertsToPopulate ( ) ; } ; describe ( 'Alerts timeline' , ( ) => { before ( ( ) => { cleanKibana ( ) ; loginAndWaitForPage ( ALERTS_URL , ROLES . platform_engineer ) ; waitForAlertsPanelToBeLoaded ( ) ; waitForAlertsIndexToBeCreated ( ) ; createCustomRuleActivated ( getNewRule ( ) ) ; refreshPage ( ) ; waitForAlertsToPopulate ( 500 ) ; login ( ROLES . reader ) ; } ) ; context ( 'Privileges: read only' , ( ) => { beforeEach ( ( ) => { loadDetectionsPage ( ROLES . reader ) ; } ) ; it ( 'should not allow user with read only privileges to attach alerts to cases' , ( ) => { expandFirstAlertActions ( ) ; cy . get ( ATTACH_ALERT_TO_CASE_BUTTON ) . should ( 'not.exist' ) ; } ) ; } ) ; context ( 'Privileges: can crud' , ( ) => { beforeEach ( ( ) => { loadDetectionsPage ( ROLES . platform_engineer ) ; } ) ; it ( 'should allow a user with crud privileges to attach alerts to cases' , ( ) => { expandFirstAlertActions ( ) ; cy . get ( ATTACH_ALERT_TO_CASE_BUTTON ) . first ( ) . should ( 'not.be.disabled' ) ; } ) ; } ) ; } ) ;