-
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
[SIEM] Cases] Capture timeline click and open timeline in case view #66327
Merged
stephmilovic
merged 14 commits into
elastic:master
from
stephmilovic:capture-case-timeline-click
May 18, 2020
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6af2043
init commit
stephmilovic 57d8a80
working
stephmilovic 98a4bc2
tests
stephmilovic 0f64c89
fix preview mode
stephmilovic 4388801
Merge branch 'master' into capture-case-timeline-click
stephmilovic 59fc054
Merge branch 'master' into capture-case-timeline-click
stephmilovic 3d65ba8
added another test
stephmilovic 5a44d4c
Merge branch 'master' into capture-case-timeline-click
elasticmachine 123d5db
fix cypress tests
stephmilovic 19be127
Merge branch 'capture-case-timeline-click' of github.com:stephmilovic…
stephmilovic 4ae1afd
Merge branch 'master' into capture-case-timeline-click
elasticmachine 2ca25f8
resolve conflict
stephmilovic 69c144f
Merge branch 'capture-case-timeline-click' of github.com:stephmilovic…
stephmilovic d725c27
Merge branch 'master' into capture-case-timeline-click
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
x-pack/plugins/siem/public/cases/components/user_action_tree/user_action_markdown.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { Router, mockHistory } from '../__mock__/router'; | ||
import { UserActionMarkdown } from './user_action_markdown'; | ||
import { TestProviders } from '../../../common/mock'; | ||
import * as timelineHelpers from '../../../timelines/components/open_timeline/helpers'; | ||
import { useApolloClient } from '../../../common/utils/apollo_context'; | ||
const mockUseApolloClient = useApolloClient as jest.Mock; | ||
jest.mock('../../../common/utils/apollo_context'); | ||
const onChangeEditable = jest.fn(); | ||
const onSaveContent = jest.fn(); | ||
|
||
const timelineId = '1e10f150-949b-11ea-b63c-2bc51864784c'; | ||
const defaultProps = { | ||
content: `A link to a timeline [timeline](http://localhost:5601/app/siem#/timelines?timeline=(id:'${timelineId}',isOpen:!t))`, | ||
id: 'markdown-id', | ||
isEditable: false, | ||
onChangeEditable, | ||
onSaveContent, | ||
}; | ||
|
||
describe('UserActionMarkdown ', () => { | ||
const queryTimelineByIdSpy = jest.spyOn(timelineHelpers, 'queryTimelineById'); | ||
beforeEach(() => { | ||
mockUseApolloClient.mockClear(); | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
it('Opens timeline when timeline link clicked - isEditable: false', async () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<Router history={mockHistory}> | ||
<UserActionMarkdown {...defaultProps} /> | ||
</Router> | ||
</TestProviders> | ||
); | ||
wrapper | ||
.find(`[data-test-subj="markdown-timeline-link"]`) | ||
.first() | ||
.simulate('click'); | ||
|
||
expect(queryTimelineByIdSpy).toBeCalledWith({ | ||
apolloClient: mockUseApolloClient(), | ||
timelineId, | ||
updateIsLoading: expect.any(Function), | ||
updateTimeline: expect.any(Function), | ||
}); | ||
}); | ||
|
||
it('Opens timeline when timeline link clicked - isEditable: true ', async () => { | ||
const wrapper = mount( | ||
<TestProviders> | ||
<Router history={mockHistory}> | ||
<UserActionMarkdown {...{ ...defaultProps, isEditable: true }} /> | ||
</Router> | ||
</TestProviders> | ||
); | ||
wrapper | ||
.find(`[data-test-subj="preview-tab"]`) | ||
.first() | ||
.simulate('click'); | ||
wrapper | ||
.find(`[data-test-subj="markdown-timeline-link"]`) | ||
.first() | ||
.simulate('click'); | ||
expect(queryTimelineByIdSpy).toBeCalledWith({ | ||
apolloClient: mockUseApolloClient(), | ||
timelineId, | ||
updateIsLoading: expect.any(Function), | ||
updateTimeline: expect.any(Function), | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is defaulted to false, so not required