Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierM committed Dec 19, 2020
1 parent b0009ca commit 565872d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import '../../mock/match_media';
import { useKibana } from '../../lib/kibana';
import { TestProviders } from '../../mock';
import { FilterManager } from '../../../../../../../src/plugins/data/public';
import { useAddToTimeline } from '../../hooks/use_add_to_timeline';
import { useSourcererScope } from '../../containers/sourcerer';
import { DraggableWrapperHoverContent } from './draggable_wrapper_hover_content';
import {
Expand All @@ -41,8 +40,14 @@ jest.mock('uuid', () => {
v4: jest.fn(() => 'uuid.v4()'),
};
});

jest.mock('../../hooks/use_add_to_timeline');
const mockStartDragToTimeline = jest.fn();
jest.mock('../../hooks/use_add_to_timeline', () => {
const original = jest.requireActual('../../hooks/use_add_to_timeline');
return {
...original,
useAddToTimeline: () => ({ startDragToTimeline: mockStartDragToTimeline }),
};
});
const mockAddFilters = jest.fn();
const mockGetTimelineFilterManager = jest.fn().mockReturnValue({
addFilters: mockAddFilters,
Expand Down Expand Up @@ -78,8 +83,7 @@ const defaultProps = {

describe('DraggableWrapperHoverContent', () => {
beforeAll(() => {
// our mock implementation of the useAddToTimeline hook returns a mock startDragToTimeline function:
(useAddToTimeline as jest.Mock).mockReturnValue({ startDragToTimeline: jest.fn() });
mockStartDragToTimeline.mockReset();
(useSourcererScope as jest.Mock).mockReturnValue({
browserFields: mockBrowserFields,
selectedPatterns: [],
Expand Down Expand Up @@ -376,7 +380,7 @@ describe('DraggableWrapperHoverContent', () => {
});
});

test('when clicked, it invokes the `startDragToTimeline` function returned by the `useAddToTimeline` hook', () => {
test('when clicked, it invokes the `startDragToTimeline` function returned by the `useAddToTimeline` hook', async () => {
const wrapper = mount(
<TestProviders>
<DraggableWrapperHoverContent
Expand All @@ -389,19 +393,11 @@ describe('DraggableWrapperHoverContent', () => {
</TestProviders>
);

// The following "startDragToTimeline" function returned by our mock
// useAddToTimeline hook is called when the user clicks the
// Add to timeline investigation action:
const { startDragToTimeline } = useAddToTimeline({
draggableId,
fieldName: aggregatableStringField,
});

wrapper.find('[data-test-subj="add-to-timeline"]').first().simulate('click');
wrapper.update();

waitFor(() => {
expect(startDragToTimeline).toHaveBeenCalled();
await waitFor(() => {
wrapper.update();
expect(mockStartDragToTimeline).toHaveBeenCalled();
});
});
});
Expand Down Expand Up @@ -461,7 +457,7 @@ describe('DraggableWrapperHoverContent', () => {
expect(wrapper.find('[data-test-subj="show-top-field"]').first().exists()).toBe(false);
});

test(`it should invokes goGetTimelineId when user is over the 'Show top field' button`, () => {
test(`it should invokes goGetTimelineId when user is over the 'Show top field' button`, async () => {
const allowlistedField = 'signal.rule.name';
const wrapper = mount(
<TestProviders>
Expand All @@ -476,7 +472,7 @@ describe('DraggableWrapperHoverContent', () => {
);
const button = wrapper.find(`[data-test-subj="show-top-field"]`).first();
button.simulate('mouseenter');
waitFor(() => {
await waitFor(() => {
expect(goGetTimelineId).toHaveBeenCalledWith(true);
});
});
Expand All @@ -502,7 +498,7 @@ describe('DraggableWrapperHoverContent', () => {
expect(toggleTopN).toBeCalled();
});

test(`it does NOT render the Top N histogram when when showTopN is false`, async () => {
test(`it does NOT render the Top N histogram when when showTopN is false`, () => {
const allowlistedField = 'signal.rule.name';
const wrapper = mount(
<TestProviders>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const DataDrivenColumns = React.memo<Props>(
</EuiScreenReaderOnly>
)}

{hasRowRenderers && (
{notesCount && (
<EuiScreenReaderOnly data-test-subj="hasNotesScreenReaderOnly">
<p>{i18n.EVENT_HAS_NOTES({ row: ariaRowindex, notesCount })}</p>
</EuiScreenReaderOnly>
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 565872d

Please sign in to comment.