diff --git a/src/plugins/controls/public/control_group/editor/control_editor.test.tsx b/src/plugins/controls/public/control_group/editor/control_editor.test.tsx index 1bcfa766331c..e21783baa706 100644 --- a/src/plugins/controls/public/control_group/editor/control_editor.test.tsx +++ b/src/plugins/controls/public/control_group/editor/control_editor.test.tsx @@ -10,9 +10,10 @@ import { ReactWrapper } from 'enzyme'; import React from 'react'; import { act } from 'react-dom/test-utils'; -import { stubDataView } from '@kbn/data-views-plugin/common/data_view.stub'; +import { createStubDataView } from '@kbn/data-views-plugin/common/data_view.stub'; import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers'; +import { stubFieldSpecMap } from '@kbn/data-views-plugin/common/field.stub'; import { OptionsListEmbeddableFactory } from '../..'; import { OptionsListEmbeddableInput, @@ -40,6 +41,25 @@ describe('Data control editor', () => { explicitInput?: Partial; } + const stubDataView = createStubDataView({ + spec: { + id: 'logstash-*', + fields: { + ...stubFieldSpecMap, + 'machine.os.raw': { + name: 'machine.os.raw', + customLabel: 'OS', + type: 'string', + esTypes: ['keyword'], + aggregatable: true, + searchable: true, + }, + }, + title: 'logstash-*', + timeFieldName: '@timestamp', + }, + }); + pluginServices.getServices().dataViews.get = jest.fn().mockResolvedValue(stubDataView); pluginServices.getServices().dataViews.getIdsWithTitle = jest .fn() diff --git a/src/plugins/controls/public/control_group/editor/control_editor.tsx b/src/plugins/controls/public/control_group/editor/control_editor.tsx index c175507c9541..bdc09a393b0f 100644 --- a/src/plugins/controls/public/control_group/editor/control_editor.tsx +++ b/src/plugins/controls/public/control_group/editor/control_editor.tsx @@ -182,7 +182,7 @@ export const ControlEditor = ({ const disabled = fieldRegistry && selectedField - ? !fieldRegistry[selectedField].compatibleControlTypes.includes(controlType) + ? !fieldRegistry[selectedField]?.compatibleControlTypes.includes(controlType) : true; const keyPadMenuItem = (