File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,23 @@ describe('Event filter form', () => {
111111 expect ( store . getState ( ) ! . management ! . eventFilters ! . form ! . hasNameError ) . toBeFalsy ( ) ;
112112 } ) ;
113113
114+ it ( 'should change name with a white space still shows an error' , async ( ) => {
115+ component = renderComponentWithdata ( ) ;
116+
117+ const nameInput = component . getByPlaceholderText ( NAME_PLACEHOLDER ) ;
118+
119+ act ( ( ) => {
120+ fireEvent . change ( nameInput , {
121+ target : {
122+ value : ' ' ,
123+ } ,
124+ } ) ;
125+ } ) ;
126+
127+ expect ( store . getState ( ) ! . management ! . eventFilters ! . form ! . entry ! . name ) . toBe ( '' ) ;
128+ expect ( store . getState ( ) ! . management ! . eventFilters ! . form ! . hasNameError ) . toBeTruthy ( ) ;
129+ } ) ;
130+
114131 it ( 'should change comments' , async ( ) => {
115132 component = renderComponentWithdata ( ) ;
116133
Original file line number Diff line number Diff line change @@ -91,11 +91,12 @@ export const EventFiltersForm: React.FC<EventFiltersFormProps> = memo(
9191 const handleOnChangeName = useCallback (
9292 ( e : React . ChangeEvent < HTMLInputElement > ) => {
9393 if ( ! exception ) return ;
94+ const name = e . target . value . toString ( ) . trim ( ) ;
9495 dispatch ( {
9596 type : 'eventFiltersChangeForm' ,
9697 payload : {
97- entry : { ...exception , name : e . target . value . toString ( ) } ,
98- hasNameError : ! e . target . value ,
98+ entry : { ...exception , name } ,
99+ hasNameError : ! name ,
99100 } ,
100101 } ) ;
101102 } ,
You can’t perform that action at this time.
0 commit comments