mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: fix type errors in tests (#63270)
* fix any's in tests * fix more any's in tests * more test type fixes * fixing any's in tests part 3 * more test type fixes * fixing test any's p5 * some tidy up * fix template_srv
This commit is contained in:
@@ -8,7 +8,7 @@ import { AlertStatesWorker } from './AlertStatesWorker';
|
||||
import { DashboardQueryRunnerOptions } from './types';
|
||||
|
||||
jest.mock('@grafana/runtime', () => ({
|
||||
...(jest.requireActual('@grafana/runtime') as unknown as object),
|
||||
...jest.requireActual('@grafana/runtime'),
|
||||
getBackendSrv: () => backendSrv,
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Observable, of, throwError } from 'rxjs';
|
||||
|
||||
import { getDefaultTimeRange } from '@grafana/data';
|
||||
import { AnnotationQuery, DataSourceApi, getDefaultTimeRange } from '@grafana/data';
|
||||
import { createDashboardModelFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures';
|
||||
|
||||
import { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
|
||||
import * as store from '../../../../store/store';
|
||||
@@ -11,12 +12,12 @@ import { toAsyncOfResult } from './testHelpers';
|
||||
import { AnnotationQueryRunnerOptions } from './types';
|
||||
|
||||
function getDefaultOptions(): AnnotationQueryRunnerOptions {
|
||||
const annotation: any = {};
|
||||
const dashboard: any = {};
|
||||
const datasource: any = {
|
||||
const annotation = {} as AnnotationQuery;
|
||||
const dashboard = createDashboardModelFixture();
|
||||
const datasource = {
|
||||
annotationQuery: {},
|
||||
annotations: {},
|
||||
};
|
||||
} as unknown as DataSourceApi;
|
||||
const range = getDefaultTimeRange();
|
||||
|
||||
return { annotation, datasource, dashboard, range };
|
||||
@@ -36,10 +37,10 @@ describe('AnnotationsQueryRunner', () => {
|
||||
|
||||
describe('when canWork is called with correct props', () => {
|
||||
it('then it should return true', () => {
|
||||
const datasource: any = {
|
||||
const datasource = {
|
||||
annotationQuery: jest.fn(),
|
||||
annotations: {},
|
||||
};
|
||||
} as unknown as DataSourceApi;
|
||||
|
||||
expect(runner.canRun(datasource)).toBe(true);
|
||||
});
|
||||
@@ -47,7 +48,7 @@ describe('AnnotationsQueryRunner', () => {
|
||||
|
||||
describe('when canWork is called without datasource', () => {
|
||||
it('then it should return false', () => {
|
||||
const datasource: any = undefined;
|
||||
const datasource = undefined;
|
||||
|
||||
expect(runner.canRun(datasource)).toBe(false);
|
||||
});
|
||||
@@ -55,9 +56,9 @@ describe('AnnotationsQueryRunner', () => {
|
||||
|
||||
describe('when canWork is called with incorrect props', () => {
|
||||
it('then it should return false', () => {
|
||||
const datasource: any = {
|
||||
const datasource = {
|
||||
annotationQuery: jest.fn(),
|
||||
};
|
||||
} as unknown as DataSourceApi;
|
||||
|
||||
expect(runner.canRun(datasource)).toBe(false);
|
||||
});
|
||||
@@ -65,9 +66,9 @@ describe('AnnotationsQueryRunner', () => {
|
||||
|
||||
describe('when run is called with unsupported props', () => {
|
||||
it('then it should return the correct results', async () => {
|
||||
const datasource: any = {
|
||||
const datasource = {
|
||||
annotationQuery: jest.fn(),
|
||||
};
|
||||
} as unknown as DataSourceApi;
|
||||
const { options, executeAnnotationQueryMock } = getTestContext();
|
||||
|
||||
await expect(runner.run({ ...options, datasource })).toEmitValuesWith((received) => {
|
||||
|
||||
@@ -2,13 +2,18 @@ import { Subject, throwError } from 'rxjs';
|
||||
import { delay } from 'rxjs/operators';
|
||||
|
||||
import { AnnotationQuery } from '@grafana/data';
|
||||
import { setDataSourceSrv } from '@grafana/runtime';
|
||||
import { DataSourceSrv, setDataSourceSrv } from '@grafana/runtime';
|
||||
import { DashboardModel } from 'app/features/dashboard/state';
|
||||
|
||||
import { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
|
||||
import * as annotationsSrv from '../../../annotations/executeAnnotationQuery';
|
||||
|
||||
import { AnnotationsWorker } from './AnnotationsWorker';
|
||||
import { createDashboardQueryRunner, setDashboardQueryRunnerFactory } from './DashboardQueryRunner';
|
||||
import {
|
||||
createDashboardQueryRunner,
|
||||
DashboardQueryRunnerFactoryArgs,
|
||||
setDashboardQueryRunnerFactory,
|
||||
} from './DashboardQueryRunner';
|
||||
import { getDefaultOptions, LEGACY_DS_NAME, NEXT_GEN_DS_NAME, toAsyncOfResult } from './testHelpers';
|
||||
import { DashboardQueryRunnerOptions, DashboardQueryRunnerWorkerResult } from './types';
|
||||
import { emptyResult } from './utils';
|
||||
@@ -23,12 +28,12 @@ function getTestContext(dataSourceSrvRejects = false) {
|
||||
cancellations: () => cancellations,
|
||||
destroy: () => undefined,
|
||||
}));
|
||||
createDashboardQueryRunner({} as any);
|
||||
createDashboardQueryRunner({} as DashboardQueryRunnerFactoryArgs);
|
||||
const executeAnnotationQueryMock = jest
|
||||
.spyOn(annotationsSrv, 'executeAnnotationQuery')
|
||||
.mockReturnValue(toAsyncOfResult({ events: [{ id: 'NextGen' }] }));
|
||||
const annotationQueryMock = jest.fn().mockResolvedValue([{ id: 'Legacy' }]);
|
||||
const dataSourceSrvMock: any = {
|
||||
const dataSourceSrvMock = {
|
||||
get: async (name: string) => {
|
||||
if (dataSourceSrvRejects) {
|
||||
return Promise.reject(`Could not find datasource with name: ${name}`);
|
||||
@@ -47,7 +52,7 @@ function getTestContext(dataSourceSrvRejects = false) {
|
||||
|
||||
return {};
|
||||
},
|
||||
};
|
||||
} as DataSourceSrv;
|
||||
setDataSourceSrv(dataSourceSrvMock);
|
||||
const options = getDefaultOptions();
|
||||
|
||||
@@ -97,7 +102,7 @@ describe('AnnotationsWorker', () => {
|
||||
|
||||
describe('when canWork is called with incorrect props', () => {
|
||||
it('then it should return false', () => {
|
||||
const dashboard: any = { annotations: { list: [] } };
|
||||
const dashboard = { annotations: { list: [] } } as unknown as DashboardModel;
|
||||
const options = { ...getDefaultOptions(), dashboard };
|
||||
|
||||
expect(worker.canWork(options)).toBe(false);
|
||||
@@ -106,7 +111,7 @@ describe('AnnotationsWorker', () => {
|
||||
|
||||
describe('when run is called with incorrect props', () => {
|
||||
it('then it should return the correct results', async () => {
|
||||
const dashboard: any = { annotations: { list: [] } };
|
||||
const dashboard = { annotations: { list: [] } } as unknown as DashboardModel;
|
||||
const options = { ...getDefaultOptions(), dashboard };
|
||||
|
||||
await expect(worker.work(options)).toEmitValues([{ alertStates: [], annotations: [] }]);
|
||||
|
||||
@@ -2,7 +2,8 @@ import { throwError } from 'rxjs';
|
||||
import { delay, first } from 'rxjs/operators';
|
||||
|
||||
import { AlertState, AlertStateInfo } from '@grafana/data';
|
||||
import { setDataSourceSrv } from '@grafana/runtime';
|
||||
import { DataSourceSrv, setDataSourceSrv } from '@grafana/runtime';
|
||||
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
|
||||
import { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
|
||||
import { backendSrv } from '../../../../core/services/backend_srv';
|
||||
@@ -13,13 +14,13 @@ import { getDefaultOptions, LEGACY_DS_NAME, NEXT_GEN_DS_NAME, toAsyncOfResult }
|
||||
import { DashboardQueryRunner, DashboardQueryRunnerResult } from './types';
|
||||
|
||||
jest.mock('@grafana/runtime', () => ({
|
||||
...(jest.requireActual('@grafana/runtime') as unknown as object),
|
||||
...jest.requireActual('@grafana/runtime'),
|
||||
getBackendSrv: () => backendSrv,
|
||||
}));
|
||||
|
||||
function getTestContext() {
|
||||
jest.clearAllMocks();
|
||||
const timeSrvMock: any = { timeRange: jest.fn() };
|
||||
const timeSrvMock = { timeRange: jest.fn() } as unknown as TimeSrv;
|
||||
const options = getDefaultOptions();
|
||||
// These tests are setup so all the workers and runners are invoked once, this wouldn't be the case in real life
|
||||
const runner = createDashboardQueryRunner({ dashboard: options.dashboard, timeSrv: timeSrvMock });
|
||||
@@ -33,7 +34,7 @@ function getTestContext() {
|
||||
.spyOn(annotationsSrv, 'executeAnnotationQuery')
|
||||
.mockReturnValue(toAsyncOfResult({ events: [{ id: 'NextGen' }] }));
|
||||
const annotationQueryMock = jest.fn().mockResolvedValue([{ id: 'Legacy' }]);
|
||||
const dataSourceSrvMock: any = {
|
||||
const dataSourceSrvMock = {
|
||||
get: async (name: string) => {
|
||||
if (name === LEGACY_DS_NAME) {
|
||||
return {
|
||||
@@ -49,7 +50,7 @@ function getTestContext() {
|
||||
|
||||
return {};
|
||||
},
|
||||
};
|
||||
} as DataSourceSrv;
|
||||
setDataSourceSrv(dataSourceSrvMock);
|
||||
|
||||
return { runner, options, annotationQueryMock, executeAnnotationQueryMock, getMock };
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { getDefaultTimeRange } from '@grafana/data';
|
||||
import { AnnotationQuery, DataSourceApi, getDefaultTimeRange } from '@grafana/data';
|
||||
import { createDashboardModelFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures';
|
||||
|
||||
import { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
|
||||
import * as store from '../../../../store/store';
|
||||
@@ -7,11 +8,11 @@ import { LegacyAnnotationQueryRunner } from './LegacyAnnotationQueryRunner';
|
||||
import { AnnotationQueryRunnerOptions } from './types';
|
||||
|
||||
function getDefaultOptions(annotationQuery?: jest.Mock): AnnotationQueryRunnerOptions {
|
||||
const annotation: any = {};
|
||||
const dashboard: any = {};
|
||||
const datasource: any = {
|
||||
const annotation = {} as AnnotationQuery;
|
||||
const dashboard = createDashboardModelFixture();
|
||||
const datasource = {
|
||||
annotationQuery: annotationQuery ?? jest.fn().mockResolvedValue([{ id: '1' }]),
|
||||
};
|
||||
} as unknown as DataSourceApi;
|
||||
const range = getDefaultTimeRange();
|
||||
|
||||
return { annotation, datasource, dashboard, range };
|
||||
@@ -31,9 +32,9 @@ describe('LegacyAnnotationQueryRunner', () => {
|
||||
|
||||
describe('when canWork is called with correct props', () => {
|
||||
it('then it should return true', () => {
|
||||
const datasource: any = {
|
||||
const datasource = {
|
||||
annotationQuery: jest.fn(),
|
||||
};
|
||||
} as unknown as DataSourceApi;
|
||||
|
||||
expect(runner.canRun(datasource)).toBe(true);
|
||||
});
|
||||
@@ -41,7 +42,7 @@ describe('LegacyAnnotationQueryRunner', () => {
|
||||
|
||||
describe('when canWork is called without datasource', () => {
|
||||
it('then it should return false', () => {
|
||||
const datasource: any = undefined;
|
||||
const datasource = undefined;
|
||||
|
||||
expect(runner.canRun(datasource)).toBe(false);
|
||||
});
|
||||
@@ -49,10 +50,10 @@ describe('LegacyAnnotationQueryRunner', () => {
|
||||
|
||||
describe('when canWork is called with incorrect props', () => {
|
||||
it('then it should return false', () => {
|
||||
const datasource: any = {
|
||||
const datasource = {
|
||||
annotationQuery: jest.fn(),
|
||||
annotations: {},
|
||||
};
|
||||
} as unknown as DataSourceApi;
|
||||
|
||||
expect(runner.canRun(datasource)).toBe(false);
|
||||
});
|
||||
@@ -60,10 +61,10 @@ describe('LegacyAnnotationQueryRunner', () => {
|
||||
|
||||
describe('when run is called with unsupported props', () => {
|
||||
it('then it should return the correct results', async () => {
|
||||
const datasource: any = {
|
||||
const datasource = {
|
||||
annotationQuery: jest.fn(),
|
||||
annotations: {},
|
||||
};
|
||||
} as unknown as DataSourceApi;
|
||||
const options = { ...getDefaultOptions(), datasource };
|
||||
|
||||
await expect(runner.run(options)).toEmitValuesWith((received) => {
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
import { AnnotationEvent, getDefaultTimeRange } from '@grafana/data';
|
||||
import { AnnotationEvent, AnnotationQuery, getDefaultTimeRange } from '@grafana/data';
|
||||
import { Dashboard } from '@grafana/schema';
|
||||
import { DashboardModel } from 'app/features/dashboard/state';
|
||||
|
||||
import { SnapshotWorker } from './SnapshotWorker';
|
||||
import { DashboardQueryRunnerOptions } from './types';
|
||||
|
||||
function getDefaultOptions(): DashboardQueryRunnerOptions {
|
||||
const dashboard: any = {};
|
||||
const dashboard = new DashboardModel({} as Dashboard);
|
||||
const range = getDefaultTimeRange();
|
||||
|
||||
return { dashboard, range };
|
||||
}
|
||||
|
||||
function getSnapshotData(annotation: any, timeEnd: number | undefined = undefined): AnnotationEvent[] {
|
||||
function getSnapshotData(annotation: AnnotationQuery, timeEnd: number | undefined = undefined): AnnotationEvent[] {
|
||||
return [{ annotation, source: {}, timeEnd, time: 1 }];
|
||||
}
|
||||
|
||||
function getAnnotation(timeEnd: number | undefined = undefined) {
|
||||
function getAnnotation(timeEnd: number | undefined = undefined): AnnotationQuery {
|
||||
const annotation = {
|
||||
enable: true,
|
||||
hide: false,
|
||||
@@ -33,7 +35,7 @@ describe('SnapshotWorker', () => {
|
||||
|
||||
describe('when canWork is called with correct props', () => {
|
||||
it('then it should return true', () => {
|
||||
const dashboard: any = { annotations: { list: [getAnnotation(), {}] } };
|
||||
const dashboard = { annotations: { list: [getAnnotation(), {}] } } as unknown as DashboardModel;
|
||||
const options = { ...getDefaultOptions(), dashboard };
|
||||
|
||||
expect(worker.canWork(options)).toBe(true);
|
||||
@@ -42,7 +44,7 @@ describe('SnapshotWorker', () => {
|
||||
|
||||
describe('when canWork is called with incorrect props', () => {
|
||||
it('then it should return false', () => {
|
||||
const dashboard: any = { annotations: { list: [{}] } };
|
||||
const dashboard = { annotations: { list: [{}] } } as unknown as DashboardModel;
|
||||
const options = { ...getDefaultOptions(), dashboard };
|
||||
|
||||
expect(worker.canWork(options)).toBe(false);
|
||||
@@ -51,7 +53,7 @@ describe('SnapshotWorker', () => {
|
||||
|
||||
describe('when run is called with incorrect props', () => {
|
||||
it('then it should return the correct results', async () => {
|
||||
const dashboard: any = { annotations: { list: [{}] } };
|
||||
const dashboard = { annotations: { list: [{}] } } as unknown as DashboardModel;
|
||||
const options = { ...getDefaultOptions(), dashboard };
|
||||
|
||||
await expect(worker.work(options)).toEmitValues([{ alertStates: [], annotations: [] }]);
|
||||
@@ -64,7 +66,9 @@ describe('SnapshotWorker', () => {
|
||||
const noRegionEqualTime = getAnnotation(1);
|
||||
const region = getAnnotation(2);
|
||||
const noSnapshotData = { ...getAnnotation(), snapshotData: undefined };
|
||||
const dashboard: any = { annotations: { list: [noRegionUndefined, region, noSnapshotData, noRegionEqualTime] } };
|
||||
const dashboard = {
|
||||
annotations: { list: [noRegionUndefined, region, noSnapshotData, noRegionEqualTime] },
|
||||
} as unknown as DashboardModel;
|
||||
const options = { ...getDefaultOptions(), dashboard };
|
||||
|
||||
await expect(worker.work(options)).toEmitValuesWith((received) => {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { AlertState, getDefaultTimeRange, TimeRange } from '@grafana/data';
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
import { disableRBAC, enableRBAC, grantUserPermissions } from 'app/features/alerting/unified/mocks';
|
||||
import { Annotation } from 'app/features/alerting/unified/utils/constants';
|
||||
import { createDashboardModelFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures';
|
||||
import { AccessControlAction } from 'app/types/accessControl';
|
||||
import { PromAlertingRuleState, PromRuleDTO, PromRulesResponse, PromRuleType } from 'app/types/unified-alerting-dto';
|
||||
|
||||
@@ -14,12 +15,20 @@ import { UnifiedAlertStatesWorker } from './UnifiedAlertStatesWorker';
|
||||
import { DashboardQueryRunnerOptions } from './types';
|
||||
|
||||
jest.mock('@grafana/runtime', () => ({
|
||||
...(jest.requireActual('@grafana/runtime') as unknown as object),
|
||||
...jest.requireActual('@grafana/runtime'),
|
||||
getBackendSrv: () => backendSrv,
|
||||
}));
|
||||
|
||||
function getDefaultOptions(): DashboardQueryRunnerOptions {
|
||||
const dashboard: any = { id: 'an id', uid: 'a uid', meta: { publicDashboardAccessToken: '' } };
|
||||
const dashboard = createDashboardModelFixture(
|
||||
{
|
||||
id: 12345,
|
||||
uid: 'a uid',
|
||||
},
|
||||
{
|
||||
publicDashboardAccessToken: '',
|
||||
}
|
||||
);
|
||||
const range = getDefaultTimeRange();
|
||||
|
||||
return { dashboard, range };
|
||||
@@ -60,7 +69,7 @@ describe('UnifiedAlertStatesWorker', () => {
|
||||
|
||||
describe('when canWork is called with no dashboard id', () => {
|
||||
it('then it should return false', () => {
|
||||
const dashboard: any = {};
|
||||
const dashboard = createDashboardModelFixture({});
|
||||
const options = { ...getDefaultOptions(), dashboard };
|
||||
|
||||
expect(worker.canWork(options)).toBe(false);
|
||||
@@ -80,7 +89,7 @@ describe('UnifiedAlertStatesWorker', () => {
|
||||
describe('when run is called with incorrect props', () => {
|
||||
it('then it should return the correct results', async () => {
|
||||
const { getMock, options } = getTestContext();
|
||||
const dashboard: any = {};
|
||||
const dashboard = createDashboardModelFixture({});
|
||||
|
||||
await expect(worker.work({ ...options, dashboard })).toEmitValuesWith((received) => {
|
||||
expect(received).toHaveLength(1);
|
||||
@@ -168,8 +177,8 @@ describe('UnifiedAlertStatesWorker', () => {
|
||||
const results = received[0];
|
||||
expect(results).toEqual({
|
||||
alertStates: [
|
||||
{ id: 0, state: AlertState.Alerting, dashboardId: 'an id', panelId: 1 },
|
||||
{ id: 1, state: AlertState.Pending, dashboardId: 'an id', panelId: 2 },
|
||||
{ id: 0, state: AlertState.Alerting, dashboardId: 12345, panelId: 1 },
|
||||
{ id: 1, state: AlertState.Pending, dashboardId: 12345, panelId: 2 },
|
||||
],
|
||||
annotations: [],
|
||||
});
|
||||
@@ -179,7 +188,7 @@ describe('UnifiedAlertStatesWorker', () => {
|
||||
expect(getMock).toHaveBeenCalledWith(
|
||||
'/api/prometheus/grafana/api/v1/rules',
|
||||
{ dashboard_uid: 'a uid' },
|
||||
'dashboard-query-runner-unified-alert-states-an id'
|
||||
'dashboard-query-runner-unified-alert-states-12345'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,17 +4,19 @@ import { Subject } from 'rxjs';
|
||||
|
||||
// Importing this way to be able to spy on grafana/data
|
||||
import * as grafanaData from '@grafana/data';
|
||||
import { setDataSourceSrv, setEchoSrv } from '@grafana/runtime';
|
||||
import { DataSourceApi } from '@grafana/data';
|
||||
import { DataSourceSrv, setDataSourceSrv, setEchoSrv } from '@grafana/runtime';
|
||||
|
||||
import { Echo } from '../../../core/services/echo/Echo';
|
||||
import { createDashboardModelFixture } from '../../dashboard/state/__fixtures__/dashboardFixtures';
|
||||
|
||||
import {
|
||||
createDashboardQueryRunner,
|
||||
DashboardQueryRunnerFactoryArgs,
|
||||
setDashboardQueryRunnerFactory,
|
||||
} from './DashboardQueryRunner/DashboardQueryRunner';
|
||||
import { emptyResult } from './DashboardQueryRunner/utils';
|
||||
import { PanelQueryRunner } from './PanelQueryRunner';
|
||||
import { PanelQueryRunner, QueryRunnerOptions } from './PanelQueryRunner';
|
||||
|
||||
jest.mock('@grafana/data', () => ({
|
||||
__esModule: true,
|
||||
@@ -83,7 +85,7 @@ function describeQueryRunnerScenario(
|
||||
},
|
||||
};
|
||||
|
||||
const response: any = {
|
||||
const response = {
|
||||
data: [
|
||||
{
|
||||
target: 'hello',
|
||||
@@ -95,21 +97,21 @@ function describeQueryRunnerScenario(
|
||||
],
|
||||
};
|
||||
|
||||
setDataSourceSrv({} as any);
|
||||
setDataSourceSrv({} as DataSourceSrv);
|
||||
setDashboardQueryRunnerFactory(() => ({
|
||||
getResult: emptyResult,
|
||||
run: () => undefined,
|
||||
cancel: () => undefined,
|
||||
cancellations: () => new Subject<any>(),
|
||||
cancellations: () => new Subject(),
|
||||
destroy: () => undefined,
|
||||
}));
|
||||
createDashboardQueryRunner({} as any);
|
||||
createDashboardQueryRunner({} as DashboardQueryRunnerFactoryArgs);
|
||||
|
||||
beforeEach(async () => {
|
||||
setEchoSrv(new Echo());
|
||||
setupFn();
|
||||
|
||||
const datasource: any = {
|
||||
const datasource = {
|
||||
name: 'TestDB',
|
||||
uid: 'TestDB-uid',
|
||||
interval: ctx.dsInterval,
|
||||
@@ -119,21 +121,21 @@ function describeQueryRunnerScenario(
|
||||
},
|
||||
getRef: () => ({ type: 'test', uid: 'TestDB-uid' }),
|
||||
testDatasource: jest.fn(),
|
||||
};
|
||||
} as unknown as DataSourceApi;
|
||||
|
||||
const args: any = {
|
||||
const args = {
|
||||
datasource,
|
||||
scopedVars: ctx.scopedVars,
|
||||
minInterval: ctx.minInterval,
|
||||
maxDataPoints: ctx.maxDataPoints,
|
||||
maxDataPoints: ctx.maxDataPoints ?? Infinity,
|
||||
timeRange: {
|
||||
from: grafanaData.dateTime().subtract(1, 'days'),
|
||||
to: grafanaData.dateTime(),
|
||||
raw: { from: '1d', to: 'now' },
|
||||
},
|
||||
panelId: 1,
|
||||
queries: [{ refId: 'A', test: 1 }],
|
||||
};
|
||||
queries: [{ refId: 'A' }],
|
||||
} as QueryRunnerOptions;
|
||||
|
||||
ctx.runner = new PanelQueryRunner(panelConfig || defaultPanelConfig);
|
||||
ctx.runner.getData({ withTransforms: true, withFieldConfig: true }).subscribe({
|
||||
|
||||
@@ -115,7 +115,7 @@ function runRequestScenario(desc: string, fn: (ctx: ScenarioCtx) => void) {
|
||||
function runRequestScenarioThatThrows(desc: string, fn: (ctx: ScenarioCtx) => void) {
|
||||
describe(desc, () => {
|
||||
const ctx = new ScenarioCtx();
|
||||
let consoleSpy: jest.SpyInstance<any>;
|
||||
let consoleSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
||||
Reference in New Issue
Block a user