import { act } from 'react-dom/test-utils' ; import { TestBed } from '@kbn/test/jest' ; import { Phase } from '../../../../common/types' ; import { createFormToggleAction } from './form_toggle_action' ; import { createFormSetValueAction } from './form_set_value_action' ; const createFormCheckboxAction = ( testBed , dataTestSubject ) => async ( checked ) => { const { form , component } = testBed ; await act ( async ( ) => { form . selectCheckBox ( dataTestSubject , checked ) ; } ) ; component . update ( ) ; } ; export const createForceMergeActions = ( testBed , phase ) => { const { exists } = testBed ; const toggleSelector = `${ phase }-forceMergeSwitch` ; return { forceMergeExists : ( ) => exists ( toggleSelector ) , toggleForceMerge : createFormToggleAction ( testBed , toggleSelector ) , setForcemergeSegmentsCount : createFormSetValueAction ( testBed , `${ phase }-selectedForceMergeSegments` ) , setBestCompression : createFormCheckboxAction ( testBed , `${ phase }-bestCompression` ) , } ; } ;