[App Search] Migrate Crawler Status Indicator, Crawler Status Banner, and Crawl Request polling#107603
Conversation
3882342 to
f8ab0fc
Compare
aaadbc7 to
b4668d5
Compare
| ].includes(crawlRequests[0]?.status) | ||
| ) { | ||
| actions.createNewTimeoutForCrawlRequests(POLLING_DURATION); | ||
| } else if ( |
There was a problem hiding this comment.
Jest is telling me this line is not covered........ I can't figure out why since lines 206-208 are covered!!!
| closePopover(); | ||
| stopCrawl(); |
There was a problem hiding this comment.
I can't figure out how to write a test that will hit this codepath. See my comment at https://github.com/elastic/kibana/pull/107603/files#diff-d1ef29a662c4e757d0513752525db5973ddeb30c2bd74b8b51e1af3125eac914R35
.../public/applications/app_search/components/crawler/components/crawler_status_banner.test.tsx
Outdated
Show resolved
Hide resolved
.../public/applications/app_search/components/crawler/components/crawler_status_banner.test.tsx
Outdated
Show resolved
Hide resolved
| setMockValues({ | ||
| ...MOCK_VALUES, | ||
| mostRecentCrawlRequestStatus: null, | ||
| }); |
There was a problem hiding this comment.
I'm seeing this
setMockValues({
...MOCK_VALUES,
key: value
});repeated a lot. Would it make sense to define a helper function like
function setMockValuesWithDefaults(values) { /* not loving the function name but you get the idea :) */
setMockValues({
...MOCK_VALUES,
...values
});
}?
There was a problem hiding this comment.
Eh, wrapping a single function call in another single function call doesn't feel any DRYer to me.
There was a problem hiding this comment.
Not repeating ...MOCK_VALUES every time is kind of DRY'er but I'm happy either way 😄
...rise_search/public/applications/app_search/components/crawler/crawler_overview_logic.test.ts
Outdated
Show resolved
Hide resolved
...rise_search/public/applications/app_search/components/crawler/crawler_overview_logic.test.ts
Outdated
Show resolved
Hide resolved
...rise_search/public/applications/app_search/components/crawler/crawler_overview_logic.test.ts
Outdated
Show resolved
Hide resolved
...rise_search/public/applications/app_search/components/crawler/crawler_overview_logic.test.ts
Outdated
Show resolved
Hide resolved
...nterprise_search/public/applications/app_search/components/crawler/crawler_overview_logic.ts
Outdated
Show resolved
Hide resolved
...nterprise_search/public/applications/app_search/components/crawler/crawler_overview_logic.ts
Show resolved
Hide resolved
| it('can be opened to stop crawls', () => { | ||
| const wrapper = shallow(<StopCrawlPopoverContextMenu stopCrawl={stopCrawl} />); | ||
|
|
||
| wrapper.dive().find(EuiButton).simulate('click'); | ||
| rerender(wrapper); | ||
|
|
||
| expect(wrapper.prop('isOpen')).toEqual(true); | ||
|
|
||
| // TODO I can't figure out how to find the EuiContextMenuItem inside this component's | ||
| // EuiContextMenuPanel. It renders inside of an EuiResizeObserver and I figure out how | ||
| // to get in it | ||
|
|
||
| // const menuItem = wrapper | ||
| // .find(EuiContextMenuPanel) | ||
| // .find(EuiResizeObserver) | ||
| // .find(EuiContextMenuItem); | ||
|
|
||
| // expect(menuItem).toHaveLength(1); | ||
|
|
||
| // menuItem.simulate('click'); | ||
|
|
||
| // expect(stopCrawl).toHaveBeenCalled(); | ||
|
|
||
| // rerender(wrapper); | ||
|
|
||
| // expect(wrapper.dive().find(EuiContextMenuPanel)).toHaveLength(0); | ||
| }); |
There was a problem hiding this comment.
This seems to work:
it('can be opened to stop crawls', () => {
const wrapper = mount(<StopCrawlPopoverContextMenu stopCrawl={stopCrawl} />);
wrapper.find(EuiButton).simulate('click');
expect(wrapper.find(EuiPopover).prop('isOpen')).toEqual(true);
const menuItem = wrapper
.find(EuiContextMenuPanel)
.find(EuiResizeObserver)
.find(EuiContextMenuItem);
expect(menuItem).toHaveLength(1);
menuItem.simulate('click');
expect(stopCrawl).toHaveBeenCalled();
});But not sure if we are OK with not using shallow in that test.
Diff
diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/crawler_status_indicator/stop_crawl_popover_context_menu.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/crawler_status_indicator/stop_crawl_popover_context_menu.test.tsx
index 654aa9226cd..a2a30f03047 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/crawler_status_indicator/stop_crawl_popover_context_menu.test.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/crawler_status_indicator/stop_crawl_popover_context_menu.test.tsx
@@ -6,11 +6,15 @@
*/
import React from 'react';
-import { shallow } from 'enzyme';
+import { shallow, mount } from 'enzyme';
-import { EuiButton, EuiPopover } from '@elastic/eui';
-
-import { rerender } from '../../../../../test_helpers';
+import {
+ EuiButton,
+ EuiContextMenuItem,
+ EuiContextMenuPanel,
+ EuiPopover,
+ EuiResizeObserver,
+} from '@elastic/eui';
import { StopCrawlPopoverContextMenu } from './stop_crawl_popover_context_menu';
@@ -25,30 +29,21 @@ describe('StopCrawlsPopoverContextMenu', () => {
});
it('can be opened to stop crawls', () => {
- const wrapper = shallow(<StopCrawlPopoverContextMenu stopCrawl={stopCrawl} />);
-
- wrapper.dive().find(EuiButton).simulate('click');
- rerender(wrapper);
-
- expect(wrapper.prop('isOpen')).toEqual(true);
-
- // TODO I can't figure out how to find the EuiContextMenuItem inside this component's
- // EuiContextMenuPanel. It renders inside of an EuiResizeObserver and I figure out how
- // to get in it
+ const wrapper = mount(<StopCrawlPopoverContextMenu stopCrawl={stopCrawl} />);
- // const menuItem = wrapper
- // .find(EuiContextMenuPanel)
- // .find(EuiResizeObserver)
- // .find(EuiContextMenuItem);
+ wrapper.find(EuiButton).simulate('click');
- // expect(menuItem).toHaveLength(1);
+ expect(wrapper.find(EuiPopover).prop('isOpen')).toEqual(true);
- // menuItem.simulate('click');
+ const menuItem = wrapper
+ .find(EuiContextMenuPanel)
+ .find(EuiResizeObserver)
+ .find(EuiContextMenuItem);
- // expect(stopCrawl).toHaveBeenCalled();
+ expect(menuItem).toHaveLength(1);
- // rerender(wrapper);
+ menuItem.simulate('click');
- // expect(wrapper.dive().find(EuiContextMenuPanel)).toHaveLength(0);
+ expect(stopCrawl).toHaveBeenCalled();
});
});There was a problem hiding this comment.
ahhh let me try with mountWithIntl which is a customized mount which handles our i18n
Co-authored-by: Constance <constancecchen@users.noreply.github.com> Co-authored-by: Orhan Toy <toyorhan@gmail.com>
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
… and Crawl Request polling (elastic#107603)
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
… and Crawl Request polling (elastic#107603)
…-png-pdf-report-type * 'master' of github.com:elastic/kibana: (392 commits) update linting doc (elastic#105748) [APM] Various improvements from elastic#104851 (elastic#107726) Update dependency @elastic/charts to v33.2.0 (master) (elastic#107842) Fix default route link on kibana homepage (elastic#107809) [APM] Invalidate trackPageview on route change (elastic#107741) Service map backend links (elastic#107317) [index patterns] index pattern create modal (elastic#101853) [RAC] integrating rbac search strategy with alert table (elastic#107242) [Security Solution] Siem signals -> alerts as data field and index aliases (elastic#106049) [Metrics UI] Add checkbox to optionally drop partial buckets (elastic#107676) [Metrics UI] Fix metric threshold preview regression (elastic#107674) Disable Product check in @elastic/elasticsearch-js (elastic#107642) [App Search] Migrate Crawler Status Indicator, Crawler Status Banner, and Crawl Request polling (elastic#107603) [Security Solution, Lists] Replace legacy imports from 'elasticsearch' package (elastic#107226) [maps] asset tracking tutorial (elastic#104552) [scripts/build_ts_refs] when using `--clean` initialize caches (elastic#107777) Upgrade EUI to v36.1.0 (elastic#107231) [RAC] [TGrid] Implements cell actions in the TGrid (elastic#107771) Realign cypress/ccs_integration with cypress/integration (elastic#107743) Allow optional OSS to X-Pack dependencies (elastic#107432) ... # Conflicts: # x-pack/examples/reporting_example/public/application.tsx # x-pack/examples/reporting_example/public/components/app.tsx # x-pack/plugins/canvas/public/services/legacy/stubs/reporting.ts # x-pack/plugins/reporting/common/types.ts # x-pack/plugins/reporting/public/lib/reporting_api_client/context.tsx # x-pack/plugins/reporting/public/management/mount_management_section.tsx # x-pack/plugins/reporting/public/management/report_listing.test.tsx # x-pack/plugins/reporting/public/plugin.ts # x-pack/plugins/reporting/public/share_context_menu/register_pdf_png_reporting.tsx # x-pack/plugins/reporting/server/export_types/printable_pdf/execute_job/index.ts
Summary
Migrates the
CrawlerStatusIndicatorandCrawlerStatusBannercomponents from our standalone UX. To support this, I've also migrates our Crawl Request polling.Checklist
Delete any items that are not applicable to this PR.