grafana/public/app/features/explore/LogsVolumePanel.test.tsx
Piotr Jamróz a7238ba933
Explore: Support mixed data sources for supplementary query (#63036)
* Consolidate logs volume logic (full range and limited)

* Fix showing limited histogram message

* Test passing meta data to logs volume provider

* Improve readability

* Clean up types

* Add basic support for multiple log volumes

* Move the comment back to the right place

* Improve readability

* Clean up the logic to support Logs Samples

* Update docs

* Sort log volumes

* Provide title to logs volume panel

* Move logs volume cache to the provider factory

* Add helper functions

* Reuse only if queries are the same

* Fix alphabetical sorting

* Move caching out of the provider

* Support errors and loading state

* Remove unused code

* Consolidate supplementary query utils

* Add tests for supplementaryQueries

* Update tests

* Simplify logs volume extra info

* Update tests

* Remove comment

* Update tests

* Fix hiding the histogram for hidden queries

* Simplify loading message

* Update tests

* Wait for full fallback histogram to load before showing it

* Fix a typo

* Add feedback comments

* Move feedback comments to github

* Do not filter out hidden queries as they may be used as references in other queries

* Group log volume by refId

* Support showing fallback histograms per query to avoid duplicates

* Improve type-checking

* Fix supplementaryQueries.test.ts

* Fix logsModel.test.ts

* Fix loading fallback results

* Fix unit tests

* WIP

* Update deprecated styles

* Simplify test

* Simplify rendering zoom info

* Update deprecated styles

* Simplify getLogsVolumeDataSourceInfo

* Simplify isLogsVolumeLimited()

* Simplify rendering zoom info
2023-03-07 15:00:11 +01:00

57 lines
1.8 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import React from 'react';
import { DataQueryResponse, LoadingState, EventBusSrv } from '@grafana/data';
import { LogsVolumePanel } from './LogsVolumePanel';
jest.mock('./Graph/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={() => {}}
onHiddenSeriesChanged={() => null}
eventBus={new EventBusSrv()}
/>
);
}
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();
});
it('does not show the panel when there is no volume data', () => {
renderPanel(undefined);
expect(screen.queryByText('Log volume')).not.toBeInTheDocument();
});
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();
});
});