Skip to content

Commit

Permalink
Blocks save event filter with a white space name (#101599)
Browse files Browse the repository at this point in the history
  • Loading branch information
dasansol92 authored and kibanamachine committed Jun 9, 2021
1 parent f9ca6ff commit f798bb0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ describe('Event filter form', () => {
expect(store.getState()!.management!.eventFilters!.form!.hasNameError).toBeFalsy();
});

it('should change name with a white space still shows an error', async () => {
component = renderComponentWithdata();

const nameInput = component.getByPlaceholderText(NAME_PLACEHOLDER);

act(() => {
fireEvent.change(nameInput, {
target: {
value: ' ',
},
});
});

expect(store.getState()!.management!.eventFilters!.form!.entry!.name).toBe('');
expect(store.getState()!.management!.eventFilters!.form!.hasNameError).toBeTruthy();
});

it('should change comments', async () => {
component = renderComponentWithdata();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ export const EventFiltersForm: React.FC<EventFiltersFormProps> = memo(
const handleOnChangeName = useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
if (!exception) return;
const name = e.target.value.toString().trim();
dispatch({
type: 'eventFiltersChangeForm',
payload: {
entry: { ...exception, name: e.target.value.toString() },
hasNameError: !e.target.value,
entry: { ...exception, name },
hasNameError: !name,
},
});
},
Expand Down

0 comments on commit f798bb0

Please sign in to comment.