mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Skip logfmt errors * Run volume queries as range queries * Remove auto-skipping parsing errors * Remove auto-skipping parsing errors * Cache logs volume results * Remove auto-loading * Fix tests * Clean up * Disable logs volume in live streaming * Clean up * Add logs volume timeout * Switch tooltip mode * Increase timeout to 15s * Fix test * Change timeout to 10 seconds * Remove unused code * Extract styles * Remove info about zoom level
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import React from 'react';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { LogsVolumePanel } from './LogsVolumePanel';
|
|
import { DataQueryResponse, LoadingState } from '@grafana/data';
|
|
|
|
jest.mock('./ExploreGraph', () => {
|
|
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}
|
|
onLoadLogsVolume={() => {}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
describe('LogsVolumePanel', () => {
|
|
it('shows loading message', () => {
|
|
renderPanel({ state: LoadingState.Loading, error: undefined, data: [] });
|
|
expect(screen.getByText('Logs volume is loading...')).toBeInTheDocument();
|
|
});
|
|
|
|
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();
|
|
});
|
|
|
|
it('shows error message', () => {
|
|
renderPanel({ state: LoadingState.Error, error: { data: { message: 'Test error message' } }, data: [] });
|
|
expect(screen.getByText('Failed to load volume logs for this query')).toBeInTheDocument();
|
|
expect(screen.getByText('Test error message')).toBeInTheDocument();
|
|
});
|
|
|
|
it('does not show the panel when there is no volume data', () => {
|
|
renderPanel(undefined);
|
|
expect(screen.queryByText('Logs volume')).not.toBeInTheDocument();
|
|
});
|
|
});
|