import '../../__mocks__/engine_logic.mock' ; import { setMockValues } from '../../../__mocks__/kea_logic' ; import React from 'react' ; import { shallow } from 'enzyme' ; import { RelevanceTuningCallouts } from './relevance_tuning_callouts' ; describe ( 'RelevanceTuningCallouts' , ( ) => { const values = { engineHasSchemaFields : true , engine : { invalidBoosts : false , unsearchedUnconfirmedFields : false , } , schemaFieldsWithConflicts : [ ] , } ; beforeEach ( ( ) => { jest . clearAllMocks ( ) ; setMockValues ( values ) ; } ) ; const subject = ( ) => shallow ( < RelevanceTuningCallouts />); it ( 'renders' , ( ) => { const wrapper = subject ( ) ; expect ( wrapper . find ( '[data-test-subj="RelevanceTuningInvalidBoostsCallout"]' ) . exists ( ) ) . toBe ( false ) ; expect ( wrapper . find ( '[data-test-subj="RelevanceTuningUnsearchedFieldsCallout"]' ) . exists ( ) ) . toBe ( false ) ; expect ( subject ( ) . find ( '[data-test-subj="SchemaConflictsCallout"]' ) . exists ( ) ) . toBe ( false ) ; } ) ; it ( 'shows a message when there are invalid boosts' , ( ) => { setMockValues ( { ... values , engine : { invalidBoosts : true , unsearchedUnconfirmedFields : false , } , } ) ; expect ( subject ( ) . find ( '[data-test-subj="RelevanceTuningInvalidBoostsCallout"]' ) . exists ( ) ) . toBe ( true ) ; } ) ; it ( 'shows a message when there are unconfirmed fields' , ( ) => { setMockValues ( { ... values , engine : { invalidBoosts : false , unsearchedUnconfirmedFields : true , } , } ) ; expect ( subject ( ) . find ( '[data-test-subj="RelevanceTuningUnsearchedFieldsCallout"]' ) . exists ( ) ) . toBe ( true ) ; } ) ; it ( 'shows a message when there are schema field conflicts' , ( ) => { setMockValues ( { ... values , schemaFieldsWithConflicts : [ 'fe' , 'fi' , 'fo' ] , } ) ; expect ( subject ( ) . find ( '[data-test-subj="SchemaConflictsCallout"]' ) . exists ( ) ) . toBe ( true ) ; } ) ; } ) ;