Chore: fix type errors in tests (#63270)

* fix any's in tests

* fix more any's in tests

* more test type fixes

* fixing any's in tests part 3

* more test type fixes

* fixing test any's p5

* some tidy up

* fix template_srv
This commit is contained in:
Ashley Harrison
2023-02-14 16:46:42 +01:00
committed by GitHub
parent 4b0faf1c9e
commit f8d89eff56
139 changed files with 675 additions and 1080 deletions

View File

@@ -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"]

View File

@@ -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);
});

View File

@@ -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', () => {

View File

@@ -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,
});

View File

@@ -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);

View File

@@ -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)) {

View File

@@ -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];

View File

@@ -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<FieldConfigPropertyItem>(() => {
@@ -68,9 +80,9 @@ export const customFieldRegistry: FieldConfigOptionsRegistry = new Registry<Fiel
});
locationUtil.initialize({
config: { appSubUrl: '/subUrl' } as any,
getVariablesUrlParams: (() => {}) 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,
}
);

View File

@@ -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,

View File

@@ -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(

View File

@@ -398,12 +398,12 @@ describe('restoreCustomOverrideRules', () => {
});
interface ScenarioOptions {
defaults?: FieldConfig<any>;
defaults?: FieldConfig;
overrides?: ConfigOverrideRule[];
disabledStandardOptions?: FieldConfigProperty[];
standardOptions?: Partial<Record<FieldConfigProperty, StandardOptionConfig>>;
plugin?: PanelPlugin;
options?: any;
options?: Record<string, unknown>;
isAfterPluginChange?: boolean;
}

View File

@@ -455,7 +455,7 @@ describe('Labels as Columns', () => {
});
function toSimpleObject(frame: DataFrame) {
const obj: any = {};
const obj: Record<string, unknown> = {};
for (const field of frame.fields) {
obj[field.name] = field.values.toArray();
}

View File

@@ -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)
);
};

View File

