-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "[Security Solution] Fix timeline dynamic batching (#204034)"
This reverts commit 088169f.
- Loading branch information
Showing
18 changed files
with
1,027 additions
and
796 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
51 changes: 0 additions & 51 deletions
51
...ons/security/plugins/security_solution/public/common/mock/mock_timeline_search_service.ts
This file was deleted.
Oops, something went wrong.
236 changes: 236 additions & 0 deletions
236
...rity/plugins/security_solution/public/timelines/components/timeline/footer/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,236 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import { TestProviders } from '../../../../common/mock/test_providers'; | ||
|
||
import { FooterComponent, PagingControlComponent } from '.'; | ||
import { TimelineId } from '../../../../../common/types/timeline'; | ||
|
||
jest.mock('../../../../common/lib/kibana'); | ||
|
||
describe('Footer Timeline Component', () => { | ||
const loadMore = jest.fn(); | ||
const updatedAt = 1546878704036; | ||
const serverSideEventCount = 15546; | ||
const itemsCount = 2; | ||
|
||
describe('rendering', () => { | ||
it('shoult render the default timeline footer', () => { | ||
render( | ||
<TestProviders> | ||
<FooterComponent | ||
activePage={0} | ||
updatedAt={updatedAt} | ||
height={100} | ||
id={TimelineId.test} | ||
isLive={false} | ||
isLoading={false} | ||
itemsCount={itemsCount} | ||
itemsPerPage={2} | ||
itemsPerPageOptions={[1, 5, 10, 20]} | ||
onChangePage={loadMore} | ||
totalCount={serverSideEventCount} | ||
/> | ||
</TestProviders> | ||
); | ||
|
||
expect(screen.getByTestId('timeline-footer')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the loading panel at the beginning ', () => { | ||
render( | ||
<TestProviders> | ||
<FooterComponent | ||
activePage={0} | ||
updatedAt={updatedAt} | ||
height={100} | ||
id={TimelineId.test} | ||
isLive={false} | ||
isLoading={true} | ||
itemsCount={itemsCount} | ||
itemsPerPage={2} | ||
itemsPerPageOptions={[1, 5, 10, 20]} | ||
onChangePage={loadMore} | ||
totalCount={serverSideEventCount} | ||
/> | ||
</TestProviders> | ||
); | ||
|
||
expect(screen.getByTestId('LoadingPanelTimeline')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the loadMore button if it needs to fetch more', () => { | ||
render( | ||
<TestProviders> | ||
<FooterComponent | ||
activePage={0} | ||
updatedAt={updatedAt} | ||
height={100} | ||
id={TimelineId.test} | ||
isLive={false} | ||
isLoading={false} | ||
itemsCount={itemsCount} | ||
itemsPerPage={2} | ||
itemsPerPageOptions={[1, 5, 10, 20]} | ||
onChangePage={loadMore} | ||
totalCount={serverSideEventCount} | ||
/> | ||
</TestProviders> | ||
); | ||
|
||
expect(screen.getByTestId('timeline-pagination')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render `Loading...` when fetching new data', () => { | ||
render( | ||
<PagingControlComponent | ||
activePage={0} | ||
totalCount={30} | ||
totalPages={3} | ||
onPageClick={loadMore} | ||
isLoading={true} | ||
/> | ||
); | ||
|
||
expect(screen.queryByTestId('LoadingPanelTimeline')).not.toBeInTheDocument(); | ||
expect(screen.getByText('Loading...')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the Pagination in the more load button when fetching new data', () => { | ||
render( | ||
<PagingControlComponent | ||
activePage={0} | ||
totalCount={30} | ||
totalPages={3} | ||
onPageClick={loadMore} | ||
isLoading={false} | ||
/> | ||
); | ||
|
||
expect(screen.getByTestId('timeline-pagination')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should NOT render the loadMore button because there is nothing else to fetch', () => { | ||
render( | ||
<TestProviders> | ||
<FooterComponent | ||
activePage={0} | ||
updatedAt={updatedAt} | ||
height={100} | ||
id={TimelineId.test} | ||
isLive={false} | ||
isLoading={true} | ||
itemsCount={itemsCount} | ||
itemsPerPage={2} | ||
itemsPerPageOptions={[1, 5, 10, 20]} | ||
onChangePage={loadMore} | ||
totalCount={serverSideEventCount} | ||
/> | ||
</TestProviders> | ||
); | ||
|
||
expect(screen.queryByTestId('timeline-pagination')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the popover to select new itemsPerPage in timeline', () => { | ||
render( | ||
<TestProviders> | ||
<FooterComponent | ||
activePage={0} | ||
updatedAt={updatedAt} | ||
height={100} | ||
id={TimelineId.test} | ||
isLive={false} | ||
isLoading={false} | ||
itemsCount={itemsCount} | ||
itemsPerPage={1} | ||
itemsPerPageOptions={[1, 5, 10, 20]} | ||
onChangePage={loadMore} | ||
totalCount={serverSideEventCount} | ||
/> | ||
</TestProviders> | ||
); | ||
|
||
fireEvent.click(screen.getByTestId('local-events-count-button')); | ||
expect(screen.getByTestId('timelinePickSizeRow')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('Events', () => { | ||
it('should call loadmore when clicking on the button load more', () => { | ||
render( | ||
<TestProviders> | ||
<FooterComponent | ||
activePage={0} | ||
updatedAt={updatedAt} | ||
height={100} | ||
id={TimelineId.test} | ||
isLive={false} | ||
isLoading={false} | ||
itemsCount={itemsCount} | ||
itemsPerPage={2} | ||
itemsPerPageOptions={[1, 5, 10, 20]} | ||
onChangePage={loadMore} | ||
totalCount={serverSideEventCount} | ||
/> | ||
</TestProviders> | ||
); | ||
|
||
fireEvent.click(screen.getByTestId('pagination-button-next')); | ||
expect(loadMore).toBeCalled(); | ||
}); | ||
|
||
it('should render the auto-refresh message instead of load more button when stream live is on', () => { | ||
render( | ||
<TestProviders> | ||
<FooterComponent | ||
activePage={0} | ||
updatedAt={updatedAt} | ||
height={100} | ||
id={TimelineId.test} | ||
isLive={true} | ||
isLoading={false} | ||
itemsCount={itemsCount} | ||
itemsPerPage={2} | ||
itemsPerPageOptions={[1, 5, 10, 20]} | ||
onChangePage={loadMore} | ||
totalCount={serverSideEventCount} | ||
/> | ||
</TestProviders> | ||
); | ||
|
||
expect(screen.queryByTestId('timeline-pagination')).not.toBeInTheDocument(); | ||
expect(screen.getByTestId('is-live-on-message')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the load more button when stream live is off', () => { | ||
render( | ||
<TestProviders> | ||
<FooterComponent | ||
activePage={0} | ||
updatedAt={updatedAt} | ||
height={100} | ||
id={TimelineId.test} | ||
isLive={false} | ||
isLoading={false} | ||
itemsCount={itemsCount} | ||
itemsPerPage={2} | ||
itemsPerPageOptions={[1, 5, 10, 20]} | ||
onChangePage={loadMore} | ||
totalCount={serverSideEventCount} | ||
/> | ||
</TestProviders> | ||
); | ||
|
||
expect(screen.getByTestId('timeline-pagination')).toBeInTheDocument(); | ||
expect(screen.queryByTestId('is-live-on-message')).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.