import { ROLES } from '../../../common/test' ; import { DETECTIONS_RULE_MANAGEMENT_URL , ALERTS_URL } from '../../urls/navigation' ; import { getNewRule } from '../../objects/rule' ; import { PAGE_TITLE } from '../../screens/common/page' ; import { login , loginAndWaitForPageWithoutDateRange , waitForPageWithoutDateRange , } from '../../tasks/login' ; import { waitForAlertsIndexToBeCreated } from '../../tasks/alerts' ; import { goToRuleDetails } from '../../tasks/alerts_detection_rules' ; import { createCustomRule , deleteCustomRule } from '../../tasks/api_calls/rules' ; import { getCallOut , waitForCallOutToBeShown } from '../../tasks/common/callouts' ; import { cleanKibana } from '../../tasks/common' ; const loadPageAsPlatformEngineerUser = ( url ) => { waitForPageWithoutDateRange ( url , ROLES . soc_manager ) ; waitForPageTitleToBeShown ( ) ; } ; const waitForPageTitleToBeShown = ( ) => { cy . get ( PAGE_TITLE ) . should ( 'be.visible' ) ; } ; describe ( 'Detections > Need Admin Callouts indicating an admin is needed to migrate the alert data set' , ( ) => { const NEED_ADMIN_FOR_UPDATE_CALLOUT = 'need-admin-for-update-rules' ; before ( ( ) => { cleanKibana ( ) ; loginAndWaitForPageWithoutDateRange ( ALERTS_URL , ROLES . platform_engineer ) ; waitForAlertsIndexToBeCreated ( ) ; login ( ROLES . soc_manager ) ; } ) ; context ( 'The users index_mapping_outdated is "true" and their admin callouts should show up' , ( ) => { beforeEach ( ( ) => { cy . intercept ( 'GET' , '/api/detection_engine/index' , { index_mapping_outdated : true , name : '.siem-signals-default' , } ) ; } ) ; context ( 'On Detections home page' , ( ) => { beforeEach ( ( ) => { loadPageAsPlatformEngineerUser ( ALERTS_URL ) ; } ) ; it ( 'We show the need admin primary callout' , ( ) => { waitForCallOutToBeShown ( NEED_ADMIN_FOR_UPDATE_CALLOUT , 'primary' ) ; } ) ; } ) ; context ( 'On Rules Management page' , ( ) => { beforeEach ( ( ) => { loadPageAsPlatformEngineerUser ( DETECTIONS_RULE_MANAGEMENT_URL ) ; } ) ; it ( 'We show 1 primary callout of need admin' , ( ) => { waitForCallOutToBeShown ( NEED_ADMIN_FOR_UPDATE_CALLOUT , 'primary' ) ; } ) ; } ) ; context ( 'On Rule Details page' , ( ) => { beforeEach ( ( ) => { createCustomRule ( getNewRule ( ) ) ; loadPageAsPlatformEngineerUser ( DETECTIONS_RULE_MANAGEMENT_URL ) ; waitForPageTitleToBeShown ( ) ; goToRuleDetails ( ) ; } ) ; afterEach ( ( ) => { deleteCustomRule ( ) ; } ) ; it ( 'We show 1 primary callout' , ( ) => { waitForCallOutToBeShown ( NEED_ADMIN_FOR_UPDATE_CALLOUT , 'primary' ) ; } ) ; } ) ; } ) ; context ( 'The users index_mapping_outdated is "false" and their admin callouts should not show up ' , ( ) => { beforeEach ( ( ) => { cy . intercept ( 'GET' , '/api/detection_engine/index' , { index_mapping_outdated : false , name : '.siem-signals-default' , } ) ; } ) ; context ( 'On Detections home page' , ( ) => { beforeEach ( ( ) => { loadPageAsPlatformEngineerUser ( ALERTS_URL ) ; } ) ; it ( 'We show the need admin primary callout' , ( ) => { getCallOut ( NEED_ADMIN_FOR_UPDATE_CALLOUT ) . should ( 'not.exist' ) ; } ) ; } ) ; context ( 'On Rules Management page' , ( ) => { beforeEach ( ( ) => { loadPageAsPlatformEngineerUser ( DETECTIONS_RULE_MANAGEMENT_URL ) ; } ) ; it ( 'We show 1 primary callout of need admin' , ( ) => { getCallOut ( NEED_ADMIN_FOR_UPDATE_CALLOUT ) . should ( 'not.exist' ) ; } ) ; } ) ; context ( 'On Rule Details page' , ( ) => { beforeEach ( ( ) => { createCustomRule ( getNewRule ( ) ) ; loadPageAsPlatformEngineerUser ( DETECTIONS_RULE_MANAGEMENT_URL ) ; waitForPageTitleToBeShown ( ) ; goToRuleDetails ( ) ; } ) ; afterEach ( ( ) => { deleteCustomRule ( ) ; } ) ; it ( 'We show 1 primary callout' , ( ) => { getCallOut ( NEED_ADMIN_FOR_UPDATE_CALLOUT ) . should ( 'not.exist' ) ; } ) ; } ) ; } ) ; context ( 'The users index_mapping_outdated is "null" and their admin callouts should not show up ' , ( ) => { beforeEach ( ( ) => { cy . intercept ( 'GET' , '/api/detection_engine/index' , { index_mapping_outdated : null , name : '.siem-signals-default' , } ) ; } ) ; context ( 'On Detections home page' , ( ) => { beforeEach ( ( ) => { loadPageAsPlatformEngineerUser ( ALERTS_URL ) ; } ) ; it ( 'We show the need admin primary callout' , ( ) => { getCallOut ( NEED_ADMIN_FOR_UPDATE_CALLOUT ) . should ( 'not.exist' ) ; } ) ; } ) ; context ( 'On Rules Management page' , ( ) => { beforeEach ( ( ) => { loadPageAsPlatformEngineerUser ( DETECTIONS_RULE_MANAGEMENT_URL ) ; } ) ; it ( 'We show 1 primary callout of need admin' , ( ) => { getCallOut ( NEED_ADMIN_FOR_UPDATE_CALLOUT ) . should ( 'not.exist' ) ; } ) ; } ) ; context ( 'On Rule Details page' , ( ) => { beforeEach ( ( ) => { createCustomRule ( getNewRule ( ) ) ; loadPageAsPlatformEngineerUser ( DETECTIONS_RULE_MANAGEMENT_URL ) ; waitForPageTitleToBeShown ( ) ; goToRuleDetails ( ) ; } ) ; afterEach ( ( ) => { deleteCustomRule ( ) ; } ) ; it ( 'We show 1 primary callout' , ( ) => { getCallOut ( NEED_ADMIN_FOR_UPDATE_CALLOUT ) . should ( 'not.exist' ) ; } ) ; } ) ; } ) ; } ) ;