import { TestCaseWithoutTimeline } from '../../objects/case' ; import { ALL_CASES_NAME } from '../../screens/all_cases' ; import { goToCreateNewCase } from '../../tasks/all_cases' ; import { cleanKibana , deleteCases } from '../../tasks/common' ; import { backToCases , createCase , fillCasesMandatoryfields , filterStatusOpen , } from '../../tasks/create_new_case' ; import { loginAndWaitForHostDetailsPage , loginWithUserAndWaitForPageWithoutDateRange , logout , } from '../../tasks/login' ; import { createUsersAndRoles , deleteUsersAndRoles , secAll , secAllUser , secReadCasesAllUser , secReadCasesAll , } from '../../tasks/privileges' ; import { CASES_URL } from '../../urls/navigation' ; import { openSourcerer } from '../../tasks/sourcerer' ; const usersToCreate = [ secAllUser , secReadCasesAllUser ] ; const rolesToCreate = [ secAll , secReadCasesAll ] ; const visitSecuritySolution = ( ) => { loginAndWaitForHostDetailsPage ( ) ; openSourcerer ( ) ; logout ( ) ; } ; const testCase = { name : 'This is the title of the case' , tags : [ 'Tag1' , 'Tag2' ] , description : 'This is the case description' , reporter : 'elastic' , owner : 'securitySolution' , } ; describe ( 'Cases privileges' , ( ) => { before ( ( ) => { cleanKibana ( ) ; createUsersAndRoles ( usersToCreate , rolesToCreate ) ; visitSecuritySolution ( ) ; } ) ; after ( ( ) => { deleteUsersAndRoles ( usersToCreate , rolesToCreate ) ; cleanKibana ( ) ; } ) ; beforeEach ( ( ) => { deleteCases ( ) ; } ) ; for ( const user of [ secAllUser , secReadCasesAllUser ] ) { it ( `User ${ user . username } with role(s) ${ user . roles . join ( ) } can create a case` , ( ) => { loginWithUserAndWaitForPageWithoutDateRange ( CASES_URL , user ) ; goToCreateNewCase ( ) ; fillCasesMandatoryfields ( testCase ) ; createCase ( ) ; backToCases ( ) ; filterStatusOpen ( ) ; cy . get ( ALL_CASES_NAME ) . should ( 'have.text' , testCase . name ) ; } ) ; } } ) ;