From 92adc292e14cc5d3687996cd179c32fe3782510a Mon Sep 17 00:00:00 2001 From: Elena Stoeva Date: Thu, 14 Nov 2024 17:36:25 +0000 Subject: [PATCH] Fix existing jest tests --- .../client_integration/configuration_form.test.tsx | 10 ++++++++++ .../configuration_form/configuration_form.tsx | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/configuration_form.test.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/configuration_form.test.tsx index 4c73fd1037dda..9c317fd2486cd 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/configuration_form.test.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/__jest__/client_integration/configuration_form.test.tsx @@ -7,6 +7,7 @@ import { AppDependencies } from '../../../..'; import { registerTestBed, TestBed } from '@kbn/test-jest-helpers'; +import { licensingMock } from '@kbn/licensing-plugin/public/mocks'; import { ConfigurationForm } from '../../components/configuration_form'; import { WithAppDependencies } from './helpers/setup_environment'; import { TestSubjects } from './helpers/mappings_editor.helpers'; @@ -36,6 +37,9 @@ describe('Mappings editor: configuration form', () => { config: { enableMappingsSourceFieldSection: true, }, + plugins: { + licensing: licensingMock.createStart(), + }, } as unknown as AppDependencies; await act(async () => { @@ -53,6 +57,9 @@ describe('Mappings editor: configuration form', () => { config: { enableMappingsSourceFieldSection: true, }, + plugins: { + licensing: licensingMock.createStart(), + }, } as unknown as AppDependencies; await act(async () => { @@ -69,6 +76,9 @@ describe('Mappings editor: configuration form', () => { config: { enableMappingsSourceFieldSection: false, }, + plugins: { + licensing: licensingMock.createStart(), + }, } as unknown as AppDependencies; await act(async () => { diff --git a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/configuration_form/configuration_form.tsx b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/configuration_form/configuration_form.tsx index 9f79d97e2ebbd..124e65471a21c 100644 --- a/x-pack/plugins/index_management/public/application/components/mappings_editor/components/configuration_form/configuration_form.tsx +++ b/x-pack/plugins/index_management/public/application/components/mappings_editor/components/configuration_form/configuration_form.tsx @@ -16,6 +16,7 @@ import { useDispatch } from '../../mappings_state_context'; import { DynamicMappingSection } from './dynamic_mapping_section'; import { SourceFieldSection, + STORED_SOURCE_OPTION, SYNTHETIC_SOURCE_OPTION, DISABLED_SOURCE_OPTION, } from './source_field_section'; @@ -48,7 +49,11 @@ const formSerializer = (formData: GenericObject) => { : sourceField?.option === DISABLED_SOURCE_OPTION ? { enabled: false } : sourceField?.includes || sourceField?.excludes - ? { includes: sourceField?.includes, excludes: sourceField?.excludes } + ? { + enabled: sourceField?.option === STORED_SOURCE_OPTION ? true : undefined, + includes: sourceField?.includes, + excludes: sourceField?.excludes, + } : undefined; const serialized = { @@ -96,7 +101,7 @@ const formDeserializer = (formData: GenericObject) => { dynamic_date_formats, }, sourceField: { - option: mode ?? (enabled === false ? 'disabled' : undefined), + option: mode ?? (enabled === false ? 'disabled' : enabled === true ? 'stored' : undefined), includes, excludes, },