(({ scope: scopeId }
[isPopoverOpen, sourcererScope.selectedPatterns]
);
+ const buttonWithTooptip = useMemo(() => {
+ return tooltipContent ? (
+
+ {trigger}
+
+ ) : (
+ trigger
+ );
+ }, [trigger, tooltipContent]);
+
return (
-
-
-
-
- <>{i18n.SELECT_INDEX_PATTERNS}>
-
-
- {i18n.INDEX_PATTERNS_SELECTION_LABEL}
-
- {comboBox}
-
-
-
-
- {i18n.INDEX_PATTERNS_RESET}
-
-
-
-
- {i18n.SAVE_INDEX_PATTERNS}
-
-
-
-
-
-
+
+
+
+ <>{i18n.SELECT_INDEX_PATTERNS}>
+
+
+ {i18n.INDEX_PATTERNS_SELECTION_LABEL}
+
+ {comboBox}
+
+
+
+
+ {i18n.INDEX_PATTERNS_RESET}
+
+
+
+
+ {i18n.SAVE_INDEX_PATTERNS}
+
+
+
+
+
);
});
Sourcerer.displayName = 'Sourcerer';
diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/pick_events.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/pick_events.test.tsx
index 3c6dc68edefc..e519cfcd204a 100644
--- a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/pick_events.test.tsx
+++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/pick_events.test.tsx
@@ -5,7 +5,9 @@
* 2.0.
*/
-import { fireEvent, render } from '@testing-library/react';
+import { fireEvent, render, within } from '@testing-library/react';
+import { EuiToolTip } from '@elastic/eui';
+
import React from 'react';
import { PickEventType } from './pick_events';
import {
@@ -19,6 +21,14 @@ import { TimelineEventsType } from '../../../../../common';
import { createStore } from '../../../../common/store';
import { SourcererScopeName } from '../../../../common/store/sourcerer/model';
+jest.mock('@elastic/eui', () => {
+ const actual = jest.requireActual('@elastic/eui');
+ return {
+ ...actual,
+ EuiToolTip: jest.fn(),
+ };
+});
+
describe('pick_events', () => {
const defaultProps = {
eventType: 'all' as TimelineEventsType,
@@ -53,6 +63,23 @@ describe('pick_events', () => {
},
};
const store = createStore(state, SUB_PLUGINS_REDUCER, kibanaObservable, storage);
+
+ const mockTooltip = ({
+ tooltipContent,
+ children,
+ }: {
+ tooltipContent: string;
+ children: React.ReactElement;
+ }) => (
+
+ {tooltipContent}
+ {children}
+
+ );
+
+ beforeAll(() => {
+ (EuiToolTip as unknown as jest.Mock).mockImplementation(mockTooltip);
+ });
beforeEach(() => {
jest.clearAllMocks();
jest.restoreAllMocks();
@@ -68,6 +95,32 @@ describe('pick_events', () => {
initialPatterns.sort().join('')
);
});
+
+ it('renders tooltip', () => {
+ render(
+
+
+
+ );
+
+ expect((EuiToolTip as unknown as jest.Mock).mock.calls[0][0].content).toEqual(
+ initialPatterns
+ .filter((p) => p != null)
+ .sort()
+ .join(', ')
+ );
+ });
+
+ it('renders popover button inside tooltip', () => {
+ const wrapper = render(
+
+
+
+ );
+ const tooltip = wrapper.getByTestId('timeline-sourcerer-tooltip');
+ expect(within(tooltip).getByTestId('sourcerer-timeline-trigger')).toBeTruthy();
+ });
+
it('correctly filters options', () => {
const wrapper = render(
diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/pick_events.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/pick_events.tsx
index dbe04eccac52..6d86d7c0f133 100644
--- a/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/pick_events.tsx
+++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/search_or_filter/pick_events.tsx
@@ -295,6 +295,20 @@ const PickEventTypeComponents: React.FC = ({
[isPopoverOpen, sourcererScope.selectedPatterns]
);
+ const buttonWithTooptip = useMemo(() => {
+ return tooltipContent ? (
+
+ {button}
+
+ ) : (
+ button
+ );
+ }, [button, tooltipContent]);
+
const ButtonContent = useMemo(
() => (
@@ -326,69 +340,66 @@ const PickEventTypeComponents: React.FC = ({
return (
-
-
-
-
- <>{i18n.SELECT_INDEX_PATTERNS}>
-
-
- {filter}
-
-
- <>
-
- {comboBox}
- >
-
- {!showAdvanceSettings && (
- <>
-
-
- {i18n.CONFIGURE_INDEX_PATTERNS}
-
- >
- )}
-
-
-
-
- {i18n.DATA_SOURCES_RESET}
-
-
-
-
- {i18n.SAVE_INDEX_PATTERNS}
-
-
-
-
-
-
+
+
+
+ <>{i18n.SELECT_INDEX_PATTERNS}>
+
+
+ {filter}
+
+
+ <>
+
+ {comboBox}
+ >
+
+ {!showAdvanceSettings && (
+ <>
+
+
+ {i18n.CONFIGURE_INDEX_PATTERNS}
+
+ >
+ )}
+
+
+
+
+ {i18n.DATA_SOURCES_RESET}
+
+
+
+
+ {i18n.SAVE_INDEX_PATTERNS}
+
+
+
+
+
);
};