Chore: more ts test fixes (#63438)

* replace anys in tests

* more test fixes

* clean up any's in tests
This commit is contained in:
Ashley Harrison 2023-02-23 10:07:44 +00:00 committed by GitHub
parent bcaf4dc0b1
commit 4a2695349d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 187 additions and 349 deletions

View File

@ -4524,17 +4524,6 @@ exports[`better eslint`] = {
"public/app/features/variables/shared/testing/variableBuilder.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/features/variables/state/actions.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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
],
"public/app/features/variables/state/actions.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@ -4551,26 +4540,14 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"]
],
"public/app/features/variables/state/initVariableTransaction.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/variables/state/keyedVariablesReducer.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/variables/state/processVariable.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/variables/state/reducers.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/variables/state/sharedReducer.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/variables/state/sharedReducer.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -4685,11 +4662,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"]
],
"public/app/plugins/datasource/azuremonitor/azure_monitor/azure_monitor_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"]
],
"public/app/plugins/datasource/azuremonitor/azure_monitor/azure_monitor_datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -4703,8 +4675,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/plugins/datasource/azuremonitor/azure_resource_graph/azure_resource_graph_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.", "0"]
],
"public/app/plugins/datasource/azuremonitor/azure_resource_graph/azure_resource_graph_datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -4715,21 +4686,12 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"]
],
"public/app/plugins/datasource/azuremonitor/components/MetricsQueryEditor/dataHooks.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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/plugins/datasource/azuremonitor/components/MonitorConfig.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/azuremonitor/components/QueryEditor/QueryEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/azuremonitor/components/ResourcePicker/ResourcePicker.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/azuremonitor/datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
@ -4755,10 +4717,6 @@ exports[`better eslint`] = {
"public/app/plugins/datasource/azuremonitor/utils/messageFromError.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/azuremonitor/utils/useAsyncState.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/cloud-monitoring/CloudMonitoringMetricFindQuery.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@ -4769,11 +4727,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/plugins/datasource/cloud-monitoring/components/Aggregation.test.tsx: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"]
],
"public/app/plugins/datasource/cloud-monitoring/components/Aggregation.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
@ -4782,16 +4735,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/cloud-monitoring/components/GroupBy.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/cloud-monitoring/components/MQLQueryEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/cloud-monitoring/components/VariableQueryEditor.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/cloud-monitoring/components/VariableQueryEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -4814,22 +4760,11 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"]
],
"public/app/plugins/datasource/cloud-monitoring/functions.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"]
],
"public/app/plugins/datasource/cloud-monitoring/functions.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/plugins/datasource/cloud-monitoring/specs/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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/plugins/datasource/cloud-monitoring/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
@ -4846,10 +4781,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/cloudwatch/components/MetricsQueryEditor/MetricsQueryEditor.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/cloudwatch/components/QueryEditor.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -4882,10 +4813,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"]
],
"public/app/plugins/datasource/cloudwatch/utils/datalinks.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/cloudwatch/utils/datalinks.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@ -5082,8 +5009,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "2"]
],
"public/app/plugins/datasource/grafana/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.", "0"]
],
"public/app/plugins/datasource/grafana/datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -5210,9 +5136,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "61"],
[0, 0, 0, "Unexpected any. Specify a different type.", "62"]
],
"public/app/plugins/datasource/graphite/datasource_integration.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/graphite/gfunc.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@ -5284,9 +5207,7 @@ exports[`better eslint`] = {
],
"public/app/plugins/datasource/graphite/specs/store.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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/graphite/state/context.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
@ -5436,29 +5357,8 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"]
],
"public/app/plugins/datasource/influxdb/specs/influx_query_model.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/influxdb/specs/response_parser.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"]
],
"public/app/plugins/datasource/jaeger/components/SearchForm.test.tsx: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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/plugins/datasource/jaeger/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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/jaeger/datasource.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -5491,11 +5391,6 @@ exports[`better eslint`] = {
"public/app/plugins/datasource/loki/LiveStreams.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/loki/components/LokiContextUi.test.tsx: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"]
],
"public/app/plugins/datasource/loki/components/LokiLabelBrowser.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
@ -5613,10 +5508,6 @@ exports[`better eslint`] = {
"public/app/plugins/datasource/opentsdb/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/opentsdb/specs/datasource.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/prometheus/components/PromLink.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
@ -5723,11 +5614,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "32"],
[0, 0, 0, "Unexpected any. Specify a different type.", "33"]
],
"public/app/plugins/datasource/prometheus/language_provider.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"]
],
"public/app/plugins/datasource/prometheus/language_provider.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -5750,10 +5636,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "9"]
],
"public/app/plugins/datasource/prometheus/metric_find_query.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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/prometheus/metric_find_query.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@ -5798,17 +5681,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderContainer.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryBuilderContainer.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryEditorSelector.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/datasource/prometheus/querybuilder/components/PromQueryEditorSelector.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
],
@ -5942,9 +5817,6 @@ exports[`better eslint`] = {
"public/app/plugins/datasource/tempo/language_provider.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/tempo/resultTransformer.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/datasource/tempo/resultTransformer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -6025,25 +5897,11 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/plugins/datasource/zipkin/QueryField.test.tsx: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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/plugins/datasource/zipkin/QueryField.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/plugins/datasource/zipkin/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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
],
"public/app/plugins/datasource/zipkin/datasource.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -6065,21 +5923,11 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/panel/alertGroups/AlertGroupsPanel.test.tsx: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"]
],
"public/app/plugins/panel/alertlist/AlertList.tsx: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"]
],
"public/app/plugins/panel/alertlist/AlertListMigration.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"]
],
"public/app/plugins/panel/alertlist/AlertListMigrationHandler.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -6719,11 +6567,6 @@ exports[`better eslint`] = {
"public/app/plugins/panel/nodeGraph/ViewControls.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/panel/nodeGraph/layout.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"]
],
"public/app/plugins/panel/nodeGraph/layout.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
@ -6749,9 +6592,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/panel/stat/StatMigrations.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/panel/stat/StatMigrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@ -6909,10 +6749,6 @@ exports[`better eslint`] = {
"public/app/plugins/panel/text/TextPanelEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/panel/text/textPanelMigrationHandler.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/panel/text/textPanelMigrationHandler.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
@ -6925,33 +6761,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/plugins/panel/timeseries/migrations.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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Unexpected any. Specify a different type.", "18"],
[0, 0, 0, "Unexpected any. Specify a different type.", "19"],
[0, 0, 0, "Unexpected any. Specify a different type.", "20"],
[0, 0, 0, "Unexpected any. Specify a different type.", "21"],
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
[0, 0, 0, "Unexpected any. Specify a different type.", "23"],
[0, 0, 0, "Unexpected any. Specify a different type.", "24"]
],
"public/app/plugins/panel/timeseries/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],

