-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[App Search] Implement various Relevance Tuning states and form actio…
…ns (#92644) (#93135) Co-authored-by: Jason Stoltzfus <[email protected]>
- Loading branch information
1 parent
9eb6fb7
commit eecda09
Showing
16 changed files
with
584 additions
and
90 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
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
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
86 changes: 86 additions & 0 deletions
86
...ic/applications/app_search/components/relevance_tuning/relevance_tuning_callouts.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,86 @@ | ||
/* | ||
* 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 '../../__mocks__/engine_logic.mock'; | ||
import { setMockValues } from '../../../__mocks__/kea.mock'; | ||
|
||
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', () => { | ||
// An invalid boost would be if a user creats a functional boost on a number field, then that | ||
// field later changes to text. At this point, the boost still exists but is invalid for | ||
// a text field. | ||
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', () => { | ||
// An invalid boost would be if a user creats a functional boost on a number field, then that | ||
// field later changes to text. At this point, the boost still exists but is invalid for | ||
// a text field. | ||
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', () => { | ||
// Schema conflicts occur when a meta engine has fields in source engines with have differing types, | ||
// hence relevance tuning cannot be applied as we don't know the actual type | ||
setMockValues({ | ||
...values, | ||
schemaFieldsWithConflicts: ['fe', 'fi', 'fo'], | ||
}); | ||
expect(subject().find('[data-test-subj="SchemaConflictsCallout"]').exists()).toBe(true); | ||
}); | ||
}); |
Oops, something went wrong.