From f8d89eff562dfb7c90b0bb617c639339af30d55c Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Tue, 14 Feb 2023 16:46:42 +0100 Subject: [PATCH] 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 --- .betterer.results | 520 +----------------- .../src/dataframe/MutableDataFrame.test.ts | 2 +- .../src/dataframe/frameComparisons.test.ts | 10 +- .../grafana-data/src/datetime/parser.test.ts | 4 +- .../grafana-data/src/events/EventBus.test.ts | 6 +- .../src/field/displayProcessor.test.ts | 2 +- .../src/field/fieldDisplay.test.ts | 12 +- .../src/field/fieldOverrides.test.ts | 70 ++- packages/grafana-data/src/field/scale.test.ts | 4 +- .../src/panel/PanelPlugin.test.tsx | 15 +- .../panel/getPanelOptionsWithDefaults.test.ts | 4 +- .../transformers/labelsToFields.test.ts | 2 +- .../transformers/merge.test.ts | 16 +- .../transformers/reduce.test.ts | 4 +- .../transformers/seriesToRows.test.ts | 11 +- .../src/utils/valueMappings.test.ts | 4 +- .../src/config/webpack.plugin.config.test.ts | 4 +- .../Forms/Legacy/Select/SelectOption.test.tsx | 2 +- .../src/components/Table/utils.test.tsx | 30 +- .../angular/AngularLocationWrapper.test.ts | 2 +- .../panel/specs/metrics_panel_ctrl.test.ts | 2 +- .../components/NavBar/NavBarItem.test.tsx | 4 +- .../components/TimelineChart/utils.test.ts | 17 +- .../app/core/navigation/GrafanaRoute.test.tsx | 8 +- public/app/core/reducers/root.test.ts | 2 +- .../core/services/__mocks__/backend_srv.ts | 1 + public/app/core/specs/backend_srv.test.ts | 16 +- public/app/core/specs/flatten.test.ts | 15 +- public/app/core/specs/ticks.test.ts | 15 +- public/app/core/specs/time_series.test.ts | 45 +- public/app/core/utils/errors.test.ts | 2 +- public/app/core/utils/explore.test.ts | 7 +- public/app/core/utils/fetch.test.ts | 2 +- public/app/core/utils/timePicker.test.ts | 4 +- .../features/alerting/AlertTabCtrl.test.ts | 9 +- .../getAlertingValidationMessage.test.ts | 20 +- .../alerting/state/ThresholdMapper.test.ts | 18 +- .../features/alerting/state/selectors.test.ts | 14 +- .../alerting/unified/AmRoutes.test.tsx | 4 +- .../alerting/unified/RuleList.test.tsx | 4 +- .../DashExportModal/DashboardExporter.test.ts | 2 +- .../DashboardPrompt/DashboardPrompt.test.tsx | 4 +- .../PanelEditor/OptionsPaneOptions.test.tsx | 3 +- .../PanelEditor/state/actions.test.ts | 31 +- .../forms/SaveDashboardForm.test.tsx | 18 +- .../SharePublicDashboard.test.tsx | 2 +- .../SubMenu/DashboardLinksDashboard.test.tsx | 11 +- .../containers/DashboardPage.test.tsx | 16 +- .../containers/SoloPanelPage.test.tsx | 25 +- .../dashboard/dashgrid/DashboardGrid.test.tsx | 7 +- .../dashboard/services/TimeSrv.test.ts | 34 +- .../state/DashboardModel.refresh.test.ts | 4 +- .../dashboard/state/DashboardModel.test.ts | 14 +- .../dashboard/utils/panelMerge.test.ts | 10 +- public/app/features/datasources/api.test.ts | 2 +- .../datasources/state/actions.test.ts | 2 +- .../ThresholdsEditor.test.tsx | 20 +- .../ValueMappingsEditor.test.tsx | 22 +- .../ValueMappingsEditorModal.test.tsx | 4 +- public/app/features/dimensions/scale.test.ts | 3 +- .../explore/NodeGraphContainer.test.tsx | 2 +- .../RichHistoryStarredTab.test.tsx | 2 +- .../explore/TraceView/TraceView.test.tsx | 4 +- .../explore/state/explorePane.test.ts | 2 +- .../app/features/explore/state/main.test.ts | 2 +- .../features/explore/utils/decorators.test.ts | 2 +- .../app/features/explore/utils/links.test.ts | 11 +- .../expressions/ExpressionDatasource.test.ts | 2 +- .../app/features/geo/format/geojson.test.ts | 4 +- .../features/geo/gazetteer/gazetteer.test.ts | 4 +- .../features/geo/gazetteer/worldmap.test.ts | 2 +- .../features/invites/SignupInvited.test.tsx | 5 +- .../DeleteLibraryPanelModal/reducer.test.ts | 3 +- .../LibraryPanelsSearch.test.tsx | 8 +- public/app/features/live/live.test.ts | 18 +- .../PublicDashboardListTable.test.tsx | 2 +- .../components/SnapshotListTable.test.tsx | 4 +- .../manage-dashboards/state/actions.test.ts | 9 +- public/app/features/org/state/actions.test.ts | 13 +- .../panel/panellinks/specs/link_srv.test.ts | 16 +- .../panel/state/getAllSuggestions.test.ts | 2 +- public/app/features/panel/state/utils.test.ts | 16 +- .../playlist/PlaylistEditPage.test.tsx | 13 +- .../features/playlist/PlaylistPage.test.tsx | 2 +- .../plugins/admin/pages/Browse.test.tsx | 3 +- .../plugins/components/AppRootPage.test.tsx | 7 +- .../plugins/tests/plugin_loader.test.ts | 4 - .../features/profile/state/reducers.test.ts | 2 +- .../AlertStatesWorker.test.ts | 2 +- .../AnnotationsQueryRunner.test.ts | 25 +- .../AnnotationsWorker.test.ts | 19 +- .../DashboardQueryRunner.test.ts | 11 +- .../LegacyAnnotationQueryRunner.test.ts | 25 +- .../SnapshotWorker.test.ts | 20 +- .../UnifiedAlertStatesWorker.test.ts | 23 +- .../query/state/PanelQueryRunner.test.ts | 26 +- .../features/query/state/runRequest.test.ts | 2 +- .../components/SearchResultsGrid.test.tsx | 4 +- .../ServiceAccountPage.test.tsx | 8 +- public/app/features/teams/TeamPages.test.tsx | 3 +- .../features/templating/template_srv.test.ts | 22 +- .../app/features/templating/template_srv.ts | 2 +- .../extractFields/extractFields.test.ts | 4 +- .../adhoc/picker/AdHocFilter.test.tsx | 4 +- .../editor/getVariableQueryEditor.test.tsx | 38 +- .../getAllVariableValuesForUrl.test.ts | 2 +- public/app/features/variables/guard.test.ts | 86 +-- .../features/variables/inspect/utils.test.ts | 14 +- .../OptionsPicker/OptionPicker.test.tsx | 3 +- .../pickers/OptionsPicker/actions.test.ts | 2 +- .../query/VariableQueryRunner.test.ts | 11 +- .../variables/query/operators.test.ts | 6 +- .../query/variableQueryObserver.test.ts | 8 +- .../azure_log_analytics_datasource.test.ts | 2 +- .../azure_monitor_datasource.test.ts | 2 +- .../azure_resource_graph_datasource.test.ts | 2 +- .../ArgQueryEditor/ArgQueryEditor.test.tsx | 2 +- .../LogsQueryEditor/LogsQueryEditor.test.tsx | 2 +- .../MetricsQueryEditor.test.tsx | 2 +- .../ResourcePicker/ResourcePicker.test.tsx | 2 +- .../components/ResourcePicker/utils.test.ts | 2 +- .../resourcePicker/resourcePickerData.test.ts | 2 +- .../datasource/azuremonitor/variables.test.ts | 2 +- .../components/AnnotationQueryEditor.test.tsx | 2 +- .../components/MetricQueryEditor.test.tsx | 2 +- .../components/QueryEditor.test.tsx | 2 +- .../cloud-monitoring/functions.test.ts | 2 +- .../cloud-monitoring/specs/datasource.test.ts | 2 +- .../dashboard/DashboardQueryEditor.test.tsx | 2 +- .../elasticsearch/datasource.test.ts | 4 +- .../datasource/grafana/datasource.test.ts | 2 +- .../datasource/graphite/datasource.test.ts | 2 +- .../influxdb/specs/response_parser.test.ts | 2 +- .../datasource/mixed/MixedDataSource.test.ts | 2 +- .../opentsdb/specs/datasource.test.ts | 2 +- .../prometheus/metric_find_query.test.ts | 2 +- .../datasource/zipkin/datasource.test.ts | 2 +- .../alertGroups/AlertGroupsPanel.test.tsx | 2 +- .../panel/annolist/AnnoListPanel.test.tsx | 2 +- 139 files changed, 675 insertions(+), 1080 deletions(-) diff --git a/.betterer.results b/.betterer.results index 7e9cc245d29..9a7a5d883fb 100644 --- a/.betterer.results +++ b/.betterer.results @@ -47,9 +47,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "7"], [0, 0, 0, "Unexpected any. Specify a different type.", "8"] ], - "packages/grafana-data/src/dataframe/MutableDataFrame.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-data/src/dataframe/MutableDataFrame.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -72,12 +69,6 @@ exports[`better eslint`] = { "packages/grafana-data/src/dataframe/dimensions.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-data/src/dataframe/frameComparisons.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"] - ], "packages/grafana-data/src/dataframe/frameComparisons.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -132,9 +123,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "8"], [0, 0, 0, "Do not use any type assertions.", "9"] ], - "packages/grafana-data/src/datetime/parser.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-data/src/datetime/parser.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -157,10 +145,7 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "1"] ], "packages/grafana-data/src/events/EventBus.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"] ], "packages/grafana-data/src/events/EventBus.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -180,49 +165,12 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], - "packages/grafana-data/src/field/displayProcessor.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-data/src/field/displayProcessor.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, "Do not use any type assertions.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], - "packages/grafana-data/src/field/fieldDisplay.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], - "packages/grafana-data/src/field/fieldOverrides.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"], - [0, 0, 0, "Unexpected any. Specify a different type.", "25"], - [0, 0, 0, "Unexpected any. Specify a different type.", "26"], - [0, 0, 0, "Unexpected any. Specify a different type.", "27"] - ], "packages/grafana-data/src/field/fieldOverrides.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -245,10 +193,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "10"], [0, 0, 0, "Do not use any type assertions.", "11"] ], - "packages/grafana-data/src/field/scale.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-data/src/field/scale.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -271,11 +215,6 @@ exports[`better eslint`] = { "packages/grafana-data/src/geo/layer.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-data/src/panel/PanelPlugin.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"] - ], "packages/grafana-data/src/panel/PanelPlugin.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -286,10 +225,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "6"], [0, 0, 0, "Do not use any type assertions.", "7"] ], - "packages/grafana-data/src/panel/getPanelOptionsWithDefaults.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-data/src/panel/getPanelOptionsWithDefaults.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -362,13 +297,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], - "packages/grafana-data/src/transformations/transformers/labelsToFields.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "packages/grafana-data/src/transformations/transformers/merge.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-data/src/transformations/transformers/merge.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -376,20 +304,12 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], - "packages/grafana-data/src/transformations/transformers/reduce.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-data/src/transformations/transformers/reduce.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, "Do not use any type assertions.", "2"], [0, 0, 0, "Do not use any type assertions.", "3"] ], - "packages/grafana-data/src/transformations/transformers/seriesToRows.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -756,10 +676,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"] ], - "packages/grafana-data/src/utils/valueMappings.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-data/src/utils/valueMappings.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -1045,9 +961,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "packages/grafana-toolkit/src/config/webpack.plugin.config.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-toolkit/src/config/webpack.plugin.config.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -1173,9 +1086,6 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/Forms/Legacy/Select/Select.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-ui/src/components/Forms/Legacy/Select/SelectOption.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "packages/grafana-ui/src/components/Forms/Legacy/Select/SelectOption.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -1475,18 +1385,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "packages/grafana-ui/src/components/Table/utils.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"], - [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"] - ], "packages/grafana-ui/src/components/Table/utils.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -1690,9 +1588,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"] ], - "public/app/angular/AngularLocationWrapper.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/angular/AngularLocationWrapper.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -2222,9 +2117,6 @@ exports[`better eslint`] = { [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] ], - "public/app/core/components/NavBar/NavBarItem.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/core/components/NavBar/NavBarItemMenuTrigger.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -2372,9 +2264,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "4"] ], - "public/app/core/components/TimelineChart/utils.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/core/components/TimelineChart/utils.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -2395,10 +2284,7 @@ exports[`better eslint`] = { ], "public/app/core/navigation/GrafanaRoute.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"] + [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/core/navigation/__mocks__/routeProps.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -2476,30 +2362,12 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], "public/app/core/specs/backend_srv.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"] - ], - "public/app/core/specs/flatten.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/core/specs/ticks.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/core/specs/time_series.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.", "2"] ], "public/app/core/time_series2.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -2544,12 +2412,6 @@ exports[`better eslint`] = { "public/app/core/utils/deferred.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/core/utils/errors.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/core/utils/explore.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/core/utils/explore.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -2614,9 +2476,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Do not use any type assertions.", "5"] ], - "public/app/core/utils/timePicker.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/core/utils/tracing.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -2633,11 +2492,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"] ], - "public/app/features/alerting/AlertTabCtrl.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/features/alerting/AlertTabCtrl.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -2693,12 +2547,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/alerting/getAlertingValidationMessage.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/features/alerting/getAlertingValidationMessage.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -2706,12 +2555,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/features/alerting/state/ThresholdMapper.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/features/alerting/state/ThresholdMapper.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -2743,17 +2586,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/features/alerting/state/selectors.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/features/alerting/unified/AlertsFolderView.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/alerting/unified/AmRoutes.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/alerting/unified/PanelAlertTabContent.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -2763,9 +2598,6 @@ exports[`better eslint`] = { "public/app/features/alerting/unified/PanelAlertTabContent.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], - "public/app/features/alerting/unified/RuleList.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/alerting/unified/RuleList.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] @@ -3074,8 +2906,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "12"] ], "public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.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.", "0"] ], "public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], @@ -3119,9 +2950,6 @@ exports[`better eslint`] = { [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], [0, 0, 0, "Do not use any type assertions.", "2"] ], - "public/app/features/dashboard/components/PanelEditor/OptionsPaneOptions.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dashboard/components/PanelEditor/OverrideCategoryTitle.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -3152,21 +2980,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"] ], - "public/app/features/dashboard/components/PanelEditor/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"], - [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"] - ], "public/app/features/dashboard/components/PanelEditor/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -3193,16 +3006,6 @@ exports[`better eslint`] = { "public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.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"], - [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"] - ], "public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], @@ -3240,10 +3043,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/features/dashboard/components/SubMenu/DashboardLinksDashboard.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/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], @@ -3277,12 +3076,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], - "public/app/features/dashboard/containers/DashboardPage.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/features/dashboard/containers/DashboardPage.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -3290,18 +3083,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"] ], - "public/app/features/dashboard/containers/SoloPanelPage.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"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"], - [0, 0, 0, "Unexpected any. Specify a different type.", "6"] - ], - "public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dashboard/dashgrid/DashboardGrid.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -3344,23 +3125,6 @@ exports[`better eslint`] = { "public/app/features/dashboard/services/PublicDashboardDataSource.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/dashboard/services/TimeSrv.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"] - ], "public/app/features/dashboard/services/TimeSrv.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -3427,9 +3191,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "33"], [0, 0, 0, "Do not use any type assertions.", "34"] ], - "public/app/features/dashboard/state/DashboardModel.refresh.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dashboard/state/DashboardModel.repeat.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -3441,12 +3202,7 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "7"] ], "public/app/features/dashboard/state/DashboardModel.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/features/dashboard/state/DashboardModel.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -3579,11 +3335,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "14"], [0, 0, 0, "Unexpected any. Specify a different type.", "15"] ], - "public/app/features/dashboard/utils/panelMerge.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/features/dashboard/utils/panelMerge.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -3673,31 +3424,13 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], - "public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.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/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditor.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/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditor.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditorModal.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/features/dimensions/scale.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/dimensions/scale.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -3732,9 +3465,6 @@ exports[`better eslint`] = { "public/app/features/explore/LogsMetaRow.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/explore/NodeGraphContainer.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/explore/QueryRows.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -3742,12 +3472,6 @@ exports[`better eslint`] = { "public/app/features/explore/RichHistory/RichHistory.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/explore/RichHistory/RichHistoryStarredTab.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/explore/TraceView/TraceView.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/explore/TraceView/TraceView.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -3839,9 +3563,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], - "public/app/features/explore/state/main.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/explore/state/time.test.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -3853,16 +3574,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Do not use any type assertions.", "5"] ], - "public/app/features/explore/utils/decorators.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/explore/utils/links.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"] - ], "public/app/features/explore/utils/links.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -3883,18 +3594,12 @@ exports[`better eslint`] = { "public/app/features/geo/format/geohash.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/geo/format/geojson.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/geo/format/geojson.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], "public/app/features/geo/format/utils.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/geo/gazetteer/gazetteer.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/geo/gazetteer/gazetteer.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -3936,19 +3641,9 @@ exports[`better eslint`] = { [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "4"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "5"] ], - "public/app/features/invites/SignupInvited.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/invites/state/selectors.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/library-panels/components/DeleteLibraryPanelModal/reducer.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.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/features/library-panels/components/LibraryPanelsView/actions.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -3995,9 +3690,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Do not use any type assertions.", "2"] ], - "public/app/features/live/live.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/live/pages/AddNewRule.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -4055,19 +3747,13 @@ exports[`better eslint`] = { "public/app/features/manage-dashboards/components/ImportDashboardLibraryPanelsList.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/manage-dashboards/components/SnapshotListTable.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/manage-dashboards/services/ValidationSrv.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/features/manage-dashboards/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.", "0"] ], "public/app/features/manage-dashboards/state/actions.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], @@ -4099,11 +3785,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"] ], - "public/app/features/org/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"] - ], "public/app/features/org/state/actions.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -4144,35 +3825,13 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "6"], [0, 0, 0, "Unexpected any. Specify a different type.", "7"] ], - "public/app/features/panel/panellinks/specs/link_srv.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"] - ], "public/app/features/panel/state/actions.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/panel/state/getAllSuggestions.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/panel/state/reducers.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/panel/state/utils.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/features/playlist/PlaylistEditPage.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/features/playlist/PlaylistForm.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] @@ -4219,9 +3878,6 @@ exports[`better eslint`] = { "public/app/features/plugins/admin/hooks/useHistory.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/plugins/admin/pages/Browse.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/plugins/admin/pages/Browse.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -4243,9 +3899,6 @@ exports[`better eslint`] = { "public/app/features/plugins/built_in_plugins.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/plugins/components/AppRootPage.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/plugins/components/PluginsErrorsInfo.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], @@ -4307,18 +3960,12 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"] ], - "public/app/features/plugins/tests/plugin_loader.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/plugins/utils.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, "Do not use any type assertions.", "2"], [0, 0, 0, "Do not use any type assertions.", "3"] ], - "public/app/features/profile/state/reducers.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/query-library/components/DatasourceTypePicker.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"], [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] @@ -4357,57 +4004,18 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], "public/app/features/query/state/DashboardQueryRunner/AnnotationsQueryRunner.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.", "0"] ], "public/app/features/query/state/DashboardQueryRunner/AnnotationsQueryRunner.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] ], - "public/app/features/query/state/DashboardQueryRunner/AnnotationsWorker.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/features/query/state/DashboardQueryRunner/DashboardQueryRunner.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/query/state/DashboardQueryRunner/DashboardQueryRunner.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/query/state/DashboardQueryRunner/LegacyAnnotationQueryRunner.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"] - ], - "public/app/features/query/state/DashboardQueryRunner/SnapshotWorker.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/features/query/state/DashboardQueryRunner/SnapshotWorker.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.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/features/query/state/DashboardQueryRunner/testHelpers.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -4422,22 +4030,11 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"] ], - "public/app/features/query/state/PanelQueryRunner.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/features/query/state/PanelQueryRunner.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, "Do not use any type assertions.", "2"] ], - "public/app/features/query/state/runRequest.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/query/state/runRequest.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -4484,9 +4081,6 @@ exports[`better eslint`] = { "public/app/features/search/page/components/SearchResultsCards.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/search/page/components/SearchResultsGrid.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/search/page/components/SearchResultsGrid.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] @@ -4518,11 +4112,6 @@ exports[`better eslint`] = { "public/app/features/search/utils.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/serviceaccounts/ServiceAccountPage.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/features/serviceaccounts/state/reducers.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"], @@ -4548,9 +4137,6 @@ exports[`better eslint`] = { "public/app/features/teams/TeamMembers.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/teams/TeamPages.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/teams/TeamPages.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], @@ -4565,14 +4151,6 @@ exports[`better eslint`] = { "public/app/features/templating/template_srv.mock.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/templating/template_srv.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/features/templating/template_srv.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -4664,9 +4242,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"] ], - "public/app/features/transformers/extractFields/extractFields.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/transformers/extractFields/extractFields.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] @@ -4737,9 +4312,6 @@ exports[`better eslint`] = { "public/app/features/variables/adhoc/actions.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/variables/adhoc/picker/AdHocFilter.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/variables/adhoc/picker/AdHocFilter.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], @@ -4797,19 +4369,6 @@ exports[`better eslint`] = { "public/app/features/variables/editor/VariableValuesPreview.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], - "public/app/features/variables/editor/getVariableQueryEditor.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"], - [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"] - ], "public/app/features/variables/editor/getVariableQueryEditor.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -4820,48 +4379,10 @@ exports[`better eslint`] = { "public/app/features/variables/editor/types.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "public/app/features/variables/getAllVariableValuesForUrl.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/variables/getAllVariableValuesForUrl.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], - "public/app/features/variables/guard.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"], - [0, 0, 0, "Unexpected any. Specify a different type.", "25"], - [0, 0, 0, "Unexpected any. Specify a different type.", "26"], - [0, 0, 0, "Unexpected any. Specify a different type.", "27"], - [0, 0, 0, "Unexpected any. Specify a different type.", "28"], - [0, 0, 0, "Unexpected any. Specify a different type.", "29"], - [0, 0, 0, "Unexpected any. Specify a different type.", "30"], - [0, 0, 0, "Unexpected any. Specify a different type.", "31"], - [0, 0, 0, "Unexpected any. Specify a different type.", "32"] - ], "public/app/features/variables/guard.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -4875,11 +4396,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/features/variables/inspect/utils.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/features/variables/inspect/utils.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"], @@ -4900,12 +4416,6 @@ exports[`better eslint`] = { "public/app/features/variables/interval/reducer.ts:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], - "public/app/features/variables/pickers/OptionsPicker/OptionPicker.test.tsx:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], - "public/app/features/variables/pickers/OptionsPicker/actions.test.ts:5381": [ - [0, 0, 0, "Unexpected any. Specify a different type.", "0"] - ], "public/app/features/variables/pickers/OptionsPicker/actions.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -4942,12 +4452,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/features/variables/query/VariableQueryRunner.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/features/variables/query/VariableQueryRunner.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] @@ -4967,10 +4471,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"] ], - "public/app/features/variables/query/operators.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/query/operators.ts:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"] @@ -5004,10 +4504,6 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], - "public/app/features/variables/query/variableQueryObserver.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/query/variableQueryObserver.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-data/src/dataframe/MutableDataFrame.test.ts b/packages/grafana-data/src/dataframe/MutableDataFrame.test.ts index 7718c62e469..a22ff61c746 100644 --- a/packages/grafana-data/src/dataframe/MutableDataFrame.test.ts +++ b/packages/grafana-data/src/dataframe/MutableDataFrame.test.ts @@ -60,7 +60,7 @@ describe('Apending DataFrame', () => { // Make sure length survives a spread operator const keys = Object.keys(frame); - const copy = { ...frame } as any; + const copy = { ...frame } as MutableDataFrame; expect(keys).toContain('length'); expect(copy.length).toEqual(frame.length); }); diff --git a/packages/grafana-data/src/dataframe/frameComparisons.test.ts b/packages/grafana-data/src/dataframe/frameComparisons.test.ts index 98cad7ccfe0..0841806a61b 100644 --- a/packages/grafana-data/src/dataframe/frameComparisons.test.ts +++ b/packages/grafana-data/src/dataframe/frameComparisons.test.ts @@ -1,4 +1,4 @@ -import { FieldType } from '../types/dataFrame'; +import { DataFrame, FieldType } from '../types/dataFrame'; import { compareDataFrameStructures, compareArrayValues } from './frameComparisons'; import { toDataFrame } from './processDataFrame'; @@ -32,12 +32,12 @@ describe('test comparisons', () => { expect(compareDataFrameStructures(frameA, frameA)).toBeTruthy(); expect(compareDataFrameStructures(frameA, { ...frameA })).toBeTruthy(); expect(compareDataFrameStructures(frameA, frameB)).toBeFalsy(); - expect(compareDataFrameStructures(frameA, null as any)).toBeFalsy(); - expect(compareDataFrameStructures(undefined as any, frameA)).toBeFalsy(); + expect(compareDataFrameStructures(frameA, null as unknown as DataFrame)).toBeFalsy(); + expect(compareDataFrameStructures(undefined as unknown as DataFrame, frameA)).toBeFalsy(); expect(compareArrayValues([frameA], [frameA], compareDataFrameStructures)).toBeTruthy(); - expect(compareArrayValues([frameA], null as any, compareDataFrameStructures)).toBeFalsy(); - expect(compareArrayValues(null as any, [frameA], compareDataFrameStructures)).toBeFalsy(); + expect(compareArrayValues([frameA], null as unknown as DataFrame[], compareDataFrameStructures)).toBeFalsy(); + expect(compareArrayValues(null as unknown as DataFrame[], [frameA], compareDataFrameStructures)).toBeFalsy(); }); it('name change should be a structure change', () => { diff --git a/packages/grafana-data/src/datetime/parser.test.ts b/packages/grafana-data/src/datetime/parser.test.ts index ec9e216184c..f9756c8b736 100644 --- a/packages/grafana-data/src/datetime/parser.test.ts +++ b/packages/grafana-data/src/datetime/parser.test.ts @@ -1,4 +1,4 @@ -import { systemDateFormats } from './formats'; +import { systemDateFormats, SystemDateFormatsState } from './formats'; import { dateTimeParse } from './parser'; describe('dateTimeParse', () => { @@ -10,7 +10,7 @@ describe('dateTimeParse', () => { it('should be able to parse using default format', () => { systemDateFormats.update({ fullDate: 'MMMM D, YYYY, h:mm:ss a', - interval: {} as any, + interval: {} as SystemDateFormatsState['interval'], useBrowserLocale: false, }); diff --git a/packages/grafana-data/src/events/EventBus.test.ts b/packages/grafana-data/src/events/EventBus.test.ts index 10826bdda9f..eaf69d9b499 100644 --- a/packages/grafana-data/src/events/EventBus.test.ts +++ b/packages/grafana-data/src/events/EventBus.test.ts @@ -71,7 +71,7 @@ describe('EventBus', () => { describe('Legacy emitter behavior', () => { it('Supports legacy events', () => { const bus = new EventBusSrv(); - const events: any = []; + const events: LegacyEventPayload[] = []; const handler = (event: LegacyEventPayload) => { events.push(event); }; @@ -88,8 +88,8 @@ describe('EventBus', () => { it('Interoperability with legacy events', () => { const bus = new EventBusSrv(); - const legacyEvents: any = []; - const newEvents: any = []; + const legacyEvents: LegacyEventPayload[] = []; + const newEvents: AlertSuccessEvent[] = []; bus.on(legacyEvent, (event) => { legacyEvents.push(event); diff --git a/packages/grafana-data/src/field/displayProcessor.test.ts b/packages/grafana-data/src/field/displayProcessor.test.ts index c0962202099..415d383bed3 100644 --- a/packages/grafana-data/src/field/displayProcessor.test.ts +++ b/packages/grafana-data/src/field/displayProcessor.test.ts @@ -17,7 +17,7 @@ function getDisplayProcessorFromConfig(config: FieldConfig, fieldType: FieldType }); } -function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) { +function assertSame(input: unknown, processors: DisplayProcessor[], match: DisplayValue) { processors.forEach((processor) => { const value = processor(input); for (const key of Object.keys(match)) { diff --git a/packages/grafana-data/src/field/fieldDisplay.test.ts b/packages/grafana-data/src/field/fieldDisplay.test.ts index b7c3d0c25ae..f7e293987c1 100644 --- a/packages/grafana-data/src/field/fieldDisplay.test.ts +++ b/packages/grafana-data/src/field/fieldDisplay.test.ts @@ -3,7 +3,7 @@ import { merge } from 'lodash'; import { toDataFrame } from '../dataframe/processDataFrame'; import { createTheme } from '../themes'; import { ReducerID } from '../transformations/fieldReducer'; -import { MappingType, SpecialValueMatch, ValueMapping } from '../types'; +import { FieldConfigPropertyItem, MappingType, SpecialValueMatch, ValueMapping } from '../types'; import { getDisplayProcessor } from './displayProcessor'; import { getFieldDisplayValues, GetFieldDisplayValuesOptions } from './fieldDisplay'; @@ -14,11 +14,15 @@ describe('FieldDisplay', () => { // Since FieldConfigEditors belong to grafana-ui we need to mock those here // as grafana-ui code cannot be imported in grafana-data. // TODO: figure out a way to share standard editors between data/ui tests - const mappings = { + const mappings: FieldConfigPropertyItem = { id: 'mappings', // Match field properties - process: (value: any) => value, + process: (value) => value, shouldApply: () => true, - } as any; + override: jest.fn(), + editor: jest.fn(), + name: 'Value mappings', + path: 'mappings', + }; standardFieldConfigEditorRegistry.setInit(() => { return [mappings]; diff --git a/packages/grafana-data/src/field/fieldOverrides.test.ts b/packages/grafana-data/src/field/fieldOverrides.test.ts index 3d802346614..427dd4ead48 100644 --- a/packages/grafana-data/src/field/fieldOverrides.test.ts +++ b/packages/grafana-data/src/field/fieldOverrides.test.ts @@ -31,36 +31,48 @@ import { } from './fieldOverrides'; import { getFieldDisplayName } from './fieldState'; -const property1: any = { +const property1: FieldConfigPropertyItem = { id: 'custom.property1', // Match field properties path: 'property1', // Match field properties isCustom: true, - process: (value: any) => value, + process: (value) => value, shouldApply: () => true, + override: jest.fn(), + editor: jest.fn(), + name: 'Property 1', }; -const property2 = { +const property2: FieldConfigPropertyItem = { id: 'custom.property2', // Match field properties path: 'property2', // Match field properties isCustom: true, - process: (value: any) => value, + process: (value) => value, shouldApply: () => true, + override: jest.fn(), + editor: jest.fn(), + name: 'Property 2', }; -const property3: any = { +const property3: FieldConfigPropertyItem = { id: 'custom.property3.nested', // Match field properties path: 'property3.nested', // Match field properties isCustom: true, - process: (value: any) => value, + process: (value) => value, shouldApply: () => true, + override: jest.fn(), + editor: jest.fn(), + name: 'Property 3', }; -const shouldApplyFalse: any = { +const shouldApplyFalse: FieldConfigPropertyItem = { id: 'custom.shouldApplyFalse', // Match field properties path: 'shouldApplyFalse', // Match field properties isCustom: true, - process: (value: any) => value, + process: (value) => value, shouldApply: () => false, + override: jest.fn(), + editor: jest.fn(), + name: 'Should Apply False', }; export const customFieldRegistry: FieldConfigOptionsRegistry = new Registry(() => { @@ -68,9 +80,9 @@ export const customFieldRegistry: FieldConfigOptionsRegistry = new Registry {}) as any, - getTimeRangeForUrl: (() => {}) as any, + config: { appSubUrl: '/subUrl' } as GrafanaConfig, + getVariablesUrlParams: jest.fn(), + getTimeRangeForUrl: jest.fn(), }); describe('Global MinMax', () => { @@ -181,7 +193,7 @@ describe('applyFieldOverrides', () => { defaults: {}, overrides: [], }, - replaceVariables: (value: any) => value, + replaceVariables: (value) => value, theme: createTheme(), fieldConfigRegistry: new FieldConfigOptionsRegistry(), }); @@ -300,7 +312,7 @@ describe('applyFieldOverrides', () => { }); it('getLinks should use applied field config', () => { - const replaceVariablesCalls: any[] = []; + const replaceVariablesCalls: ScopedVars[] = []; const data = applyFieldOverrides({ data: [f0], // the frame @@ -375,8 +387,8 @@ describe('setFieldConfigDefaults', () => { }; const context: FieldOverrideEnv = { - data: [] as any, - field: { type: FieldType.number } as any, + data: [], + field: { type: FieldType.number } as Field, dataFrameIndex: 0, fieldConfigRegistry: customFieldRegistry, }; @@ -410,8 +422,8 @@ describe('setFieldConfigDefaults', () => { }; const context: FieldOverrideEnv = { - data: [] as any, - field: { type: FieldType.number } as any, + data: [], + field: { type: FieldType.number } as Field, dataFrameIndex: 0, fieldConfigRegistry: customFieldRegistry, }; @@ -444,8 +456,8 @@ describe('setDynamicConfigValue', () => { }, { fieldConfigRegistry: customFieldRegistry, - data: [] as any, - field: { type: FieldType.number } as any, + data: [], + field: { type: FieldType.number } as Field, dataFrameIndex: 0, } ); @@ -467,8 +479,8 @@ describe('setDynamicConfigValue', () => { }, { fieldConfigRegistry: customFieldRegistry, - data: [] as any, - field: { type: FieldType.number } as any, + data: [], + field: { type: FieldType.number } as Field, dataFrameIndex: 0, } ); @@ -488,8 +500,8 @@ describe('setDynamicConfigValue', () => { }, { fieldConfigRegistry: customFieldRegistry, - data: [] as any, - field: { type: FieldType.number } as any, + data: [], + field: { type: FieldType.number } as Field, dataFrameIndex: 0, } ); @@ -513,8 +525,8 @@ describe('setDynamicConfigValue', () => { }, { fieldConfigRegistry: customFieldRegistry, - data: [] as any, - field: { type: FieldType.number } as any, + data: [], + field: { type: FieldType.number } as Field, dataFrameIndex: 0, } ); @@ -539,8 +551,8 @@ describe('setDynamicConfigValue', () => { }, { fieldConfigRegistry: customFieldRegistry, - data: [] as any, - field: { type: FieldType.number } as any, + data: [], + field: { type: FieldType.number } as Field, dataFrameIndex: 0, } ); @@ -553,8 +565,8 @@ describe('setDynamicConfigValue', () => { }, { fieldConfigRegistry: customFieldRegistry, - data: [] as any, - field: { type: FieldType.number } as any, + data: [], + field: { type: FieldType.number } as Field, dataFrameIndex: 0, } ); diff --git a/packages/grafana-data/src/field/scale.test.ts b/packages/grafana-data/src/field/scale.test.ts index aa7e3a706a9..874d283fc44 100644 --- a/packages/grafana-data/src/field/scale.test.ts +++ b/packages/grafana-data/src/field/scale.test.ts @@ -38,12 +38,12 @@ describe('getScaleCalculator', () => { const theme = createTheme(); const calc = getScaleCalculator(field, theme); - expect(calc(true as any)).toEqual({ + expect(calc(true as unknown as number)).toEqual({ percent: 1, color: theme.visualization.getColorByName('green'), threshold: undefined, }); - expect(calc(false as any)).toEqual({ + expect(calc(false as unknown as number)).toEqual({ percent: 0, color: theme.visualization.getColorByName('red'), threshold: undefined, diff --git a/packages/grafana-data/src/panel/PanelPlugin.test.tsx b/packages/grafana-data/src/panel/PanelPlugin.test.tsx index 074b60db072..e4451b73244 100644 --- a/packages/grafana-data/src/panel/PanelPlugin.test.tsx +++ b/packages/grafana-data/src/panel/PanelPlugin.test.tsx @@ -1,8 +1,13 @@ import React from 'react'; import { PanelOptionsEditorBuilder } from '..'; -import { identityOverrideProcessor, standardEditorsRegistry, standardFieldConfigEditorRegistry } from '../field'; -import { FieldConfigProperty } from '../types'; +import { + identityOverrideProcessor, + standardEditorsRegistry, + StandardEditorsRegistryItem, + standardFieldConfigEditorRegistry, +} from '../field'; +import { FieldConfigProperty, FieldConfigPropertyItem } from '../types'; import { PanelPlugin } from './PanelPlugin'; @@ -19,14 +24,14 @@ describe('PanelPlugin', () => { id: FieldConfigProperty.Max, path: 'max', }, - ] as any; + ] as FieldConfigPropertyItem[]; }); standardEditorsRegistry.setInit(() => { return [ { id: 'number', }, - ] as any; + ] as StandardEditorsRegistryItem[]; }); }); @@ -202,7 +207,7 @@ describe('PanelPlugin', () => { name: 'Option editor', description: 'Option editor description', defaultValue: 10, - } as any); + } as FieldConfigPropertyItem); }, }); expect(() => panel.fieldConfigRegistry).toThrowErrorMatchingInlineSnapshot( diff --git a/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.test.ts b/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.test.ts index f4189f13181..0d26895cd0e 100644 --- a/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.test.ts +++ b/packages/grafana-data/src/panel/getPanelOptionsWithDefaults.test.ts @@ -398,12 +398,12 @@ describe('restoreCustomOverrideRules', () => { }); interface ScenarioOptions { - defaults?: FieldConfig; + defaults?: FieldConfig; overrides?: ConfigOverrideRule[]; disabledStandardOptions?: FieldConfigProperty[]; standardOptions?: Partial>; plugin?: PanelPlugin; - options?: any; + options?: Record; isAfterPluginChange?: boolean; } diff --git a/packages/grafana-data/src/transformations/transformers/labelsToFields.test.ts b/packages/grafana-data/src/transformations/transformers/labelsToFields.test.ts index 8fa028285bc..1fe663527e4 100644 --- a/packages/grafana-data/src/transformations/transformers/labelsToFields.test.ts +++ b/packages/grafana-data/src/transformations/transformers/labelsToFields.test.ts @@ -455,7 +455,7 @@ describe('Labels as Columns', () => { }); function toSimpleObject(frame: DataFrame) { - const obj: any = {}; + const obj: Record = {}; for (const field of frame.fields) { obj[field.name] = field.values.toArray(); } diff --git a/packages/grafana-data/src/transformations/transformers/merge.test.ts b/packages/grafana-data/src/transformations/transformers/merge.test.ts index 9c4b210e42f..30c38aacd80 100644 --- a/packages/grafana-data/src/transformations/transformers/merge.test.ts +++ b/packages/grafana-data/src/transformations/transformers/merge.test.ts @@ -585,18 +585,18 @@ describe('Merge multiple to single', () => { }); }); -const createField = (name: string, type: FieldType, values: any[], config = {}, display?: DisplayProcessor): Field => { +const createField = ( + name: string, + type: FieldType, + values: unknown[], + config = {}, + display?: DisplayProcessor +): Field => { return { name, type, values: new ArrayVector(values), config, labels: undefined, display }; }; const unwrap = (fields: Field[]): Field[] => { return fields.map((field) => - createField( - field.name, - field.type, - field.values.toArray().map((value: any) => value), - field.config, - field.display - ) + createField(field.name, field.type, field.values.toArray(), field.config, field.display) ); }; diff --git a/packages/grafana-data/src/transformations/transformers/reduce.test.ts b/packages/grafana-data/src/transformations/transformers/reduce.test.ts index 1825618d26a..6ad69449486 100644 --- a/packages/grafana-data/src/transformations/transformers/reduce.test.ts +++ b/packages/grafana-data/src/transformations/transformers/reduce.test.ts @@ -261,8 +261,8 @@ describe('Reducer Transformer', () => { expect(frames[0].length).toEqual(1); expect(frames[1].length).toEqual(1); - const view0 = new DataFrameView(frames[0]); - const view1 = new DataFrameView(frames[1]); + const view0 = new DataFrameView(frames[0]); + const view1 = new DataFrameView(frames[1]); expect({ ...view0.get(0) }).toMatchInlineSnapshot(` { "temperature": 6, diff --git a/packages/grafana-data/src/transformations/transformers/seriesToRows.test.ts b/packages/grafana-data/src/transformations/transformers/seriesToRows.test.ts index 9cfc1d930ef..8a8b781ba88 100644 --- a/packages/grafana-data/src/transformations/transformers/seriesToRows.test.ts +++ b/packages/grafana-data/src/transformations/transformers/seriesToRows.test.ts @@ -245,17 +245,10 @@ describe('Series to rows', () => { }); }); -const createField = (name: string, type: FieldType, values: any[], config = {}): Field => { +const createField = (name: string, type: FieldType, values: unknown[], config = {}): Field => { return { name, type, values: new ArrayVector(values), config, labels: undefined }; }; const unwrap = (fields: Field[]): Field[] => { - return fields.map((field) => - createField( - field.name, - field.type, - field.values.toArray().map((value: any) => value), - field.config - ) - ); + return fields.map((field) => createField(field.name, field.type, field.values.toArray(), field.config)); }; diff --git a/packages/grafana-data/src/utils/valueMappings.test.ts b/packages/grafana-data/src/utils/valueMappings.test.ts index 1d656debfef..85b197735fe 100644 --- a/packages/grafana-data/src/utils/valueMappings.test.ts +++ b/packages/grafana-data/src/utils/valueMappings.test.ts @@ -135,12 +135,12 @@ describe('Format value with value mappings', () => { it('should return match result for undefined value', () => { const value = undefined; - expect(getValueMappingResult(testSet1, value as any)).toEqual({ text: 'it is null' }); + expect(getValueMappingResult(testSet1, value)).toEqual({ text: 'it is null' }); }); it('should return match result for nan value', () => { const value = Number.NaN; - expect(getValueMappingResult(testSet1, value as any)).toEqual({ text: 'it is nan' }); + expect(getValueMappingResult(testSet1, value)).toEqual({ text: 'it is nan' }); }); it('should return range mapping that matches first', () => { diff --git a/packages/grafana-toolkit/src/config/webpack.plugin.config.test.ts b/packages/grafana-toolkit/src/config/webpack.plugin.config.test.ts index ea20c19979f..5791f5920f7 100644 --- a/packages/grafana-toolkit/src/config/webpack.plugin.config.test.ts +++ b/packages/grafana-toolkit/src/config/webpack.plugin.config.test.ts @@ -1,4 +1,4 @@ -import fs from 'fs'; +import fs, { BigIntStats } from 'fs'; import { findModuleFiles, loadWebpackConfig } from './webpack.plugin.config'; // eslint-disable-next-line no-duplicate-imports @@ -24,7 +24,7 @@ describe('Plugin webpack config', () => { beforeAll(() => { jest.spyOn(fs, 'statSync').mockReturnValue({ isDirectory: () => false, - } as any); + } as BigIntStats); }); afterAll(() => { diff --git a/packages/grafana-ui/src/components/Forms/Legacy/Select/SelectOption.test.tsx b/packages/grafana-ui/src/components/Forms/Legacy/Select/SelectOption.test.tsx index 2d4ab15c4ea..1d3078e0a78 100644 --- a/packages/grafana-ui/src/components/Forms/Legacy/Select/SelectOption.test.tsx +++ b/packages/grafana-ui/src/components/Forms/Legacy/Select/SelectOption.test.tsx @@ -4,7 +4,7 @@ import renderer from 'react-test-renderer'; import SelectOption from './SelectOption'; -const model: OptionProps = { +const model: OptionProps = { data: jest.fn(), cx: jest.fn(), clearValue: jest.fn(), diff --git a/packages/grafana-ui/src/components/Table/utils.test.tsx b/packages/grafana-ui/src/components/Table/utils.test.tsx index 51f8a97d348..c1d73e0da95 100644 --- a/packages/grafana-ui/src/components/Table/utils.test.tsx +++ b/packages/grafana-ui/src/components/Table/utils.test.tsx @@ -192,7 +192,7 @@ describe('Table utils', () => { type: FieldType.number, getLinks: () => [], state: null, - display: (value: any) => ({ + display: () => ({ numeric: 1, percent: 0.01, color: '', @@ -215,7 +215,7 @@ describe('Table utils', () => { values: new ArrayVector([1, 2, 2, 1, 3, 5, 6]), name: 'value', type: FieldType.number, - display: jest.fn((value: any) => ({ + display: jest.fn().mockImplementation((value) => ({ numeric: 1, percent: 0.01, color: '', @@ -223,7 +223,7 @@ describe('Table utils', () => { text: `${value}.0`, })), }; - const rows: any[] = [{ index: 0 }, { index: 1 }, { index: 2 }, { index: 3 }, { index: 4 }]; + const rows = [{ index: 0 }, { index: 1 }, { index: 2 }, { index: 3 }, { index: 4 }]; const result = calculateUniqueFieldValues(rows, field); @@ -244,7 +244,7 @@ describe('Table utils', () => { name: 'value', type: FieldType.number, }; - const rows: any[] = [{ index: 0 }, { index: 1 }, { index: 2 }, { index: 3 }, { index: 4 }]; + const rows = [{ index: 0 }, { index: 1 }, { index: 2 }, { index: 3 }, { index: 4 }]; const result = calculateUniqueFieldValues(rows, field); @@ -263,7 +263,7 @@ describe('Table utils', () => { name: 'value', type: FieldType.number, }; - const rows: any[] = [{ index: 0 }, { index: 1 }, { index: 2 }, { index: 3 }, { index: 4 }]; + const rows = [{ index: 0 }, { index: 1 }, { index: 2 }, { index: 3 }, { index: 4 }]; const result = calculateUniqueFieldValues(rows, field); @@ -280,7 +280,12 @@ describe('Table utils', () => { describe('rowToFieldValue', () => { describe('happy paths', () => { describe('field without field display', () => { - const field: any = { values: new ArrayVector(['a', 'b', 'c']) }; + const field: Field = { + name: 'value', + type: FieldType.string, + config: {}, + values: new ArrayVector(['a', 'b', 'c']), + }; const row = { index: 1 }; const result = rowToFieldValue(row, field); @@ -294,7 +299,7 @@ describe('Table utils', () => { values: new ArrayVector([1, 2, 2, 1, 3, 5, 6]), name: 'value', type: FieldType.number, - display: jest.fn((value: any) => ({ + display: jest.fn().mockImplementation((value) => ({ numeric: 1, percent: 0.01, color: '', @@ -320,7 +325,12 @@ describe('Table utils', () => { expect(result).toEqual(''); }); describe('row is missing', () => { - const field: any = { values: new ArrayVector(['a', 'b', 'c']) }; + const field = { + name: 'value', + type: FieldType.string, + config: {}, + values: new ArrayVector(['a', 'b', 'c']), + }; const row = undefined; const result = rowToFieldValue(row, field); @@ -502,8 +512,8 @@ describe('Table utils', () => { it.skip('should have good performance', () => { const ITERATIONS = 100000; - const a: any = { values: Array(ITERATIONS) }; - const b: any = { values: Array(ITERATIONS) }; + const a = { values: Array(ITERATIONS) } as unknown as Row; + const b = { values: Array(ITERATIONS) } as unknown as Row; for (let i = 0; i < ITERATIONS; i++) { a.values[i] = Math.random() * Date.now(); b.values[i] = Math.random() * Date.now(); diff --git a/public/app/angular/AngularLocationWrapper.test.ts b/public/app/angular/AngularLocationWrapper.test.ts index 613e570af37..7bd20c89f8c 100644 --- a/public/app/angular/AngularLocationWrapper.test.ts +++ b/public/app/angular/AngularLocationWrapper.test.ts @@ -100,7 +100,7 @@ describe('AngularLocationWrapper', () => { it('should copy object', function () { locationService.push('/path/b'); - const obj: Record = { one: '1', two: true, three: null }; + const obj: Record = { one: '1', two: true, three: null }; wrapper.search(obj); expect(obj).toEqual({ one: '1', two: true, three: null }); obj.one = 'changed'; diff --git a/public/app/angular/panel/specs/metrics_panel_ctrl.test.ts b/public/app/angular/panel/specs/metrics_panel_ctrl.test.ts index 12b281be6ff..04f72d46fe4 100644 --- a/public/app/angular/panel/specs/metrics_panel_ctrl.test.ts +++ b/public/app/angular/panel/specs/metrics_panel_ctrl.test.ts @@ -1,7 +1,7 @@ jest.mock('app/core/core', () => ({})); jest.mock('app/core/config', () => { return { - ...(jest.requireActual('app/core/config') as unknown as object), + ...jest.requireActual('app/core/config'), bootData: { user: {}, }, diff --git a/public/app/core/components/NavBar/NavBarItem.test.tsx b/public/app/core/components/NavBar/NavBarItem.test.tsx index 840b61b7a85..fe89f225b39 100644 --- a/public/app/core/components/NavBar/NavBarItem.test.tsx +++ b/public/app/core/components/NavBar/NavBarItem.test.tsx @@ -4,7 +4,7 @@ import React from 'react'; import { BrowserRouter } from 'react-router-dom'; import { locationUtil } from '@grafana/data'; -import { config, setLocationService } from '@grafana/runtime'; +import { config, LocationService, setLocationService } from '@grafana/runtime'; // Need to mock createBrowserHistory here to avoid errors jest.mock('history', () => ({ @@ -38,7 +38,7 @@ async function getTestContext(overrides: Partial = {}, subUrl = '', isMen config.appSubUrl = subUrl; locationUtil.initialize({ config, getTimeRangeForUrl: jest.fn(), getVariablesUrlParams: jest.fn() }); const pushMock = jest.fn(); - const locationService: any = { push: pushMock }; + const locationService = { push: pushMock } as unknown as LocationService; setLocationService(locationService); const props = { ...defaults, ...overrides }; diff --git a/public/app/core/components/TimelineChart/utils.test.ts b/public/app/core/components/TimelineChart/utils.test.ts index cff8d46a595..a2be4c15661 100644 --- a/public/app/core/components/TimelineChart/utils.test.ts +++ b/public/app/core/components/TimelineChart/utils.test.ts @@ -1,4 +1,13 @@ -import { ArrayVector, createTheme, FieldType, ThresholdsMode, TimeRange, toDataFrame, dateTime } from '@grafana/data'; +import { + ArrayVector, + createTheme, + FieldType, + ThresholdsMode, + TimeRange, + toDataFrame, + dateTime, + DataFrame, +} from '@grafana/data'; import { LegendDisplayMode, VizLegendOptions } from '@grafana/schema'; import { @@ -183,7 +192,7 @@ describe('getThresholdItems', () => { describe('prepareTimelineLegendItems', () => { it('should return legend items without crashing when single (base) threshold', () => { - const frame: any = [ + const frames = [ { refId: 'A', fields: [ @@ -238,10 +247,10 @@ describe('prepareTimelineLegendItems', () => { }, ], }, - ]; + ] as unknown as DataFrame[]; const result = prepareTimelineLegendItems( - frame, + frames, { displayMode: LegendDisplayMode.List } as VizLegendOptions, theme ); diff --git a/public/app/core/navigation/GrafanaRoute.test.tsx b/public/app/core/navigation/GrafanaRoute.test.tsx index accd7e09086..8fcc532a4d4 100644 --- a/public/app/core/navigation/GrafanaRoute.test.tsx +++ b/public/app/core/navigation/GrafanaRoute.test.tsx @@ -1,5 +1,7 @@ import { render, screen } from '@testing-library/react'; +import { History, Location } from 'history'; import React, { ComponentType } from 'react'; +import { match } from 'react-router-dom'; import { TestProvider } from 'test/helpers/TestProvider'; import { setEchoSrv } from '@grafana/runtime'; @@ -10,9 +12,9 @@ import { GrafanaRoute, Props } from './GrafanaRoute'; function setup(overrides: Partial) { const props: Props = { - location: { search: '?query=hello&test=asd' } as any, - history: {} as any, - match: {} as any, + location: { search: '?query=hello&test=asd' } as Location, + history: {} as History, + match: {} as match, route: { path: '/', component: () =>
, diff --git a/public/app/core/reducers/root.test.ts b/public/app/core/reducers/root.test.ts index fd64756ac7b..6bb8712b231 100644 --- a/public/app/core/reducers/root.test.ts +++ b/public/app/core/reducers/root.test.ts @@ -7,7 +7,7 @@ import { cleanUpAction } from '../actions/cleanUp'; import { createRootReducer } from './root'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), config: { bootData: { navTree: [], diff --git a/public/app/core/services/__mocks__/backend_srv.ts b/public/app/core/services/__mocks__/backend_srv.ts index f43e5b77d4d..92bd8b24d77 100644 --- a/public/app/core/services/__mocks__/backend_srv.ts +++ b/public/app/core/services/__mocks__/backend_srv.ts @@ -34,6 +34,7 @@ export const backendSrv = { getFolderByUid: jest.fn(), post: jest.fn(), resolveCancelerIfExists: jest.fn(), + search: jest.fn(), datasourceRequest: jest.fn(() => Promise.resolve(makePromResponse())), // Observable support diff --git a/public/app/core/specs/backend_srv.test.ts b/public/app/core/specs/backend_srv.test.ts index eab93722279..7bc6335ff53 100644 --- a/public/app/core/specs/backend_srv.test.ts +++ b/public/app/core/specs/backend_srv.test.ts @@ -3,11 +3,11 @@ import { Observable, of } from 'rxjs'; import { delay } from 'rxjs/operators'; import { AppEvents, DataQueryErrorType, EventBusExtended } from '@grafana/data'; -import { BackendSrvRequest, FetchError } from '@grafana/runtime'; +import { BackendSrvRequest, FetchError, FetchResponse } from '@grafana/runtime'; import { TokenRevokedModal } from '../../features/users/TokenRevokedModal'; import { ShowModalReactEvent } from '../../types/events'; -import { BackendSrv } from '../services/backend_srv'; +import { BackendSrv, BackendSrvDependencies } from '../services/backend_srv'; import { ContextSrv, User } from '../services/context_srv'; const getTestContext = (overides?: object) => { @@ -65,7 +65,7 @@ const getTestContext = (overides?: object) => { expect(fromFetchMock).toHaveBeenCalledTimes(1); }; - const expectRequestCallChain = (options: any) => { + const expectRequestCallChain = (options: unknown) => { expect(parseRequestOptionsMock).toHaveBeenCalledTimes(1); expect(parseRequestOptionsMock).toHaveBeenCalledWith(options); expectCallChain(); @@ -109,7 +109,7 @@ describe('backendSrv', () => { orgId: orgId, }, }, - } as any); + } as BackendSrvDependencies); if (noBackendCache) { await srv.withNoBackendCache(async () => { @@ -377,7 +377,7 @@ describe('backendSrv', () => { requestId: 'A', }; - let slowError: any = null; + let slowError = null; backendSrv.request(options).catch((err) => { slowError = err; }); @@ -415,7 +415,7 @@ describe('backendSrv', () => { .mockResolvedValue({ ok: true, status: 200, statusText: 'OK', data: { message: 'Ok' } }); const url = '/api/dashboard/'; - let inspectorPacket: any = null; + let inspectorPacket: FetchResponse | FetchError; backendSrv.getInspectorStream().subscribe({ next: (rsp) => (inspectorPacket = rsp), }); @@ -536,7 +536,7 @@ describe('backendSrv', () => { method: 'GET', }; - let inspectorPacket: any = null; + let inspectorPacket: FetchResponse | FetchError; backendSrv.getInspectorStream().subscribe({ next: (rsp) => (inspectorPacket = rsp), }); @@ -563,7 +563,7 @@ describe('backendSrv', () => { describe('when called with 2 separate requests and then cancelAllInFlightRequests is called', () => { const url = '/api/dashboard/'; - const getRequestObservable = (message: string, unsubscribe: any) => + const getRequestObservable = (message: string, unsubscribe: jest.Mock) => new Observable((subscriber) => { subscriber.next({ ok: true, diff --git a/public/app/core/specs/flatten.test.ts b/public/app/core/specs/flatten.test.ts index 64bd87d52ef..4ff45313269 100644 --- a/public/app/core/specs/flatten.test.ts +++ b/public/app/core/specs/flatten.test.ts @@ -2,18 +2,15 @@ import flatten from 'app/core/utils/flatten'; describe('flatten', () => { it('should return flatten object', () => { - const flattened = flatten( - { - level1: 'level1-value', + const flattened = flatten({ + level1: 'level1-value', + deeper: { + level2: 'level2-value', deeper: { - level2: 'level2-value', - deeper: { - level3: 'level3-value', - }, + level3: 'level3-value', }, }, - null as unknown as { delimiter?: any; maxDepth?: any; safe?: any } - ); + }); expect(flattened['level1']).toBe('level1-value'); expect(flattened['deeper.level2']).toBe('level2-value'); diff --git a/public/app/core/specs/ticks.test.ts b/public/app/core/specs/ticks.test.ts index 51713625745..81ea8601e4f 100644 --- a/public/app/core/specs/ticks.test.ts +++ b/public/app/core/specs/ticks.test.ts @@ -2,22 +2,21 @@ import * as ticks from '../utils/ticks'; describe('ticks', () => { describe('getFlotTickDecimals()', () => { - const ctx: any = {}; - - beforeEach(() => { - ctx.axis = {}; - }); + const axis = { + min: null, + max: null, + }; it('should calculate decimals precision based on graph height', () => { - let dec = ticks.getFlotTickDecimals(0, 10, ctx.axis, 200); + let dec = ticks.getFlotTickDecimals(0, 10, axis, 200); expect(dec.tickDecimals).toBe(1); expect(dec.scaledDecimals).toBe(1); - dec = ticks.getFlotTickDecimals(0, 100, ctx.axis, 200); + dec = ticks.getFlotTickDecimals(0, 100, axis, 200); expect(dec.tickDecimals).toBe(0); expect(dec.scaledDecimals).toBe(-1); - dec = ticks.getFlotTickDecimals(0, 1, ctx.axis, 200); + dec = ticks.getFlotTickDecimals(0, 1, axis, 200); expect(dec.tickDecimals).toBe(2); expect(dec.scaledDecimals).toBe(3); }); diff --git a/public/app/core/specs/time_series.test.ts b/public/app/core/specs/time_series.test.ts index 655d9bce233..933759cb17e 100644 --- a/public/app/core/specs/time_series.test.ts +++ b/public/app/core/specs/time_series.test.ts @@ -1,8 +1,8 @@ import TimeSeries, { updateLegendValues } from 'app/core/time_series2'; describe('TimeSeries', () => { - let points, series: any; - const yAxisFormats = ['short', 'ms']; + let points: any[][]; + let series: TimeSeries; let testData: { alias?: string; datapoints: any }; beforeEach(() => { @@ -20,13 +20,13 @@ describe('TimeSeries', () => { describe('when getting flot pairs', () => { it('with connected style, should ignore nulls', () => { series = new TimeSeries(testData); - points = series.getFlotPairs('connected', yAxisFormats); + points = series.getFlotPairs('connected'); expect(points.length).toBe(3); }); it('with null as zero style, should replace nulls with zero', () => { series = new TimeSeries(testData); - points = series.getFlotPairs('null as zero', yAxisFormats); + points = series.getFlotPairs('null as zero'); expect(points.length).toBe(4); expect(points[1][1]).toBe(0); }); @@ -38,7 +38,7 @@ describe('TimeSeries', () => { [null, 2], ], }); - series.getFlotPairs('null', yAxisFormats); + series.getFlotPairs('null'); expect(series.stats.current).toBe(10); }); @@ -49,13 +49,13 @@ describe('TimeSeries', () => { [-4, 2], ], }); - series.getFlotPairs('null', yAxisFormats); + series.getFlotPairs('null'); expect(series.stats.max).toBe(-4); }); it('average value should ignore nulls', () => { series = new TimeSeries(testData); - series.getFlotPairs('null', yAxisFormats); + series.getFlotPairs('null'); expect(series.stats.avg).toBe(6.333333333333333); }); @@ -69,7 +69,7 @@ describe('TimeSeries', () => { [15, 6], ], }); - series.getFlotPairs('null', yAxisFormats); + series.getFlotPairs('null'); expect(series.stats.delta).toBe(14); }); @@ -82,7 +82,7 @@ describe('TimeSeries', () => { [15, 5], ], }); - series.getFlotPairs('null', yAxisFormats); + series.getFlotPairs('null'); expect(series.stats.delta).toBe(14); }); @@ -95,7 +95,7 @@ describe('TimeSeries', () => { [null, 5], ], }); - series.getFlotPairs('null', yAxisFormats); + series.getFlotPairs('null'); expect(series.stats.delta).toBe(9); }); @@ -109,7 +109,7 @@ describe('TimeSeries', () => { [10, 6], ], }); - series.getFlotPairs('null', yAxisFormats); + series.getFlotPairs('null'); expect(series.stats.delta).toBe(19); }); @@ -122,19 +122,19 @@ describe('TimeSeries', () => { [8, 5], ], }); - series.getFlotPairs('null', yAxisFormats); + series.getFlotPairs('null'); expect(series.stats.delta).toBe(17); }); it('the range value should be max - min', () => { series = new TimeSeries(testData); - series.getFlotPairs('null', yAxisFormats); + series.getFlotPairs('null'); expect(series.stats.range).toBe(9); }); it('first value should ingone nulls', () => { series = new TimeSeries(testData); - series.getFlotPairs('null', yAxisFormats); + series.getFlotPairs('null'); expect(series.stats.first).toBe(1); series = new TimeSeries({ datapoints: [ @@ -144,13 +144,13 @@ describe('TimeSeries', () => { [8, 5], ], }); - series.getFlotPairs('null', yAxisFormats); + series.getFlotPairs('null'); expect(series.stats.first).toBe(1); }); it('with null as zero style, average value should treat nulls as 0', () => { series = new TimeSeries(testData); - series.getFlotPairs('null as zero', yAxisFormats); + series.getFlotPairs('null as zero'); expect(series.stats.avg).toBe(4.75); }); @@ -238,7 +238,7 @@ describe('TimeSeries', () => { }); describe('can detect if series contains ms precision', () => { - let fakedata: any; + let fakedata: typeof testData; beforeEach(() => { fakedata = testData; @@ -258,7 +258,7 @@ describe('TimeSeries', () => { }); describe('series overrides', () => { - let series: any; + let series: TimeSeries; beforeEach(() => { series = new TimeSeries(testData); }); @@ -390,14 +390,14 @@ describe('TimeSeries', () => { }); describe('value formatter', () => { - let series: any; + let series: TimeSeries; beforeEach(() => { series = new TimeSeries(testData); }); it('should format non-numeric values as empty string', () => { expect(series.formatValue(null)).toBe(''); - expect(series.formatValue(undefined)).toBe(''); + expect(series.formatValue(undefined as unknown as null)).toBe(''); expect(series.formatValue(NaN)).toBe(''); expect(series.formatValue(Infinity)).toBe(''); expect(series.formatValue(-Infinity)).toBe(''); @@ -405,7 +405,8 @@ describe('TimeSeries', () => { }); describe('legend decimals', () => { - let series: any, panel: any; + let series: TimeSeries; + let panel: any; const height = 200; beforeEach(() => { testData = { @@ -418,7 +419,7 @@ describe('TimeSeries', () => { ], }; series = new TimeSeries(testData); - series.getFlotPairs(); + series.getFlotPairs('connected'); panel = { decimals: null, yaxes: [ diff --git a/public/app/core/utils/errors.test.ts b/public/app/core/utils/errors.test.ts index fcddaaa1470..262f4d1481d 100644 --- a/public/app/core/utils/errors.test.ts +++ b/public/app/core/utils/errors.test.ts @@ -46,7 +46,7 @@ describe('errors functions', () => { describe('when getMessageFromError gets an error object', () => { beforeEach(() => { - message = getMessageFromError({ customError: 'error string' } as any); + message = getMessageFromError({ customError: 'error string' }); }); it('should return the stringified error', () => { diff --git a/public/app/core/utils/explore.test.ts b/public/app/core/utils/explore.test.ts index 3d252d5960b..1792d869240 100644 --- a/public/app/core/utils/explore.test.ts +++ b/public/app/core/utils/explore.test.ts @@ -41,7 +41,7 @@ const datasourceSrv = new DatasourceSrvMock(defaultDs, { const getDataSourceSrvMock = jest.fn().mockReturnValue(datasourceSrv); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getDataSourceSrv: () => getDataSourceSrvMock(), })); @@ -291,10 +291,11 @@ describe('hasRefId', () => { describe('when called with an object that has refId somewhere in the object tree', () => { it('then it should return the object', () => { - const input: any = { data: [123, null, {}, { series: [123, null, {}, { refId: 'A' }] }] }; + const mockObject = { refId: 'A' }; + const input = { data: [123, null, {}, { series: [123, null, {}, mockObject] }] }; const result = getValueWithRefId(input); - expect(result).toBe(input.data[3].series[3]); + expect(result).toBe(mockObject); }); }); }); diff --git a/public/app/core/utils/fetch.test.ts b/public/app/core/utils/fetch.test.ts index b510ea90bf4..df817c560f4 100644 --- a/public/app/core/utils/fetch.test.ts +++ b/public/app/core/utils/fetch.test.ts @@ -10,7 +10,7 @@ import { } from './fetch'; jest.mock('@grafana/data', () => ({ - ...(jest.requireActual('@grafana/data') as unknown as object), + ...jest.requireActual('@grafana/data'), deprecationWarning: () => {}, })); diff --git a/public/app/core/utils/timePicker.test.ts b/public/app/core/utils/timePicker.test.ts index 3fe23e6e841..66068966385 100644 --- a/public/app/core/utils/timePicker.test.ts +++ b/public/app/core/utils/timePicker.test.ts @@ -1,8 +1,8 @@ -import { toUtc, AbsoluteTimeRange } from '@grafana/data'; +import { toUtc, AbsoluteTimeRange, TimeRange } from '@grafana/data'; import { getShiftedTimeRange, getZoomedTimeRange } from './timePicker'; -export const setup = (options?: any) => { +export const setup = (options?: { direction?: number; range?: TimeRange }) => { const defaultOptions = { range: { from: toUtc('2019-01-01 10:00:00'), diff --git a/public/app/features/alerting/AlertTabCtrl.test.ts b/public/app/features/alerting/AlertTabCtrl.test.ts index 6b02d1a4d7e..7eb6012815f 100644 --- a/public/app/features/alerting/AlertTabCtrl.test.ts +++ b/public/app/features/alerting/AlertTabCtrl.test.ts @@ -1,3 +1,6 @@ +import { DashboardSrv } from '../dashboard/services/DashboardSrv'; +import { DatasourceSrv } from '../plugins/datasource_srv'; + import { AlertTabCtrl } from './AlertTabCtrl'; interface Args { @@ -16,9 +19,9 @@ function setupTestContext({ notifications = [] }: Args = {}) { render: jest.fn(), }, }; - const dashboardSrv: any = {}; - const uiSegmentSrv: any = {}; - const datasourceSrv: any = {}; + const dashboardSrv = {} as DashboardSrv; + const uiSegmentSrv = {}; + const datasourceSrv = {} as DatasourceSrv; const controller = new AlertTabCtrl($scope, dashboardSrv, uiSegmentSrv, datasourceSrv); controller.notifications = notifications; diff --git a/public/app/features/alerting/getAlertingValidationMessage.test.ts b/public/app/features/alerting/getAlertingValidationMessage.test.ts index b97bdb78e63..3252378a5de 100644 --- a/public/app/features/alerting/getAlertingValidationMessage.test.ts +++ b/public/app/features/alerting/getAlertingValidationMessage.test.ts @@ -35,8 +35,8 @@ describe('getAlertingValidationMessage', () => { getList(): DataSourceInstanceSettings[] { return []; }, - getInstanceSettings: (() => {}) as any, - reload: () => jest.fn(), + getInstanceSettings: jest.fn(), + reload: jest.fn(), }; const targets: ElasticsearchQuery[] = [ { refId: 'A', query: '@hostname:$hostname' }, @@ -75,11 +75,11 @@ describe('getAlertingValidationMessage', () => { return Promise.resolve(alertingDatasource); }, - getInstanceSettings: (() => {}) as any, + getInstanceSettings: jest.fn(), getList(): DataSourceInstanceSettings[] { return []; }, - reload: () => jest.fn(), + reload: jest.fn(), }; const targets: any[] = [ { refId: 'A', query: 'some query', datasource: 'alertingDatasource' }, @@ -107,11 +107,11 @@ describe('getAlertingValidationMessage', () => { get: (ref: DataSourceRef) => { return getMock(ref.uid); }, - getInstanceSettings: (() => {}) as any, + getInstanceSettings: jest.fn(), getList(): DataSourceInstanceSettings[] { return []; }, - reload: () => jest.fn(), + reload: jest.fn(), }; const targets: ElasticsearchQuery[] = [ { refId: 'A', query: '@hostname:$hostname' }, @@ -142,11 +142,11 @@ describe('getAlertingValidationMessage', () => { get: (ref: DataSourceRef) => { return getMock(ref.uid); }, - getInstanceSettings: (() => {}) as any, + getInstanceSettings: jest.fn(), getList(): DataSourceInstanceSettings[] { return []; }, - reload: () => jest.fn(), + reload: jest.fn(), }; const targets: ElasticsearchQuery[] = [ { refId: 'A', query: '@hostname:hostname' }, @@ -176,11 +176,11 @@ describe('getAlertingValidationMessage', () => { get: (ref: DataSourceRef) => { return getMock(ref.uid); }, - getInstanceSettings: (() => {}) as any, + getInstanceSettings: jest.fn(), getList(): DataSourceInstanceSettings[] { return []; }, - reload: () => jest.fn(), + reload: jest.fn(), }; const targets: ElasticsearchQuery[] = [ { refId: 'A', query: '@hostname:hostname' }, diff --git a/public/app/features/alerting/state/ThresholdMapper.test.ts b/public/app/features/alerting/state/ThresholdMapper.test.ts index df70c654af5..7df5c6c9e2a 100644 --- a/public/app/features/alerting/state/ThresholdMapper.test.ts +++ b/public/app/features/alerting/state/ThresholdMapper.test.ts @@ -1,3 +1,5 @@ +import { PanelModel } from 'app/features/dashboard/state'; + import { hiddenReducerTypes, ThresholdMapper } from './ThresholdMapper'; import alertDef from './alertDef'; @@ -8,7 +10,7 @@ const visibleReducerTypes = alertDef.reducerTypes describe('ThresholdMapper', () => { describe('with greater than evaluator', () => { it('can map query conditions to thresholds', () => { - const panel: any = { + const panel = { type: 'graph', options: { alertThresholds: true }, alert: { @@ -19,7 +21,7 @@ describe('ThresholdMapper', () => { }, ], }, - }; + } as unknown as PanelModel; const updated = ThresholdMapper.alertToGraphThresholds(panel); expect(updated).toBe(true); @@ -30,7 +32,7 @@ describe('ThresholdMapper', () => { describe('with outside range evaluator', () => { it('can map query conditions to thresholds', () => { - const panel: any = { + const panel = { type: 'graph', options: { alertThresholds: true }, alert: { @@ -41,7 +43,7 @@ describe('ThresholdMapper', () => { }, ], }, - }; + } as unknown as PanelModel; const updated = ThresholdMapper.alertToGraphThresholds(panel); expect(updated).toBe(true); @@ -55,7 +57,7 @@ describe('ThresholdMapper', () => { describe('with inside range evaluator', () => { it('can map query conditions to thresholds', () => { - const panel: any = { + const panel = { type: 'graph', options: { alertThresholds: true }, alert: { @@ -66,7 +68,7 @@ describe('ThresholdMapper', () => { }, ], }, - }; + } as unknown as PanelModel; const updated = ThresholdMapper.alertToGraphThresholds(panel); expect(updated).toBe(true); @@ -120,7 +122,7 @@ describe('ThresholdMapper', () => { }); function getPanel({ reducerType }: { reducerType?: string } = {}) { - const panel: any = { + const panel = { type: 'graph', options: { alertThreshold: true }, alert: { @@ -132,7 +134,7 @@ function getPanel({ reducerType }: { reducerType?: string } = {}) { }, ], }, - }; + } as unknown as PanelModel; return panel; } diff --git a/public/app/features/alerting/state/selectors.test.ts b/public/app/features/alerting/state/selectors.test.ts index a38bb798b86..434a9dab5a0 100644 --- a/public/app/features/alerting/state/selectors.test.ts +++ b/public/app/features/alerting/state/selectors.test.ts @@ -1,9 +1,11 @@ +import { AlertRulesState, StoreState } from 'app/types'; + import { getSearchQuery, getAlertRuleItems } from './selectors'; describe('Get search query', () => { it('should get search query', () => { - const state = { searchQuery: 'dashboard' }; - const result = getSearchQuery(state as any); + const state: AlertRulesState = { searchQuery: 'dashboard', items: [], isLoading: false }; + const result = getSearchQuery(state); expect(result).toEqual(state.searchQuery); }); @@ -29,9 +31,9 @@ describe('Get alert rule items', () => { ], searchQuery: '', }, - }; + } as unknown as StoreState; - const result = getAlertRuleItems(state as any); + const result = getAlertRuleItems(state); expect(result.length).toEqual(1); }); @@ -90,9 +92,9 @@ describe('Get alert rule items', () => { ], searchQuery: 'dashboard', }, - }; + } as unknown as StoreState; - const result = getAlertRuleItems(state as any); + const result = getAlertRuleItems(state); expect(result.length).toEqual(3); }); }); diff --git a/public/app/features/alerting/unified/AmRoutes.test.tsx b/public/app/features/alerting/unified/AmRoutes.test.tsx index d1a70e3ff21..375514e8045 100644 --- a/public/app/features/alerting/unified/AmRoutes.test.tsx +++ b/public/app/features/alerting/unified/AmRoutes.test.tsx @@ -5,7 +5,7 @@ import { TestProvider } from 'test/helpers/TestProvider'; import { selectOptionInTest } from 'test/helpers/selectOptionInTest'; import { byLabelText, byRole, byTestId, byText } from 'testing-library-selector'; -import { locationService, setDataSourceSrv } from '@grafana/runtime'; +import { DataSourceSrv, locationService, setDataSourceSrv } from '@grafana/runtime'; import { contextSrv } from 'app/core/services/context_srv'; import { AlertManagerCortexConfig, @@ -201,7 +201,7 @@ describe('AmRoutes', () => { afterEach(() => { jest.resetAllMocks(); - setDataSourceSrv(undefined as any); + setDataSourceSrv(undefined as unknown as DataSourceSrv); }); it('loads and shows routes', async () => { diff --git a/public/app/features/alerting/unified/RuleList.test.tsx b/public/app/features/alerting/unified/RuleList.test.tsx index 14fc8c4495c..2002599fb2c 100644 --- a/public/app/features/alerting/unified/RuleList.test.tsx +++ b/public/app/features/alerting/unified/RuleList.test.tsx @@ -5,7 +5,7 @@ import React from 'react'; import { TestProvider } from 'test/helpers/TestProvider'; import { byRole, byTestId, byText } from 'testing-library-selector'; -import { locationService, logInfo, setBackendSrv, setDataSourceSrv } from '@grafana/runtime'; +import { DataSourceSrv, locationService, logInfo, setBackendSrv, setDataSourceSrv } from '@grafana/runtime'; import { backendSrv } from 'app/core/services/backend_srv'; import { contextSrv } from 'app/core/services/context_srv'; import * as ruleActionButtons from 'app/features/alerting/unified/components/rules/RuleActionsButtons'; @@ -140,7 +140,7 @@ describe('RuleList', () => { afterEach(() => { jest.resetAllMocks(); - setDataSourceSrv(undefined as any); + setDataSourceSrv(undefined as unknown as DataSourceSrv); }); it('load & show rule groups from multiple cloud data sources', async () => { diff --git a/public/app/features/dashboard/components/DashExportModal/DashboardExporter.test.ts b/public/app/features/dashboard/components/DashExportModal/DashboardExporter.test.ts index 11621cb2f4b..e695b88a000 100644 --- a/public/app/features/dashboard/components/DashExportModal/DashboardExporter.test.ts +++ b/public/app/features/dashboard/components/DashExportModal/DashboardExporter.test.ts @@ -20,7 +20,7 @@ jest.mock('app/core/store', () => { }); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getDataSourceSrv: () => { return { get: (v: any) => { diff --git a/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.test.tsx b/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.test.tsx index 923efa7eb4b..ecd7a47530f 100644 --- a/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.test.tsx +++ b/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.test.tsx @@ -1,6 +1,6 @@ import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks'; -import { setContextSrv } from '../../../../core/services/context_srv'; +import { ContextSrv, setContextSrv } from '../../../../core/services/context_srv'; import { PanelModel } from '../../state/PanelModel'; import { createDashboardModelFixture, createPanelJSONFixture } from '../../state/__fixtures__/dashboardFixtures'; @@ -32,7 +32,7 @@ function getDefaultDashboardModel() { } function getTestContext() { - const contextSrv: any = { isSignedIn: true, isEditor: true }; + const contextSrv = { isSignedIn: true, isEditor: true } as ContextSrv; setContextSrv(contextSrv); const dash = getDefaultDashboardModel(); const original = dash.getSaveModelClone(); diff --git a/public/app/features/dashboard/components/PanelEditor/OptionsPaneOptions.test.tsx b/public/app/features/dashboard/components/PanelEditor/OptionsPaneOptions.test.tsx index de347d3b897..0d4e7fed37c 100644 --- a/public/app/features/dashboard/components/PanelEditor/OptionsPaneOptions.test.tsx +++ b/public/app/features/dashboard/components/PanelEditor/OptionsPaneOptions.test.tsx @@ -10,6 +10,7 @@ import { PanelData, standardEditorsRegistry, standardFieldConfigEditorRegistry, + TimeRange, toDataFrame, } from '@grafana/data'; import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks'; @@ -42,7 +43,7 @@ class OptionsPaneOptionsTestScenario { panelData: PanelData = { series: [], state: LoadingState.Done, - timeRange: {} as any, + timeRange: {} as TimeRange, }; plugin = getPanelPlugin({ diff --git a/public/app/features/dashboard/components/PanelEditor/state/actions.test.ts b/public/app/features/dashboard/components/PanelEditor/state/actions.test.ts index bf5ffddd1eb..ac7c255d8a6 100644 --- a/public/app/features/dashboard/components/PanelEditor/state/actions.test.ts +++ b/public/app/features/dashboard/components/PanelEditor/state/actions.test.ts @@ -1,4 +1,6 @@ +import { PanelPlugin } from '@grafana/data'; import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks'; +import { LibraryElementDTOMeta } from '@grafana/schema'; import { createDashboardModelFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures'; import { panelModelAndPluginReady, removePanel } from 'app/features/panel/state/reducers'; @@ -104,7 +106,7 @@ describe('panelEditor actions', () => { const sourcePanel = new PanelModel({ id: 12, type: 'graph' }); sourcePanel.plugin = { customFieldConfigs: {}, - } as any; + } as unknown as PanelPlugin; const dashboard = createDashboardModelFixture({ panels: [{ id: 12, type: 'graph' }], @@ -242,9 +244,9 @@ describe('panelEditor actions', () => { describe('skipPanelUpdate', () => { describe('when called with panel with an library uid different from the modified panel', () => { it('then it should return true', () => { - const meta: any = {}; - const modified: any = { libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }; - const panel: any = { libraryPanel: { uid: '456', name: 'Name', meta, version: 1 } }; + const meta = {} as LibraryElementDTOMeta; + const modified = new PanelModel({ libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }); + const panel = new PanelModel({ libraryPanel: { uid: '456', name: 'Name', meta, version: 1 } }); expect(skipPanelUpdate(modified, panel)).toEqual(true); }); @@ -252,9 +254,9 @@ describe('panelEditor actions', () => { describe('when called with a panel that is the same as the modified panel', () => { it('then it should return true', () => { - const meta: any = {}; - const modified: any = { id: 14, libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }; - const panel: any = { id: 14, libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }; + const meta = {} as LibraryElementDTOMeta; + const modified = new PanelModel({ id: 14, libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }); + const panel = new PanelModel({ id: 14, libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }); expect(skipPanelUpdate(modified, panel)).toEqual(true); }); @@ -262,9 +264,12 @@ describe('panelEditor actions', () => { describe('when called with a panel that is repeated', () => { it('then it should return true', () => { - const meta: any = {}; - const modified: any = { libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }; - const panel: any = { repeatPanelId: 14, libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }; + const meta = {} as LibraryElementDTOMeta; + const modified = new PanelModel({ libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }); + const panel = new PanelModel({ + repeatPanelId: 14, + libraryPanel: { uid: '123', name: 'Name', meta, version: 1 }, + }); expect(skipPanelUpdate(modified, panel)).toEqual(true); }); @@ -272,9 +277,9 @@ describe('panelEditor actions', () => { describe('when called with a panel that is a duplicate of the modified panel', () => { it('then it should return false', () => { - const meta: any = {}; - const modified: any = { libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }; - const panel: any = { libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }; + const meta = {} as LibraryElementDTOMeta; + const modified = new PanelModel({ libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }); + const panel = new PanelModel({ libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }); expect(skipPanelUpdate(modified, panel)).toEqual(false); }); diff --git a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.test.tsx b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.test.tsx index d25abff8e42..0988e2e7356 100644 --- a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.test.tsx +++ b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.test.tsx @@ -12,8 +12,8 @@ import { SaveDashboardForm } from './SaveDashboardForm'; const prepareDashboardMock = ( timeChanged: boolean, variableValuesChanged: boolean, - resetTimeSpy: any, - resetVarsSpy: any + resetTimeSpy: jest.Mock, + resetVarsSpy: jest.Mock ) => { const json = { title: 'name', @@ -29,12 +29,12 @@ const prepareDashboardMock = ( meta: {}, ...json, getSaveModelClone: () => json, - }; + } as unknown as DashboardModel; }; -const renderAndSubmitForm = async (dashboard: any, submitSpy: any) => { +const renderAndSubmitForm = async (dashboard: DashboardModel, submitSpy: jest.Mock) => { render( {}} onSuccess={() => {}} onSubmit={async (jsonModel) => { @@ -62,14 +62,14 @@ describe('SaveDashboardAsForm', () => { it('renders switches when variables or timerange', () => { render( {}} onSuccess={() => {}} onSubmit={async () => { return {}; }} saveModel={{ - clone: prepareDashboardMock(true, true, jest.fn(), jest.fn()) as any, + clone: prepareDashboardMock(true, true, jest.fn(), jest.fn()), diff: {}, diffCount: 0, hasChanges: true, @@ -99,7 +99,7 @@ describe('SaveDashboardAsForm', () => { const resetVarsSpy = jest.fn(); const submitSpy = jest.fn(); - await renderAndSubmitForm(prepareDashboardMock(false, false, resetTimeSpy, resetVarsSpy) as any, submitSpy); + await renderAndSubmitForm(prepareDashboardMock(false, false, resetTimeSpy, resetVarsSpy), submitSpy); expect(resetTimeSpy).not.toBeCalled(); expect(resetVarsSpy).not.toBeCalled(); @@ -112,7 +112,7 @@ describe('SaveDashboardAsForm', () => { const resetTimeSpy = jest.fn(); const resetVarsSpy = jest.fn(); const submitSpy = jest.fn(); - await renderAndSubmitForm(prepareDashboardMock(true, true, resetTimeSpy, resetVarsSpy) as any, submitSpy); + await renderAndSubmitForm(prepareDashboardMock(true, true, resetTimeSpy, resetVarsSpy), submitSpy); expect(resetTimeSpy).toBeCalledTimes(0); expect(resetVarsSpy).toBeCalledTimes(0); diff --git a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboard.test.tsx b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboard.test.tsx index 7091793c186..76d03e49d95 100644 --- a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboard.test.tsx +++ b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboard.test.tsx @@ -24,7 +24,7 @@ import { PublicDashboard } from './SharePublicDashboardUtils'; const server = setupServer(); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, })); diff --git a/public/app/features/dashboard/components/SubMenu/DashboardLinksDashboard.test.tsx b/public/app/features/dashboard/components/SubMenu/DashboardLinksDashboard.test.tsx index 8f2263dc68a..dd7eeee731c 100644 --- a/public/app/features/dashboard/components/SubMenu/DashboardLinksDashboard.test.tsx +++ b/public/app/features/dashboard/components/SubMenu/DashboardLinksDashboard.test.tsx @@ -1,3 +1,6 @@ +import { backendSrv } from 'app/core/services/__mocks__/backend_srv'; +import { LinkSrv } from 'app/features/panel/panellinks/link_srv'; + import { DashboardSearchItem, DashboardSearchItemType } from '../../../search/types'; import { DashboardLink } from '../../state/DashboardModel'; @@ -18,9 +21,7 @@ describe('searchForTags', () => { type: 'dashboards', url: '/d/6ieouugGk/DashLinks', }; - const backendSrv: any = { - search: jest.fn((args) => []), - }; + jest.spyOn(backendSrv, 'search').mockResolvedValue([]); return { link, backendSrv }; }; @@ -64,9 +65,9 @@ describe('resolveLinks', () => { type: DashboardSearchItemType.DashDB, }, ]; - const linkSrv: any = { + const linkSrv = { getLinkUrl: jest.fn((args) => args.url), - }; + } as unknown as LinkSrv; const sanitize = jest.fn((args) => args); const sanitizeUrl = jest.fn((args) => args); diff --git a/public/app/features/dashboard/containers/DashboardPage.test.tsx b/public/app/features/dashboard/containers/DashboardPage.test.tsx index f34e450863c..89ac8c23743 100644 --- a/public/app/features/dashboard/containers/DashboardPage.test.tsx +++ b/public/app/features/dashboard/containers/DashboardPage.test.tsx @@ -1,7 +1,7 @@ import { render, screen } from '@testing-library/react'; import React from 'react'; import { Provider } from 'react-redux'; -import { Router } from 'react-router-dom'; +import { match, Router } from 'react-router-dom'; import { useEffectOnce } from 'react-use'; import { AutoSizerProps } from 'react-virtualized-auto-sizer'; import { mockToolkitActionCreator } from 'test/core/redux/mocks'; @@ -10,9 +10,11 @@ import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock'; import { createTheme } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; import { config, locationService, setDataSourceSrv } from '@grafana/runtime'; +import { Dashboard } from '@grafana/schema'; import { notifyApp } from 'app/core/actions'; import { GrafanaContext } from 'app/core/context/GrafanaContext'; import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps'; +import { RouteDescriptor } from 'app/core/navigation/types'; import { HOME_NAV_ID } from 'app/core/reducers/navModel'; import { DashboardInitPhase, DashboardMeta, DashboardRoutes } from 'app/types'; @@ -20,6 +22,7 @@ import { configureStore } from '../../../store/configureStore'; import { Props as LazyLoaderProps } from '../dashgrid/LazyLoader'; import { DashboardSrv, setDashboardSrv } from '../services/DashboardSrv'; import { DashboardModel } from '../state'; +import { createDashboardModelFixture } from '../state/__fixtures__/dashboardFixtures'; import { Props, UnthemedDashboardPage } from './DashboardPage'; @@ -73,7 +76,7 @@ interface ScenarioContext { setup: (fn: () => void) => void; } -function getTestDashboard(overrides?: any, metaOverrides?: Partial): DashboardModel { +function getTestDashboard(overrides?: Partial, metaOverrides?: Partial): DashboardModel { const data = Object.assign( { title: 'My dashboard', @@ -89,8 +92,7 @@ function getTestDashboard(overrides?: any, metaOverrides?: Partial void) { @@ -110,8 +112,8 @@ function dashboardPageScenario(description: string, scenarioFn: (ctx: ScenarioCo const store = configureStore(); const props: Props = { ...getRouteComponentProps({ - match: { params: { slug: 'my-dash', uid: '11' } } as any, - route: { routeName: DashboardRoutes.Normal } as any, + match: { params: { slug: 'my-dash', uid: '11' } } as unknown as match, + route: { routeName: DashboardRoutes.Normal } as RouteDescriptor, }), navIndex: { dashboards: { text: 'Dashboards', id: 'dashboards', parentItem: { text: 'Home', id: HOME_NAV_ID } }, @@ -279,7 +281,7 @@ describe('DashboardPage', () => { ctx.rerender({ match: { params: { uid: 'new-uid' }, - } as any, + } as unknown as match, dashboard: getTestDashboard({ title: 'Another dashboard' }), }); }); diff --git a/public/app/features/dashboard/containers/SoloPanelPage.test.tsx b/public/app/features/dashboard/containers/SoloPanelPage.test.tsx index 40b378351d1..c24325c2497 100644 --- a/public/app/features/dashboard/containers/SoloPanelPage.test.tsx +++ b/public/app/features/dashboard/containers/SoloPanelPage.test.tsx @@ -1,13 +1,17 @@ import { render, screen } from '@testing-library/react'; import React from 'react'; +import { match } from 'react-router-dom'; import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock'; +import { Dashboard } from '@grafana/schema'; import { GrafanaContext } from 'app/core/context/GrafanaContext'; +import { RouteDescriptor } from 'app/core/navigation/types'; import { DashboardMeta, DashboardRoutes } from 'app/types'; import { getRouteComponentProps } from '../../../core/navigation/__mocks__/routeProps'; import { Props as DashboardPanelProps } from '../dashgrid/DashboardPanel'; import { DashboardModel } from '../state'; +import { createDashboardModelFixture } from '../state/__fixtures__/dashboardFixtures'; import { Props, SoloPanelPage } from './SoloPanelPage'; @@ -26,14 +30,14 @@ jest.mock('app/features/dashboard/dashgrid/DashboardPanel', () => { interface ScenarioContext { dashboard?: DashboardModel | null; secondaryDashboard?: DashboardModel | null; - setDashboard: (overrides?: any, metaOverrides?: Partial) => void; - setSecondaryDashboard: (overrides?: any, metaOverrides?: Partial) => void; + setDashboard: (overrides?: Partial, metaOverrides?: Partial) => void; + setSecondaryDashboard: (overrides?: Partial, metaOverrides?: Partial) => void; mount: (propOverrides?: Partial) => void; rerender: (propOverrides?: Partial) => void; setup: (fn: () => void) => void; } -function getTestDashboard(overrides?: any, metaOverrides?: Partial): DashboardModel { +function getTestDashboard(overrides?: Partial, metaOverrides?: Partial): DashboardModel { const data = Object.assign( { title: 'My dashboard', @@ -49,8 +53,7 @@ function getTestDashboard(overrides?: any, metaOverrides?: Partial void) { @@ -61,10 +64,10 @@ function soloPanelPageScenario(description: string, scenarioFn: (ctx: ScenarioCo setup: (fn) => { setupFn = fn; }, - setDashboard: (overrides?: any, metaOverrides?: Partial) => { + setDashboard: (overrides, metaOverrides) => { ctx.dashboard = getTestDashboard(overrides, metaOverrides); }, - setSecondaryDashboard: (overrides?: any, metaOverrides?: Partial) => { + setSecondaryDashboard: (overrides, metaOverrides) => { ctx.secondaryDashboard = getTestDashboard(overrides, metaOverrides); }, mount: (propOverrides?: Partial) => { @@ -72,11 +75,11 @@ function soloPanelPageScenario(description: string, scenarioFn: (ctx: ScenarioCo ...getRouteComponentProps({ match: { params: { slug: 'my-dash', uid: '11' }, - } as any, + } as unknown as match, queryParams: { panelId: '1', }, - route: { routeName: DashboardRoutes.Normal } as any, + route: { routeName: DashboardRoutes.Normal } as RouteDescriptor, }), initDashboard: jest.fn(), dashboard: null, @@ -148,8 +151,8 @@ describe('SoloPanelPage', () => { soloPanelPageScenario('When user navigates to other SoloPanelPage', (ctx) => { ctx.setup(() => { ctx.mount(); - ctx.setDashboard({ uid: 1, panels: [{ id: 1, type: 'graph', title: 'Panel 1' }] }); - ctx.setSecondaryDashboard({ uid: 2, panels: [{ id: 1, type: 'graph', title: 'Panel 2' }] }); + ctx.setDashboard({ uid: '1', panels: [{ id: 1, type: 'graph', title: 'Panel 1' }] }); + ctx.setSecondaryDashboard({ uid: '2', panels: [{ id: 1, type: 'graph', title: 'Panel 2' }] }); }); it('Should show other graph', () => { diff --git a/public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx b/public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx index 111583e7745..5e030a7e018 100644 --- a/public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx @@ -1,9 +1,11 @@ import { render } from '@testing-library/react'; import React from 'react'; +import { Dashboard } from '@grafana/schema'; import { DashboardMeta } from 'app/types'; import { DashboardModel } from '../state'; +import { createDashboardModelFixture } from '../state/__fixtures__/dashboardFixtures'; import { DashboardGrid, Props } from './DashboardGrid'; @@ -14,7 +16,7 @@ jest.mock('app/features/dashboard/dashgrid/LazyLoader', () => { return { LazyLoader }; }); -function getTestDashboard(overrides?: any, metaOverrides?: Partial): DashboardModel { +function getTestDashboard(overrides?: Partial, metaOverrides?: Partial): DashboardModel { const data = Object.assign( { title: 'My dashboard', @@ -48,8 +50,7 @@ function getTestDashboard(overrides?: any, metaOverrides?: Partial { diff --git a/public/app/features/dashboard/services/TimeSrv.test.ts b/public/app/features/dashboard/services/TimeSrv.test.ts index 751251a452f..571b236d098 100644 --- a/public/app/features/dashboard/services/TimeSrv.test.ts +++ b/public/app/features/dashboard/services/TimeSrv.test.ts @@ -4,6 +4,8 @@ import { ContextSrvStub } from 'test/specs/helpers'; import { dateTime, isDateTime } from '@grafana/data'; import { config, HistoryWrapper, locationService, setLocationService } from '@grafana/runtime'; +import { TimeModel } from '../state/TimeModel'; + import { TimeSrv } from './TimeSrv'; jest.mock('app/core/core', () => ({ @@ -14,7 +16,7 @@ jest.mock('app/core/core', () => ({ describe('timeSrv', () => { let timeSrv: TimeSrv; - let _dashboard: any; + let _dashboard: TimeModel; let locationUpdates: H.Location[] = []; beforeEach(() => { @@ -23,9 +25,10 @@ describe('timeSrv', () => { getTimezone: jest.fn(() => 'browser'), refresh: false, timeRangeUpdated: jest.fn(() => {}), + timepicker: {}, }; - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); timeSrv.init(_dashboard); locationUpdates = []; @@ -54,7 +57,7 @@ describe('timeSrv', () => { it('should handle relative times', () => { locationService.push('/d/id?from=now-2d&to=now'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); timeSrv.init(_dashboard); const time = timeSrv.timeRange(); @@ -65,7 +68,7 @@ describe('timeSrv', () => { it('should handle formatted dates', () => { locationService.push('/d/id?from=20140410T052010&to=20140520T031022'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); timeSrv.init(_dashboard); const time = timeSrv.timeRange(); @@ -76,7 +79,7 @@ describe('timeSrv', () => { it('should ignore refresh if time absolute', () => { locationService.push('/d/id?from=20140410T052010&to=20140520T031022'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); // dashboard saved with refresh on _dashboard.refresh = true; @@ -92,6 +95,7 @@ describe('timeSrv', () => { getTimezone: jest.fn(() => 'browser'), refresh: false, timeRangeUpdated: jest.fn(() => {}), + timepicker: {}, }; locationService.push('/d/id?from=now-24h&to=now'); @@ -119,7 +123,7 @@ describe('timeSrv', () => { it('should handle formatted dates without time', () => { locationService.push('/d/id?from=20140410&to=20140520'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); timeSrv.init(_dashboard); const time = timeSrv.timeRange(); @@ -130,7 +134,7 @@ describe('timeSrv', () => { it('should handle epochs', () => { locationService.push('/d/id?from=1410337646373&to=1410337665699'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); timeSrv.init(_dashboard); const time = timeSrv.timeRange(); @@ -141,7 +145,7 @@ describe('timeSrv', () => { it('should handle epochs that look like formatted date without time', () => { locationService.push('/d/id?from=20149999&to=20159999'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); timeSrv.init(_dashboard); const time = timeSrv.timeRange(); @@ -152,7 +156,7 @@ describe('timeSrv', () => { it('should handle epochs that look like formatted date', () => { locationService.push('/d/id?from=201499991234567&to=201599991234567'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); timeSrv.init(_dashboard); const time = timeSrv.timeRange(); @@ -163,7 +167,7 @@ describe('timeSrv', () => { it('should handle bad dates', () => { locationService.push('/d/id?from=20151126T00010%3C%2Fp%3E%3Cspan%20class&to=now'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); _dashboard.time.from = 'now-6h'; timeSrv.init(_dashboard); @@ -174,7 +178,7 @@ describe('timeSrv', () => { it('should handle refresh_intervals=null when refresh is enabled', () => { locationService.push('/d/id?refresh=30s'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); _dashboard.timepicker = { refresh_intervals: null, @@ -186,7 +190,7 @@ describe('timeSrv', () => { it('handles time window specfied as interval string', () => { locationService.push('/d/id?time=1410337645000&time.window=10s'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); timeSrv.init(_dashboard); const time = timeSrv.timeRange(); @@ -197,7 +201,7 @@ describe('timeSrv', () => { it('handles time window specified in ms', () => { locationService.push('/d/id?time=1410337645000&time.window=10000'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); timeSrv.init(_dashboard); const time = timeSrv.timeRange(); @@ -208,7 +212,7 @@ describe('timeSrv', () => { it('corrects inverted from/to dates in ms', () => { locationService.push('/d/id?from=1621436828909&to=1621436818909'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); timeSrv.init(_dashboard); const time = timeSrv.timeRange(); @@ -219,7 +223,7 @@ describe('timeSrv', () => { it('corrects inverted from/to dates as relative times', () => { locationService.push('/d/id?from=now&to=now-1h'); - timeSrv = new TimeSrv(new ContextSrvStub() as any); + timeSrv = new TimeSrv(new ContextSrvStub()); timeSrv.init(_dashboard); const time = timeSrv.timeRange(); diff --git a/public/app/features/dashboard/state/DashboardModel.refresh.test.ts b/public/app/features/dashboard/state/DashboardModel.refresh.test.ts index 14117453a5d..f09d4a9d336 100644 --- a/public/app/features/dashboard/state/DashboardModel.refresh.test.ts +++ b/public/app/features/dashboard/state/DashboardModel.refresh.test.ts @@ -1,6 +1,6 @@ import { appEvents } from '../../../core/core'; import { VariablesChanged } from '../../variables/types'; -import { getTimeSrv, setTimeSrv } from '../services/TimeSrv'; +import { getTimeSrv, setTimeSrv, TimeSrv } from '../services/TimeSrv'; import { PanelModel } from './PanelModel'; import { createDashboardModelFixture } from './__fixtures__/dashboardFixtures'; @@ -58,7 +58,7 @@ describe('Strict panel refresh', () => { beforeEach(() => { setTimeSrv({ isRefreshOutsideThreshold: () => isRefreshOutsideThreshold, - } as any); + } as unknown as TimeSrv); }); afterEach(() => { diff --git a/public/app/features/dashboard/state/DashboardModel.test.ts b/public/app/features/dashboard/state/DashboardModel.test.ts index 1a0e6822d32..b2f1cf20c90 100644 --- a/public/app/features/dashboard/state/DashboardModel.test.ts +++ b/public/app/features/dashboard/state/DashboardModel.test.ts @@ -329,7 +329,7 @@ describe('DashboardModel', () => { }, {}, // getVariablesFromState stub to return a variable - () => [{} as any] + jest.fn().mockImplementation(() => [{}]) ); }); @@ -653,8 +653,8 @@ describe('DashboardModel', () => { expect(saveModel.panels[1].scopedVars).toBe(undefined); model.collapseRows(); - const savedModelWithCollapsedRows: any = model.getSaveModelClone(); - expect(savedModelWithCollapsedRows.panels[0].panels.length).toBe(1); + const savedModelWithCollapsedRows = model.getSaveModelClone(); + expect(savedModelWithCollapsedRows.panels[0].panels!.length).toBe(1); }); it('getSaveModelClone should not remove repeated panels and scopedVars during snapshot', () => { @@ -708,8 +708,8 @@ describe('DashboardModel', () => { expect(saveModel.panels.find((x) => x.type !== 'row')?.scopedVars?.app.value).toBe('se1'); model.collapseRows(); - const savedModelWithCollapsedRows: any = model.getSaveModelClone(); - expect(savedModelWithCollapsedRows.panels[0].panels.length).toBe(2); + const savedModelWithCollapsedRows = model.getSaveModelClone(); + expect(savedModelWithCollapsedRows.panels[0].panels!.length).toBe(2); }); }); @@ -1106,7 +1106,7 @@ describe('DashboardModel', () => { describe('exitViewPanel', () => { function getTestContext() { - const panel: any = { setIsViewing: jest.fn() }; + const panel = new PanelModel({ setIsViewing: jest.fn() }); const dashboard = createDashboardModelFixture(); dashboard.startRefresh = jest.fn(); dashboard.panelInView = panel; @@ -1143,7 +1143,7 @@ describe('exitViewPanel', () => { describe('exitPanelEditor', () => { function getTestContext(pauseAutoRefresh = false) { - const panel: any = { destroy: jest.fn() }; + const panel = new PanelModel({ destroy: jest.fn() }); const dashboard = createDashboardModelFixture(); const timeSrvMock = { pauseAutoRefresh: jest.fn(), diff --git a/public/app/features/dashboard/utils/panelMerge.test.ts b/public/app/features/dashboard/utils/panelMerge.test.ts index f68d0dd0ddd..45a8195a12a 100644 --- a/public/app/features/dashboard/utils/panelMerge.test.ts +++ b/public/app/features/dashboard/utils/panelMerge.test.ts @@ -69,7 +69,7 @@ describe('Merge dashbaord panels', () => { rawPanels.push({ id: 7, type: 'canvas', - } as any); + } as PanelModel); const info = dashboard.updatePanels(rawPanels); expect(info.changed).toBeTruthy(); @@ -85,16 +85,16 @@ describe('Merge dashbaord panels', () => { }); it('should allow change in key order for nested elements', () => { - (rawPanels[2] as any).fieldConfig = { + rawPanels[2].fieldConfig = { defaults: { color: { mode: 'thresholds' }, mappings: [], thresholds: { steps: [ - { color: 'green', value: null }, + { color: 'green', value: -Infinity }, { color: 'red', value: 80 }, ], - mode: 'absolute', + mode: ThresholdsMode.Absolute, }, }, overrides: [], @@ -112,7 +112,7 @@ describe('Merge dashbaord panels', () => { }); it('should replace a type change', () => { - (rawPanels[1] as any).type = 'canvas'; + rawPanels[1].type = 'canvas'; const info = dashboard.updatePanels(rawPanels); expect(info.changed).toBeTruthy(); diff --git a/public/app/features/datasources/api.test.ts b/public/app/features/datasources/api.test.ts index f4bb9caa984..9324a0f66cd 100644 --- a/public/app/features/datasources/api.test.ts +++ b/public/app/features/datasources/api.test.ts @@ -7,7 +7,7 @@ import { getDataSourceByIdOrUid } from './api'; jest.mock('app/core/services/backend_srv'); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: jest.fn(), })); diff --git a/public/app/features/datasources/state/actions.test.ts b/public/app/features/datasources/state/actions.test.ts index 121eced9d97..113a9be0a8e 100644 --- a/public/app/features/datasources/state/actions.test.ts +++ b/public/app/features/datasources/state/actions.test.ts @@ -32,7 +32,7 @@ jest.mock('../api'); jest.mock('app/core/services/backend_srv'); jest.mock('app/core/core'); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getDataSourceSrv: jest.fn().mockReturnValue({ reload: jest.fn() }), getBackendSrv: jest.fn().mockReturnValue({ get: jest.fn() }), })); diff --git a/public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.test.tsx b/public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.test.tsx index 8b5c640ed26..77781f098ad 100644 --- a/public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.test.tsx +++ b/public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.test.tsx @@ -2,7 +2,7 @@ import { render, screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; -import { createTheme, ThresholdsMode } from '@grafana/data'; +import { createTheme, Threshold, ThresholdsMode } from '@grafana/data'; import { mockThemeContext } from '@grafana/ui'; import { ThresholdsEditor, Props } from './ThresholdsEditor'; @@ -151,9 +151,9 @@ describe('ThresholdsEditor', () => { const thresholds = { mode: ThresholdsMode.Absolute, steps: [ - { value: -Infinity, color: '#7EB26D', key: 1 }, - { value: 50, color: '#EAB839', key: 2 }, - { value: 75, color: '#6ED0E0', key: 3 }, + { value: -Infinity, color: '#7EB26D' }, + { value: 50, color: '#EAB839' }, + { value: 75, color: '#6ED0E0' }, ], }; setup({ thresholds }); @@ -173,12 +173,12 @@ describe('ThresholdsEditor', () => { thresholds: { mode: ThresholdsMode.Absolute, steps: [ - { value: -Infinity, color: '#7EB26D', key: 1 }, - { value: 75, color: '#6ED0E0', key: 2 }, - { color: '#7EB26D', key: 3 } as any, - { value: 78, color: '#EAB839', key: 4 }, - { value: null, color: '#7EB26D', key: 5 } as any, - { value: null, color: '#7EB26D', key: 6 } as any, + { value: -Infinity, color: '#7EB26D' }, + { value: 75, color: '#6ED0E0' }, + { color: '#7EB26D' } as unknown as Threshold, + { value: 78, color: '#EAB839' }, + { value: null, color: '#7EB26D' } as unknown as Threshold, + { value: null, color: '#7EB26D' } as unknown as Threshold, ], }, }); diff --git a/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditor.test.tsx b/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditor.test.tsx index af45eee4069..c62fc73bf78 100644 --- a/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditor.test.tsx +++ b/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditor.test.tsx @@ -1,17 +1,13 @@ import { render, screen } from '@testing-library/react'; import React from 'react'; -import { MappingType } from '@grafana/data'; +import { MappingType, StandardEditorsRegistryItem } from '@grafana/data'; import { ValueMappingsEditor, Props } from './ValueMappingsEditor'; -const setup = (spy?: any, propOverrides?: object) => { +const setup = (propOverrides?: Partial) => { const props: Props = { - onChange: (mappings: any) => { - if (spy) { - spy(mappings); - } - }, + onChange: jest.fn(), value: [ { type: MappingType.ValueToText, @@ -28,8 +24,10 @@ const setup = (spy?: any, propOverrides?: object) => { }, }, ], - item: {} as any, - context: {} as any, + item: {} as StandardEditorsRegistryItem, + context: { + data: [], + }, }; Object.assign(props, propOverrides); @@ -45,8 +43,8 @@ describe('Render', () => { }); it('should render icon picker when icon exists and icon setting is set to true', () => { - const propOverrides = { - item: { settings: { icon: true } }, + const propOverrides: Partial = { + item: { settings: { icon: true } } as StandardEditorsRegistryItem, value: [ { type: MappingType.ValueToText, @@ -56,7 +54,7 @@ describe('Render', () => { }, ], }; - setup({}, propOverrides); + setup(propOverrides); const iconPicker = screen.getByTestId('iconPicker'); diff --git a/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditorModal.test.tsx b/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditorModal.test.tsx index 09fcd9e701d..f2a7c224aa0 100644 --- a/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditorModal.test.tsx +++ b/public/app/features/dimensions/editors/ValueMappingsEditor/ValueMappingsEditorModal.test.tsx @@ -7,10 +7,10 @@ import { selectors } from '@grafana/e2e-selectors'; import { ValueMappingsEditorModal, Props } from './ValueMappingsEditorModal'; -const setup = (spy?: any, propOverrides?: object) => { +const setup = (spy?: jest.Mock, propOverrides?: Partial) => { const props: Props = { onClose: jest.fn(), - onChange: (mappings: any) => { + onChange: (mappings) => { if (spy) { spy(mappings); } diff --git a/public/app/features/dimensions/scale.test.ts b/public/app/features/dimensions/scale.test.ts index 86cb69421f7..275081f961f 100644 --- a/public/app/features/dimensions/scale.test.ts +++ b/public/app/features/dimensions/scale.test.ts @@ -1,10 +1,11 @@ import { ArrayVector, DataFrame, FieldType } from '@grafana/data'; +import { ScaleDimensionConfig } from '@grafana/schema'; import { getScaledDimension, validateScaleConfig } from './scale'; describe('scale dimensions', () => { it('should validate empty input', () => { - const out = validateScaleConfig({} as any, { + const out = validateScaleConfig({} as ScaleDimensionConfig, { min: 5, max: 10, }); diff --git a/public/app/features/explore/NodeGraphContainer.test.tsx b/public/app/features/explore/NodeGraphContainer.test.tsx index ea9b2a784a5..fc991d5eaa0 100644 --- a/public/app/features/explore/NodeGraphContainer.test.tsx +++ b/public/app/features/explore/NodeGraphContainer.test.tsx @@ -54,7 +54,7 @@ const nodes = new MutableDataFrame({ ]), }); -function toFields(fields: Array<[string, any[]]>) { +function toFields(fields: Array<[string, unknown[]]>) { return fields.map(([name, values]) => { return { name, values }; }); diff --git a/public/app/features/explore/RichHistory/RichHistoryStarredTab.test.tsx b/public/app/features/explore/RichHistory/RichHistoryStarredTab.test.tsx index 4cedf1e8e8f..635e802236a 100644 --- a/public/app/features/explore/RichHistory/RichHistoryStarredTab.test.tsx +++ b/public/app/features/explore/RichHistory/RichHistoryStarredTab.test.tsx @@ -23,7 +23,7 @@ const setup = (activeDatasourceOnly = false) => { queries: [], loading: false, totalQueries: 0, - activeDatasourceInstance: {} as any, + activeDatasourceInstance: '', updateFilters: jest.fn(), loadMoreRichHistory: jest.fn(), clearRichHistoryResults: jest.fn(), diff --git a/public/app/features/explore/TraceView/TraceView.test.tsx b/public/app/features/explore/TraceView/TraceView.test.tsx index da19941910e..ddb7338155c 100644 --- a/public/app/features/explore/TraceView/TraceView.test.tsx +++ b/public/app/features/explore/TraceView/TraceView.test.tsx @@ -4,7 +4,7 @@ import React, { createRef } from 'react'; import { Provider } from 'react-redux'; import { DataFrame, MutableDataFrame, getDefaultTimeRange, LoadingState } from '@grafana/data'; -import { setDataSourceSrv } from '@grafana/runtime'; +import { DataSourceSrv, setDataSourceSrv } from '@grafana/runtime'; import { ExploreId } from 'app/types'; import { configureStore } from '../../../store/configureStore'; @@ -62,7 +62,7 @@ describe('TraceView', () => { getInstanceSettings() { return undefined; }, - } as any); + } as DataSourceSrv); }); it('renders TraceTimelineViewer', () => { diff --git a/public/app/features/explore/state/explorePane.test.ts b/public/app/features/explore/state/explorePane.test.ts index 478708e8ea6..02debf075c0 100644 --- a/public/app/features/explore/state/explorePane.test.ts +++ b/public/app/features/explore/state/explorePane.test.ts @@ -19,7 +19,7 @@ jest.mock('../../dashboard/services/TimeSrv', () => ({ const { testRange, defaultInitialState } = createDefaultInitialState(); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ updateTimeRange: jest.fn(), }), diff --git a/public/app/features/explore/state/main.test.ts b/public/app/features/explore/state/main.test.ts index f4450c6fe07..a169d52bd6a 100644 --- a/public/app/features/explore/state/main.test.ts +++ b/public/app/features/explore/state/main.test.ts @@ -197,7 +197,7 @@ describe('Explore reducer', () => { }); }); -export const setup = (urlStateOverrides?: any) => { +export const setup = (urlStateOverrides?: Partial) => { const urlStateDefaults: ExploreUrlState = { datasource: 'some-datasource', queries: [], diff --git a/public/app/features/explore/utils/decorators.test.ts b/public/app/features/explore/utils/decorators.test.ts index a3cc75e3798..89f160e21a4 100644 --- a/public/app/features/explore/utils/decorators.test.ts +++ b/public/app/features/explore/utils/decorators.test.ts @@ -26,7 +26,7 @@ import { jest.mock('@grafana/data', () => ({ ...jest.requireActual('@grafana/data'), dateTimeFormat: () => 'format() jest mocked', - dateTimeFormatTimeAgo: (ts: any) => 'fromNow() jest mocked', + dateTimeFormatTimeAgo: () => 'fromNow() jest mocked', })); const getTestContext = () => { diff --git a/public/app/features/explore/utils/links.test.ts b/public/app/features/explore/utils/links.test.ts index 3d111b947f9..4bb06ec6817 100644 --- a/public/app/features/explore/utils/links.test.ts +++ b/public/app/features/explore/utils/links.test.ts @@ -6,14 +6,13 @@ import { Field, FieldType, InterpolateFunction, - LinkModel, TimeRange, toDataFrame, } from '@grafana/data'; import { setTemplateSrv } from '@grafana/runtime'; import { initTemplateSrv } from '../../../../test/helpers/initTemplateSrv'; -import { setContextSrv } from '../../../core/services/context_srv'; +import { ContextSrv, setContextSrv } from '../../../core/services/context_srv'; import { setLinkSrv } from '../../panel/panellinks/link_srv'; import { getFieldLinksForExplore } from './links'; @@ -266,7 +265,7 @@ function setup( dataFrameOtherFieldOverride?: Field[] ) { setLinkSrv({ - getDataLinkUIModel(link: DataLink, replaceVariables: InterpolateFunction | undefined, origin: any): LinkModel { + getDataLinkUIModel(link: DataLink, replaceVariables: InterpolateFunction | undefined, origin) { return { href: link.url, title: link.title, @@ -274,17 +273,17 @@ function setup( origin: origin, }; }, - getAnchorInfo(link: any) { + getAnchorInfo(link) { return { ...link }; }, - getLinkUrl(link: any) { + getLinkUrl(link) { return link.url; }, }); setContextSrv({ hasAccessToExplore: () => hasAccess, - } as any); + } as ContextSrv); const field: Field = { name: 'flux-dimensions', diff --git a/public/app/features/expressions/ExpressionDatasource.test.ts b/public/app/features/expressions/ExpressionDatasource.test.ts index c90a2107ca6..4c5f29b61a1 100644 --- a/public/app/features/expressions/ExpressionDatasource.test.ts +++ b/public/app/features/expressions/ExpressionDatasource.test.ts @@ -5,7 +5,7 @@ import { ExpressionDatasourceApi } from './ExpressionDatasource'; import { ExpressionQueryType } from './types'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, getTemplateSrv: () => ({ replace: (val: string) => (val ? val.replace('$input', '10').replace('$window', '10s') : val), diff --git a/public/app/features/geo/format/geojson.test.ts b/public/app/features/geo/format/geojson.test.ts index f9572f22ac8..b6c18008325 100644 --- a/public/app/features/geo/format/geojson.test.ts +++ b/public/app/features/geo/format/geojson.test.ts @@ -80,12 +80,12 @@ describe('Read GeoJSON', () => { `); expect( - frame.fields.reduce((acc, v, idx, arr) => { + frame.fields.reduce>((acc, v, idx, arr) => { if (v.type !== FieldType.geo) { acc[v.name] = v.values.toArray(); } return acc; - }, {} as any) + }, {}) ).toMatchInlineSnapshot(` { "hello": [ diff --git a/public/app/features/geo/gazetteer/gazetteer.test.ts b/public/app/features/geo/gazetteer/gazetteer.test.ts index 45ee0005966..8aa840ccdeb 100644 --- a/public/app/features/geo/gazetteer/gazetteer.test.ts +++ b/public/app/features/geo/gazetteer/gazetteer.test.ts @@ -2,7 +2,7 @@ import { getCenterPointWGS84 } from 'app/features/transformers/spatial/utils'; import { getGazetteer } from './gazetteer'; -let backendResults: any = { hello: 'world' }; +let backendResults: Record = { hello: 'world' }; const geojsonObject = { type: 'FeatureCollection', @@ -44,7 +44,7 @@ const geojsonObject = { }; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => ({ get: jest.fn().mockResolvedValue(backendResults), }), diff --git a/public/app/features/geo/gazetteer/worldmap.test.ts b/public/app/features/geo/gazetteer/worldmap.test.ts index d3342da7346..daaff61191b 100644 --- a/public/app/features/geo/gazetteer/worldmap.test.ts +++ b/public/app/features/geo/gazetteer/worldmap.test.ts @@ -7,7 +7,7 @@ import { getGazetteer } from './gazetteer'; let backendResults: any = { hello: 'world' }; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => ({ get: jest.fn().mockResolvedValue(backendResults), }), diff --git a/public/app/features/invites/SignupInvited.test.tsx b/public/app/features/invites/SignupInvited.test.tsx index 41f76d4ddb7..25c5944c578 100644 --- a/public/app/features/invites/SignupInvited.test.tsx +++ b/public/app/features/invites/SignupInvited.test.tsx @@ -1,6 +1,7 @@ import { render, screen, waitFor, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; +import { match } from 'react-router-dom'; import { TestProvider } from 'test/helpers/TestProvider'; import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps'; @@ -16,7 +17,7 @@ jest.mock('app/core/core', () => ({ })); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, })); @@ -40,7 +41,7 @@ async function setupTestContext({ get = defaultGet }: { get?: typeof defaultGet ...getRouteComponentProps({ match: { params: { code: 'some code' }, - } as any, + } as unknown as match, }), }; diff --git a/public/app/features/library-panels/components/DeleteLibraryPanelModal/reducer.test.ts b/public/app/features/library-panels/components/DeleteLibraryPanelModal/reducer.test.ts index f2604303d3f..dd483d826fd 100644 --- a/public/app/features/library-panels/components/DeleteLibraryPanelModal/reducer.test.ts +++ b/public/app/features/library-panels/components/DeleteLibraryPanelModal/reducer.test.ts @@ -1,4 +1,5 @@ import { LoadingState } from '@grafana/data'; +import { DashboardSearchItem } from 'app/features/search/types'; import { reducerTester } from '../../../../../test/core/redux/reducerTester'; @@ -24,7 +25,7 @@ describe('deleteLibraryPanelModalReducer', () => { describe('when searchCompleted is dispatched', () => { it('then state should be correct', () => { - const dashboards: any[] = [{ title: 'A' }, { title: 'B' }]; + const dashboards = [{ title: 'A' }, { title: 'B' }] as DashboardSearchItem[]; reducerTester() .givenReducer(deleteLibraryPanelModalReducer, initialDeleteLibraryPanelModalState) .whenActionIsDispatched(searchCompleted({ dashboards })) diff --git a/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.test.tsx b/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.test.tsx index 399156c2bdc..c1686b83c7d 100644 --- a/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.test.tsx +++ b/public/app/features/library-panels/components/LibraryPanelsSearch/LibraryPanelsSearch.test.tsx @@ -3,7 +3,7 @@ import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; -import { PanelPluginMeta, PluginType } from '@grafana/data'; +import { PanelPluginMeta, PluginMetaInfo, PluginType } from '@grafana/data'; import { config } from '@grafana/runtime'; import { Panel } from '@grafana/schema'; import { getGrafanaSearcher } from 'app/features/search/service'; @@ -16,7 +16,7 @@ import { LibraryElementsSearchResult } from '../../types'; import { LibraryPanelsSearch, LibraryPanelsSearchProps } from './LibraryPanelsSearch'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), config: { panels: { timeseries: { @@ -28,7 +28,7 @@ jest.mock('@grafana/runtime', () => ({ })); jest.mock('debounce-promise', () => { - const debounce = (fn: any) => { + const debounce = () => { const debounced = () => Promise.resolve([ { label: 'General', value: { uid: '', title: 'General' } }, @@ -46,7 +46,7 @@ async function getTestContext( searchResult: LibraryElementsSearchResult = { elements: [], perPage: 40, page: 1, totalCount: 0 } ) { jest.clearAllMocks(); - const pluginInfo: any = { logos: { small: '', large: '' } }; + const pluginInfo = { logos: { small: '', large: '' } } as PluginMetaInfo; const graph: PanelPluginMeta = { name: 'Graph', id: 'graph', diff --git a/public/app/features/live/live.test.ts b/public/app/features/live/live.test.ts index 7c1f6f1cc8c..7fd6536fa69 100644 --- a/public/app/features/live/live.test.ts +++ b/public/app/features/live/live.test.ts @@ -1,21 +1,23 @@ import { Subject } from 'rxjs'; import { DataQueryResponse, FieldType, LiveChannelScope } from '@grafana/data'; +import { BackendSrv } from '@grafana/runtime'; -import { StreamingDataQueryResponse } from './centrifuge/service'; +import { CentrifugeSrv, StreamingDataQueryResponse } from './centrifuge/service'; import { StreamingDataFrame } from './data/StreamingDataFrame'; import { StreamingResponseDataType } from './data/utils'; import { GrafanaLiveService } from './live'; describe('GrafanaLiveService', () => { + const mockGetDataStream = jest.fn(); const deps = { - backendSrv: {}, + backendSrv: {} as BackendSrv, centrifugeSrv: { - getDataStream: jest.fn(), - }, + getDataStream: mockGetDataStream, + } as unknown as CentrifugeSrv, }; - const liveService = new GrafanaLiveService(deps as any); + const liveService = new GrafanaLiveService(deps); const liveDataStreamOptions = { addr: { @@ -31,7 +33,7 @@ describe('GrafanaLiveService', () => { it('should map response from Centrifuge Service to a streaming data frame', async () => { const dummySubject = new Subject(); - deps.centrifugeSrv.getDataStream.mockReturnValueOnce(dummySubject); + mockGetDataStream.mockReturnValueOnce(dummySubject); let response: DataQueryResponse | undefined; liveService.getDataStream(liveDataStreamOptions).subscribe((next) => { @@ -53,7 +55,7 @@ describe('GrafanaLiveService', () => { it('should add partial streaming data to the buffer', async () => { const dummySubject = new Subject(); - deps.centrifugeSrv.getDataStream.mockReturnValueOnce(dummySubject); + mockGetDataStream.mockReturnValueOnce(dummySubject); let response: DataQueryResponse | undefined; liveService.getDataStream(liveDataStreamOptions).subscribe((next) => { @@ -123,7 +125,7 @@ describe('GrafanaLiveService', () => { it('should return an empty frame if first message was not a full frame', async () => { jest.spyOn(console, 'warn').mockImplementation(jest.fn); const dummySubject = new Subject(); - deps.centrifugeSrv.getDataStream.mockReturnValueOnce(dummySubject); + mockGetDataStream.mockReturnValueOnce(dummySubject); let response: DataQueryResponse | undefined; liveService.getDataStream(liveDataStreamOptions).subscribe((next) => { diff --git a/public/app/features/manage-dashboards/components/PublicDashboardListTable/PublicDashboardListTable.test.tsx b/public/app/features/manage-dashboards/components/PublicDashboardListTable/PublicDashboardListTable.test.tsx index 254ea59467e..71dee2c3ce9 100644 --- a/public/app/features/manage-dashboards/components/PublicDashboardListTable/PublicDashboardListTable.test.tsx +++ b/public/app/features/manage-dashboards/components/PublicDashboardListTable/PublicDashboardListTable.test.tsx @@ -57,7 +57,7 @@ const server = setupServer( ); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, })); diff --git a/public/app/features/manage-dashboards/components/SnapshotListTable.test.tsx b/public/app/features/manage-dashboards/components/SnapshotListTable.test.tsx index 582566c98dd..4d7886238d8 100644 --- a/public/app/features/manage-dashboards/components/SnapshotListTable.test.tsx +++ b/public/app/features/manage-dashboards/components/SnapshotListTable.test.tsx @@ -3,7 +3,7 @@ import { locationService } from '@grafana/runtime'; import { getSnapshots } from './SnapshotListTable'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => ({ get: jest.fn().mockResolvedValue([ { @@ -24,7 +24,7 @@ jest.mock('@grafana/runtime', () => ({ })); describe('getSnapshots', () => { - (global as any).window = Object.create(window); + global.window = Object.create(window); Object.defineProperty(window, 'location', { value: { href: 'http://localhost:3000/grafana/dashboard/snapshots', diff --git a/public/app/features/manage-dashboards/state/actions.test.ts b/public/app/features/manage-dashboards/state/actions.test.ts index eb7eefc96aa..d0d15c6e6b8 100644 --- a/public/app/features/manage-dashboards/state/actions.test.ts +++ b/public/app/features/manage-dashboards/state/actions.test.ts @@ -1,6 +1,7 @@ import { thunkTester } from 'test/core/thunk/thunkTester'; -import { setBackendSrv } from '@grafana/runtime'; +import { DataSourceInstanceSettings } from '@grafana/data'; +import { BackendSrv, setBackendSrv } from '@grafana/runtime'; import { validateDashboardJson } from '../utils/validation'; @@ -20,7 +21,7 @@ describe('importDashboard', () => { uid: 'ds-uid', name: 'ds-name', type: 'prometheus', - } as any, + } as DataSourceInstanceSettings, ], elements: [], folder: { @@ -32,13 +33,13 @@ describe('importDashboard', () => { let postArgs: any; setBackendSrv({ - post: (url: string, args: any) => { + post: (url, args) => { postArgs = args; return Promise.resolve({ importedUrl: '/my/dashboard', }); }, - } as any); + } as BackendSrv); await thunkTester({ importDashboard: { diff --git a/public/app/features/org/state/actions.test.ts b/public/app/features/org/state/actions.test.ts index 924d2aef871..dedda1a8fb5 100644 --- a/public/app/features/org/state/actions.test.ts +++ b/public/app/features/org/state/actions.test.ts @@ -1,5 +1,6 @@ import { thunkTester } from 'test/core/thunk/thunkTester'; +import { BackendSrv } from '@grafana/runtime'; import { updateConfigurationSubtitle } from 'app/core/actions'; import { OrgRole } from 'app/types'; @@ -25,10 +26,10 @@ describe('updateOrganization', () => { describe('when updateOrganization thunk is dispatched', () => { const getMock = jest.fn().mockResolvedValue({ id: 1, name: 'New Org Name' }); const putMock = jest.fn().mockResolvedValue({ id: 1, name: 'New Org Name' }); - const backendSrvMock: any = { + const backendSrvMock = { get: getMock, put: putMock, - }; + } as unknown as BackendSrv; it('then it should dispatch updateConfigurationSubtitle', async () => { const { initialState } = setup(); @@ -47,9 +48,9 @@ describe('setUserOrganization', () => { describe('when setUserOrganization thunk is dispatched', () => { const postMock = jest.fn().mockResolvedValue({ id: 1, name: 'New Org Name' }); - const backendSrvMock: any = { + const backendSrvMock = { post: postMock, - }; + } as unknown as BackendSrv; const orgId = 1; @@ -69,9 +70,9 @@ describe('setUserOrganization', () => { describe('getUserOrganizations', () => { describe('when getUserOrganizations thunk is dispatched', () => { const getMock = jest.fn().mockResolvedValue({ orgId: 1, name: 'New Org Name', role: OrgRole.Editor }); - const backendSrvMock: any = { + const backendSrvMock = { get: getMock, - }; + } as unknown as BackendSrv; it('then it should dispatch updateConfigurationSubtitle', async () => { const { initialState } = setup(); diff --git a/public/app/features/panel/panellinks/specs/link_srv.test.ts b/public/app/features/panel/panellinks/specs/link_srv.test.ts index 791a95d7441..580f79b659c 100644 --- a/public/app/features/panel/panellinks/specs/link_srv.test.ts +++ b/public/app/features/panel/panellinks/specs/link_srv.test.ts @@ -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( diff --git a/public/app/features/panel/state/getAllSuggestions.test.ts b/public/app/features/panel/state/getAllSuggestions.test.ts index dcb489ff84a..b8ae2419131 100644 --- a/public/app/features/panel/state/getAllSuggestions.test.ts +++ b/public/app/features/panel/state/getAllSuggestions.test.ts @@ -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'] = { diff --git a/public/app/features/panel/state/utils.test.ts b/public/app/features/panel/state/utils.test.ts index f37af140f32..d08da0b2194 100644 --- a/public/app/features/panel/state/utils.test.ts +++ b/public/app/features/panel/state/utils.test.ts @@ -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']); }); }); diff --git a/public/app/features/playlist/PlaylistEditPage.test.tsx b/public/app/features/playlist/PlaylistEditPage.test.tsx index ac0e0e8ba03..77362c3a3ed 100644 --- a/public/app/features/playlist/PlaylistEditPage.test.tsx +++ b/public/app/features/playlist/PlaylistEditPage.test.tsx @@ -1,12 +1,15 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { History, Location } from 'history'; import React from 'react'; +import { type match } from 'react-router-dom'; import { TestProvider } from 'test/helpers/TestProvider'; import { locationService } from '@grafana/runtime'; +import { RouteDescriptor } from 'app/core/navigation/types'; import { backendSrv } from 'app/core/services/backend_srv'; -import { PlaylistEditPage } from './PlaylistEditPage'; +import { PlaylistEditPage, RouteParams } from './PlaylistEditPage'; import { Playlist } from './types'; jest.mock('@grafana/runtime', () => ({ @@ -24,10 +27,10 @@ async function getTestContext({ name, interval, items, uid }: Partial jest.clearAllMocks(); const playlist = { name, items, interval, uid } as unknown as Playlist; const queryParams = {}; - const route: any = {}; - const match: any = { params: { uid: 'foo' } }; - const location: any = {}; - const history: any = {}; + const route = {} as RouteDescriptor; + const match = { params: { uid: 'foo' } } as unknown as match; + const location = {} as Location; + const history = {} as History; const getMock = jest.spyOn(backendSrv, 'get'); const putMock = jest.spyOn(backendSrv, 'put'); diff --git a/public/app/features/playlist/PlaylistPage.test.tsx b/public/app/features/playlist/PlaylistPage.test.tsx index 51af4e47ad4..347af817756 100644 --- a/public/app/features/playlist/PlaylistPage.test.tsx +++ b/public/app/features/playlist/PlaylistPage.test.tsx @@ -9,7 +9,7 @@ import { PlaylistPage } from './PlaylistPage'; const fnMock = jest.fn(); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => ({ get: fnMock, }), diff --git a/public/app/features/plugins/admin/pages/Browse.test.tsx b/public/app/features/plugins/admin/pages/Browse.test.tsx index 687b0a057bc..b3da8c31164 100644 --- a/public/app/features/plugins/admin/pages/Browse.test.tsx +++ b/public/app/features/plugins/admin/pages/Browse.test.tsx @@ -6,6 +6,7 @@ import { TestProvider } from 'test/helpers/TestProvider'; import { PluginType, escapeStringForRegex } from '@grafana/data'; import { locationService } from '@grafana/runtime'; import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps'; +import { RouteDescriptor } from 'app/core/navigation/types'; import { configureStore } from 'app/store/configureStore'; import { getCatalogPluginMock, getPluginsStateMock } from '../__mocks__'; @@ -32,7 +33,7 @@ const renderBrowse = ( const store = configureStore({ plugins: pluginsStateOverride || getPluginsStateMock(plugins) }); locationService.push(path); const props = getRouteComponentProps({ - route: { routeName: PluginAdminRoutes.Home } as any, + route: { routeName: PluginAdminRoutes.Home } as RouteDescriptor, }); return render( diff --git a/public/app/features/plugins/components/AppRootPage.test.tsx b/public/app/features/plugins/components/AppRootPage.test.tsx index d31cbe28759..d19e0e89b23 100644 --- a/public/app/features/plugins/components/AppRootPage.test.tsx +++ b/public/app/features/plugins/components/AppRootPage.test.tsx @@ -9,6 +9,7 @@ import { getMockPlugin } from '@grafana/data/test/__mocks__/pluginMocks'; import { locationService, setEchoSrv } from '@grafana/runtime'; import { GrafanaContext } from 'app/core/context/GrafanaContext'; import { GrafanaRoute } from 'app/core/navigation/GrafanaRoute'; +import { RouteDescriptor } from 'app/core/navigation/types'; import { Echo } from 'app/core/services/echo/Echo'; import { configureStore } from 'app/store/configureStore'; @@ -90,14 +91,16 @@ function renderUnderRouter() { appPluginNavItem.parentItem = appsSection; const store = configureStore(); - const route = { component: () => }; + const route = { + component: () => , + } as unknown as RouteDescriptor; locationService.push('/a/my-awesome-plugin'); render( - } /> + } /> diff --git a/public/app/features/plugins/tests/plugin_loader.test.ts b/public/app/features/plugins/tests/plugin_loader.test.ts index e7af4f5d919..ab94ea5f960 100644 --- a/public/app/features/plugins/tests/plugin_loader.test.ts +++ b/public/app/features/plugins/tests/plugin_loader.test.ts @@ -1,10 +1,6 @@ // Use the real plugin_loader (stubbed by default) jest.unmock('app/features/plugins/plugin_loader'); -(global as any).ace = { - define: jest.fn(), -}; - jest.mock('app/core/core', () => { return { coreModule: { diff --git a/public/app/features/profile/state/reducers.test.ts b/public/app/features/profile/state/reducers.test.ts index 766bbfca5ab..2429a287a16 100644 --- a/public/app/features/profile/state/reducers.test.ts +++ b/public/app/features/profile/state/reducers.test.ts @@ -17,7 +17,7 @@ import { } from './reducers'; describe('userReducer', () => { - let dateNow: any; + let dateNow: jest.SpyInstance; beforeAll(() => { dateNow = jest.spyOn(Date, 'now').mockImplementation(() => 1609470000000); // 2021-01-01 04:00:00 diff --git a/public/app/features/query/state/DashboardQueryRunner/AlertStatesWorker.test.ts b/public/app/features/query/state/DashboardQueryRunner/AlertStatesWorker.test.ts index 6c75831bb31..1caa4b12a4f 100644 --- a/public/app/features/query/state/DashboardQueryRunner/AlertStatesWorker.test.ts +++ b/public/app/features/query/state/DashboardQueryRunner/AlertStatesWorker.test.ts @@ -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, })); diff --git a/public/app/features/query/state/DashboardQueryRunner/AnnotationsQueryRunner.test.ts b/public/app/features/query/state/DashboardQueryRunner/AnnotationsQueryRunner.test.ts index 9e04b783c8d..264f431e4d8 100644 --- a/public/app/features/query/state/DashboardQueryRunner/AnnotationsQueryRunner.test.ts +++ b/public/app/features/query/state/DashboardQueryRunner/AnnotationsQueryRunner.test.ts @@ -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) => { diff --git a/public/app/features/query/state/DashboardQueryRunner/AnnotationsWorker.test.ts b/public/app/features/query/state/DashboardQueryRunner/AnnotationsWorker.test.ts index 87cd6497051..d83545fc021 100644 --- a/public/app/features/query/state/DashboardQueryRunner/AnnotationsWorker.test.ts +++ b/public/app/features/query/state/DashboardQueryRunner/AnnotationsWorker.test.ts @@ -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: [] }]); diff --git a/public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.test.ts b/public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.test.ts index 43c0509e6eb..3604fb574d0 100644 --- a/public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.test.ts +++ b/public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.test.ts @@ -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 }; diff --git a/public/app/features/query/state/DashboardQueryRunner/LegacyAnnotationQueryRunner.test.ts b/public/app/features/query/state/DashboardQueryRunner/LegacyAnnotationQueryRunner.test.ts index 9111583e8df..25c25318896 100644 --- a/public/app/features/query/state/DashboardQueryRunner/LegacyAnnotationQueryRunner.test.ts +++ b/public/app/features/query/state/DashboardQueryRunner/LegacyAnnotationQueryRunner.test.ts @@ -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) => { diff --git a/public/app/features/query/state/DashboardQueryRunner/SnapshotWorker.test.ts b/public/app/features/query/state/DashboardQueryRunner/SnapshotWorker.test.ts index f8f1f499869..fa1770780c3 100644 --- a/public/app/features/query/state/DashboardQueryRunner/SnapshotWorker.test.ts +++ b/public/app/features/query/state/DashboardQueryRunner/SnapshotWorker.test.ts @@ -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) => { diff --git a/public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.test.ts b/public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.test.ts index f9f9e2fd81a..8d58e1bf12d 100644 --- a/public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.test.ts +++ b/public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.test.ts @@ -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' ); }); }); diff --git a/public/app/features/query/state/PanelQueryRunner.test.ts b/public/app/features/query/state/PanelQueryRunner.test.ts index 1b34e93a03a..4422a8e2b23 100644 --- a/public/app/features/query/state/PanelQueryRunner.test.ts +++ b/public/app/features/query/state/PanelQueryRunner.test.ts @@ -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(), + 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({ diff --git a/public/app/features/query/state/runRequest.test.ts b/public/app/features/query/state/runRequest.test.ts index 92dcf7bac02..d52bdfdee42 100644 --- a/public/app/features/query/state/runRequest.test.ts +++ b/public/app/features/query/state/runRequest.test.ts @@ -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; + let consoleSpy: jest.SpyInstance; beforeEach(() => { consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); diff --git a/public/app/features/search/page/components/SearchResultsGrid.test.tsx b/public/app/features/search/page/components/SearchResultsGrid.test.tsx index 3f7b34f606a..05eb1187051 100644 --- a/public/app/features/search/page/components/SearchResultsGrid.test.tsx +++ b/public/app/features/search/page/components/SearchResultsGrid.test.tsx @@ -1,5 +1,5 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react'; -import React from 'react'; +import React, { KeyboardEvent } from 'react'; import { Observable } from 'rxjs'; import { ArrayVector, DataFrame, DataFrameView, FieldType } from '@grafana/data'; @@ -38,7 +38,7 @@ describe('SearchResultsGrid', () => { height: 600, clearSelection: jest.fn(), onTagSelected: jest.fn(), - keyboardEvents: new Observable(), + keyboardEvents: new Observable>(), }; it('should render grid of dashboards', () => { diff --git a/public/app/features/serviceaccounts/ServiceAccountPage.test.tsx b/public/app/features/serviceaccounts/ServiceAccountPage.test.tsx index 6cf3d35903a..47483c46dd0 100644 --- a/public/app/features/serviceaccounts/ServiceAccountPage.test.tsx +++ b/public/app/features/serviceaccounts/ServiceAccountPage.test.tsx @@ -1,8 +1,10 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { History, Location } from 'history'; import React from 'react'; import { TestProvider } from 'test/helpers/TestProvider'; +import { RouteDescriptor } from 'app/core/navigation/types'; import { ApiKey, OrgRole, ServiceAccountDTO } from 'app/types'; import { ServiceAccountPageUnconnected, Props } from './ServiceAccountPage'; @@ -35,10 +37,10 @@ const setup = (propOverrides: Partial) => { path: '/org/serviceaccounts/1', url: 'http://localhost:3000/org/serviceaccounts/1', }, - history: {} as any, - location: {} as any, + history: {} as History, + location: {} as Location, queryParams: {}, - route: {} as any, + route: {} as RouteDescriptor, timezone: '', createServiceAccountToken: createServiceAccountTokenMock, deleteServiceAccount: deleteServiceAccountMock, diff --git a/public/app/features/teams/TeamPages.test.tsx b/public/app/features/teams/TeamPages.test.tsx index fab1b3b90ab..72a564f6d3d 100644 --- a/public/app/features/teams/TeamPages.test.tsx +++ b/public/app/features/teams/TeamPages.test.tsx @@ -1,5 +1,6 @@ import { render, screen } from '@testing-library/react'; import React from 'react'; +import { match } from 'react-router-dom'; import { TestProvider } from 'test/helpers/TestProvider'; import { createTheme } from '@grafana/data'; @@ -70,7 +71,7 @@ const setup = (propOverrides?: object) => { id: '1', page: null, }, - } as any, + } as unknown as match, }), pageNav: { text: 'Cool team ' }, teamId: 1, diff --git a/public/app/features/templating/template_srv.test.ts b/public/app/features/templating/template_srv.test.ts index 6b6604a925f..b564a1025d3 100644 --- a/public/app/features/templating/template_srv.test.ts +++ b/public/app/features/templating/template_srv.test.ts @@ -10,6 +10,8 @@ import { createAdHocVariableAdapter } from '../variables/adhoc/adapter'; import { createQueryVariableAdapter } from '../variables/query/adapter'; import { VariableModel } from '../variables/types'; +import { TemplateSrv } from './template_srv'; + const key = 'key'; variableAdapters.setInit(() => [ @@ -22,13 +24,13 @@ const interpolateMock = jest.fn(); jest.mock('@grafana/scenes', () => ({ ...jest.requireActual('@grafana/scenes'), sceneGraph: { - interpolate: (...args: any[]) => interpolateMock(...args), + interpolate: (...args: unknown[]) => interpolateMock(...args), }, })); describe('templateSrv', () => { silenceConsoleOutput(); - let _templateSrv: any; + let _templateSrv: TemplateSrv; describe('init', () => { beforeEach(() => { @@ -48,7 +50,7 @@ describe('templateSrv', () => { it('scoped vars should support objects', () => { const target = _templateSrv.replace('${series.name} ${series.nested.field}', { - series: { value: { name: 'Server1', nested: { field: 'nested' } } }, + series: { value: { name: 'Server1', nested: { field: 'nested' } }, text: 'foo' }, }); expect(target).toBe('Server1 nested'); }); @@ -63,14 +65,14 @@ describe('templateSrv', () => { it('scoped vars should support objects with propert names with dot', () => { const target = _templateSrv.replace('${series.name} ${series.nested["field.with.dot"]}', { - series: { value: { name: 'Server1', nested: { 'field.with.dot': 'nested' } } }, + series: { value: { name: 'Server1', nested: { 'field.with.dot': 'nested' } }, text: 'foo' }, }); expect(target).toBe('Server1 nested'); }); it('scoped vars should support arrays of objects', () => { const target = _templateSrv.replace('${series.rows[0].name} ${series.rows[1].name}', { - series: { value: { rows: [{ name: 'first' }, { name: 'second' }] } }, + series: { value: { rows: [{ name: 'first' }, { name: 'second' }] }, text: 'foo' }, }); expect(target).toBe('first second'); }); @@ -658,8 +660,8 @@ describe('templateSrv', () => { }); it('should not pass object to custom function', () => { - let passedValue: any = null; - _templateSrv.replace('this.${test}.filters', {}, (value: any) => { + let passedValue: string | null = null; + _templateSrv.replace('this.${test}.filters', {}, (value: string) => { passedValue = value; }); @@ -674,8 +676,8 @@ describe('templateSrv', () => { }); it('should not pass object to custom function', () => { - let passedValue: any = null; - _templateSrv.replace('this.${test}.filters', {}, (value: any) => { + let passedValue: string | null = null; + _templateSrv.replace('this.${test}.filters', {}, (value: string) => { passedValue = value; }); @@ -827,7 +829,7 @@ describe('templateSrv', () => { it('should use scene interpolator when scoped var provided', () => { const variable = new TestVariable({}); - _templateSrv.replace('test ${test}', { __sceneObject: { value: variable } }); + _templateSrv.replace('test ${test}', { __sceneObject: { value: variable, text: 'foo' } }); expect(interpolateMock).toHaveBeenCalledTimes(1); expect(interpolateMock.mock.calls[0][0]).toEqual(variable); diff --git a/public/app/features/templating/template_srv.ts b/public/app/features/templating/template_srv.ts index d7d3ad49de3..a29e7480bca 100644 --- a/public/app/features/templating/template_srv.ts +++ b/public/app/features/templating/template_srv.ts @@ -125,7 +125,7 @@ export class TemplateSrv implements BaseTemplateSrv { return filters; } - formatValue(value: any, format: any, variable: any, text?: string): string { + formatValue(value: any, format?: any, variable?: any, text?: string): string { // for some scopedVars there is no variable variable = variable || {}; diff --git a/public/app/features/transformers/extractFields/extractFields.test.ts b/public/app/features/transformers/extractFields/extractFields.test.ts index 79898512beb..8ee2f67923c 100644 --- a/public/app/features/transformers/extractFields/extractFields.test.ts +++ b/public/app/features/transformers/extractFields/extractFields.test.ts @@ -19,10 +19,10 @@ describe('Fields from JSON', () => { const frames = extractFieldsTransformer.transformer(cfg, ctx)([data]); expect(frames.length).toEqual(1); expect( - frames[0].fields.reduce((acc, v) => { + frames[0].fields.reduce>((acc, v) => { acc[v.name] = v.type; return acc; - }, {} as any) + }, {}) ).toMatchInlineSnapshot(` { "a": "string", diff --git a/public/app/features/variables/adhoc/picker/AdHocFilter.test.tsx b/public/app/features/variables/adhoc/picker/AdHocFilter.test.tsx index 4b85bfaa35a..fbbccbd6fe7 100644 --- a/public/app/features/variables/adhoc/picker/AdHocFilter.test.tsx +++ b/public/app/features/variables/adhoc/picker/AdHocFilter.test.tsx @@ -3,7 +3,7 @@ import userEvent from '@testing-library/user-event'; import React from 'react'; import selectEvent from 'react-select-event'; -import { setDataSourceSrv } from '@grafana/runtime'; +import { DataSourceSrv, setDataSourceSrv } from '@grafana/runtime'; import { AdHocVariableFilter } from '../../types'; @@ -77,7 +77,7 @@ function setup() { }, }; }, - } as any); + } as unknown as DataSourceSrv); const filters: AdHocVariableFilter[] = [ { diff --git a/public/app/features/variables/editor/getVariableQueryEditor.test.tsx b/public/app/features/variables/editor/getVariableQueryEditor.test.tsx index a69e66195f7..fd1e449933d 100644 --- a/public/app/features/variables/editor/getVariableQueryEditor.test.tsx +++ b/public/app/features/variables/editor/getVariableQueryEditor.test.tsx @@ -1,4 +1,4 @@ -import { VariableSupportType } from '@grafana/data'; +import { DataSourceApi, VariableSupportType } from '@grafana/data'; import { LegacyVariableQueryEditor } from './LegacyVariableQueryEditor'; import { getVariableQueryEditor, StandardVariableQueryEditor } from './getVariableQueryEditor'; @@ -7,10 +7,10 @@ describe('getVariableQueryEditor', () => { describe('happy cases', () => { describe('when called with a data source with custom variable support', () => { it('then it should return correct editor', async () => { - const editor: any = StandardVariableQueryEditor; - const datasource: any = { - variables: { getType: () => VariableSupportType.Custom, query: () => undefined, editor }, - }; + const editor = StandardVariableQueryEditor; + const datasource = { + variables: { getType: () => VariableSupportType.Custom, query: jest.fn(), editor }, + } as unknown as DataSourceApi; const result = await getVariableQueryEditor(datasource); @@ -20,10 +20,10 @@ describe('getVariableQueryEditor', () => { describe('when called with a data source with standard variable support', () => { it('then it should return correct editor', async () => { - const editor: any = StandardVariableQueryEditor; - const datasource: any = { - variables: { getType: () => VariableSupportType.Standard, toDataQuery: () => undefined }, - }; + const editor = StandardVariableQueryEditor; + const datasource = { + variables: { getType: () => VariableSupportType.Standard, toDataQuery: jest.fn() }, + } as unknown as DataSourceApi; const result = await getVariableQueryEditor(datasource); @@ -33,10 +33,13 @@ describe('getVariableQueryEditor', () => { describe('when called with a data source with datasource variable support', () => { it('then it should return correct editor', async () => { - const editor: any = StandardVariableQueryEditor; + const editor = StandardVariableQueryEditor; const plugin = { components: { QueryEditor: editor } }; const importDataSourcePluginFunc = jest.fn().mockResolvedValue(plugin); - const datasource: any = { variables: { getType: () => VariableSupportType.Datasource }, meta: {} }; + const datasource = { + variables: { getType: () => VariableSupportType.Datasource }, + meta: {}, + } as unknown as DataSourceApi; const result = await getVariableQueryEditor(datasource, importDataSourcePluginFunc); @@ -48,10 +51,10 @@ describe('getVariableQueryEditor', () => { describe('when called with a data source with legacy variable support', () => { it('then it should return correct editor', async () => { - const editor: any = StandardVariableQueryEditor; + const editor = StandardVariableQueryEditor; const plugin = { components: { VariableQueryEditor: editor } }; const importDataSourcePluginFunc = jest.fn().mockResolvedValue(plugin); - const datasource: any = { metricFindQuery: () => undefined, meta: {} }; + const datasource = { metricFindQuery: () => undefined, meta: {} } as unknown as DataSourceApi; const result = await getVariableQueryEditor(datasource, importDataSourcePluginFunc); @@ -65,7 +68,7 @@ describe('getVariableQueryEditor', () => { describe('negative cases', () => { describe('when variable support is not recognized', () => { it('then it should return null', async () => { - const datasource: any = {}; + const datasource = {} as unknown as DataSourceApi; const result = await getVariableQueryEditor(datasource); @@ -77,7 +80,10 @@ describe('getVariableQueryEditor', () => { it('then it should return throw', async () => { const plugin = { components: {} }; const importDataSourcePluginFunc = jest.fn().mockResolvedValue(plugin); - const datasource: any = { variables: { getType: () => VariableSupportType.Datasource }, meta: {} }; + const datasource = { + variables: { getType: () => VariableSupportType.Datasource }, + meta: {}, + } as unknown as DataSourceApi; await expect(getVariableQueryEditor(datasource, importDataSourcePluginFunc)).rejects.toThrow( new Error('Missing QueryEditor in plugin definition.') @@ -91,7 +97,7 @@ describe('getVariableQueryEditor', () => { it('then it should return LegacyVariableQueryEditor', async () => { const plugin = { components: {} }; const importDataSourcePluginFunc = jest.fn().mockResolvedValue(plugin); - const datasource: any = { metricFindQuery: () => undefined, meta: {} }; + const datasource = { metricFindQuery: () => undefined, meta: {} } as unknown as DataSourceApi; const result = await getVariableQueryEditor(datasource, importDataSourcePluginFunc); diff --git a/public/app/features/variables/getAllVariableValuesForUrl.test.ts b/public/app/features/variables/getAllVariableValuesForUrl.test.ts index 8d8ef1172c6..159ec8405d2 100644 --- a/public/app/features/variables/getAllVariableValuesForUrl.test.ts +++ b/public/app/features/variables/getAllVariableValuesForUrl.test.ts @@ -31,7 +31,7 @@ describe('getAllVariableValuesForUrl', () => { }); it('should set multiple url params', () => { - let params: any = getVariablesUrlParams(); + const params = getVariablesUrlParams(); expect(params['var-test']).toMatchObject(['val1', 'val2']); }); }); diff --git a/public/app/features/variables/guard.test.ts b/public/app/features/variables/guard.test.ts index d01b060bce0..1afcf66bbef 100644 --- a/public/app/features/variables/guard.test.ts +++ b/public/app/features/variables/guard.test.ts @@ -1,4 +1,4 @@ -import { TypedVariableModel, VariableSupportType, VariableType } from '@grafana/data'; +import { DataSourceApi, TypedVariableModel, VariableSupportType, VariableType } from '@grafana/data'; import { LegacyVariableQueryEditor } from './editor/LegacyVariableQueryEditor'; import { StandardVariableQueryEditor } from './editor/getVariableQueryEditor'; @@ -30,21 +30,21 @@ describe('type guards', () => { describe('hasLegacyVariableSupport', () => { describe('when called with a legacy data source', () => { it('should return true', () => { - const datasource: any = { metricFindQuery: () => undefined }; + const datasource = { metricFindQuery: () => undefined } as unknown as DataSourceApi; expect(hasLegacyVariableSupport(datasource)).toBe(true); }); }); describe('when called with data source without metricFindQuery function', () => { it('should return false', () => { - const datasource: any = {}; + const datasource = {} as DataSourceApi; expect(hasLegacyVariableSupport(datasource)).toBe(false); }); }); describe('when called with a legacy data source with variable support', () => { it('should return false', () => { - const datasource: any = { metricFindQuery: () => undefined, variables: {} }; + const datasource = { metricFindQuery: () => undefined, variables: {} } as unknown as DataSourceApi; expect(hasLegacyVariableSupport(datasource)).toBe(false); }); }); @@ -53,23 +53,23 @@ describe('type guards', () => { describe('hasStandardVariableSupport', () => { describe('when called with a data source with standard variable support', () => { it('should return true', () => { - const datasource: any = { + const datasource = { metricFindQuery: () => undefined, variables: { getType: () => VariableSupportType.Standard, toDataQuery: () => undefined }, - }; + } as unknown as DataSourceApi; expect(hasStandardVariableSupport(datasource)).toBe(true); }); describe('and with a custom query', () => { it('should return true', () => { - const datasource: any = { + const datasource = { metricFindQuery: () => undefined, variables: { getType: () => VariableSupportType.Standard, toDataQuery: () => undefined, query: () => undefined, }, - }; + } as unknown as DataSourceApi; expect(hasStandardVariableSupport(datasource)).toBe(true); }); }); @@ -77,17 +77,17 @@ describe('type guards', () => { describe('when called with a data source with partial standard variable support', () => { it('should return false', () => { - const datasource: any = { + const datasource = { metricFindQuery: () => undefined, variables: { getType: () => VariableSupportType.Standard, query: () => undefined }, - }; + } as unknown as DataSourceApi; expect(hasStandardVariableSupport(datasource)).toBe(false); }); }); describe('when called with a data source without standard variable support', () => { it('should return false', () => { - const datasource: any = { metricFindQuery: () => undefined }; + const datasource = { metricFindQuery: () => undefined } as unknown as DataSourceApi; expect(hasStandardVariableSupport(datasource)).toBe(false); }); }); @@ -96,37 +96,37 @@ describe('type guards', () => { describe('hasCustomVariableSupport', () => { describe('when called with a data source with custom variable support', () => { it('should return true', () => { - const datasource: any = { + const datasource = { metricFindQuery: () => undefined, variables: { getType: () => VariableSupportType.Custom, query: () => undefined, editor: {} }, - }; + } as unknown as DataSourceApi; expect(hasCustomVariableSupport(datasource)).toBe(true); }); }); describe('when called with a data source with custom variable support but without editor', () => { it('should return false', () => { - const datasource: any = { + const datasource = { metricFindQuery: () => undefined, variables: { getType: () => VariableSupportType.Custom, query: () => undefined }, - }; + } as unknown as DataSourceApi; expect(hasCustomVariableSupport(datasource)).toBe(false); }); }); describe('when called with a data source with custom variable support but without query', () => { it('should return false', () => { - const datasource: any = { + const datasource = { metricFindQuery: () => undefined, variables: { getType: () => VariableSupportType.Custom, editor: {} }, - }; + } as unknown as DataSourceApi; expect(hasCustomVariableSupport(datasource)).toBe(false); }); }); describe('when called with a data source without custom variable support', () => { it('should return false', () => { - const datasource: any = { metricFindQuery: () => undefined }; + const datasource = { metricFindQuery: () => undefined } as unknown as DataSourceApi; expect(hasCustomVariableSupport(datasource)).toBe(false); }); }); @@ -135,17 +135,17 @@ describe('type guards', () => { describe('hasDatasourceVariableSupport', () => { describe('when called with a data source with datasource variable support', () => { it('should return true', () => { - const datasource: any = { + const datasource = { metricFindQuery: () => undefined, variables: { getType: () => VariableSupportType.Datasource }, - }; + } as unknown as DataSourceApi; expect(hasDatasourceVariableSupport(datasource)).toBe(true); }); }); describe('when called with a data source without datasource variable support', () => { it('should return false', () => { - const datasource: any = { metricFindQuery: () => undefined }; + const datasource = { metricFindQuery: () => undefined } as unknown as DataSourceApi; expect(hasDatasourceVariableSupport(datasource)).toBe(false); }); }); @@ -203,8 +203,8 @@ describe('isLegacyQueryEditor', () => { describe('happy cases', () => { describe('when called with a legacy query editor but without a legacy data source', () => { it('then is should return true', () => { - const component: any = LegacyVariableQueryEditor; - const datasource: any = {}; + const component = LegacyVariableQueryEditor; + const datasource = {} as DataSourceApi; expect(isLegacyQueryEditor(component, datasource)).toBe(true); }); @@ -212,8 +212,8 @@ describe('isLegacyQueryEditor', () => { describe('when called with a legacy data source but without a legacy query editor', () => { it('then is should return true', () => { - const component: any = StandardVariableQueryEditor; - const datasource: any = { metricFindQuery: () => undefined }; + const component = StandardVariableQueryEditor; + const datasource = { metricFindQuery: () => undefined } as unknown as DataSourceApi; expect(isLegacyQueryEditor(component, datasource)).toBe(true); }); @@ -223,8 +223,8 @@ describe('isLegacyQueryEditor', () => { describe('negative cases', () => { describe('when called without component', () => { it('then is should return false', () => { - const component: any = null; - const datasource: any = { metricFindQuery: () => undefined }; + const component = null; + const datasource = { metricFindQuery: () => undefined } as unknown as DataSourceApi; expect(isLegacyQueryEditor(component, datasource)).toBe(false); }); @@ -232,8 +232,8 @@ describe('isLegacyQueryEditor', () => { describe('when called without a legacy query editor and without a legacy data source', () => { it('then is should return false', () => { - const component: any = StandardVariableQueryEditor; - const datasource: any = {}; + const component = StandardVariableQueryEditor; + const datasource = {} as unknown as DataSourceApi; expect(isLegacyQueryEditor(component, datasource)).toBe(false); }); @@ -245,10 +245,10 @@ describe('isQueryEditor', () => { describe('happy cases', () => { describe('when called without a legacy editor and with a data source with standard variable support', () => { it('then is should return true', () => { - const component: any = StandardVariableQueryEditor; - const datasource: any = { + const component = StandardVariableQueryEditor; + const datasource = { variables: { getType: () => VariableSupportType.Standard, toDataQuery: () => undefined }, - }; + } as unknown as DataSourceApi; expect(isQueryEditor(component, datasource)).toBe(true); }); @@ -256,10 +256,10 @@ describe('isQueryEditor', () => { describe('when called without a legacy editor and with a data source with custom variable support', () => { it('then is should return true', () => { - const component: any = StandardVariableQueryEditor; - const datasource: any = { + const component = StandardVariableQueryEditor; + const datasource = { variables: { getType: () => VariableSupportType.Custom, query: () => undefined, editor: {} }, - }; + } as unknown as DataSourceApi; expect(isQueryEditor(component, datasource)).toBe(true); }); @@ -267,8 +267,8 @@ describe('isQueryEditor', () => { describe('when called without a legacy editor and with a data source with datasource variable support', () => { it('then is should return true', () => { - const component: any = StandardVariableQueryEditor; - const datasource: any = { variables: { getType: () => VariableSupportType.Datasource } }; + const component = StandardVariableQueryEditor; + const datasource = { variables: { getType: () => VariableSupportType.Datasource } } as unknown as DataSourceApi; expect(isQueryEditor(component, datasource)).toBe(true); }); @@ -278,8 +278,8 @@ describe('isQueryEditor', () => { describe('negative cases', () => { describe('when called without component', () => { it('then is should return false', () => { - const component: any = null; - const datasource: any = { metricFindQuery: () => undefined }; + const component = null; + const datasource = { metricFindQuery: () => undefined } as unknown as DataSourceApi; expect(isQueryEditor(component, datasource)).toBe(false); }); @@ -287,8 +287,8 @@ describe('isQueryEditor', () => { describe('when called with a legacy query editor', () => { it('then is should return false', () => { - const component: any = LegacyVariableQueryEditor; - const datasource: any = { variables: { getType: () => VariableSupportType.Datasource } }; + const component = LegacyVariableQueryEditor; + const datasource = { variables: { getType: () => VariableSupportType.Datasource } } as unknown as DataSourceApi; expect(isQueryEditor(component, datasource)).toBe(false); }); @@ -296,8 +296,8 @@ describe('isQueryEditor', () => { describe('when called without a legacy query editor but with a legacy data source', () => { it('then is should return false', () => { - const component: any = StandardVariableQueryEditor; - const datasource: any = { metricFindQuery: () => undefined }; + const component = StandardVariableQueryEditor; + const datasource = { metricFindQuery: () => undefined } as unknown as DataSourceApi; expect(isQueryEditor(component, datasource)).toBe(false); }); diff --git a/public/app/features/variables/inspect/utils.test.ts b/public/app/features/variables/inspect/utils.test.ts index 2f9aceb1e65..f9cc309b58f 100644 --- a/public/app/features/variables/inspect/utils.test.ts +++ b/public/app/features/variables/inspect/utils.test.ts @@ -1,4 +1,4 @@ -import { PanelModel } from 'app/features/dashboard/state'; +import { DashboardModel, PanelModel } from 'app/features/dashboard/state'; import { variableAdapters } from '../adapters'; import { createCustomVariableAdapter } from '../custom/adapter'; @@ -303,7 +303,7 @@ describe('flattenPanels', () => { }); }); -const dashWithRepeatsAndRows: any = { +const dashWithRepeatsAndRows = { annotations: { list: [ { @@ -1163,9 +1163,9 @@ const dashWithRepeatsAndRows: any = { title: 'Variables update POC', uid: 'tISItwInz', version: 2, -}; +} as unknown as DashboardModel; -const dashWithTemplateDependenciesAndPanels: any = { +const dashWithTemplateDependenciesAndPanels = { annotations: { list: [ { @@ -1662,9 +1662,9 @@ const dashWithTemplateDependenciesAndPanels: any = { title: 'Variables dependencies update POC', uid: 'n60iRMNnk', version: 6, -}; +} as unknown as DashboardModel; -const dashWithAllVariables: any = { +const dashWithAllVariables = { annotations: { list: [ { @@ -1967,4 +1967,4 @@ const dashWithAllVariables: any = { uid: 'XkBHMzF7z', version: 6, weekStart: '', -}; +} as unknown as DashboardModel; diff --git a/public/app/features/variables/pickers/OptionsPicker/OptionPicker.test.tsx b/public/app/features/variables/pickers/OptionsPicker/OptionPicker.test.tsx index 5b5f932aef0..bb3a51b9ede 100644 --- a/public/app/features/variables/pickers/OptionsPicker/OptionPicker.test.tsx +++ b/public/app/features/variables/pickers/OptionsPicker/OptionPicker.test.tsx @@ -2,6 +2,7 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; import { Provider } from 'react-redux'; +import { Store } from 'redux'; import { LoadingState } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; @@ -50,7 +51,7 @@ function setupTestContext({ pickerState = {}, variable = {} }: Args = {}) { optionsPicker, }; const getState = jest.fn().mockReturnValue(getPreloadedState('key', templatingState)); - const store: any = { getState, dispatch, subscribe }; + const store = { getState, dispatch, subscribe } as unknown as Store; const { rerender } = render( diff --git a/public/app/features/variables/pickers/OptionsPicker/actions.test.ts b/public/app/features/variables/pickers/OptionsPicker/actions.test.ts index 8bbbaac5ff2..d6316d7f74d 100644 --- a/public/app/features/variables/pickers/OptionsPicker/actions.test.ts +++ b/public/app/features/variables/pickers/OptionsPicker/actions.test.ts @@ -398,7 +398,7 @@ describe('options picker actions', () => { const option = { ...createOption(['A']), selected: true, - value: ['A'] as any[], + value: ['A'], }; tester.thenDispatchedActionsShouldEqual( diff --git a/public/app/features/variables/query/VariableQueryRunner.test.ts b/public/app/features/variables/query/VariableQueryRunner.test.ts index 223da0473c1..1fbfe3ae31f 100644 --- a/public/app/features/variables/query/VariableQueryRunner.test.ts +++ b/public/app/features/variables/query/VariableQueryRunner.test.ts @@ -1,7 +1,7 @@ import { of, throwError } from 'rxjs'; import { delay } from 'rxjs/operators'; -import { getDefaultTimeRange, LoadingState, VariableSupportType } from '@grafana/data'; +import { DataSourceApi, getDefaultTimeRange, LoadingState, VariableSupportType } from '@grafana/data'; import { queryBuilder } from '../shared/testing/builders'; import { getPreloadedState } from '../state/helpers'; @@ -15,15 +15,10 @@ import { UpdateOptionsResults, VariableQueryRunner } from './VariableQueryRunner import { QueryRunner, QueryRunners } from './queryRunners'; import { updateVariableOptions } from './reducer'; -type DoneCallback = { - (...args: any[]): any; - fail(error?: string | { message: string }): any; -}; - function expectOnResults(args: { runner: VariableQueryRunner; identifier: KeyedVariableIdentifier; - done: DoneCallback; + done: jest.DoneCallback; expect: (results: UpdateOptionsResults[]) => void; }) { const { runner, identifier, done, expect: expectCallback } = args; @@ -51,7 +46,7 @@ function getTestContext(variable?: QueryVariableModel) { }); const key = '0123456789'; variable = variable ?? queryBuilder().withId('query').withRootStateKey(key).withName('query').build(); - const datasource: any = { metricFindQuery: jest.fn().mockResolvedValue([]) }; + const datasource = { metricFindQuery: jest.fn().mockResolvedValue([]) } as unknown as DataSourceApi; const identifier = toKeyedVariableIdentifier(variable); const searchFilter = undefined; const getTemplatedRegex = jest.fn().mockReturnValue('getTemplatedRegex result'); diff --git a/public/app/features/variables/query/operators.test.ts b/public/app/features/variables/query/operators.test.ts index 9f4fd29d987..a76cae269b2 100644 --- a/public/app/features/variables/query/operators.test.ts +++ b/public/app/features/variables/query/operators.test.ts @@ -1,6 +1,6 @@ import { of } from 'rxjs'; -import { FieldType, toDataFrame } from '@grafana/data'; +import { FieldType, PanelData, toDataFrame } from '@grafana/data'; import { queryBuilder } from '../shared/testing/builders'; import { toKeyedAction } from '../state/keyedVariablesReducer'; @@ -130,7 +130,7 @@ describe('operators', () => { ].map((scenario) => { it(`when called with series:${JSON.stringify(scenario.series, null, 0)}`, async () => { const { series, expected } = scenario; - const panelData: any = { series }; + const panelData = { series } as PanelData; const observable = of(panelData).pipe(toMetricFindValues()); await expect(observable).toEmitValuesWith((received) => { @@ -146,7 +146,7 @@ describe('operators', () => { fields: [{ name: 'time', type: FieldType.time, values: [1, 2, 3] }], }); - const panelData: any = { series: [frameWithTimeField] }; + const panelData = { series: [frameWithTimeField] } as PanelData; const observable = of(panelData).pipe(toMetricFindValues()); await expect(observable).toEmitValuesWith((received) => { diff --git a/public/app/features/variables/query/variableQueryObserver.test.ts b/public/app/features/variables/query/variableQueryObserver.test.ts index 3730b39c725..9a731d58685 100644 --- a/public/app/features/variables/query/variableQueryObserver.test.ts +++ b/public/app/features/variables/query/variableQueryObserver.test.ts @@ -1,3 +1,5 @@ +import { Subscription } from 'rxjs'; + import { LoadingState } from '@grafana/data'; import { KeyedVariableIdentifier } from '../state/types'; @@ -5,13 +7,13 @@ import { KeyedVariableIdentifier } from '../state/types'; import { UpdateOptionsResults } from './VariableQueryRunner'; import { variableQueryObserver } from './variableQueryObserver'; -function getTestContext(args: { next?: UpdateOptionsResults; error?: any; complete?: boolean }) { +function getTestContext(args: { next?: UpdateOptionsResults; error?: string; complete?: boolean }) { const { next, error, complete } = args; const resolve = jest.fn(); const reject = jest.fn(); - const subscription: any = { + const subscription = { unsubscribe: jest.fn(), - }; + } as unknown as Subscription; const observer = variableQueryObserver(resolve, reject, subscription); if (next) { diff --git a/public/app/plugins/datasource/azuremonitor/azure_log_analytics/azure_log_analytics_datasource.test.ts b/public/app/plugins/datasource/azuremonitor/azure_log_analytics/azure_log_analytics_datasource.test.ts index 3b4a11b5bf3..eab35ea8941 100644 --- a/public/app/plugins/datasource/azuremonitor/azure_log_analytics/azure_log_analytics_datasource.test.ts +++ b/public/app/plugins/datasource/azuremonitor/azure_log_analytics/azure_log_analytics_datasource.test.ts @@ -14,7 +14,7 @@ const templateSrv = new TemplateSrv(); jest.mock('app/core/services/backend_srv'); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => templateSrv, })); diff --git a/public/app/plugins/datasource/azuremonitor/azure_monitor/azure_monitor_datasource.test.ts b/public/app/plugins/datasource/azuremonitor/azure_monitor/azure_monitor_datasource.test.ts index 080078e6fe7..6b34b43c28a 100644 --- a/public/app/plugins/datasource/azuremonitor/azure_monitor/azure_monitor_datasource.test.ts +++ b/public/app/plugins/datasource/azuremonitor/azure_monitor/azure_monitor_datasource.test.ts @@ -12,7 +12,7 @@ import { AzureDataSourceJsonData, AzureMonitorLocationsResponse, AzureQueryType const templateSrv = new TemplateSrv(); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => templateSrv, })); diff --git a/public/app/plugins/datasource/azuremonitor/azure_resource_graph/azure_resource_graph_datasource.test.ts b/public/app/plugins/datasource/azuremonitor/azure_resource_graph/azure_resource_graph_datasource.test.ts index b6fad703fd6..5e65b36c129 100644 --- a/public/app/plugins/datasource/azuremonitor/azure_resource_graph/azure_resource_graph_datasource.test.ts +++ b/public/app/plugins/datasource/azuremonitor/azure_resource_graph/azure_resource_graph_datasource.test.ts @@ -19,7 +19,7 @@ const templateSrv = new TemplateSrv({ jest.mock('app/core/services/backend_srv'); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, getTemplateSrv: () => templateSrv, })); diff --git a/public/app/plugins/datasource/azuremonitor/components/ArgQueryEditor/ArgQueryEditor.test.tsx b/public/app/plugins/datasource/azuremonitor/components/ArgQueryEditor/ArgQueryEditor.test.tsx index d9d223a69e9..e1c2cbad433 100644 --- a/public/app/plugins/datasource/azuremonitor/components/ArgQueryEditor/ArgQueryEditor.test.tsx +++ b/public/app/plugins/datasource/azuremonitor/components/ArgQueryEditor/ArgQueryEditor.test.tsx @@ -8,7 +8,7 @@ import { selectors } from '../../e2e/selectors'; import ArgQueryEditor from './ArgQueryEditor'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ replace: (val: string) => { return val; diff --git a/public/app/plugins/datasource/azuremonitor/components/LogsQueryEditor/LogsQueryEditor.test.tsx b/public/app/plugins/datasource/azuremonitor/components/LogsQueryEditor/LogsQueryEditor.test.tsx index 5bf10d93801..c8983e1e10e 100644 --- a/public/app/plugins/datasource/azuremonitor/components/LogsQueryEditor/LogsQueryEditor.test.tsx +++ b/public/app/plugins/datasource/azuremonitor/components/LogsQueryEditor/LogsQueryEditor.test.tsx @@ -9,7 +9,7 @@ import { createMockResourcePickerData } from '../MetricsQueryEditor/MetricsQuery import LogsQueryEditor from './LogsQueryEditor'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ replace: (val: string) => { return val; diff --git a/public/app/plugins/datasource/azuremonitor/components/MetricsQueryEditor/MetricsQueryEditor.test.tsx b/public/app/plugins/datasource/azuremonitor/components/MetricsQueryEditor/MetricsQueryEditor.test.tsx index b5ddf15c837..daf6a84e16e 100644 --- a/public/app/plugins/datasource/azuremonitor/components/MetricsQueryEditor/MetricsQueryEditor.test.tsx +++ b/public/app/plugins/datasource/azuremonitor/components/MetricsQueryEditor/MetricsQueryEditor.test.tsx @@ -18,7 +18,7 @@ import ResourcePickerData from '../../resourcePicker/resourcePickerData'; import MetricsQueryEditor from './MetricsQueryEditor'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ replace: (val: string) => { return val; diff --git a/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/ResourcePicker.test.tsx b/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/ResourcePicker.test.tsx index 4cc55ca2f07..c9c5387f18b 100644 --- a/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/ResourcePicker.test.tsx +++ b/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/ResourcePicker.test.tsx @@ -18,7 +18,7 @@ import { ResourceRowType } from './types'; import ResourcePicker from '.'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ replace: (val: string) => { return val; diff --git a/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/utils.test.ts b/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/utils.test.ts index 0521afc5826..c6b32fb71eb 100644 --- a/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/utils.test.ts +++ b/public/app/plugins/datasource/azuremonitor/components/ResourcePicker/utils.test.ts @@ -12,7 +12,7 @@ import { } from './utils'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ replace: (val: string) => { return val; diff --git a/public/app/plugins/datasource/azuremonitor/resourcePicker/resourcePickerData.test.ts b/public/app/plugins/datasource/azuremonitor/resourcePicker/resourcePickerData.test.ts index 634394593e8..e05c130ca04 100644 --- a/public/app/plugins/datasource/azuremonitor/resourcePicker/resourcePickerData.test.ts +++ b/public/app/plugins/datasource/azuremonitor/resourcePicker/resourcePickerData.test.ts @@ -12,7 +12,7 @@ import { AzureGraphResponse } from '../types'; import ResourcePickerData from './resourcePickerData'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ replace: (val: string) => { return val; diff --git a/public/app/plugins/datasource/azuremonitor/variables.test.ts b/public/app/plugins/datasource/azuremonitor/variables.test.ts index 1c38e6aee01..244e282bbc3 100644 --- a/public/app/plugins/datasource/azuremonitor/variables.test.ts +++ b/public/app/plugins/datasource/azuremonitor/variables.test.ts @@ -8,7 +8,7 @@ import { AzureMonitorQuery, AzureQueryType } from './types'; import { VariableSupport } from './variables'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ replace: (val: string) => { return val; diff --git a/public/app/plugins/datasource/cloud-monitoring/components/AnnotationQueryEditor.test.tsx b/public/app/plugins/datasource/cloud-monitoring/components/AnnotationQueryEditor.test.tsx index 37decde5b95..f57cc94d839 100644 --- a/public/app/plugins/datasource/cloud-monitoring/components/AnnotationQueryEditor.test.tsx +++ b/public/app/plugins/datasource/cloud-monitoring/components/AnnotationQueryEditor.test.tsx @@ -8,7 +8,7 @@ import { createMockQuery } from '../__mocks__/cloudMonitoringQuery'; import { AnnotationQueryEditor } from './AnnotationQueryEditor'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ replace: (val: string) => val, }), diff --git a/public/app/plugins/datasource/cloud-monitoring/components/MetricQueryEditor.test.tsx b/public/app/plugins/datasource/cloud-monitoring/components/MetricQueryEditor.test.tsx index 82ca0af7ee1..b8f2396ab2b 100644 --- a/public/app/plugins/datasource/cloud-monitoring/components/MetricQueryEditor.test.tsx +++ b/public/app/plugins/datasource/cloud-monitoring/components/MetricQueryEditor.test.tsx @@ -8,7 +8,7 @@ import { QueryType } from '../types'; import { MetricQueryEditor } from './MetricQueryEditor'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ replace: (val: string) => val, }), diff --git a/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.test.tsx b/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.test.tsx index 0cd79aac4e6..92f7877a13a 100644 --- a/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.test.tsx +++ b/public/app/plugins/datasource/cloud-monitoring/components/QueryEditor.test.tsx @@ -8,7 +8,7 @@ import { QueryType } from '../types'; import { QueryEditor } from './QueryEditor'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ replace: (val: string) => val, }), diff --git a/public/app/plugins/datasource/cloud-monitoring/functions.test.ts b/public/app/plugins/datasource/cloud-monitoring/functions.test.ts index 2256f311a04..587221dd8a6 100644 --- a/public/app/plugins/datasource/cloud-monitoring/functions.test.ts +++ b/public/app/plugins/datasource/cloud-monitoring/functions.test.ts @@ -17,7 +17,7 @@ import { newMockDatasource } from './specs/testData'; import { AlignmentTypes, MetricDescriptor, MetricKind, TimeSeriesList, ValueTypes } from './types'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getTemplateSrv: () => ({ replace: jest.fn().mockImplementation((s: string) => s), }), diff --git a/public/app/plugins/datasource/cloud-monitoring/specs/datasource.test.ts b/public/app/plugins/datasource/cloud-monitoring/specs/datasource.test.ts index b68d79a39b4..4b3b644695b 100644 --- a/public/app/plugins/datasource/cloud-monitoring/specs/datasource.test.ts +++ b/public/app/plugins/datasource/cloud-monitoring/specs/datasource.test.ts @@ -12,7 +12,7 @@ import CloudMonitoringDataSource from '../datasource'; import { CloudMonitoringOptions } from '../types'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, })); diff --git a/public/app/plugins/datasource/dashboard/DashboardQueryEditor.test.tsx b/public/app/plugins/datasource/dashboard/DashboardQueryEditor.test.tsx index df9222c1f2c..8693b19e70d 100644 --- a/public/app/plugins/datasource/dashboard/DashboardQueryEditor.test.tsx +++ b/public/app/plugins/datasource/dashboard/DashboardQueryEditor.test.tsx @@ -17,7 +17,7 @@ import { DashboardQueryEditor } from './DashboardQueryEditor'; import { SHARED_DASHBOARD_QUERY } from './types'; jest.mock('app/core/config', () => ({ - ...(jest.requireActual('app/core/config') as unknown as object), + ...jest.requireActual('app/core/config'), panels: { timeseries: { info: { diff --git a/public/app/plugins/datasource/elasticsearch/datasource.test.ts b/public/app/plugins/datasource/elasticsearch/datasource.test.ts index 3ebe7de6960..91aa81a08bd 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.test.ts +++ b/public/app/plugins/datasource/elasticsearch/datasource.test.ts @@ -33,7 +33,7 @@ import { Filters, ElasticsearchOptions, ElasticsearchQuery } from './types'; const ELASTICSEARCH_MOCK_URL = 'http://elasticsearch.local'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, reportInteraction: jest.fn(), getDataSourceSrv: () => { @@ -60,7 +60,7 @@ const DATAQUERY_BASE = { }; jest.mock('app/features/dashboard/services/TimeSrv', () => ({ - ...(jest.requireActual('app/features/dashboard/services/TimeSrv') as unknown as object), + ...jest.requireActual('app/features/dashboard/services/TimeSrv'), getTimeSrv: () => ({ timeRange: () => createTimeRange(toUtc(TIMESRV_START), toUtc(TIMESRV_END)), }), diff --git a/public/app/plugins/datasource/grafana/datasource.test.ts b/public/app/plugins/datasource/grafana/datasource.test.ts index fc290feb849..e82e5739a74 100644 --- a/public/app/plugins/datasource/grafana/datasource.test.ts +++ b/public/app/plugins/datasource/grafana/datasource.test.ts @@ -5,7 +5,7 @@ import { GrafanaDatasource } from './datasource'; import { GrafanaAnnotationQuery, GrafanaAnnotationType, GrafanaQuery } from './types'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, getTemplateSrv: () => ({ replace: (val: string) => { diff --git a/public/app/plugins/datasource/graphite/datasource.test.ts b/public/app/plugins/datasource/graphite/datasource.test.ts index 45eda7f16b2..dbb59dd4c1d 100644 --- a/public/app/plugins/datasource/graphite/datasource.test.ts +++ b/public/app/plugins/datasource/graphite/datasource.test.ts @@ -12,7 +12,7 @@ import { GraphiteQuery, GraphiteQueryType } from './types'; import { DEFAULT_GRAPHITE_VERSION } from './versions'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, })); diff --git a/public/app/plugins/datasource/influxdb/specs/response_parser.test.ts b/public/app/plugins/datasource/influxdb/specs/response_parser.test.ts index 50de903132b..0755ec578e3 100644 --- a/public/app/plugins/datasource/influxdb/specs/response_parser.test.ts +++ b/public/app/plugins/datasource/influxdb/specs/response_parser.test.ts @@ -14,7 +14,7 @@ import ResponseParser, { getSelectedParams } from '../response_parser'; const templateSrv = new TemplateSrvStub(); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, })); diff --git a/public/app/plugins/datasource/mixed/MixedDataSource.test.ts b/public/app/plugins/datasource/mixed/MixedDataSource.test.ts index b66d083be51..5fdec6cd058 100644 --- a/public/app/plugins/datasource/mixed/MixedDataSource.test.ts +++ b/public/app/plugins/datasource/mixed/MixedDataSource.test.ts @@ -23,7 +23,7 @@ const datasourceSrv = new DatasourceSrvMock(defaultDS, { const getDataSourceSrvMock = jest.fn().mockReturnValue(datasourceSrv); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getDataSourceSrv: () => getDataSourceSrvMock(), })); diff --git a/public/app/plugins/datasource/opentsdb/specs/datasource.test.ts b/public/app/plugins/datasource/opentsdb/specs/datasource.test.ts index c305cfaf7a4..ac34846c750 100644 --- a/public/app/plugins/datasource/opentsdb/specs/datasource.test.ts +++ b/public/app/plugins/datasource/opentsdb/specs/datasource.test.ts @@ -8,7 +8,7 @@ import OpenTsDatasource from '../datasource'; import { OpenTsdbQuery } from '../types'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, })); diff --git a/public/app/plugins/datasource/prometheus/metric_find_query.test.ts b/public/app/plugins/datasource/prometheus/metric_find_query.test.ts index e7388c2b220..6a64b701467 100644 --- a/public/app/plugins/datasource/prometheus/metric_find_query.test.ts +++ b/public/app/plugins/datasource/prometheus/metric_find_query.test.ts @@ -12,7 +12,7 @@ import PrometheusMetricFindQuery from './metric_find_query'; import { PromOptions } from './types'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, })); diff --git a/public/app/plugins/datasource/zipkin/datasource.test.ts b/public/app/plugins/datasource/zipkin/datasource.test.ts index 2021db86ec9..666cc3b64d5 100644 --- a/public/app/plugins/datasource/zipkin/datasource.test.ts +++ b/public/app/plugins/datasource/zipkin/datasource.test.ts @@ -10,7 +10,7 @@ import mockJson from './mockJsonResponse.json'; import { traceFrameFields, zipkinResponse } from './utils/testData'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, })); diff --git a/public/app/plugins/panel/alertGroups/AlertGroupsPanel.test.tsx b/public/app/plugins/panel/alertGroups/AlertGroupsPanel.test.tsx index c1201a53426..b58cdd89166 100644 --- a/public/app/plugins/panel/alertGroups/AlertGroupsPanel.test.tsx +++ b/public/app/plugins/panel/alertGroups/AlertGroupsPanel.test.tsx @@ -22,7 +22,7 @@ import { PanelOptions } from './panelcfg.gen'; jest.mock('app/features/alerting/unified/api/alertmanager'); jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), config: { ...jest.requireActual('@grafana/runtime').config, buildInfo: {}, diff --git a/public/app/plugins/panel/annolist/AnnoListPanel.test.tsx b/public/app/plugins/panel/annolist/AnnoListPanel.test.tsx index e4ed97d90b6..03f3179cd3b 100644 --- a/public/app/plugins/panel/annolist/AnnoListPanel.test.tsx +++ b/public/app/plugins/panel/annolist/AnnoListPanel.test.tsx @@ -13,7 +13,7 @@ import { AnnoListPanel, Props } from './AnnoListPanel'; import { PanelOptions } from './panelcfg.gen'; jest.mock('@grafana/runtime', () => ({ - ...(jest.requireActual('@grafana/runtime') as unknown as object), + ...jest.requireActual('@grafana/runtime'), getBackendSrv: () => backendSrv, }));