Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:elastic/kibana into slo-add-preview…
…-to-custom-metric
- Loading branch information
Showing
8 changed files
with
158 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...ch_content/components/search_index/pipelines/ml_inference/pipeline_select_option.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { shallow } from 'enzyme'; | ||
|
||
import { EuiText, EuiTitle } from '@elastic/eui'; | ||
|
||
import { MLModelTypeBadge } from '../ml_model_type_badge'; | ||
|
||
import { MLInferencePipelineOption } from './ml_inference_logic'; | ||
import { PipelineSelectOption, PipelineSelectOptionDisabled } from './pipeline_select_option'; | ||
|
||
import { MODEL_REDACTED_VALUE } from './utils'; | ||
|
||
describe('PipelineSelectOption', () => { | ||
const pipeline: MLInferencePipelineOption = { | ||
disabled: false, | ||
disabledReason: undefined, | ||
modelId: 'my-model-id', | ||
modelType: 'my-model-type', | ||
pipelineName: 'my-pipeline', | ||
sourceFields: ['my-source-field1', 'my-source-field2'], | ||
indexFields: [], | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
it('renders pipeline selection option', () => { | ||
const wrapper = shallow(<PipelineSelectOption pipeline={pipeline} />); | ||
expect(wrapper.find(EuiTitle)).toHaveLength(1); | ||
expect(wrapper.find(MLModelTypeBadge)).toHaveLength(1); | ||
}); | ||
it('does not render model type badge if model type is unknown', () => { | ||
const wrapper = shallow( | ||
<PipelineSelectOption | ||
pipeline={{ | ||
...pipeline, | ||
modelType: '', | ||
}} | ||
/> | ||
); | ||
expect(wrapper.find(MLModelTypeBadge)).toHaveLength(0); | ||
}); | ||
it("redacts model ID if it's unavailable", () => { | ||
const wrapper = shallow( | ||
<PipelineSelectOption | ||
pipeline={{ | ||
...pipeline, | ||
modelId: '', | ||
}} | ||
/> | ||
); | ||
expect(wrapper.find(EuiText)).toHaveLength(4); | ||
expect(wrapper.find(EuiText).at(1).children().text()).toEqual(MODEL_REDACTED_VALUE); | ||
}); | ||
it('renders disable warning text if the pipeline is disabled', () => { | ||
const wrapper = shallow( | ||
<PipelineSelectOption | ||
pipeline={{ | ||
...pipeline, | ||
disabled: true, | ||
disabledReason: 'my-reason', | ||
}} | ||
/> | ||
); | ||
expect(wrapper.find(PipelineSelectOptionDisabled)).toHaveLength(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.