Skip to content
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

Merged
merged 4 commits into from
Oct 18, 2021

Conversation

JasonStoltz
Copy link
Member

@JasonStoltz JasonStoltz commented Oct 14, 2021

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.

screencapture-localhost-5601-auv-app-enterprise-search-app-search-engines-pokemon-curations-cur-616994257a2f2e28f770849c-2021-10-15-10_57_51

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@JasonStoltz JasonStoltz changed the title history [App Search] Added a History tab to the Automated Curation detail view Oct 14, 2021
@JasonStoltz JasonStoltz added v7.16.0 release_note:skip Skip the PR/issue when compiling release notes auto-backport Deprecated - use backport:version if exact versions are needed labels Oct 14, 2021
Copy link
Contributor

@byronhulcher byronhulcher left a 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',
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

Copy link
Member Author

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);
Copy link
Contributor

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

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

Copy link
Member Author

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.

Copy link
Contributor

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

@JasonStoltz JasonStoltz marked this pull request as ready for review October 15, 2021 15:00
@JasonStoltz JasonStoltz requested a review from a team October 15, 2021 15:00
@JasonStoltz
Copy link
Member Author

@byronhulcher This PR is finalized if you want to have a second look!

@JasonStoltz JasonStoltz enabled auto-merge (squash) October 15, 2021 15:01

expect(wrapper.find(PromotedDocuments)).toHaveLength(1);
expect(wrapper.find(OrganicDocuments)).toHaveLength(1);
expect(wrapper.find(History)).toHaveLength(0);
Copy link
Contributor

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

@JasonStoltz
Copy link
Member Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
enterpriseSearch 1547 1550 +3

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
enterpriseSearch 1.4MB 1.4MB +1.3KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
enterpriseSearch 9.4KB 9.5KB +189.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

byronhulcher pushed a commit that referenced this pull request Oct 19, 2021
…4549) (#115650)

* Handle deletes (#114545)

* [App Search] Wired up organic results on Curation Suggestions view (#114717)

* [App Search] Added a History tab to the Automated Curation detail view (#115090)

* Check platinum license (#114549)
@byronhulcher
Copy link
Contributor

Backported in #115650

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes v7.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants