Blocks save event filter with a white space name (#101599)
This commit is contained in:
parent
7604fd7c80
commit
d90285f718
|
@ -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();
|
||||
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue