Skip to content

Commit

Permalink
Fix existing jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaStoeva committed Nov 14, 2024
1 parent 853f9ff commit 92adc29
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -36,6 +37,9 @@ describe('Mappings editor: configuration form', () => {
config: {
enableMappingsSourceFieldSection: true,
},
plugins: {
licensing: licensingMock.createStart(),
},
} as unknown as AppDependencies;

await act(async () => {
Expand All @@ -53,6 +57,9 @@ describe('Mappings editor: configuration form', () => {
config: {
enableMappingsSourceFieldSection: true,
},
plugins: {
licensing: licensingMock.createStart(),
},
} as unknown as AppDependencies;

await act(async () => {
Expand All @@ -69,6 +76,9 @@ describe('Mappings editor: configuration form', () => {
config: {
enableMappingsSourceFieldSection: false,
},
plugins: {
licensing: licensingMock.createStart(),
},
} as unknown as AppDependencies;

await act(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
},
Expand Down

0 comments on commit 92adc29

Please sign in to comment.