-
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] Added a History tab to the Automated Curation detail view #115090
Conversation
537cfc0
to
4e210bd
Compare
4e210bd
to
ad6340a
Compare
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.
I think the column names for the log stream need to be i18n
-ized, but I don't want to hold up merging any longer than necessary so I'm approving for now 👍
{ | ||
type: 'field', | ||
field: 'appsearch.search_relevance_suggestions.query', | ||
header: 'Query', |
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.
Do these headers need to be i18n
-ized?
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.
They do! This PR is in draft right now, so I'm just waiting on the finalized list of columns to show.
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.
This are all gone, using OOTB headers now: 81a0904
|
||
export const AutomatedCuration: React.FC = () => { | ||
const { curationId } = useParams<{ curationId: string }>(); | ||
const logic = CurationLogic({ curationId }); | ||
const { convertToManual } = useActions(logic); | ||
const { activeQuery, dataLoading, queries, curation } = useValues(logic); | ||
const { engineName } = useValues(EngineLogic); | ||
const [selectedPageTab, setSelectedPageTab] = useState(PROMOTED); | ||
|
||
// This tab group is meant to visually mirror the dynamic group of tags in the ManualCuration component |
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.
This comment can get removed now that this tab group is no longer static
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.
Good call
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.
|
||
expect(wrapper.find(PromotedDocuments)).toHaveLength(1); | ||
expect(wrapper.find(OrganicDocuments)).toHaveLength(1); | ||
expect(wrapper.find(History)).toHaveLength(0); |
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.
When I'm writing jest tests for React components, I try to avoid using events like clicks to modify the local state. In the manual_curation.test.tsx
file you can see an example of how I'd write this kind of test
Lines 65 to 101 in ad6340a
it('includes set of tabs in the page header', () => { | |
const wrapper = shallow(<ManualCuration />); | |
const tabs = getPageHeaderTabs(wrapper).find(EuiTab); | |
tabs.at(0).simulate('click'); | |
expect(actions.onSelectPageTab).toHaveBeenNthCalledWith(1, 'promoted'); | |
tabs.at(1).simulate('click'); | |
expect(actions.onSelectPageTab).toHaveBeenNthCalledWith(2, 'hidden'); | |
}); | |
it('contains a suggested documents callout when the selectedPageTab is ', () => { | |
const wrapper = shallow(<ManualCuration />); | |
expect(wrapper.find(SuggestedDocumentsCallout)).toHaveLength(1); | |
}); | |
it('renders promoted documents when that tab is selected', () => { | |
setMockValues({ ...values, selectedPageTab: 'promoted' }); | |
const wrapper = shallow(<ManualCuration />); | |
const tabs = getPageHeaderTabs(wrapper).find(EuiTab); | |
expect(tabs.at(0).prop('isSelected')).toEqual(true); | |
expect(wrapper.find(PromotedDocuments)).toHaveLength(1); | |
}); | |
it('renders hidden documents when that tab is selected', () => { | |
setMockValues({ ...values, selectedPageTab: 'hidden' }); | |
const wrapper = shallow(<ManualCuration />); | |
const tabs = getPageHeaderTabs(wrapper).find(EuiTab); | |
expect(tabs.at(1).prop('isSelected')).toEqual(true); | |
expect(wrapper.find(HiddenDocuments)).toHaveLength(1); | |
}); |
You don't have to change it here or how you do it in the future but wanted to present how I've been handling it
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.
Hmm, I think it's a little different. You are using Kea, I'm using local state. Using local state, I think I have to use a click to modify the local state.
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.
I think I have a way to mock useState, similar to how we mock useValues/useActions. I'll post in Slack
@byronhulcher This PR is finalized if you want to have a second look! |
|
||
expect(wrapper.find(PromotedDocuments)).toHaveLength(1); | ||
expect(wrapper.find(OrganicDocuments)).toHaveLength(1); | ||
expect(wrapper.find(History)).toHaveLength(0); |
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.
I think I have a way to mock useState, similar to how we mock useValues/useActions. I'll post in Slack
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
Backported in #115650 |
Summary
Closes https://github.com/elastic/app-search-team/issues/1945
This adds a log stream to the history tab of the automated curations section.
If you want to test this, simply create an automated suggestion and then check out the History tab.
Checklist
Delete any items that are not applicable to this PR.
For maintainers