From 35514d7bc6f06c9e29d3ce60d0825f1b1e8abe87 Mon Sep 17 00:00:00 2001 From: ismail simsek Date: Mon, 5 Feb 2024 13:15:54 +0100 Subject: [PATCH] Chore: Update grafana-prometheus test types (#81816) * Update types * update betterer --- .betterer.results | 11 ----------- .../grafana-prometheus/src/datasource.test.ts | 17 +++++++++++------ .../src/metric_find_query.test.ts | 10 +++++++++- .../src/result_transformer.test.ts | 2 +- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.betterer.results b/.betterer.results index a824aa953f9..556d0c991c4 100644 --- a/.betterer.results +++ b/.betterer.results @@ -583,11 +583,6 @@ exports[`better eslint`] = { "packages/grafana-prometheus/src/configuration/ExemplarsSettings.tsx:5381": [ [0, 0, 0, "Styles should be written using objects.", "0"] ], - "packages/grafana-prometheus/src/datasource.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"] - ], "packages/grafana-prometheus/src/datasource.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -636,9 +631,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Do not use any type assertions.", "2"] ], - "packages/grafana-prometheus/src/metric_find_query.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-prometheus/src/metric_find_query.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -755,9 +747,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], - "packages/grafana-prometheus/src/result_transformer.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-prometheus/src/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], diff --git a/packages/grafana-prometheus/src/datasource.test.ts b/packages/grafana-prometheus/src/datasource.test.ts index e8009472d20..e74c2a46607 100644 --- a/packages/grafana-prometheus/src/datasource.test.ts +++ b/packages/grafana-prometheus/src/datasource.test.ts @@ -5,9 +5,11 @@ import { AnnotationEvent, AnnotationQueryRequest, CoreApp, + CustomVariableModel, DataQueryRequest, DataSourceInstanceSettings, dateTime, + LoadingState, rangeUtil, TimeRange, VariableHide, @@ -461,7 +463,7 @@ describe('PrometheusDatasource', () => { }); describe('When interpolating variables', () => { - let customVariable: any; + let customVariable: CustomVariableModel; beforeEach(() => { customVariable = { id: '', @@ -474,11 +476,14 @@ describe('PrometheusDatasource', () => { current: {}, name: '', type: 'custom', - label: null, + error: null, + rootStateKey: '', + state: LoadingState.Done, + description: '', + label: undefined, hide: VariableHide.dontHide, skipUrlSync: false, index: -1, - initLock: null, }; }); @@ -490,7 +495,7 @@ describe('PrometheusDatasource', () => { describe('and value is a number', () => { it('should return a number', () => { - expect(ds.interpolateQueryExpr(1000 as any, customVariable)).toEqual(1000); + expect(ds.interpolateQueryExpr(1000 as unknown as string, customVariable)).toEqual(1000); }); }); @@ -861,7 +866,7 @@ describe('PrometheusDatasource2', () => { }); describe('region annotations for sectors', () => { - const options: any = { + const options = { annotation: { expr: 'ALERTS{alertstate="firing"}', tagKeys: 'job', @@ -872,7 +877,7 @@ describe('PrometheusDatasource2', () => { from: time({ seconds: 63 }), to: time({ seconds: 900 }), }, - }; + } as unknown as AnnotationQueryRequest; async function runAnnotationQuery(data: number[][]) { let response = createAnnotationResponse(); diff --git a/packages/grafana-prometheus/src/metric_find_query.test.ts b/packages/grafana-prometheus/src/metric_find_query.test.ts index 0b860e96740..1a4f8c662e5 100644 --- a/packages/grafana-prometheus/src/metric_find_query.test.ts +++ b/packages/grafana-prometheus/src/metric_find_query.test.ts @@ -62,7 +62,15 @@ describe('PrometheusMetricFindQuery', () => { ); }); - const setupMetricFindQuery = (data: any, datasource?: PrometheusDatasource) => { + const setupMetricFindQuery = ( + data: { + query: string; + response: { + data: unknown; + }; + }, + datasource?: PrometheusDatasource + ) => { fetchMock.mockImplementation(() => of({ status: 'success', data: data.response } as unknown as FetchResponse)); return new PrometheusMetricFindQuery(datasource ?? legacyPrometheusDatasource, data.query); }; diff --git a/packages/grafana-prometheus/src/result_transformer.test.ts b/packages/grafana-prometheus/src/result_transformer.test.ts index 1c18dce5425..62ce599eaa6 100644 --- a/packages/grafana-prometheus/src/result_transformer.test.ts +++ b/packages/grafana-prometheus/src/result_transformer.test.ts @@ -909,7 +909,7 @@ describe('Prometheus Result Transformer', () => { }, ], } as unknown as DataQueryRequest; - const testOptions: any = { + const testOptions = { exemplarTraceIdDestinations: [ { name: 'traceID',