-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[App Search] Wired up organic results on Curation Suggestions view #114717
Merged
JasonStoltz
merged 6 commits into
elastic:master
from
JasonStoltz:organic-results-suggestions
Oct 19, 2021
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0494263
Added Organic Results
JasonStoltz e9a0c3c
Merge branch 'master' into organic-results-suggestions
kibanamachine 2b801a8
Use new URL
JasonStoltz 047eafc
Show empty prompt
JasonStoltz f467bdd
Merge branch 'master' into organic-results-suggestions
JasonStoltz 7ad9040
Merge branch 'master' into organic-results-suggestions
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ import React from 'react'; | |
|
||
import { shallow } from 'enzyme'; | ||
|
||
import { EuiEmptyPrompt } from '@elastic/eui'; | ||
|
||
import { AppSearchPageTemplate } from '../../../layout'; | ||
|
||
import { Result } from '../../../result'; | ||
|
@@ -26,44 +28,29 @@ describe('CurationSuggestion', () => { | |
suggestion: { | ||
query: 'foo', | ||
updated_at: '2021-07-08T14:35:50Z', | ||
promoted: ['1', '2', '3'], | ||
}, | ||
suggestedPromotedDocuments: [ | ||
{ | ||
id: { | ||
raw: '1', | ||
}, | ||
_meta: { | ||
id: '1', | ||
engine: 'some-engine', | ||
}, | ||
}, | ||
{ | ||
id: { | ||
raw: '2', | ||
}, | ||
_meta: { | ||
id: '2', | ||
engine: 'some-engine', | ||
}, | ||
}, | ||
{ | ||
id: { | ||
raw: '3', | ||
}, | ||
_meta: { | ||
id: '3', | ||
engine: 'some-engine', | ||
}, | ||
}, | ||
], | ||
curation: { | ||
promoted: [ | ||
promoted: [{ id: '4', foo: 'foo' }], | ||
organic: [ | ||
{ | ||
id: '4', | ||
foo: 'foo', | ||
id: { raw: '3', snippet: null }, | ||
foo: { raw: 'bar', snippet: null }, | ||
_meta: { id: '3' }, | ||
}, | ||
], | ||
curation: { | ||
promoted: [{ id: '1', foo: 'foo' }], | ||
organic: [ | ||
{ | ||
id: { raw: '5', snippet: null }, | ||
foo: { raw: 'bar', snippet: null }, | ||
_meta: { id: '5' }, | ||
}, | ||
{ | ||
id: { raw: '6', snippet: null }, | ||
foo: { raw: 'bar', snippet: null }, | ||
_meta: { id: '6' }, | ||
}, | ||
], | ||
}, | ||
}, | ||
isMetaEngine: true, | ||
engine: { | ||
|
@@ -99,19 +86,18 @@ describe('CurationSuggestion', () => { | |
it('shows existing promoted documents', () => { | ||
const wrapper = shallow(<CurationSuggestion />); | ||
const suggestedResultsPanel = wrapper.find(CurationResultPanel).at(0); | ||
// gets populated from 'curation' in state, and converted to results format (i.e, has raw properties, etc.) | ||
expect(suggestedResultsPanel.prop('results')).toEqual([ | ||
{ | ||
id: { | ||
raw: '4', | ||
raw: '1', | ||
snippet: null, | ||
}, | ||
foo: { | ||
raw: 'foo', | ||
snippet: null, | ||
}, | ||
_meta: { | ||
id: '4', | ||
id: '1', | ||
}, | ||
}, | ||
]); | ||
|
@@ -120,7 +106,21 @@ describe('CurationSuggestion', () => { | |
it('shows suggested promoted documents', () => { | ||
const wrapper = shallow(<CurationSuggestion />); | ||
const suggestedResultsPanel = wrapper.find(CurationResultPanel).at(1); | ||
expect(suggestedResultsPanel.prop('results')).toEqual(values.suggestedPromotedDocuments); | ||
expect(suggestedResultsPanel.prop('results')).toEqual([ | ||
{ | ||
id: { | ||
raw: '4', | ||
snippet: null, | ||
}, | ||
foo: { | ||
raw: 'foo', | ||
snippet: null, | ||
}, | ||
_meta: { | ||
id: '4', | ||
}, | ||
}, | ||
]); | ||
}); | ||
|
||
it('displays the query in the title', () => { | ||
|
@@ -142,20 +142,59 @@ describe('CurationSuggestion', () => { | |
it('displays proposed organic results', () => { | ||
const wrapper = shallow(<CurationSuggestion />); | ||
wrapper.find('[data-test-subj="showOrganicResults"]').simulate('click'); | ||
expect(wrapper.find('[data-test-subj="proposedOrganicResults"]').find(Result).length).toBe(4); | ||
expect(wrapper.find(Result).at(0).prop('isMetaEngine')).toEqual(true); | ||
expect(wrapper.find(Result).at(0).prop('schemaForTypeHighlights')).toEqual( | ||
const resultsWrapper = wrapper.find('[data-test-subj="proposedOrganicResults"]').find(Result); | ||
expect(resultsWrapper.length).toBe(1); | ||
expect(resultsWrapper.find(Result).at(0).prop('result')).toEqual({ | ||
id: { raw: '3', snippet: null }, | ||
foo: { raw: 'bar', snippet: null }, | ||
_meta: { id: '3' }, | ||
}); | ||
expect(resultsWrapper.find(Result).at(0).prop('isMetaEngine')).toEqual(true); | ||
expect(resultsWrapper.find(Result).at(0).prop('schemaForTypeHighlights')).toEqual( | ||
values.engine.schema | ||
); | ||
}); | ||
|
||
it('displays current organic results', () => { | ||
const wrapper = shallow(<CurationSuggestion />); | ||
wrapper.find('[data-test-subj="showOrganicResults"]').simulate('click'); | ||
expect(wrapper.find('[data-test-subj="currentOrganicResults"]').find(Result).length).toBe(4); | ||
expect(wrapper.find(Result).at(0).prop('isMetaEngine')).toEqual(true); | ||
expect(wrapper.find(Result).at(0).prop('schemaForTypeHighlights')).toEqual( | ||
const resultWrapper = wrapper.find('[data-test-subj="currentOrganicResults"]').find(Result); | ||
expect(resultWrapper.length).toBe(2); | ||
expect(resultWrapper.find(Result).at(0).prop('result')).toEqual({ | ||
id: { raw: '5', snippet: null }, | ||
foo: { raw: 'bar', snippet: null }, | ||
_meta: { id: '5' }, | ||
}); | ||
expect(resultWrapper.find(Result).at(0).prop('isMetaEngine')).toEqual(true); | ||
expect(resultWrapper.find(Result).at(0).prop('schemaForTypeHighlights')).toEqual( | ||
values.engine.schema | ||
); | ||
}); | ||
|
||
it('shows an empty prompt when there are no organic results', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
setMockValues({ | ||
...values, | ||
suggestion: { | ||
...values.suggestion, | ||
organic: [], | ||
curation: { | ||
...values.suggestion.curation, | ||
organic: [], | ||
}, | ||
}, | ||
}); | ||
const wrapper = shallow(<CurationSuggestion />); | ||
wrapper.find('[data-test-subj="showOrganicResults"]').simulate('click'); | ||
expect(wrapper.find('[data-test-subj="currentOrganicResults"]').exists()).toBe(false); | ||
expect(wrapper.find('[data-test-subj="proposedOrganicResults"]').exists()).toBe(false); | ||
expect(wrapper.find(EuiEmptyPrompt).exists()).toBe(true); | ||
}); | ||
|
||
it('renders even if no data is set yet', () => { | ||
setMockValues({ | ||
suggestion: null, | ||
}); | ||
const wrapper = shallow(<CurationSuggestion />); | ||
expect(wrapper.find(AppSearchPageTemplate).exists()).toBe(true); | ||
}); | ||
}); |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of typescript here!