mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Add Loki ASH tests checking proper rendering of timeline chart component (#83235)
Add Loki ASH tests checking proper rendering of timeline chart component
This commit is contained in:
parent
a4cc4179c8
commit
cc9ff3f8c9
@ -3,7 +3,8 @@ import { render, waitFor } from '@testing-library/react';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import React from 'react';
|
||||
import { byRole, byText } from 'testing-library-selector';
|
||||
import { Props } from 'react-virtualized-auto-sizer';
|
||||
import { byRole, byTestId, byText } from 'testing-library-selector';
|
||||
|
||||
import { DataFrameJSON } from '@grafana/data';
|
||||
import { setBackendSrv } from '@grafana/runtime';
|
||||
@ -15,6 +16,16 @@ import LokiStateHistory from './LokiStateHistory';
|
||||
|
||||
const server = setupServer();
|
||||
|
||||
jest.mock('react-virtualized-auto-sizer', () => {
|
||||
return ({ children }: Props) =>
|
||||
children({
|
||||
height: 600,
|
||||
scaledHeight: 600,
|
||||
scaledWidth: 1,
|
||||
width: 1,
|
||||
});
|
||||
});
|
||||
|
||||
beforeAll(() => {
|
||||
setBackendSrv(backendSrv);
|
||||
server.listen({ onUnhandledRequest: 'error' });
|
||||
@ -80,6 +91,7 @@ const ui = {
|
||||
timestampViewer: byRole('list', { name: 'State history by timestamp' }),
|
||||
record: byRole('listitem'),
|
||||
noRecords: byText('No state transitions have occurred in the last 30 days'),
|
||||
timelineChart: byTestId('uplot-main-div'),
|
||||
};
|
||||
|
||||
describe('LokiStateHistory', () => {
|
||||
@ -96,6 +108,14 @@ describe('LokiStateHistory', () => {
|
||||
expect(timestampViewerElement).toHaveTextContent('/api/folders/:uid/');
|
||||
});
|
||||
|
||||
it('should render timeline chart', async () => {
|
||||
render(<LokiStateHistory ruleUID="ABC123" />, { wrapper: TestProvider });
|
||||
|
||||
await waitFor(() => expect(ui.loadingIndicator.query()).not.toBeInTheDocument());
|
||||
|
||||
expect(ui.timelineChart.get()).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render no entries message when no records are returned', async () => {
|
||||
server.use(
|
||||
http.get('/api/v1/rules/history', () =>
|
||||
|
Loading…
Reference in New Issue
Block a user