2021-09-30 08:46:11 -05:00
|
|
|
import { render, screen } from '@testing-library/react';
|
2022-04-22 08:33:13 -05:00
|
|
|
import React from 'react';
|
|
|
|
|
2022-11-03 04:55:02 -05:00
|
|
|
import { DataQueryResponse, LoadingState, EventBusSrv } from '@grafana/data';
|
2021-09-30 08:46:11 -05:00
|
|
|
|
2022-04-22 08:33:13 -05:00
|
|
|
import { LogsVolumePanel } from './LogsVolumePanel';
|
|
|
|
|
2022-11-16 04:16:27 -06:00
|
|
|
jest.mock('./Graph/ExploreGraph', () => {
|
2021-09-30 08:46:11 -05:00
|
|
|
const ExploreGraph = () => <span>ExploreGraph</span>;
|
|
|
|
return {
|
|
|
|
ExploreGraph,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
function renderPanel(logsVolumeData?: DataQueryResponse) {
|
|
|
|
render(
|
|
|
|
<LogsVolumePanel
|
|
|
|
absoluteRange={{ from: 0, to: 1 }}
|
|
|
|
timeZone="timeZone"
|
|
|
|
splitOpen={() => {}}
|
|
|
|
width={100}
|
|
|
|
onUpdateTimeRange={() => {}}
|
|
|
|
logsVolumeData={logsVolumeData}
|
2021-10-18 05:22:41 -05:00
|
|
|
onLoadLogsVolume={() => {}}
|
2022-06-07 07:27:32 -05:00
|
|
|
onHiddenSeriesChanged={() => null}
|
2022-11-03 04:55:02 -05:00
|
|
|
eventBus={new EventBusSrv()}
|
2023-04-11 03:05:04 -05:00
|
|
|
allLogsVolumeMaximum={20}
|
2021-09-30 08:46:11 -05:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('LogsVolumePanel', () => {
|
|
|
|
it('shows no volume data', () => {
|
|
|
|
renderPanel({ state: LoadingState.Done, error: undefined, data: [] });
|
|
|
|
expect(screen.getByText('No volume data.')).toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders logs volume histogram graph', () => {
|
|
|
|
renderPanel({ state: LoadingState.Done, error: undefined, data: [{}] });
|
|
|
|
expect(screen.getByText('ExploreGraph')).toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
2021-10-18 05:22:41 -05:00
|
|
|
it('does not show the panel when there is no volume data', () => {
|
2021-09-30 08:46:11 -05:00
|
|
|
renderPanel(undefined);
|
2021-11-10 04:20:30 -06:00
|
|
|
expect(screen.queryByText('Log volume')).not.toBeInTheDocument();
|
2021-09-30 08:46:11 -05:00
|
|
|
});
|
2023-02-10 07:43:41 -06:00
|
|
|
|
|
|
|
it('renders a loading indicator when data is streaming', () => {
|
|
|
|
renderPanel({ state: LoadingState.Streaming, error: undefined, data: [{}] });
|
|
|
|
expect(screen.getByTestId('logs-volume-streaming')).toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render loading indicator when data is not streaming', () => {
|
|
|
|
renderPanel({ state: LoadingState.Done, error: undefined, data: [{}] });
|
|
|
|
expect(screen.queryByText('logs-volume-streaming')).not.toBeInTheDocument();
|
|
|
|
});
|
2021-09-30 08:46:11 -05:00
|
|
|
});
|