import { TestBed } from '@kbn/test/jest' ; import { act } from 'react-dom/test-utils' ; import { Phase } from '../../../../common/types' ; const toggleDeletePhase = async ( testBed ) => { const { find , component } = testBed ; let button = find ( 'disableDeletePhaseButton' ) ; let action = 'disable' ; if ( ! button . length ) { button = find ( 'enableDeletePhaseButton' ) ; action = 'enable' ; } if ( ! button . length ) { throw new Error ( `Button to enable/disable delete phase was not found.` ) ; } await act ( async ( ) => { if ( action === 'disable' ) { button . simulate ( 'click' ) ; } else { button . find ( 'input' ) . simulate ( 'change' ) ; } } ) ; component . update ( ) ; } ; const togglePhase = async ( testBed , phase ) => { const { form , component } = testBed ; await act ( async ( ) => { form . toggleEuiSwitch ( `enablePhaseSwitch-${ phase }` ) ; } ) ; component . update ( ) ; } ; export const createTogglePhaseAction = ( testBed ) => async ( phase ) => { if ( phase === 'delete' ) { await toggleDeletePhase ( testBed ) ; } else { await togglePhase ( testBed , phase ) ; } } ;