View File

@ -2,6 +2,9 @@ import { AnyAction } from 'redux';
import { LoadingState } from '@grafana/data';
import * as runtime from '@grafana/runtime';
import { DataSourceSrv, LocationService } from '@grafana/runtime';
import { BackendSrv } from 'app/core/services/backend_srv';
import { DashboardModel } from 'app/features/dashboard/state';
import { reduxTester } from '../../../../test/core/redux/reduxTester';
import { toAsyncOfResult } from '../../query/state/DashboardQueryRunner/testHelpers';
@ -73,7 +76,7 @@ jest.mock('app/features/dashboard/services/TimeSrv', () => ({
runtime.setDataSourceSrv({
get: getDatasource,
getList: getMetricSources,
} as any);
} as unknown as DataSourceSrv);
describe('shared actions', () => {
describe('when initDashboardTemplating is dispatched', () => {
@ -85,7 +88,7 @@ describe('shared actions', () => {
const custom = customBuilder().build();
const textbox = textboxBuilder().build();
const list = [query, constant, datasource, custom, textbox];
const dashboard: any = { templating: { list } };
const dashboard = { templating: { list } } as DashboardModel;
reduxTester<TemplatingReducerType>()
.givenRootReducer(getTemplatingRootReducer())
@ -150,7 +153,7 @@ describe('shared actions', () => {
const key = 'key';
const var1 = queryBuilder().withName('var1').withQuery('$var2').build();
const var2 = queryBuilder().withName('var2').withQuery('$var1').build();
const dashboard: any = { templating: { list: [var1, var2] } };
const dashboard = { templating: { list: [var1, var2] } } as DashboardModel;
const preloadedState = getPreloadedState(key, {});
await expect(async () => {
@ -170,16 +173,16 @@ describe('shared actions', () => {
const custom = customBuilder().build();
const textbox = textboxBuilder().build();
const list = [query, constant, datasource, custom, textbox];
const dashboard: any = { templating: { list } };
const dashboard = { templating: { list } } as DashboardModel;
const preloadedState = getPreloadedState(key, {});
const locationService: any = { getSearchObject: () => ({}) };
const locationService = { getSearchObject: () => ({}) } as LocationService;
runtime.setLocationService(locationService);
const variableQueryRunner: any = {
const variableQueryRunner = {
cancelRequest: jest.fn(),
queueRequest: jest.fn(),
getResponse: () => toAsyncOfResult({ state: LoadingState.Done, identifier: toKeyedVariableIdentifier(query) }),
destroy: jest.fn(),
};
} as unknown as VariableQueryRunner;
setVariableQueryRunner(variableQueryRunner);
const tester = await reduxTester<TemplatingReducerType>({ preloadedState })
@ -261,9 +264,9 @@ describe('shared actions', () => {
.build();
const list = [stats, substats];
const dashboard: any = { templating: { list } };
const dashboard = { templating: { list } } as DashboardModel;
const query = { orgId: '1', 'var-stats': 'response', 'var-substats': ALL_VARIABLE_TEXT };
const locationService: any = { getSearchObject: () => query };
const locationService = { getSearchObject: () => query } as unknown as LocationService;
runtime.setLocationService(locationService);
const preloadedState = getPreloadedState(key, {});
@ -745,9 +748,9 @@ describe('shared actions', () => {
describe('cancelVariables', () => {
const cancelAllInFlightRequestsMock = jest.fn();
const backendSrvMock: any = {
const backendSrvMock = {
cancelAllInFlightRequests: cancelAllInFlightRequestsMock,
};
} as unknown as BackendSrv;
describe('when called', () => {
it('then cancelAllInFlightRequests should be called and correct actions are dispatched', async () => {

View File

@ -1,5 +1,6 @@
import { DataSourceRef, LoadingState } from '@grafana/data/src';
import { setDataSourceSrv } from '@grafana/runtime/src';
import { DashboardModel } from 'app/features/dashboard/state';
import { reduxTester } from '../../../../test/core/redux/reduxTester';
import { toAsyncOfResult } from '../../query/state/DashboardQueryRunner/testHelpers';
@ -10,7 +11,7 @@ import { createDataSourceVariableAdapter } from '../datasource/adapter';
import { createDataSourceOptions } from '../datasource/reducer';
import { cleanEditorState } from '../editor/reducer';
import { cleanPickerState } from '../pickers/OptionsPicker/reducer';
import { setVariableQueryRunner } from '../query/VariableQueryRunner';
import { setVariableQueryRunner, VariableQueryRunner } from '../query/VariableQueryRunner';
import { createQueryVariableAdapter } from '../query/adapter';
import { adHocBuilder, constantBuilder, datasourceBuilder, queryBuilder } from '../shared/testing/builders';
import { TransactionStatus, VariableModel } from '../types';
@ -53,15 +54,15 @@ function getTestContext(variables?: VariableModel[]) {
getInstanceSettings: getInstanceSettingsMock,
reload: jest.fn(),
});
const variableQueryRunner: any = {
const variableQueryRunner = {
cancelRequest: jest.fn(),
queueRequest: jest.fn(),
getResponse: () => toAsyncOfResult({ state: LoadingState.Done, identifier: { type: 'query', id: 'query' } }),
destroy: jest.fn(),
};
} as unknown as VariableQueryRunner;
setVariableQueryRunner(variableQueryRunner);
const dashboard: any = { title: 'Some dash', uid: key, templating };
const dashboard = { title: 'Some dash', uid: key, templating } as DashboardModel;
return { constant, getInstanceSettingsMock, templating, key, dashboard };
}

View File

@ -1,5 +1,7 @@
import { UrlQueryMap } from '@grafana/data';
import { setDataSourceSrv } from '@grafana/runtime';
import { DashboardModel } from 'app/features/dashboard/state';
import { DatasourceSrv } from 'app/features/plugins/datasource_srv';
import { reduxTester } from '../../../../test/core/redux/reduxTester';
import { variableAdapters } from '../adapters';
@ -60,7 +62,7 @@ setDataSourceSrv({
return Promise.resolve([]);
}),
}),
} as any);
} as unknown as DatasourceSrv);
variableAdapters.setInit(() => [createCustomVariableAdapter(), createQueryVariableAdapter()]);
@ -99,7 +101,7 @@ describe('processVariable', () => {
.build();
const list = [custom, queryDependsOnCustom, queryNoDepends];
const dashboard: any = { templating: { list } };
const dashboard = { templating: { list } } as DashboardModel;
setVariableQueryRunner(new VariableQueryRunner());
return {

View File

@ -1,6 +1,6 @@
import { cloneDeep } from 'lodash';
import { LoadingState, VariableType } from '@grafana/data';
import { BaseVariableModel, LoadingState, VariableType } from '@grafana/data';
import { reducerTester } from '../../../../test/core/redux/reducerTester';
import { variableAdapters } from '../adapters';
@ -36,11 +36,11 @@ variableAdapters.setInit(() => [createQueryVariableAdapter(), createConstantVari
describe('sharedReducer', () => {
describe('when addVariable is dispatched', () => {
it('then state should be correct', () => {
const model: any = {
const model = {
name: 'name from model',
type: 'query',
current: undefined,
};
} as unknown as BaseVariableModel;
const expected: QueryVariableModel = {
...initialQueryVariableModelState,
@ -65,13 +65,13 @@ describe('sharedReducer', () => {
describe('when addVariable is dispatched for a constant model', () => {
it('then state should be correct', () => {
const model: any = {
const model = {
name: 'constant',
type: 'constant',
query: 'a constant',
current: { selected: true, text: 'A', value: 'A' },
options: [{ selected: true, text: 'A', value: 'A' }],
};
} as unknown as BaseVariableModel;
const expected: ConstantVariableModel = {
...initialConstantVariableModelState,

View File

@ -418,7 +418,7 @@ describe('AzureMonitorDatasource', () => {
const templateVariables = createTemplateVariables(templateableProps);
templateSrv.init(Array.from(templateVariables.values()).map((item) => item.templateVariable));
const query = createMockQuery();
const azureMonitorQuery: { [index: string]: any } = {};
const azureMonitorQuery = {};
for (const [path, templateVariable] of templateVariables.entries()) {
set(azureMonitorQuery, path, `$${templateVariable.variableName}`);
}
@ -989,7 +989,7 @@ describe('AzureMonitorDatasource', () => {
resourceName: 'resource1',
metricName: 'Transactions',
})
.then((results: any) => {
.then((results) => {
expect(results.dimensions).toMatchInlineSnapshot(`
[
{
@ -1048,7 +1048,7 @@ describe('AzureMonitorDatasource', () => {
resourceName: 'resource1',
metricName: 'FreeCapacity',
})
.then((results: any) => {
.then((results) => {
expect(results.dimensions.length).toEqual(0);
});
});

View File

@ -60,7 +60,7 @@ describe('AzureResourceGraphDatasource', () => {
const templateVariables = createTemplateVariables(templateableProps);
templateSrv.init(Array.from(templateVariables.values()).map((item) => item.templateVariable));
const query = createMockQuery();
const azureResourceGraph: { [index: string]: any } = {};
const azureResourceGraph = {};
for (const [path, templateVariable] of templateVariables.entries()) {
set(azureResourceGraph, path, `$${templateVariable.variableName}`);
}

View File

@ -123,8 +123,8 @@ describe('AzureMonitor: metrics dataHooks', () => {
];
let datasource: Datasource;
let onChange: jest.Mock<any, any>;
let setError: jest.Mock<any, any>;
let onChange: jest.Mock;
let setError: jest.Mock;
beforeEach(() => {
onChange = jest.fn();

View File

@ -32,7 +32,7 @@ const singleResourceGroupSelectionURI = '/subscriptions/def-456/resourceGroups/d
const singleResourceSelectionURI =
'/subscriptions/def-456/resourceGroups/dev-3/providers/Microsoft.Compute/virtualMachines/db-server';
const noop: any = () => {};
const noop = () => {};
function createMockResourcePickerData(preserveImplementation?: string[]) {
const mockDatasource = createMockDatasource();
const mockResourcePicker = new ResourcePickerData(

View File

@ -2,7 +2,7 @@ import { renderHook } from '@testing-library/react-hooks';
import { useAsyncState } from './useAsyncState';
interface WaitableMock extends jest.Mock<any, any> {
interface WaitableMock extends jest.Mock {
waitToBeCalled(): Promise<unknown>;
}

View File

@ -3,7 +3,7 @@ import React from 'react';
import { openMenu } from 'react-select-event';
import { TemplateSrvStub } from 'test/specs/helpers';
import { ValueTypes, MetricKind } from '../types';
import { ValueTypes, MetricKind, MetricDescriptor } from '../types';
import { Aggregation, Props } from './Aggregation';
@ -14,7 +14,7 @@ const props: Props = {
metricDescriptor: {
valueType: '',
metricKind: '',
} as any,
} as unknown as MetricDescriptor,
crossSeriesReducer: '',
groupBys: [],
templateVariableOptions: [],
@ -33,7 +33,7 @@ describe('Aggregation', () => {
metricDescriptor: {
valueType: ValueTypes.DOUBLE,
metricKind: MetricKind.GAUGE,
} as any,
} as MetricDescriptor,
};
it('should not have the reduce values', () => {
@ -51,7 +51,7 @@ describe('Aggregation', () => {
metricDescriptor: {
valueType: ValueTypes.MONEY,
metricKind: MetricKind.CUMULATIVE,
} as any,
} as MetricDescriptor,
};
it('should have the reduce values', () => {

View File

@ -3,6 +3,7 @@ import React from 'react';
import { openMenu, select } from 'react-select-event';
import { createMockTimeSeriesList } from '../__mocks__/cloudMonitoringQuery';
import { MetricDescriptor } from '../types';
import { GroupBy, Props } from './GroupBy';
@ -12,7 +13,7 @@ const props: Props = {
metricDescriptor: {
valueType: '',
metricKind: '',
} as any,
} as unknown as MetricDescriptor,
variableOptionGroup: { options: [] },
labels: [],
query: createMockTimeSeriesList(),

View File

@ -10,8 +10,8 @@ import { CloudMonitoringVariableQuery, MetricFindQueryTypes } from '../types';
import { CloudMonitoringVariableQueryEditor, Props } from './VariableQueryEditor';
jest.mock('../functions', () => ({
getMetricTypes: (): any => ({ metricTypes: [], selectedMetricType: '' }),
extractServicesFromMetricDescriptors: (): any[] => [],
getMetricTypes: () => ({ metricTypes: [], selectedMetricType: '' }),
extractServicesFromMetricDescriptors: () => [],
}));
jest.mock('@grafana/runtime', () => {

View File

@ -123,7 +123,7 @@ describe('functions', () => {
});
describe('getAlignmentOptionsByMetric', () => {
let result: any;
let result: ReturnType<typeof getAlignmentOptionsByMetric>;
describe('when double and gauge is passed', () => {
beforeEach(() => {
result = getAlignmentOptionsByMetric(ValueTypes.DOUBLE, MetricKind.GAUGE);
@ -131,7 +131,7 @@ describe('functions', () => {
it('should return all alignment options except two', () => {
expect(result.length).toBe(10);
expect(result.map((o: any) => o.value)).toEqual(
expect(result.map((o) => o.value)).toEqual(
expect.not.arrayContaining(['REDUCE_COUNT_TRUE', 'REDUCE_COUNT_FALSE'])
);
});
@ -144,7 +144,7 @@ describe('functions', () => {
it('should return all alignment options except four', () => {
expect(result.length).toBe(9);
expect(result.map((o: any) => o.value)).toEqual(
expect(result.map((o) => o.value)).toEqual(
expect.not.arrayContaining([
'ALIGN_COUNT_TRUE',
'ALIGN_COUNT_FALSE',

View File

@ -1,7 +1,7 @@
import { of, throwError } from 'rxjs';
import { createFetchResponse } from 'test/helpers/createFetchResponse';
import { DataSourceInstanceSettings, toUtc } from '@grafana/data';
import { DataQueryRequest, DataSourceInstanceSettings, toUtc } from '@grafana/data';
import { backendSrv } from 'app/core/services/backend_srv'; // will use the version in __mocks__
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { TemplateSrv } from 'app/features/templating/template_srv';
@ -9,14 +9,14 @@ import { TemplateSrv } from 'app/features/templating/template_srv';
import { initialCustomVariableModelState } from '../../../../features/variables/custom/reducer';
import { CustomVariableModel } from '../../../../features/variables/types';
import CloudMonitoringDataSource from '../datasource';
import { CloudMonitoringOptions } from '../types';
import { CloudMonitoringOptions, CloudMonitoringQuery } from '../types';
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => backendSrv,
}));
type Args = { response?: any; throws?: boolean; templateSrv?: TemplateSrv };
type Args = { response?: unknown; throws?: boolean; templateSrv?: TemplateSrv };
const fetchMock = jest.spyOn(backendSrv, 'fetch');
@ -63,9 +63,9 @@ describe('CloudMonitoringDataSource', () => {
refId: 'A',
},
],
};
} as DataQueryRequest<CloudMonitoringQuery>;
const response: any = {
const response = {
results: {
A: {
refId: 'A',
@ -80,7 +80,7 @@ describe('CloudMonitoringDataSource', () => {
const { ds } = getTestcontext({ response });
await expect(ds.query(options as any)).toEmitValuesWith((received) => {
await expect(ds.query(options)).toEmitValuesWith((received) => {
const results = received[0];
expect(results.data.length).toBe(0);
});
@ -199,7 +199,7 @@ describe('CloudMonitoringDataSource', () => {
});
});
function initTemplateSrv(values: any, multi = false) {
function initTemplateSrv(values: string | string[], multi = false) {
const templateSrv = new TemplateSrv();
const test: CustomVariableModel = {
...initialCustomVariableModelState,

View File

@ -5,6 +5,7 @@ import selectEvent from 'react-select-event';
import { DataSourceInstanceSettings } from '@grafana/data';
import { config } from '@grafana/runtime';
import * as ui from '@grafana/ui';
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { TemplateSrv } from 'app/features/templating/template_srv';
import { CustomVariableModel, initialVariableModelState } from '../../../../../features/variables/types';
@ -44,7 +45,7 @@ const setup = () => {
};
templateSrv.init([variable]);
const datasource = new CloudWatchDatasource(instanceSettings, templateSrv as any, {} as any);
const datasource = new CloudWatchDatasource(instanceSettings, templateSrv, {} as TimeSrv);
datasource.metricFindQuery = async () => [{ value: 'test', label: 'test', text: 'test' }];
datasource.resources.getNamespaces = jest.fn().mockResolvedValue([]);
datasource.resources.getMetrics = jest.fn().mockResolvedValue([]);

View File

@ -1,5 +1,6 @@
import { DataQueryRequest, DataQueryResponse, dateMath } from '@grafana/data';
import { setDataSourceSrv } from '@grafana/runtime';
import { DatasourceSrv } from 'app/features/plugins/datasource_srv';
import { CloudWatchQuery } from '../types';
@ -29,7 +30,7 @@ describe('addDataLinksToLogsResponse', () => {
],
};
const mockOptions: any = {
const mockOptions = {
targets: [
{
refId: 'A',
@ -39,7 +40,7 @@ describe('addDataLinksToLogsResponse', () => {
region: 'us-east-1',
},
],
};
} as DataQueryRequest<CloudWatchQuery>;
setDataSourceSrv({
async get() {
@ -47,7 +48,7 @@ describe('addDataLinksToLogsResponse', () => {
name: 'Xray',
};
},
} as any);
} as DatasourceSrv);
await addDataLinksToLogsResponse(
mockResponse,

View File

@ -25,7 +25,7 @@ describe('grafana data source', () => {
let calledBackendSrvParams: any;
let ds: GrafanaDatasource;
beforeEach(() => {
getMock.mockImplementation((url: string, options: any) => {
getMock.mockImplementation((url, options) => {
calledBackendSrvParams = options;
return Promise.resolve([]);
});

View File

@ -1,5 +1,6 @@
import { of } from 'rxjs';
import { EventBusExtended } from '@grafana/data';
import { setBackendSrv } from '@grafana/runtime';
import { BackendSrv } from 'app/core/services/backend_srv';
@ -125,7 +126,7 @@ function mockBackendSrv(data: string) {
return of(mockedResponse);
});
const appEventsMock = {} as any;
const appEventsMock = {} as EventBusExtended;
const user: User = {
isSignedIn: props.isSignedIn,

View File

@ -14,8 +14,8 @@ import { createStore } from '../state/store';
import { GraphiteSegment } from '../types';
jest.mock('app/angular/promiseToDigest', () => ({
promiseToDigest: (scope: any) => {
return (p: Promise<any>) => p;
promiseToDigest: () => {
return (p: Promise<unknown>) => p;
},
}));

View File

@ -1,7 +1,9 @@
import { TemplateSrv } from 'app/features/templating/template_srv';
import InfluxQueryModel from '../influx_query_model';
describe('InfluxQuery', () => {
const templateSrv: any = { replace: (val: any) => val };
const templateSrv = { replace: (val) => val } as TemplateSrv;
describe('render series with measurement only', () => {
it('should generate correct query', () => {

View File

@ -2,7 +2,7 @@ import { size } from 'lodash';
import { of } from 'rxjs';
import { TemplateSrvStub } from 'test/specs/helpers';
import { FieldType, MutableDataFrame } from '@grafana/data';
import { AnnotationEvent, DataQueryRequest, FieldType, MutableDataFrame } from '@grafana/data';
import { FetchResponse } from '@grafana/runtime';
import { backendSrv } from 'app/core/services/backend_srv'; // will use the version in __mocks__
@ -313,14 +313,14 @@ describe('influxdb response parser', () => {
tagsColumn: 'host,path',
};
const queryOptions: any = {
const queryOptions = {
targets: [annotation],
range: {
from: '2018-01-01T00:00:00Z',
to: '2018-01-02T00:00:00Z',
},
};
let response: any;
} as unknown as DataQueryRequest;
let response: AnnotationEvent[];
beforeEach(async () => {
fetchMock.mockImplementation(() => {
@ -433,13 +433,13 @@ describe('influxdb response parser', () => {
expect(response[0].time).toBe(1645208701000);
expect(response[0].title).toBe('Station softwareupdated[447]: Adding client 1');
expect(response[0].text).toBe('text 1');
expect(response[0].tags[0]).toBe('cbfa07e0e3bb 1');
expect(response[0].tags[1]).toBe('/var/log/host/install.log 1');
expect(response[0].tags?.[0]).toBe('cbfa07e0e3bb 1');
expect(response[0].tags?.[1]).toBe('/var/log/host/install.log 1');
expect(response[1].time).toBe(1645208702000);
expect(response[1].title).toBe('Station softwareupdated[447]: Adding client 2');
expect(response[1].text).toBe('text 2');
expect(response[1].tags[0]).toBe('cbfa07e0e3bb 2');
expect(response[1].tags[1]).toBe('/var/log/host/install.log 2');
expect(response[1].tags?.[0]).toBe('cbfa07e0e3bb 2');
expect(response[1].tags?.[1]).toBe('/var/log/host/install.log 2');
});
});
});

View File

@ -4,7 +4,7 @@ import React from 'react';
import { of } from 'rxjs';
import { createFetchResponse } from 'test/helpers/createFetchResponse';
import { DataQueryRequest, DataSourceInstanceSettings, dateTime, PluginType } from '@grafana/data';
import { DataQueryRequest, DataSourceInstanceSettings, dateTime, PluginMetaInfo, PluginType } from '@grafana/data';
import { backendSrv } from 'app/core/services/backend_srv';
import { JaegerDatasource, JaegerJsonData } from '../datasource';
@ -32,10 +32,11 @@ describe('SearchForm', () => {
refId: '121314',
};
const ds = {
async metadataRequest(url: string, params?: Record<string, any>): Promise<any> {
async metadataRequest(url) {
if (url === '/api/services') {
return Promise.resolve(['jaeger-query', 'service2', 'service3']);
}
return undefined;
},
} as JaegerDatasource;
setupFetchMock({ data: [testResponse] });
@ -160,7 +161,7 @@ describe('SearchForm', () => {
});
});
function setupFetchMock(response: any, mock?: any) {
function setupFetchMock(response: unknown, mock?: ReturnType<typeof backendSrv.fetch>) {
const defaultMock = () => mock ?? of(createFetchResponse(response));
const fetchMock = jest.spyOn(backendSrv, 'fetch');
@ -179,7 +180,7 @@ const defaultSettings: DataSourceInstanceSettings<JaegerJsonData> = {
id: 'jaeger',
name: 'jaeger',
type: PluginType.datasource,
info: {} as any,
info: {} as PluginMetaInfo,
module: '',
baseUrl: '',
},

View File

@ -6,10 +6,12 @@ import {
DataSourceInstanceSettings,
dateTime,
FieldType,
PluginMetaInfo,
PluginType,
ScopedVars,
} from '@grafana/data';
import { backendSrv } from 'app/core/services/backend_srv';
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { ALL_OPERATIONS_KEY } from './components/SearchForm';
import { JaegerDatasource, JaegerJsonData } from './datasource';
@ -35,14 +37,14 @@ jest.mock('@grafana/runtime', () => ({
}),
}));
const timeSrvStub: any = {
timeRange(): any {
const timeSrvStub = {
timeRange() {
return {
from: dateTime(1531468681),
to: dateTime(1531489712),
};
},
};
} as TimeSrv;
describe('JaegerDatasource', () => {
beforeEach(() => {
@ -111,7 +113,7 @@ describe('JaegerDatasource', () => {
const response = await lastValueFrom(
ds.query({
targets: [{ queryType: 'upload', refId: 'A' }],
} as any)
} as DataQueryRequest<JaegerQuery>)
);
expect(response.error?.message).toBe('The JSON file uploaded is not in a valid Jaeger format');
expect(response.data.length).toBe(0);
@ -317,7 +319,7 @@ describe('when performing testDataSource', () => {
});
});
function setupFetchMock(response: any, mock?: any) {
function setupFetchMock(response: unknown, mock?: ReturnType<typeof backendSrv.fetch>) {
const defaultMock = () => mock ?? of(createFetchResponse(response));
const fetchMock = jest.spyOn(backendSrv, 'fetch');
@ -336,7 +338,7 @@ const defaultSettings: DataSourceInstanceSettings<JaegerJsonData> = {
id: 'jaeger',
name: 'jaeger',
type: PluginType.datasource,
info: {} as any,
info: {} as PluginMetaInfo,
module: '',
baseUrl: '',
},

View File

@ -18,8 +18,8 @@ describe('LokiContextUi', () => {
const savedGlobal = global;
beforeAll(() => {
// TODO: `structuredClone` is not yet in jsdom https://github.com/jsdom/jsdom/issues/3363
if (!(global as any).structuredClone) {
(global as any).structuredClone = function structuredClone(objectToClone: any) {
if (!global.structuredClone) {
global.structuredClone = function structuredClone(objectToClone: unknown) {
const stringified = JSON.stringify(objectToClone);
const parsed = JSON.parse(stringified);
return parsed;

View File

@ -2,6 +2,7 @@ import { of } from 'rxjs';
import { DataQueryRequest, dateTime } from '@grafana/data';
import { backendSrv } from 'app/core/services/backend_srv'; // will use the version in __mocks__
import { TemplateSrv } from 'app/features/templating/template_srv';
import { createFetchResponse } from '../../../../../test/helpers/createFetchResponse';
import OpenTsDatasource from '../datasource';
@ -23,16 +24,16 @@ const metricFindQueryData = [
];
describe('opentsdb', () => {
function getTestcontext({ data = metricFindQueryData }: { data?: any } = {}) {
function getTestcontext({ data = metricFindQueryData }: { data?: unknown } = {}) {
jest.clearAllMocks();
const fetchMock = jest.spyOn(backendSrv, 'fetch');
fetchMock.mockImplementation(() => of(createFetchResponse(data)));
const instanceSettings = { url: '', jsonData: { tsdbVersion: 1 } };
const replace = jest.fn((value) => value);
const templateSrv: any = {
const templateSrv = {
replace,
};
} as unknown as TemplateSrv;
const ds = new OpenTsDatasource(instanceSettings, templateSrv);

View File

@ -11,7 +11,7 @@ import { PromQuery } from './types';
describe('Language completion provider', () => {
const datasource: PrometheusDatasource = {
metadataRequest: () => ({ data: { data: [] as any[] } }),
metadataRequest: () => ({ data: { data: [] } }),
getTimeRangeParams: () => ({ start: '0', end: '1' }),
interpolateString: (string: string) => string,
hasLabelsMatchAPISupport: () => false,
@ -373,7 +373,7 @@ describe('Language completion provider', () => {
it('returns label suggestions on label context and metric', async () => {
const datasources: PrometheusDatasource = {
metadataRequest: () => ({ data: { data: [{ __name__: 'metric', bar: 'bazinga' }] as any[] } }),
metadataRequest: () => ({ data: { data: [{ __name__: 'metric', bar: 'bazinga' }] } }),
getTimeRangeParams: () => ({ start: '0', end: '1' }),
interpolateString: (string: string) => string,
} as unknown as PrometheusDatasource;
@ -647,7 +647,7 @@ describe('Language completion provider', () => {
it('does not re-fetch default labels', async () => {
const datasource: PrometheusDatasource = {
metadataRequest: jest.fn(() => ({ data: { data: [] as any[] } })),
metadataRequest: jest.fn(() => ({ data: { data: [] } })),
getTimeRangeParams: jest.fn(() => ({ start: '0', end: '1' })),
interpolateString: (string: string) => string,
} as unknown as PrometheusDatasource;

View File

@ -4,6 +4,7 @@ import { of } from 'rxjs';
import { DataSourceInstanceSettings, toUtc } from '@grafana/data';
import { FetchResponse } from '@grafana/runtime';
import { backendSrv } from 'app/core/services/backend_srv'; // will use the version in __mocks__
import { TemplateSrv } from 'app/features/templating/template_srv';
import { PromApplication } from '../../../types/unified-alerting-dto';
@ -35,7 +36,7 @@ const raw = {
jest.mock('app/features/dashboard/services/TimeSrv', () => ({
__esModule: true,
getTimeSrv: jest.fn().mockReturnValue({
timeRange(): any {
timeRange() {
return {
from: raw.from,
to: raw.to,
@ -46,9 +47,9 @@ jest.mock('app/features/dashboard/services/TimeSrv', () => ({
}));
const templateSrvStub = {
getAdhocFilters: jest.fn(() => [] as any[]),
replace: jest.fn((a: string) => a),
} as any;
getAdhocFilters: jest.fn().mockImplementation(() => []),
replace: jest.fn().mockImplementation((a: string) => a),
} as unknown as TemplateSrv;
beforeEach(() => {
jest.clearAllMocks();

View File

@ -2,6 +2,8 @@ import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { DataSourceInstanceSettings, DataSourcePluginMeta } from '@grafana/data';
import { PrometheusDatasource } from '../../datasource';
import PromQlLanguageProvider from '../../language_provider';
import { EmptyLanguageProviderMock } from '../../language_provider.mock';
@ -39,8 +41,8 @@ function setup(queryOverrides: Partial<PromQuery> = {}) {
{
url: '',
jsonData: {},
meta: {} as any,
} as any,
meta: {} as DataSourcePluginMeta,
} as DataSourceInstanceSettings,
undefined,
undefined,
languageProvider

View File

@ -30,7 +30,7 @@ jest.mock('app/core/store', () => {
return undefined;
},
set() {},
getObject(key: string, defaultValue: any) {
getObject(key: string, defaultValue: unknown) {
return defaultValue;
},
};
@ -200,7 +200,7 @@ describe('PromQueryEditorSelector', () => {
});
function renderWithMode(mode: QueryEditorMode) {
return renderWithProps({ editorMode: mode } as any);
return renderWithProps({ editorMode: mode });
}
function renderWithDatasourceDefaultEditorMode(mode: QueryEditorMode) {

View File

@ -7,6 +7,7 @@ import {
DataSourceInstanceSettings,
dateTime,
ArrayVector,
PluginMetaInfo,
} from '@grafana/data';
import {
@ -36,7 +37,7 @@ const defaultSettings: DataSourceInstanceSettings = {
id: 'tempo',
name: 'tempo',
type: PluginType.datasource,
info: {} as any,
info: {} as PluginMetaInfo,
module: '',
baseUrl: '',
},

View File

@ -30,10 +30,11 @@ describe('QueryField', () => {
describe('useServices', () => {
it('returns services from datasource', async () => {
const ds = {
async metadataRequest(url: string, params?: Record<string, any>): Promise<any> {
async metadataRequest(url) {
if (url === '/api/v2/services') {
return Promise.resolve(['service1', 'service2']);
}
return undefined;
},
} as ZipkinDatasource;
@ -49,7 +50,7 @@ describe('useServices', () => {
describe('useLoadOptions', () => {
it('loads spans and traces', async () => {
const ds = {
async metadataRequest(url: string, params?: Record<string, any>): Promise<any> {
async metadataRequest(url, params) {
if (url === '/api/v2/spans' && params?.serviceName === 'service1') {
return Promise.resolve(['span1', 'span2']);
}
@ -57,6 +58,7 @@ describe('useLoadOptions', () => {
if (url === '/api/v2/traces' && params?.serviceName === 'service1' && params?.spanName === 'span1') {
return Promise.resolve([[{ name: 'trace1', duration: 10_000, traceId: 'traceId1' }]]);
}
return undefined;
},
} as ZipkinDatasource;

View File

@ -1,12 +1,13 @@
import { lastValueFrom, of } from 'rxjs';
import { createFetchResponse } from 'test/helpers/createFetchResponse';
import { DataSourceInstanceSettings, FieldType } from '@grafana/data';
import { DataQueryRequest, DataSourceInstanceSettings, DataSourcePluginMeta, FieldType } from '@grafana/data';
import { TemplateSrv } from '@grafana/runtime';
import { backendSrv } from 'app/core/services/backend_srv';
import { ZipkinDatasource } from './datasource';
import mockJson from './mockJsonResponse.json';
import { ZipkinQuery, ZipkinSpan } from './types';
import { traceFrameFields, zipkinResponse } from './utils/testData';
jest.mock('@grafana/runtime', () => ({
@ -26,17 +27,21 @@ describe('ZipkinDatasource', () => {
it('runs query', async () => {
setupBackendSrv(zipkinResponse);
const ds = new ZipkinDatasource(defaultSettings, templateSrv);
await expect(ds.query({ targets: [{ query: '12345' }] } as any)).toEmitValuesWith((val) => {
expect(val[0].data[0].fields).toMatchObject(traceFrameFields);
});
await expect(ds.query({ targets: [{ query: '12345' }] } as DataQueryRequest<ZipkinQuery>)).toEmitValuesWith(
(val) => {
expect(val[0].data[0].fields).toMatchObject(traceFrameFields);
}
);
});
it('runs query with traceId that includes special characters', async () => {
setupBackendSrv(zipkinResponse);
const ds = new ZipkinDatasource(defaultSettings, templateSrv);
await expect(ds.query({ targets: [{ query: 'a/b' }] } as any)).toEmitValuesWith((val) => {
expect(val[0].data[0].fields).toMatchObject(traceFrameFields);
});
await expect(ds.query({ targets: [{ query: 'a/b' }] } as DataQueryRequest<ZipkinQuery>)).toEmitValuesWith(
(val) => {
expect(val[0].data[0].fields).toMatchObject(traceFrameFields);
}
);
});
it('should handle json file upload', async () => {
@ -45,7 +50,7 @@ describe('ZipkinDatasource', () => {
const response = await lastValueFrom(
ds.query({
targets: [{ queryType: 'upload', refId: 'A' }],
} as any)
} as DataQueryRequest<ZipkinQuery>)
);
const field = response.data[0].fields[0];
expect(field.name).toBe('traceID');
@ -59,7 +64,7 @@ describe('ZipkinDatasource', () => {
const response = await lastValueFrom(
ds.query({
targets: [{ queryType: 'upload', refId: 'A' }],
} as any)
} as DataQueryRequest<ZipkinQuery>)
);
expect(response.error?.message).toBeDefined();
expect(response.data.length).toBe(0);
@ -68,7 +73,7 @@ describe('ZipkinDatasource', () => {
describe('metadataRequest', () => {
it('runs query', async () => {
setupBackendSrv(['service 1', 'service 2']);
setupBackendSrv(['service 1', 'service 2'] as unknown as ZipkinSpan[]);
const ds = new ZipkinDatasource(defaultSettings);
const response = await ds.metadataRequest('/api/v2/services');
expect(response).toEqual(['service 1', 'service 2']);
@ -76,7 +81,7 @@ describe('ZipkinDatasource', () => {
});
});
function setupBackendSrv(response: any) {
function setupBackendSrv(response: ZipkinSpan[]) {
const defaultMock = () => of(createFetchResponse(response));
const fetchMock = jest.spyOn(backendSrv, 'fetch');
@ -88,7 +93,7 @@ const defaultSettings: DataSourceInstanceSettings = {
uid: '1',
type: 'tracing',
name: 'zipkin',
meta: {} as any,
meta: {} as DataSourcePluginMeta,
jsonData: {},
access: 'proxy',
readOnly: false,

View File

@ -5,6 +5,7 @@ import { byTestId } from 'testing-library-selector';
import { getDefaultTimeRange, LoadingState, PanelProps, FieldConfigSource } from '@grafana/data';
import { setDataSourceSrv } from '@grafana/runtime';
import { Dashboard } from '@grafana/schema';
import { fetchAlertGroups } from 'app/features/alerting/unified/api/alertmanager';
import {
mockAlertGroup,
@ -13,7 +14,8 @@ import {
MockDataSourceSrv,
} from 'app/features/alerting/unified/mocks';
import { DataSourceType } from 'app/features/alerting/unified/utils/datasource';
import { setDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
import { DashboardSrv, setDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
import { DashboardModel } from 'app/features/dashboard/state';
import { configureStore } from 'app/store/configureStore';
import { AlertGroupsPanel } from './AlertGroupsPanel';
@ -58,10 +60,9 @@ const defaultProps: PanelProps<PanelOptions> = {
options: defaultOptions,
eventBus: {
subscribe: jest.fn(),
getStream: () =>
({
subscribe: jest.fn(),
} as any),
getStream: jest.fn().mockReturnValue({
subscribe: jest.fn(),
}),
publish: jest.fn(),
removeAllListeners: jest.fn(),
newScopedBus: jest.fn(),
@ -80,8 +81,9 @@ const defaultProps: PanelProps<PanelOptions> = {
const renderPanel = (options: PanelOptions = defaultOptions) => {
const store = configureStore();
const dash: any = { id: 1, formatDate: (time: number) => new Date(time).toISOString() };
const dashSrv: any = { getCurrent: () => dash };
const dash = new DashboardModel({ id: 1 } as Dashboard);
dash.formatDate = (time: number) => new Date(time).toISOString();
const dashSrv = { getCurrent: () => dash } as DashboardSrv;
setDashboardSrv(dashSrv);
defaultProps.options = options;

View File

@ -5,7 +5,7 @@ import { AlertListOptions, ShowOption, SortOrder } from './types';
describe('AlertList Panel Migration', () => {
it('should migrate from < 7.5', () => {
const panel: Omit<PanelModel, 'fieldConfig'> & Record<string, any> = {
const panel: Omit<PanelModel, 'fieldConfig'> & Record<string, unknown> = {
id: 7,
links: [],
pluginVersion: '7.4.0',
@ -23,7 +23,7 @@ describe('AlertList Panel Migration', () => {
options: {},
};
const newOptions = alertListPanelMigrationHandler(panel as PanelModel);
const newOptions = alertListPanelMigrationHandler(panel as unknown as PanelModel);
expect(newOptions).toMatchObject({
showOptions: ShowOption.Current,
maxItems: 10,
@ -51,7 +51,7 @@ describe('AlertList Panel Migration', () => {
});
it('should handle >= 7.5', () => {
const panel: Omit<PanelModel<AlertListOptions>, 'fieldConfig'> & Record<string, any> = {
const panel: Omit<PanelModel<AlertListOptions>, 'fieldConfig'> & Record<string, unknown> = {
id: 7,
links: [],
pluginVersion: '7.5.0',
@ -78,7 +78,7 @@ describe('AlertList Panel Migration', () => {
},
};
const newOptions = alertListPanelMigrationHandler(panel as PanelModel);
const newOptions = alertListPanelMigrationHandler(panel as unknown as PanelModel);
expect(newOptions).toMatchObject({
showOptions: 'current',
maxItems: 10,
@ -110,7 +110,7 @@ describe('AlertList Panel Migration', () => {
});
it('should handle config with no options or stateFilter', () => {
const panel: Omit<PanelModel, 'fieldConfig'> & Record<string, any> = {
const panel: Omit<PanelModel, 'fieldConfig'> & Record<string, unknown> = {
id: 7,
links: [],
pluginVersion: '7.4.0',
@ -121,7 +121,7 @@ describe('AlertList Panel Migration', () => {
options: {},
};
const newOptions = alertListPanelMigrationHandler(panel as PanelModel);
const newOptions = alertListPanelMigrationHandler(panel as unknown as PanelModel);
expect(newOptions).toMatchObject({
showOptions: ShowOption.Current,
maxItems: 10,

View File

@ -3,9 +3,9 @@ import { renderHook } from '@testing-library/react-hooks';
import { useLayout } from './layout';
import { EdgeDatum, NodeDatum } from './types';
let onmessage: jest.MockedFunction<any>;
let postMessage: jest.MockedFunction<any>;
let terminate: jest.MockedFunction<any>;
let onmessage: jest.Mock;
let postMessage: jest.Mock;
let terminate: jest.Mock;
jest.mock('./createLayoutWorker', () => {
return {

View File

@ -63,7 +63,7 @@ describe('Stat Panel Migrations', () => {
});
it('use no color unless one was configured', () => {
let old: any = {
const old = {
angular: {
valueName: 'name',
},
@ -73,7 +73,7 @@ describe('Stat Panel Migrations', () => {
let options = statPanelChangedHandler(panel, 'singlestat', old);
expect(options.colorMode).toBe(BigValueColorMode.None);
old = {
const oldWithColorBackground = {
angular: {
valueName: 'name',
colorBackground: true,
@ -81,7 +81,7 @@ describe('Stat Panel Migrations', () => {
};
panel = {} as PanelModel;
options = statPanelChangedHandler(panel, 'singlestat', old);
options = statPanelChangedHandler(panel, 'singlestat', oldWithColorBackground);
expect(options.colorMode).toBe(BigValueColorMode.Background);
});
});

View File

@ -6,13 +6,13 @@ import { textPanelMigrationHandler } from './textPanelMigrationHandler';
describe('textPanelMigrationHandler', () => {
describe('when invoked and previous version was old Angular text panel', () => {
it('then should migrate options', () => {
const panel: any = {
const panel = {
content: '<span>Hello World<span>',
mode: 'html',
options: {},
};
const result = textPanelMigrationHandler(panel);
const result = textPanelMigrationHandler(panel as unknown as PanelModel);
expect(result.content).toEqual('<span>Hello World<span>');
expect(result.mode).toEqual('html');
@ -23,14 +23,14 @@ describe('textPanelMigrationHandler', () => {
describe('when invoked and previous version 7.1 or later', () => {
it('then not migrate options', () => {
const panel: any = {
const panel = {
content: '<span>Hello World<span>',
mode: 'html',
options: { content: 'New content' },
pluginVersion: '7.1.0',
};
const result = textPanelMigrationHandler(panel);
const result = textPanelMigrationHandler(panel as unknown as PanelModel);
expect(result.content).toEqual('New content');
});

View File

@ -16,7 +16,7 @@ describe('Graph Migrations', () => {
});
it('simple bars', () => {
const old: any = {
const old = {
angular: {
bars: true,
},
@ -27,7 +27,7 @@ describe('Graph Migrations', () => {
});
it('stairscase', () => {
const old: any = {
const old = {
angular: stairscase,
};
const panel = {} as PanelModel;
@ -45,7 +45,7 @@ describe('Graph Migrations', () => {
});
it('twoYAxis', () => {
const old: any = {
const old = {
angular: twoYAxis,
};
const panel = {} as PanelModel;
@ -54,7 +54,7 @@ describe('Graph Migrations', () => {
});
it('stepped line', () => {
const old: any = {
const old = {
angular: stepedColordLine,
};
const panel = {} as PanelModel;
@ -63,7 +63,7 @@ describe('Graph Migrations', () => {
});
it('preserves colors from series overrides', () => {
const old: any = {
const old = {
angular: customColor,
};
const panel = {} as PanelModel;
@ -72,7 +72,7 @@ describe('Graph Migrations', () => {
});
it('preserves series overrides using a regex alias', () => {
const old: any = {
const old = {
angular: customColorRegex,
};
const panel = {} as PanelModel;
@ -84,7 +84,7 @@ describe('Graph Migrations', () => {
describe('legend', () => {
test('without values', () => {
const old: any = {
const old = {
angular: {
legend: {
show: true,
@ -102,7 +102,7 @@ describe('Graph Migrations', () => {
expect(panel).toMatchSnapshot();
});
test('with single value', () => {
const old: any = {
const old = {
angular: {
legend: {
show: true,
@ -120,7 +120,7 @@ describe('Graph Migrations', () => {
expect(panel).toMatchSnapshot();
});
test('with multiple values', () => {
const old: any = {
const old = {
angular: legend,
};
const panel = {} as PanelModel;
@ -128,7 +128,7 @@ describe('Graph Migrations', () => {
expect(panel).toMatchSnapshot();
});
test('with sideWidth', () => {
const old: any = {
const old = {
angular: {
legend: {
alignAsTable: true,
@ -148,7 +148,7 @@ describe('Graph Migrations', () => {
describe('stacking', () => {
test('simple', () => {
const old: any = {
const old = {
angular: stacking,
};
const panel = {} as PanelModel;
@ -156,7 +156,7 @@ describe('Graph Migrations', () => {
expect(panel).toMatchSnapshot();
});
test('groups', () => {
const old: any = {
const old = {
angular: stackingGroups,
};
const panel = {} as PanelModel;
@ -167,7 +167,7 @@ describe('Graph Migrations', () => {
describe('thresholds', () => {
test('Only gt thresholds', () => {
const old: any = {
const old = {
angular: {
thresholds: [
{
@ -211,7 +211,7 @@ describe('Graph Migrations', () => {
});
test('gt & lt thresholds', () => {
const old: any = {
const old = {
angular: {
thresholds: [
{
@ -256,7 +256,7 @@ describe('Graph Migrations', () => {
});
test('Only lt thresholds', () => {
const old: any = {
const old = {
angular: {
thresholds: [
{
@ -333,14 +333,14 @@ describe('Graph Migrations', () => {
describe('tooltip', () => {
test('tooltip mode', () => {
const single: any = {
const single = {
angular: {
tooltip: {
shared: false,
},
},
};
const multi: any = {
const multi = {
angular: {
tooltip: {
shared: true,
@ -359,7 +359,7 @@ describe('Graph Migrations', () => {
});
test('sort order', () => {
const none: any = {
const none = {
angular: {
tooltip: {
shared: true,
@ -368,7 +368,7 @@ describe('Graph Migrations', () => {
},
};
const asc: any = {
const asc = {
angular: {
tooltip: {
shared: true,
@ -377,7 +377,7 @@ describe('Graph Migrations', () => {
},
};
const desc: any = {
const desc = {
angular: {
tooltip: {
shared: true,
@ -386,7 +386,7 @@ describe('Graph Migrations', () => {
},
};
const singleModeWithUnnecessaryOption: any = {
const singleModeWithUnnecessaryOption = {
angular: {
tooltip: {
shared: false,
@ -414,7 +414,7 @@ describe('Graph Migrations', () => {
describe('x axis', () => {
test('should hide x axis', () => {
const old: any = {
const old = {
angular: {
xaxis: {
show: false,
@ -430,7 +430,7 @@ describe('Graph Migrations', () => {
describe('transforms', () => {
test.each(['negative-Y', 'constant'])('should preserve %p transform', (transform) => {
const old: any = {
const old = {
angular: {
seriesOverrides: [
{
@ -448,7 +448,7 @@ describe('Graph Migrations', () => {
describe('null values', () => {
test('nullPointMode = null', () => {
const old: any = {
const old = {
angular: {
nullPointMode: 'null',
},
@ -458,7 +458,7 @@ describe('Graph Migrations', () => {
expect(panel.fieldConfig.defaults.custom.spanNulls).toBeFalsy();
});
test('nullPointMode = connected', () => {
const old: any = {
const old = {
angular: {
nullPointMode: 'connected',
},