Skip to content

Commit

Permalink
Revert "[Security Solution] Fix timeline dynamic batching (#204034)"
Browse files Browse the repository at this point in the history
This reverts commit 088169f.
  • Loading branch information
logeekal authored Jan 8, 2025
1 parent 3d9f34c commit efddadc
Show file tree
Hide file tree
Showing 18 changed files with 1,027 additions and 796 deletions.
1 change: 1 addition & 0 deletions packages/kbn-babel-preset/styled_components_files.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -40620,6 +40620,7 @@
"xpack.securitySolution.flyout.user.closeButton": "fermer",
"xpack.securitySolution.flyout.user.preview.viewDetailsLabel": "Afficher tous les détails de l'utilisateur",
"xpack.securitySolution.footer.autoRefreshActiveDescription": "Actualisation automatique active",
"xpack.securitySolution.footer.autoRefreshActiveTooltip": "Lorsque l'actualisation automatique est activée, la chronologie vous montrera les {numberOfItems} derniers événements correspondant à votre recherche.",
"xpack.securitySolution.footer.cancel": "Annuler",
"xpack.securitySolution.footer.data": "données",
"xpack.securitySolution.footer.events": "Événements",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40477,6 +40477,7 @@
"xpack.securitySolution.flyout.user.closeButton": "閉じる",
"xpack.securitySolution.flyout.user.preview.viewDetailsLabel": "すべてのユーザー詳細を表示",
"xpack.securitySolution.footer.autoRefreshActiveDescription": "自動更新アクション",
"xpack.securitySolution.footer.autoRefreshActiveTooltip": "自動更新が有効な間、タイムラインはクエリーに一致する最新の {numberOfItems} 件のイベントを表示します。",
"xpack.securitySolution.footer.cancel": "キャンセル",
"xpack.securitySolution.footer.data": "データ",
"xpack.securitySolution.footer.events": "イベント",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39881,6 +39881,7 @@
"xpack.securitySolution.flyout.user.closeButton": "关闭",
"xpack.securitySolution.flyout.user.preview.viewDetailsLabel": "显示全部用户详情",
"xpack.securitySolution.footer.autoRefreshActiveDescription": "自动刷新已启用",
"xpack.securitySolution.footer.autoRefreshActiveTooltip": "自动刷新已启用时,时间线将显示匹配查询的最近 {numberOfItems} 个事件。",
"xpack.securitySolution.footer.cancel": "取消",
"xpack.securitySolution.footer.data": "数据",
"xpack.securitySolution.footer.events": "事件",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export type OnColumnRemoved = (columnId: ColumnId) => void;

export type OnColumnResized = ({ columnId, delta }: { columnId: ColumnId; delta: number }) => void;

/** Invoked when a user clicks to load next batch */
export type OnFetchMoreRecords = VoidFunction;
/** Invoked when a user clicks to load more item */
export type OnFetchMoreRecords = (nextPage: number) => void;

/** Invoked when a user checks/un-checks a row */
export type OnRowSelected = ({
Expand Down

This file was deleted.

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();
});
});
});
Loading

0 comments on commit efddadc

Please sign in to comment.