-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SIEM] fix timelineType for selectable timeline (#66549)
* fix timelineType for selectable timeline * fix cypress test * fix cypress test * disable template timeline's tab * rename flag * update filter to return only default template * update wording * update placeholder according to timelinetype * fix i18n Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
c0a1e90
commit 72d31e3
Showing
15 changed files
with
182 additions
and
38 deletions.
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
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
112 changes: 112 additions & 0 deletions
112
x-pack/plugins/siem/public/timelines/components/timeline/selectable_timeline/index.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,112 @@ | ||
/* | ||
* 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 { shallow, ShallowWrapper, mount } from 'enzyme'; | ||
import { TimelineType } from '../../../../../common/types/timeline'; | ||
import { SortFieldTimeline, Direction } from '../../../../graphql/types'; | ||
import { SearchProps } from './'; | ||
|
||
describe('SelectableTimeline', () => { | ||
const mockFetchAllTimeline = jest.fn(); | ||
const mockEuiSelectable = jest.fn(); | ||
|
||
jest.doMock('@elastic/eui', () => { | ||
const originalModule = jest.requireActual('@elastic/eui'); | ||
return { | ||
...originalModule, | ||
EuiSelectable: mockEuiSelectable.mockImplementation(({ children }) => <div>{children}</div>), | ||
}; | ||
}); | ||
|
||
jest.doMock('../../../containers/all', () => { | ||
return { | ||
useGetAllTimeline: jest.fn(() => ({ | ||
fetchAllTimeline: mockFetchAllTimeline, | ||
timelines: [], | ||
})), | ||
}; | ||
}); | ||
|
||
const { | ||
SelectableTimeline, | ||
|
||
ORIGINAL_PAGE_SIZE, | ||
} = jest.requireActual('./'); | ||
|
||
const props = { | ||
hideUntitled: false, | ||
getSelectableOptions: jest.fn(), | ||
onClosePopover: jest.fn(), | ||
onTimelineChange: jest.fn(), | ||
timelineType: TimelineType.default, | ||
}; | ||
|
||
describe('should render', () => { | ||
let wrapper: ShallowWrapper; | ||
|
||
describe('timeline', () => { | ||
beforeAll(() => { | ||
wrapper = shallow(<SelectableTimeline {...props} />); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('render placeholder', () => { | ||
const searchProps: SearchProps = wrapper | ||
.find('[data-test-subj="selectable-input"]') | ||
.prop('searchProps'); | ||
expect(searchProps.placeholder).toEqual('e.g. Timeline name or description'); | ||
}); | ||
}); | ||
|
||
describe('template timeline', () => { | ||
const templateTimelineProps = { ...props, timelineType: TimelineType.template }; | ||
beforeAll(() => { | ||
wrapper = shallow(<SelectableTimeline {...templateTimelineProps} />); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('render placeholder', () => { | ||
const searchProps: SearchProps = wrapper | ||
.find('[data-test-subj="selectable-input"]') | ||
.prop('searchProps'); | ||
expect(searchProps.placeholder).toEqual('e.g. Template timeline name or description'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('fetchAllTimeline', () => { | ||
const args = { | ||
pageInfo: { | ||
pageIndex: 1, | ||
pageSize: ORIGINAL_PAGE_SIZE, | ||
}, | ||
search: '', | ||
sort: { | ||
sortField: SortFieldTimeline.updated, | ||
sortOrder: Direction.desc, | ||
}, | ||
onlyUserFavorite: false, | ||
timelineType: TimelineType.default, | ||
}; | ||
beforeAll(() => { | ||
mount(<SelectableTimeline {...props} />); | ||
}); | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('shoule be called with correct args', () => { | ||
expect(mockFetchAllTimeline).toBeCalledWith(args); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.