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:
@@ -1,6 +1,8 @@
|
||||
import { FieldType, locationUtil, toDataFrame, VariableOrigin } from '@grafana/data';
|
||||
import { FieldType, GrafanaConfig, locationUtil, toDataFrame, VariableOrigin } from '@grafana/data';
|
||||
import { setTemplateSrv } from '@grafana/runtime';
|
||||
import { ContextSrv } from 'app/core/services/context_srv';
|
||||
import { getTimeSrv, setTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||
import { TimeModel } from 'app/features/dashboard/state/TimeModel';
|
||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
import { variableAdapters } from 'app/features/variables/adapters';
|
||||
import { createQueryVariableAdapter } from 'app/features/variables/query/adapter';
|
||||
@@ -21,13 +23,13 @@ describe('linkSrv', () => {
|
||||
let originalTimeService: TimeSrv;
|
||||
|
||||
function initLinkSrv() {
|
||||
const _dashboard: any = {
|
||||
const _dashboard = {
|
||||
time: { from: 'now-6h', to: 'now' },
|
||||
getTimezone: jest.fn(() => 'browser'),
|
||||
timeRangeUpdated: () => {},
|
||||
};
|
||||
} as unknown as TimeModel;
|
||||
|
||||
const timeSrv = new TimeSrv({} as any);
|
||||
const timeSrv = new TimeSrv({} as ContextSrv);
|
||||
timeSrv.init(_dashboard);
|
||||
timeSrv.setTime({ from: 'now-1h', to: 'now' });
|
||||
_dashboard.refresh = false;
|
||||
@@ -127,9 +129,9 @@ describe('linkSrv', () => {
|
||||
"when link '$url' and config.appSubUrl set to '$appSubUrl' then result should be '$expected'",
|
||||
({ url, appSubUrl, expected }) => {
|
||||
locationUtil.initialize({
|
||||
config: { appSubUrl } as any,
|
||||
getVariablesUrlParams: (() => {}) as any,
|
||||
getTimeRangeForUrl: (() => {}) as any,
|
||||
config: { appSubUrl } as GrafanaConfig,
|
||||
getVariablesUrlParams: jest.fn(),
|
||||
getTimeRangeForUrl: jest.fn(),
|
||||
});
|
||||
|
||||
const link = linkSrv.getDataLinkUIModel(
|
||||
|
||||
@@ -19,7 +19,7 @@ jest.unmock('app/features/plugins/plugin_loader');
|
||||
for (const pluginId of panelsToCheckFirst) {
|
||||
config.panels[pluginId] = {
|
||||
module: `app/plugins/panel/${pluginId}/module`,
|
||||
} as any;
|
||||
} as PanelPluginMeta;
|
||||
}
|
||||
|
||||
config.panels['text'] = {
|
||||
|
||||
@@ -4,23 +4,23 @@ import { filterPluginList } from './util';
|
||||
|
||||
describe('panel state utils', () => {
|
||||
it('should include timeseries in a graph query', async () => {
|
||||
const pluginsList: PanelPluginMeta[] = [
|
||||
{ id: 'graph', name: 'Graph (old)' } as any,
|
||||
const pluginsList = [
|
||||
{ id: 'graph', name: 'Graph (old)' },
|
||||
{ id: 'timeseries', name: 'Graph (old)' },
|
||||
{ id: 'timeline', name: 'Timeline' },
|
||||
];
|
||||
const found = filterPluginList(pluginsList, escapeStringForRegex('gra'), { id: 'xyz' } as any);
|
||||
] as PanelPluginMeta[];
|
||||
const found = filterPluginList(pluginsList, escapeStringForRegex('gra'), { id: 'xyz' } as PanelPluginMeta);
|
||||
expect(found.map((v) => v.id)).toEqual(['graph', 'timeseries']);
|
||||
});
|
||||
|
||||
it('should handle escaped regex characters in the search query (e.g. -)', async () => {
|
||||
const pluginsList: PanelPluginMeta[] = [
|
||||
{ id: 'graph', name: 'Graph (old)' } as any,
|
||||
const pluginsList = [
|
||||
{ id: 'graph', name: 'Graph (old)' },
|
||||
{ id: 'timeseries', name: 'Graph (old)' },
|
||||
{ id: 'timeline', name: 'Timeline' },
|
||||
{ id: 'panelwithdashes', name: 'Panel-With-Dashes' },
|
||||
];
|
||||
const found = filterPluginList(pluginsList, escapeStringForRegex('panel-'), { id: 'xyz' } as any);
|
||||
] as PanelPluginMeta[];
|
||||
const found = filterPluginList(pluginsList, escapeStringForRegex('panel-'), { id: 'xyz' } as PanelPluginMeta);
|
||||
expect(found.map((v) => v.id)).toEqual(['panelwithdashes']);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user