From 3e2566870809e67e6a906b43286320db0b04a575 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Tue, 11 May 2021 14:03:24 +0200 Subject: [PATCH] Add custom serializer to overwrite the default one from the shared field --- .../processors/registered_domain.test.tsx | 25 ++++++++++++++++++- .../common_fields/ignore_missing_field.tsx | 2 +- .../processors/registered_domain.tsx | 3 ++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/processors/registered_domain.test.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/processors/registered_domain.test.tsx index 0ba9b5eb16e17..962e099f5b667 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/processors/registered_domain.test.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/__jest__/processors/registered_domain.test.tsx @@ -12,7 +12,7 @@ import { setup, SetupResult, getProcessorValue } from './processor.helpers'; const defaultRegisteredDomainParameters = { description: undefined, if: undefined, - ignore_missing: true, + ignore_missing: undefined, ignore_failure: undefined, }; @@ -82,6 +82,29 @@ describe('Processor: Registered Domain', () => { }); }); + test('should still send ignore_missing:false when the toggle is disabled', async () => { + const { + actions: { saveNewProcessor }, + form, + } = testBed; + + // Add "field" value (required) + form.setInputValue('fieldNameField.input', 'field_1'); + + // Disable ignore missing toggle + form.toggleEuiSwitch('ignoreMissingSwitch.input'); + + // Save the field with new changes + await saveNewProcessor(); + + const processors = getProcessorValue(onUpdate, REGISTERED_DOMAIN_TYPE); + expect(processors[0][REGISTERED_DOMAIN_TYPE]).toEqual({ + ...defaultRegisteredDomainParameters, + field: 'field_1', + ignore_missing: false, + }); + }); + test('allows optional parameters to be set', async () => { const { actions: { saveNewProcessor }, diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/common_fields/ignore_missing_field.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/common_fields/ignore_missing_field.tsx index 744e9798c4fb0..2fe23cbedf694 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/common_fields/ignore_missing_field.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/common_fields/ignore_missing_field.tsx @@ -43,7 +43,7 @@ export const fieldsConfig: FieldsConfig = { }, }; -type Props = Partial; +type Props = Partial>; export const IgnoreMissingField: FunctionComponent = (props) => ( { return ( @@ -24,7 +25,7 @@ export const RegisteredDomain: FunctionComponent = () => { - + ); };