@@ -261,8 +261,8 @@ describe('Reducer Transformer', () => {
expect(frames[0].length).toEqual(1);
expect(frames[1].length).toEqual(1);
const view0 = new DataFrameView<any>(frames[0]);
const view1 = new DataFrameView<any>(frames[1]);
const view0 = new DataFrameView(frames[0]);
const view1 = new DataFrameView(frames[1]);
expect({ ...view0.get(0) }).toMatchInlineSnapshot(`
{
"temperature": 6,

View File

@@ -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));
};

View File

@@ -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', () => {

View File

@@ -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(() => {

View File

@@ -4,7 +4,7 @@ import renderer from 'react-test-renderer';
import SelectOption from './SelectOption';
const model: OptionProps<any> = {
const model: OptionProps = {
data: jest.fn(),
cx: jest.fn(),
clearValue: jest.fn(),

View File

@@ -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();

View File

@@ -100,7 +100,7 @@ describe('AngularLocationWrapper', () => {
it('should copy object', function () {
locationService.push('/path/b');
const obj: Record<string, any> = { one: '1', two: true, three: null };
const obj: Record<string, unknown> = { one: '1', two: true, three: null };
wrapper.search(obj);
expect(obj).toEqual({ one: '1', two: true, three: null });
obj.one = 'changed';

View File

@@ -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: {},
},

View File

@@ -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<Props> = {}, 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 };

View File

@@ -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
);

View File

@@ -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<Props>) {
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: () => <div />,

View File

@@ -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: [],

View File

@@ -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

View File

@@ -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,

View File

@@ -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');

View File

@@ -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);
});

View File

@@ -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: [

View File

@@ -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', () => {

View File

@@ -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);
});
});
});

View File

@@ -10,7 +10,7 @@ import {
} from './fetch';
jest.mock('@grafana/data', () => ({
...(jest.requireActual('@grafana/data') as unknown as object),
...jest.requireActual('@grafana/data'),
deprecationWarning: () => {},
}));

View File

@@ -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'),

View File

@@ -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;

View File

@@ -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' },

View File

@@ -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;
}

View File

@@ -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);
});
});

View File

@@ -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 () => {

View File

@@ -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 () => {

View File

@@ -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) => {

View File

@@ -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();

View File

@@ -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({

View File

@@ -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);
});

View File

@@ -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(
<SaveDashboardForm
dashboard={dashboard as DashboardModel}
dashboard={dashboard}
onCancel={() => {}}
onSuccess={() => {}}
onSubmit={async (jsonModel) => {
@@ -62,14 +62,14 @@ describe('SaveDashboardAsForm', () => {
it('renders switches when variables or timerange', () => {
render(
<SaveDashboardForm
dashboard={prepareDashboardMock(true, true, jest.fn(), jest.fn()) as any}
dashboard={prepareDashboardMock(true, true, jest.fn(), jest.fn())}
onCancel={() => {}}
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);

View File

@@ -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,
}));

View File

@@ -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);

View File

@@ -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<DashboardMeta>): DashboardModel {
function getTestDashboard(overrides?: Partial<Dashboard>, metaOverrides?: Partial<DashboardMeta>): DashboardModel {
const data = Object.assign(
{
title: 'My dashboard',
@@ -89,8 +92,7 @@ function getTestDashboard(overrides?: any, metaOverrides?: Partial<DashboardMeta
overrides
);
const meta = Object.assign({ canSave: true, canEdit: true }, metaOverrides);
return new DashboardModel(data, meta);
return createDashboardModelFixture(data, metaOverrides);
}
function dashboardPageScenario(description: string, scenarioFn: (ctx: ScenarioContext) => 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' }),
});
});

View File

@@ -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<DashboardMeta>) => void;
setSecondaryDashboard: (overrides?: any, metaOverrides?: Partial<DashboardMeta>) => void;
setDashboard: (overrides?: Partial<Dashboard>, metaOverrides?: Partial<DashboardMeta>) => void;
setSecondaryDashboard: (overrides?: Partial<Dashboard>, metaOverrides?: Partial<DashboardMeta>) => void;
mount: (propOverrides?: Partial<Props>) => void;
rerender: (propOverrides?: Partial<Props>) => void;
setup: (fn: () => void) => void;
}
function getTestDashboard(overrides?: any, metaOverrides?: Partial<DashboardMeta>): DashboardModel {
function getTestDashboard(overrides?: Partial<Dashboard>, metaOverrides?: Partial<DashboardMeta>): DashboardModel {
const data = Object.assign(
{
title: 'My dashboard',
@@ -49,8 +53,7 @@ function getTestDashboard(overrides?: any, metaOverrides?: Partial<DashboardMeta
overrides
);
const meta = Object.assign({ canSave: true, canEdit: true }, metaOverrides);
return new DashboardModel(data, meta);
return createDashboardModelFixture(data, metaOverrides);
}
function soloPanelPageScenario(description: string, scenarioFn: (ctx: ScenarioContext) => void) {
@@ -61,10 +64,10 @@ function soloPanelPageScenario(description: string, scenarioFn: (ctx: ScenarioCo
setup: (fn) => {
setupFn = fn;
},
setDashboard: (overrides?: any, metaOverrides?: Partial<DashboardMeta>) => {
setDashboard: (overrides, metaOverrides) => {
ctx.dashboard = getTestDashboard(overrides, metaOverrides);
},
setSecondaryDashboard: (overrides?: any, metaOverrides?: Partial<DashboardMeta>) => {
setSecondaryDashboard: (overrides, metaOverrides) => {
ctx.secondaryDashboard = getTestDashboard(overrides, metaOverrides);
},
mount: (propOverrides?: Partial<Props>) => {
@@ -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', () => {

View File

@@ -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<DashboardMeta>): DashboardModel {
function getTestDashboard(overrides?: Partial<Dashboard>, metaOverrides?: Partial<DashboardMeta>): DashboardModel {
const data = Object.assign(
{
title: 'My dashboard',
@@ -48,8 +50,7 @@ function getTestDashboard(overrides?: any, metaOverrides?: Partial<DashboardMeta
overrides
);
const meta = Object.assign({ canSave: true, canEdit: true }, metaOverrides);
return new DashboardModel(data, meta);
return createDashboardModelFixture(data, metaOverrides);
}
describe('DashboardGrid', () => {

View File

@@ -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();

View File

@@ -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(() => {

View File

@@ -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(),

View File

@@ -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();

View File

@@ -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(),
}));

View File

@@ -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() }),
}));

View File

@@ -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,
],
},
});

View File

@@ -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<Props>) => {
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<Props> = {
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');

View File

@@ -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<Props>) => {
const props: Props = {
onClose: jest.fn(),
onChange: (mappings: any) => {
onChange: (mappings) => {
if (spy) {
spy(mappings);
}

View File

@@ -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,
});

View File

@@ -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 };
});

View File

@@ -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(),

View File

@@ -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', () => {

View File

@@ -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(),
}),

View File

@@ -197,7 +197,7 @@ describe('Explore reducer', () => {
});
});
export const setup = (urlStateOverrides?: any) => {
export const setup = (urlStateOverrides?: Partial<ExploreUrlState>) => {
const urlStateDefaults: ExploreUrlState = {
datasource: 'some-datasource',
queries: [],

View File

@@ -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 = () => {

View File

@@ -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<any> {
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<string | null> = {
name: 'flux-dimensions',

View File

@@ -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),

View File

@@ -80,12 +80,12 @@ describe('Read GeoJSON', () => {
`);
expect(
frame.fields.reduce((acc, v, idx, arr) => {
frame.fields.reduce<Record<string, unknown[]>>((acc, v, idx, arr) => {
if (v.type !== FieldType.geo) {
acc[v.name] = v.values.toArray();
}
return acc;
}, {} as any)
}, {})
).toMatchInlineSnapshot(`
{
"hello": [

View File

@@ -2,7 +2,7 @@ import { getCenterPointWGS84 } from 'app/features/transformers/spatial/utils';
import { getGazetteer } from './gazetteer';
let backendResults: any = { hello: 'world' };
let backendResults: Record<string, unknown> = { 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),
}),

View File

@@ -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),
}),

View File

@@ -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,
}),
};

View File

@@ -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<DeleteLibraryPanelModalState>()
.givenReducer(deleteLibraryPanelModalReducer, initialDeleteLibraryPanelModalState)
.whenActionIsDispatched(searchCompleted({ dashboards }))

View File

@@ -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',

View File

@@ -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<StreamingDataQueryResponse>();
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<StreamingDataQueryResponse>();
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<StreamingDataQueryResponse>();
deps.centrifugeSrv.getDataStream.mockReturnValueOnce(dummySubject);
mockGetDataStream.mockReturnValueOnce(dummySubject);
let response: DataQueryResponse | undefined;
liveService.getDataStream(liveDataStreamOptions).subscribe((next) => {

View File

@@ -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,
}));

View File

@@ -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',

View File

@@ -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: {

View File

@@ -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();

View File

@@ -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(

View File

@@ -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'] = {

View File

@@ -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']);
});
});

View File

@@ -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<Playlist>
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<RouteParams>;
const location = {} as Location;
const history = {} as History;
const getMock = jest.spyOn(backendSrv, 'get');
const putMock = jest.spyOn(backendSrv, 'put');

View File

@@ -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,
}),

View File

@@ -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(

View File

@@ -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: () => <AppRootPage pluginId="my-awesome-plugin" pluginNavSection={appsSection} /> };
const route = {
component: () => <AppRootPage pluginId="my-awesome-plugin" pluginNavSection={appsSection} />,
} as unknown as RouteDescriptor;
locationService.push('/a/my-awesome-plugin');
render(
<Router history={locationService.getHistory()}>
<Provider store={store}>
<GrafanaContext.Provider value={getGrafanaContextMock()}>
<Route path="/a/:pluginId" exact render={(props) => <GrafanaRoute {...props} route={route as any} />} />
<Route path="/a/:pluginId" exact render={(props) => <GrafanaRoute {...props} route={route} />} />
</GrafanaContext.Provider>
</Provider>
</Router>

View File

@@ -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: {

View File

@@ -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

View File

@@ -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,
}));

View File

@@ -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) => {

View File

@@ -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: [] }]);

View File

@@ -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 };

View File

@@ -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) => {

View File

@@ -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) => {

View File

@@ -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'
);
});
});

View File

@@ -4,17 +4,19 @@ import { Subject } from 'rxjs';
// Importing this way to be able to spy on grafana/data
import * as grafanaData from '@grafana/data';
import { setDataSourceSrv, setEchoSrv } from '@grafana/runtime';
import { DataSourceApi } from '@grafana/data';
import { DataSourceSrv, setDataSourceSrv, setEchoSrv } from '@grafana/runtime';
import { Echo } from '../../../core/services/echo/Echo';
import { createDashboardModelFixture } from '../../dashboard/state/__fixtures__/dashboardFixtures';
import {
createDashboardQueryRunner,
DashboardQueryRunnerFactoryArgs,
setDashboardQueryRunnerFactory,
} from './DashboardQueryRunner/DashboardQueryRunner';
import { emptyResult } from './DashboardQueryRunner/utils';
import { PanelQueryRunner } from './PanelQueryRunner';
import { PanelQueryRunner, QueryRunnerOptions } from './PanelQueryRunner';
jest.mock('@grafana/data', () => ({
__esModule: true,
@@ -83,7 +85,7 @@ function describeQueryRunnerScenario(
},
};
const response: any = {
const response = {
data: [
{
target: 'hello',
@@ -95,21 +97,21 @@ function describeQueryRunnerScenario(
],
};
setDataSourceSrv({} as any);
setDataSourceSrv({} as DataSourceSrv);
setDashboardQueryRunnerFactory(() => ({
getResult: emptyResult,
run: () => undefined,
cancel: () => undefined,
cancellations: () => new Subject<any>(),
cancellations: () => new Subject(),
destroy: () => undefined,
}));
createDashboardQueryRunner({} as any);
createDashboardQueryRunner({} as DashboardQueryRunnerFactoryArgs);
beforeEach(async () => {
setEchoSrv(new Echo());
setupFn();
const datasource: any = {
const datasource = {
name: 'TestDB',
uid: 'TestDB-uid',
interval: ctx.dsInterval,
@@ -119,21 +121,21 @@ function describeQueryRunnerScenario(
},
getRef: () => ({ type: 'test', uid: 'TestDB-uid' }),
testDatasource: jest.fn(),
};
} as unknown as DataSourceApi;
const args: any = {
const args = {
datasource,
scopedVars: ctx.scopedVars,
minInterval: ctx.minInterval,
maxDataPoints: ctx.maxDataPoints,
maxDataPoints: ctx.maxDataPoints ?? Infinity,
timeRange: {
from: grafanaData.dateTime().subtract(1, 'days'),
to: grafanaData.dateTime(),
raw: { from: '1d', to: 'now' },
},
panelId: 1,
queries: [{ refId: 'A', test: 1 }],
};
queries: [{ refId: 'A' }],
} as QueryRunnerOptions;
ctx.runner = new PanelQueryRunner(panelConfig || defaultPanelConfig);
ctx.runner.getData({ withTransforms: true, withFieldConfig: true }).subscribe({

View File

@@ -115,7 +115,7 @@ function runRequestScenario(desc: string, fn: (ctx: ScenarioCtx) => void) {
function runRequestScenarioThatThrows(desc: string, fn: (ctx: ScenarioCtx) => void) {
describe(desc, () => {
const ctx = new ScenarioCtx();
let consoleSpy: jest.SpyInstance<any>;
let consoleSpy: jest.SpyInstance;
beforeEach(() => {
consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});

View File

@@ -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<any>(),
keyboardEvents: new Observable<KeyboardEvent<Element>>(),
};
it('should render grid of dashboards', () => {

View File

@@ -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<Props>) => {
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,

View File

@@ -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,

Some files were not shown because too many files have changed in this diff Show More