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, "Do not use any type assertions.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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": [ "packages/grafana-data/src/dataframe/dimensions.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "packages/grafana-data/src/dataframe/frameComparisons.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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"] [0, 0, 0, "Do not use any type assertions.", "1"]
], ],
"packages/grafana-data/src/events/EventBus.test.ts:5381": [ "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.", "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/events/EventBus.ts:5381": [ "packages/grafana-data/src/events/EventBus.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Do not use any type assertions.", "11"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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": [ "packages/grafana-data/src/geo/layer.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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, "Do not use any type assertions.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"] [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": [ "packages/grafana-data/src/utils/valueMappings.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"] [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": [ "packages/grafana-toolkit/src/config/webpack.plugin.config.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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": [ "packages/grafana-ui/src/components/Forms/Legacy/Select/Select.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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", "0"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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/core/navigation/__mocks__/routeProps.ts:5381": [ "public/app/core/navigation/__mocks__/routeProps.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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"] [0, 0, 0, "Unexpected any. Specify a different type.", "3"]
], ],
"public/app/core/specs/backend_srv.test.ts:5381": [ "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"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/core/specs/time_series.test.ts:5381": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "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/time_series2.ts:5381": [ "public/app/core/time_series2.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -2544,12 +2412,6 @@ exports[`better eslint`] = {
"public/app/core/utils/deferred.ts:5381": [ "public/app/core/utils/deferred.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/core/utils/explore.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "2"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/features/alerting/getAlertingValidationMessage.test.ts:5381": [ "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.", "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/alerting/getAlertingValidationMessage.ts:5381": [ "public/app/features/alerting/getAlertingValidationMessage.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [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, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"] [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": [ "public/app/features/alerting/state/ThresholdMapper.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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": [ "public/app/features/alerting/unified/AlertsFolderView.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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": [ "public/app/features/alerting/unified/PanelAlertTabContent.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", "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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"] [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"] [0, 0, 0, "Unexpected any. Specify a different type.", "12"]
], ],
"public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.test.tsx:5381": [ "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.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.tsx:5381": [ "public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [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, "Use data-testid for E2E selectors instead of aria-label", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"] [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": [ "public/app/features/dashboard/components/PanelEditor/OverrideCategoryTitle.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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": [ "public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardForm.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], [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, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"] [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": [ "public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"], [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.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"] [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": [ "public/app/features/dashboard/containers/DashboardPage.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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, "Unexpected any. Specify a different type.", "3"],
[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", "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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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": [ "public/app/features/dashboard/services/PublicDashboardDataSource.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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, "Unexpected any. Specify a different type.", "33"],
[0, 0, 0, "Do not use any type assertions.", "34"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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"] [0, 0, 0, "Unexpected any. Specify a different type.", "7"]
], ],
"public/app/features/dashboard/state/DashboardModel.test.ts:5381": [ "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.", "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/dashboard/state/DashboardModel.ts:5381": [ "public/app/features/dashboard/state/DashboardModel.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"] [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": [ "public/app/features/dimensions/editors/ThresholdsEditor/ThresholdsEditor.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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": [ "public/app/features/dimensions/scale.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
@@ -3732,9 +3465,6 @@ exports[`better eslint`] = {
"public/app/features/explore/LogsMetaRow.tsx:5381": [ "public/app/features/explore/LogsMetaRow.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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": [ "public/app/features/explore/RichHistory/RichHistory.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"] [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": [ "public/app/features/explore/state/time.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"] [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": [ "public/app/features/explore/utils/links.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/features/geo/format/geohash.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/features/geo/format/geojson.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/features/geo/format/utils.ts:5381": [ "public/app/features/geo/format/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/features/geo/gazetteer/gazetteer.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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", "4"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "5"] [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": [ "public/app/features/invites/state/selectors.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/features/library-panels/components/LibraryPanelsView/actions.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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, "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.", "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": [ "public/app/features/live/pages/AddNewRule.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/features/manage-dashboards/components/ImportDashboardLibraryPanelsList.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "2"]
], ],
"public/app/features/manage-dashboards/state/actions.test.ts:5381": [ "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.", "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/manage-dashboards/state/actions.ts:5381": [ "public/app/features/manage-dashboards/state/actions.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [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.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"] [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": [ "public/app/features/panel/state/actions.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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": [ "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", "0"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] [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": [ "public/app/features/plugins/admin/hooks/useHistory.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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": [ "public/app/features/plugins/built_in_plugins.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/features/plugins/components/PluginsErrorsInfo.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", "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.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"] [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": [ "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", "0"],
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "1"] [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"] [0, 0, 0, "Unexpected any. Specify a different type.", "2"]
], ],
"public/app/features/query/state/DashboardQueryRunner/AnnotationsQueryRunner.test.ts:5381": [ "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.", "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/query/state/DashboardQueryRunner/AnnotationsQueryRunner.ts:5381": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"] [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": [ "public/app/features/query/state/DashboardQueryRunner/DashboardQueryRunner.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/features/query/state/DashboardQueryRunner/SnapshotWorker.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [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.", "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": [ "public/app/features/query/state/runRequest.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "public/app/features/search/page/components/SearchResultsCards.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "public/app/features/search/page/components/SearchResultsGrid.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"] [0, 0, 0, "Do not use any type assertions.", "1"]
@@ -4518,11 +4112,6 @@ exports[`better eslint`] = {
"public/app/features/search/utils.ts:5381": [ "public/app/features/search/utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Do not use any type assertions.", "1"],
@@ -4548,9 +4137,6 @@ exports[`better eslint`] = {
"public/app/features/teams/TeamMembers.tsx:5381": [ "public/app/features/teams/TeamMembers.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/features/teams/TeamPages.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "public/app/features/templating/template_srv.mock.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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, "Do not use any type assertions.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"] [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": [ "public/app/features/transformers/extractFields/extractFields.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"] [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": [ "public/app/features/variables/adhoc/actions.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "public/app/features/variables/adhoc/picker/AdHocFilter.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/features/variables/editor/VariableValuesPreview.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", "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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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": [ "public/app/features/variables/editor/types.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/features/variables/getAllVariableValuesForUrl.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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": [ "public/app/features/variables/interval/reducer.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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": [ "public/app/features/variables/query/VariableQueryRunner.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"] [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, "Do not use any type assertions.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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 // Make sure length survives a spread operator
const keys = Object.keys(frame); const keys = Object.keys(frame);
const copy = { ...frame } as any; const copy = { ...frame } as MutableDataFrame;
expect(keys).toContain('length'); expect(keys).toContain('length');
expect(copy.length).toEqual(frame.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 { compareDataFrameStructures, compareArrayValues } from './frameComparisons';
import { toDataFrame } from './processDataFrame'; import { toDataFrame } from './processDataFrame';
@@ -32,12 +32,12 @@ describe('test comparisons', () => {
expect(compareDataFrameStructures(frameA, frameA)).toBeTruthy(); expect(compareDataFrameStructures(frameA, frameA)).toBeTruthy();
expect(compareDataFrameStructures(frameA, { ...frameA })).toBeTruthy(); expect(compareDataFrameStructures(frameA, { ...frameA })).toBeTruthy();
expect(compareDataFrameStructures(frameA, frameB)).toBeFalsy(); expect(compareDataFrameStructures(frameA, frameB)).toBeFalsy();
expect(compareDataFrameStructures(frameA, null as any)).toBeFalsy(); expect(compareDataFrameStructures(frameA, null as unknown as DataFrame)).toBeFalsy();
expect(compareDataFrameStructures(undefined as any, frameA)).toBeFalsy(); expect(compareDataFrameStructures(undefined as unknown as DataFrame, frameA)).toBeFalsy();
expect(compareArrayValues([frameA], [frameA], compareDataFrameStructures)).toBeTruthy(); expect(compareArrayValues([frameA], [frameA], compareDataFrameStructures)).toBeTruthy();
expect(compareArrayValues([frameA], null as any, compareDataFrameStructures)).toBeFalsy(); expect(compareArrayValues([frameA], null as unknown as DataFrame[], compareDataFrameStructures)).toBeFalsy();
expect(compareArrayValues(null as any, [frameA], compareDataFrameStructures)).toBeFalsy(); expect(compareArrayValues(null as unknown as DataFrame[], [frameA], compareDataFrameStructures)).toBeFalsy();
}); });
it('name change should be a structure change', () => { 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'; import { dateTimeParse } from './parser';
describe('dateTimeParse', () => { describe('dateTimeParse', () => {
@@ -10,7 +10,7 @@ describe('dateTimeParse', () => {
it('should be able to parse using default format', () => { it('should be able to parse using default format', () => {
systemDateFormats.update({ systemDateFormats.update({
fullDate: 'MMMM D, YYYY, h:mm:ss a', fullDate: 'MMMM D, YYYY, h:mm:ss a',
interval: {} as any, interval: {} as SystemDateFormatsState['interval'],
useBrowserLocale: false, useBrowserLocale: false,
}); });

View File

@@ -71,7 +71,7 @@ describe('EventBus', () => {
describe('Legacy emitter behavior', () => { describe('Legacy emitter behavior', () => {
it('Supports legacy events', () => { it('Supports legacy events', () => {
const bus = new EventBusSrv(); const bus = new EventBusSrv();
const events: any = []; const events: LegacyEventPayload[] = [];
const handler = (event: LegacyEventPayload) => { const handler = (event: LegacyEventPayload) => {
events.push(event); events.push(event);
}; };
@@ -88,8 +88,8 @@ describe('EventBus', () => {
it('Interoperability with legacy events', () => { it('Interoperability with legacy events', () => {
const bus = new EventBusSrv(); const bus = new EventBusSrv();
const legacyEvents: any = []; const legacyEvents: LegacyEventPayload[] = [];
const newEvents: any = []; const newEvents: AlertSuccessEvent[] = [];
bus.on(legacyEvent, (event) => { bus.on(legacyEvent, (event) => {
legacyEvents.push(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) => { processors.forEach((processor) => {
const value = processor(input); const value = processor(input);
for (const key of Object.keys(match)) { for (const key of Object.keys(match)) {

View File

@@ -3,7 +3,7 @@ import { merge } from 'lodash';
import { toDataFrame } from '../dataframe/processDataFrame'; import { toDataFrame } from '../dataframe/processDataFrame';
import { createTheme } from '../themes'; import { createTheme } from '../themes';
import { ReducerID } from '../transformations/fieldReducer'; import { ReducerID } from '../transformations/fieldReducer';
import { MappingType, SpecialValueMatch, ValueMapping } from '../types'; import { FieldConfigPropertyItem, MappingType, SpecialValueMatch, ValueMapping } from '../types';
import { getDisplayProcessor } from './displayProcessor'; import { getDisplayProcessor } from './displayProcessor';
import { getFieldDisplayValues, GetFieldDisplayValuesOptions } from './fieldDisplay'; import { getFieldDisplayValues, GetFieldDisplayValuesOptions } from './fieldDisplay';
@@ -14,11 +14,15 @@ describe('FieldDisplay', () => {
// Since FieldConfigEditors belong to grafana-ui we need to mock those here // Since FieldConfigEditors belong to grafana-ui we need to mock those here
// as grafana-ui code cannot be imported in grafana-data. // as grafana-ui code cannot be imported in grafana-data.
// TODO: figure out a way to share standard editors between data/ui tests // TODO: figure out a way to share standard editors between data/ui tests
const mappings = { const mappings: FieldConfigPropertyItem = {
id: 'mappings', // Match field properties id: 'mappings', // Match field properties
process: (value: any) => value, process: (value) => value,
shouldApply: () => true, shouldApply: () => true,
} as any; override: jest.fn(),
editor: jest.fn(),
name: 'Value mappings',
path: 'mappings',
};
standardFieldConfigEditorRegistry.setInit(() => { standardFieldConfigEditorRegistry.setInit(() => {
return [mappings]; return [mappings];

View File

@@ -31,36 +31,48 @@ import {
} from './fieldOverrides'; } from './fieldOverrides';
import { getFieldDisplayName } from './fieldState'; import { getFieldDisplayName } from './fieldState';
const property1: any = { const property1: FieldConfigPropertyItem = {
id: 'custom.property1', // Match field properties id: 'custom.property1', // Match field properties
path: 'property1', // Match field properties path: 'property1', // Match field properties
isCustom: true, isCustom: true,
process: (value: any) => value, process: (value) => value,
shouldApply: () => true, shouldApply: () => true,
override: jest.fn(),
editor: jest.fn(),
name: 'Property 1',
}; };
const property2 = { const property2: FieldConfigPropertyItem = {
id: 'custom.property2', // Match field properties id: 'custom.property2', // Match field properties
path: 'property2', // Match field properties path: 'property2', // Match field properties
isCustom: true, isCustom: true,
process: (value: any) => value, process: (value) => value,
shouldApply: () => true, shouldApply: () => true,
override: jest.fn(),
editor: jest.fn(),
name: 'Property 2',
}; };
const property3: any = { const property3: FieldConfigPropertyItem = {
id: 'custom.property3.nested', // Match field properties id: 'custom.property3.nested', // Match field properties
path: 'property3.nested', // Match field properties path: 'property3.nested', // Match field properties
isCustom: true, isCustom: true,
process: (value: any) => value, process: (value) => value,
shouldApply: () => true, shouldApply: () => true,
override: jest.fn(),
editor: jest.fn(),
name: 'Property 3',
}; };
const shouldApplyFalse: any = { const shouldApplyFalse: FieldConfigPropertyItem = {
id: 'custom.shouldApplyFalse', // Match field properties id: 'custom.shouldApplyFalse', // Match field properties
path: 'shouldApplyFalse', // Match field properties path: 'shouldApplyFalse', // Match field properties
isCustom: true, isCustom: true,
process: (value: any) => value, process: (value) => value,
shouldApply: () => false, shouldApply: () => false,
override: jest.fn(),
editor: jest.fn(),
name: 'Should Apply False',
}; };
export const customFieldRegistry: FieldConfigOptionsRegistry = new Registry<FieldConfigPropertyItem>(() => { export const customFieldRegistry: FieldConfigOptionsRegistry = new Registry<FieldConfigPropertyItem>(() => {
@@ -68,9 +80,9 @@ export const customFieldRegistry: FieldConfigOptionsRegistry = new Registry<Fiel
}); });
locationUtil.initialize({ locationUtil.initialize({
config: { appSubUrl: '/subUrl' } as any, config: { appSubUrl: '/subUrl' } as GrafanaConfig,
getVariablesUrlParams: (() => {}) as any, getVariablesUrlParams: jest.fn(),
getTimeRangeForUrl: (() => {}) as any, getTimeRangeForUrl: jest.fn(),
}); });
describe('Global MinMax', () => { describe('Global MinMax', () => {
@@ -181,7 +193,7 @@ describe('applyFieldOverrides', () => {
defaults: {}, defaults: {},
overrides: [], overrides: [],
}, },
replaceVariables: (value: any) => value, replaceVariables: (value) => value,
theme: createTheme(), theme: createTheme(),
fieldConfigRegistry: new FieldConfigOptionsRegistry(), fieldConfigRegistry: new FieldConfigOptionsRegistry(),
}); });
@@ -300,7 +312,7 @@ describe('applyFieldOverrides', () => {
}); });
it('getLinks should use applied field config', () => { it('getLinks should use applied field config', () => {
const replaceVariablesCalls: any[] = []; const replaceVariablesCalls: ScopedVars[] = [];
const data = applyFieldOverrides({ const data = applyFieldOverrides({
data: [f0], // the frame data: [f0], // the frame
@@ -375,8 +387,8 @@ describe('setFieldConfigDefaults', () => {
}; };
const context: FieldOverrideEnv = { const context: FieldOverrideEnv = {
data: [] as any, data: [],
field: { type: FieldType.number } as any, field: { type: FieldType.number } as Field,
dataFrameIndex: 0, dataFrameIndex: 0,
fieldConfigRegistry: customFieldRegistry, fieldConfigRegistry: customFieldRegistry,
}; };
@@ -410,8 +422,8 @@ describe('setFieldConfigDefaults', () => {
}; };
const context: FieldOverrideEnv = { const context: FieldOverrideEnv = {
data: [] as any, data: [],
field: { type: FieldType.number } as any, field: { type: FieldType.number } as Field,
dataFrameIndex: 0, dataFrameIndex: 0,
fieldConfigRegistry: customFieldRegistry, fieldConfigRegistry: customFieldRegistry,
}; };
@@ -444,8 +456,8 @@ describe('setDynamicConfigValue', () => {
}, },
{ {
fieldConfigRegistry: customFieldRegistry, fieldConfigRegistry: customFieldRegistry,
data: [] as any, data: [],
field: { type: FieldType.number } as any, field: { type: FieldType.number } as Field,
dataFrameIndex: 0, dataFrameIndex: 0,
} }
); );
@@ -467,8 +479,8 @@ describe('setDynamicConfigValue', () => {
}, },
{ {
fieldConfigRegistry: customFieldRegistry, fieldConfigRegistry: customFieldRegistry,
data: [] as any, data: [],
field: { type: FieldType.number } as any, field: { type: FieldType.number } as Field,
dataFrameIndex: 0, dataFrameIndex: 0,
} }
); );
@@ -488,8 +500,8 @@ describe('setDynamicConfigValue', () => {
}, },
{ {
fieldConfigRegistry: customFieldRegistry, fieldConfigRegistry: customFieldRegistry,
data: [] as any, data: [],
field: { type: FieldType.number } as any, field: { type: FieldType.number } as Field,
dataFrameIndex: 0, dataFrameIndex: 0,
} }
); );
@@ -513,8 +525,8 @@ describe('setDynamicConfigValue', () => {
}, },
{ {
fieldConfigRegistry: customFieldRegistry, fieldConfigRegistry: customFieldRegistry,
data: [] as any, data: [],
field: { type: FieldType.number } as any, field: { type: FieldType.number } as Field,
dataFrameIndex: 0, dataFrameIndex: 0,
} }
); );
@@ -539,8 +551,8 @@ describe('setDynamicConfigValue', () => {
}, },
{ {
fieldConfigRegistry: customFieldRegistry, fieldConfigRegistry: customFieldRegistry,
data: [] as any, data: [],
field: { type: FieldType.number } as any, field: { type: FieldType.number } as Field,
dataFrameIndex: 0, dataFrameIndex: 0,
} }
); );
@@ -553,8 +565,8 @@ describe('setDynamicConfigValue', () => {
}, },
{ {
fieldConfigRegistry: customFieldRegistry, fieldConfigRegistry: customFieldRegistry,
data: [] as any, data: [],
field: { type: FieldType.number } as any, field: { type: FieldType.number } as Field,
dataFrameIndex: 0, dataFrameIndex: 0,
} }
); );

View File

@@ -38,12 +38,12 @@ describe('getScaleCalculator', () => {
const theme = createTheme(); const theme = createTheme();
const calc = getScaleCalculator(field, theme); const calc = getScaleCalculator(field, theme);
expect(calc(true as any)).toEqual({ expect(calc(true as unknown as number)).toEqual({
percent: 1, percent: 1,
color: theme.visualization.getColorByName('green'), color: theme.visualization.getColorByName('green'),
threshold: undefined, threshold: undefined,
}); });
expect(calc(false as any)).toEqual({ expect(calc(false as unknown as number)).toEqual({
percent: 0, percent: 0,
color: theme.visualization.getColorByName('red'), color: theme.visualization.getColorByName('red'),
threshold: undefined, threshold: undefined,

View File

@@ -1,8 +1,13 @@
import React from 'react'; import React from 'react';
import { PanelOptionsEditorBuilder } from '..'; import { PanelOptionsEditorBuilder } from '..';
import { identityOverrideProcessor, standardEditorsRegistry, standardFieldConfigEditorRegistry } from '../field'; import {
import { FieldConfigProperty } from '../types'; identityOverrideProcessor,
standardEditorsRegistry,
StandardEditorsRegistryItem,
standardFieldConfigEditorRegistry,
} from '../field';
import { FieldConfigProperty, FieldConfigPropertyItem } from '../types';
import { PanelPlugin } from './PanelPlugin'; import { PanelPlugin } from './PanelPlugin';
@@ -19,14 +24,14 @@ describe('PanelPlugin', () => {
id: FieldConfigProperty.Max, id: FieldConfigProperty.Max,
path: 'max', path: 'max',
}, },
] as any; ] as FieldConfigPropertyItem[];
}); });
standardEditorsRegistry.setInit(() => { standardEditorsRegistry.setInit(() => {
return [ return [
{ {
id: 'number', id: 'number',
}, },
] as any; ] as StandardEditorsRegistryItem[];
}); });
}); });
@@ -202,7 +207,7 @@ describe('PanelPlugin', () => {
name: 'Option editor', name: 'Option editor',
description: 'Option editor description', description: 'Option editor description',
defaultValue: 10, defaultValue: 10,
} as any); } as FieldConfigPropertyItem);
}, },
}); });
expect(() => panel.fieldConfigRegistry).toThrowErrorMatchingInlineSnapshot( expect(() => panel.fieldConfigRegistry).toThrowErrorMatchingInlineSnapshot(

View File

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

View File

@@ -455,7 +455,7 @@ describe('Labels as Columns', () => {
}); });
function toSimpleObject(frame: DataFrame) { function toSimpleObject(frame: DataFrame) {
const obj: any = {}; const obj: Record<string, unknown> = {};
for (const field of frame.fields) { for (const field of frame.fields) {
obj[field.name] = field.values.toArray(); 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 }; return { name, type, values: new ArrayVector(values), config, labels: undefined, display };
}; };
const unwrap = (fields: Field[]): Field[] => { const unwrap = (fields: Field[]): Field[] => {
return fields.map((field) => return fields.map((field) =>
createField( createField(field.name, field.type, field.values.toArray(), field.config, field.display)
field.name,
field.type,
field.values.toArray().map((value: any) => value),
field.config,
field.display
)
); );
}; };

View File

@@ -261,8 +261,8 @@ describe('Reducer Transformer', () => {
expect(frames[0].length).toEqual(1); expect(frames[0].length).toEqual(1);
expect(frames[1].length).toEqual(1); expect(frames[1].length).toEqual(1);
const view0 = new DataFrameView<any>(frames[0]); const view0 = new DataFrameView(frames[0]);
const view1 = new DataFrameView<any>(frames[1]); const view1 = new DataFrameView(frames[1]);
expect({ ...view0.get(0) }).toMatchInlineSnapshot(` expect({ ...view0.get(0) }).toMatchInlineSnapshot(`
{ {
"temperature": 6, "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 }; return { name, type, values: new ArrayVector(values), config, labels: undefined };
}; };
const unwrap = (fields: Field[]): Field[] => { const unwrap = (fields: Field[]): Field[] => {
return fields.map((field) => return fields.map((field) => createField(field.name, field.type, field.values.toArray(), field.config));
createField(
field.name,
field.type,
field.values.toArray().map((value: any) => value),
field.config
)
);
}; };

View File

@@ -135,12 +135,12 @@ describe('Format value with value mappings', () => {
it('should return match result for undefined value', () => { it('should return match result for undefined value', () => {
const value = undefined; 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', () => { it('should return match result for nan value', () => {
const value = Number.NaN; 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', () => { 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'; import { findModuleFiles, loadWebpackConfig } from './webpack.plugin.config';
// eslint-disable-next-line no-duplicate-imports // eslint-disable-next-line no-duplicate-imports
@@ -24,7 +24,7 @@ describe('Plugin webpack config', () => {
beforeAll(() => { beforeAll(() => {
jest.spyOn(fs, 'statSync').mockReturnValue({ jest.spyOn(fs, 'statSync').mockReturnValue({
isDirectory: () => false, isDirectory: () => false,
} as any); } as BigIntStats);
}); });
afterAll(() => { afterAll(() => {

View File

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

View File

@@ -192,7 +192,7 @@ describe('Table utils', () => {
type: FieldType.number, type: FieldType.number,
getLinks: () => [], getLinks: () => [],
state: null, state: null,
display: (value: any) => ({ display: () => ({
numeric: 1, numeric: 1,
percent: 0.01, percent: 0.01,
color: '', color: '',
@@ -215,7 +215,7 @@ describe('Table utils', () => {
values: new ArrayVector([1, 2, 2, 1, 3, 5, 6]), values: new ArrayVector([1, 2, 2, 1, 3, 5, 6]),
name: 'value', name: 'value',
type: FieldType.number, type: FieldType.number,
display: jest.fn((value: any) => ({ display: jest.fn().mockImplementation((value) => ({
numeric: 1, numeric: 1,
percent: 0.01, percent: 0.01,
color: '', color: '',
@@ -223,7 +223,7 @@ describe('Table utils', () => {
text: `${value}.0`, 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); const result = calculateUniqueFieldValues(rows, field);
@@ -244,7 +244,7 @@ describe('Table utils', () => {
name: 'value', name: 'value',
type: FieldType.number, 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); const result = calculateUniqueFieldValues(rows, field);
@@ -263,7 +263,7 @@ describe('Table utils', () => {
name: 'value', name: 'value',
type: FieldType.number, 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); const result = calculateUniqueFieldValues(rows, field);
@@ -280,7 +280,12 @@ describe('Table utils', () => {
describe('rowToFieldValue', () => { describe('rowToFieldValue', () => {
describe('happy paths', () => { describe('happy paths', () => {
describe('field without field display', () => { 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 row = { index: 1 };
const result = rowToFieldValue(row, field); const result = rowToFieldValue(row, field);
@@ -294,7 +299,7 @@ describe('Table utils', () => {
values: new ArrayVector([1, 2, 2, 1, 3, 5, 6]), values: new ArrayVector([1, 2, 2, 1, 3, 5, 6]),
name: 'value', name: 'value',
type: FieldType.number, type: FieldType.number,
display: jest.fn((value: any) => ({ display: jest.fn().mockImplementation((value) => ({
numeric: 1, numeric: 1,
percent: 0.01, percent: 0.01,
color: '', color: '',
@@ -320,7 +325,12 @@ describe('Table utils', () => {
expect(result).toEqual(''); expect(result).toEqual('');
}); });
describe('row is missing', () => { 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 row = undefined;
const result = rowToFieldValue(row, field); const result = rowToFieldValue(row, field);
@@ -502,8 +512,8 @@ describe('Table utils', () => {
it.skip('should have good performance', () => { it.skip('should have good performance', () => {
const ITERATIONS = 100000; const ITERATIONS = 100000;
const a: any = { values: Array(ITERATIONS) }; const a = { values: Array(ITERATIONS) } as unknown as Row;
const b: any = { values: Array(ITERATIONS) }; const b = { values: Array(ITERATIONS) } as unknown as Row;
for (let i = 0; i < ITERATIONS; i++) { for (let i = 0; i < ITERATIONS; i++) {
a.values[i] = Math.random() * Date.now(); a.values[i] = Math.random() * Date.now();
b.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 () { it('should copy object', function () {
locationService.push('/path/b'); 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); wrapper.search(obj);
expect(obj).toEqual({ one: '1', two: true, three: null }); expect(obj).toEqual({ one: '1', two: true, three: null });
obj.one = 'changed'; obj.one = 'changed';

View File

@@ -1,7 +1,7 @@
jest.mock('app/core/core', () => ({})); jest.mock('app/core/core', () => ({}));
jest.mock('app/core/config', () => { jest.mock('app/core/config', () => {
return { return {
...(jest.requireActual('app/core/config') as unknown as object), ...jest.requireActual('app/core/config'),
bootData: { bootData: {
user: {}, user: {},
}, },

View File

@@ -4,7 +4,7 @@ import React from 'react';
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from 'react-router-dom';
import { locationUtil } from '@grafana/data'; 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 // Need to mock createBrowserHistory here to avoid errors
jest.mock('history', () => ({ jest.mock('history', () => ({
@@ -38,7 +38,7 @@ async function getTestContext(overrides: Partial<Props> = {}, subUrl = '', isMen
config.appSubUrl = subUrl; config.appSubUrl = subUrl;
locationUtil.initialize({ config, getTimeRangeForUrl: jest.fn(), getVariablesUrlParams: jest.fn() }); locationUtil.initialize({ config, getTimeRangeForUrl: jest.fn(), getVariablesUrlParams: jest.fn() });
const pushMock = jest.fn(); const pushMock = jest.fn();
const locationService: any = { push: pushMock }; const locationService = { push: pushMock } as unknown as LocationService;
setLocationService(locationService); setLocationService(locationService);
const props = { ...defaults, ...overrides }; 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 { LegendDisplayMode, VizLegendOptions } from '@grafana/schema';
import { import {
@@ -183,7 +192,7 @@ describe('getThresholdItems', () => {
describe('prepareTimelineLegendItems', () => { describe('prepareTimelineLegendItems', () => {
it('should return legend items without crashing when single (base) threshold', () => { it('should return legend items without crashing when single (base) threshold', () => {
const frame: any = [ const frames = [
{ {
refId: 'A', refId: 'A',
fields: [ fields: [
@@ -238,10 +247,10 @@ describe('prepareTimelineLegendItems', () => {
}, },
], ],
}, },
]; ] as unknown as DataFrame[];
const result = prepareTimelineLegendItems( const result = prepareTimelineLegendItems(
frame, frames,
{ displayMode: LegendDisplayMode.List } as VizLegendOptions, { displayMode: LegendDisplayMode.List } as VizLegendOptions,
theme theme
); );

View File

@@ -1,5 +1,7 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import { History, Location } from 'history';
import React, { ComponentType } from 'react'; import React, { ComponentType } from 'react';
import { match } from 'react-router-dom';
import { TestProvider } from 'test/helpers/TestProvider'; import { TestProvider } from 'test/helpers/TestProvider';
import { setEchoSrv } from '@grafana/runtime'; import { setEchoSrv } from '@grafana/runtime';
@@ -10,9 +12,9 @@ import { GrafanaRoute, Props } from './GrafanaRoute';
function setup(overrides: Partial<Props>) { function setup(overrides: Partial<Props>) {
const props: Props = { const props: Props = {
location: { search: '?query=hello&test=asd' } as any, location: { search: '?query=hello&test=asd' } as Location,
history: {} as any, history: {} as History,
match: {} as any, match: {} as match,
route: { route: {
path: '/', path: '/',
component: () => <div />, component: () => <div />,

View File

@@ -7,7 +7,7 @@ import { cleanUpAction } from '../actions/cleanUp';
import { createRootReducer } from './root'; import { createRootReducer } from './root';
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
config: { config: {
bootData: { bootData: {
navTree: [], navTree: [],

View File

@@ -34,6 +34,7 @@ export const backendSrv = {
getFolderByUid: jest.fn(), getFolderByUid: jest.fn(),
post: jest.fn(), post: jest.fn(),
resolveCancelerIfExists: jest.fn(), resolveCancelerIfExists: jest.fn(),
search: jest.fn(),
datasourceRequest: jest.fn(() => Promise.resolve(makePromResponse())), datasourceRequest: jest.fn(() => Promise.resolve(makePromResponse())),
// Observable support // Observable support

View File

@@ -3,11 +3,11 @@ import { Observable, of } from 'rxjs';
import { delay } from 'rxjs/operators'; import { delay } from 'rxjs/operators';
import { AppEvents, DataQueryErrorType, EventBusExtended } from '@grafana/data'; 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 { TokenRevokedModal } from '../../features/users/TokenRevokedModal';
import { ShowModalReactEvent } from '../../types/events'; 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'; import { ContextSrv, User } from '../services/context_srv';
const getTestContext = (overides?: object) => { const getTestContext = (overides?: object) => {
@@ -65,7 +65,7 @@ const getTestContext = (overides?: object) => {
expect(fromFetchMock).toHaveBeenCalledTimes(1); expect(fromFetchMock).toHaveBeenCalledTimes(1);
}; };
const expectRequestCallChain = (options: any) => { const expectRequestCallChain = (options: unknown) => {
expect(parseRequestOptionsMock).toHaveBeenCalledTimes(1); expect(parseRequestOptionsMock).toHaveBeenCalledTimes(1);
expect(parseRequestOptionsMock).toHaveBeenCalledWith(options); expect(parseRequestOptionsMock).toHaveBeenCalledWith(options);
expectCallChain(); expectCallChain();
@@ -109,7 +109,7 @@ describe('backendSrv', () => {
orgId: orgId, orgId: orgId,
}, },
}, },
} as any); } as BackendSrvDependencies);
if (noBackendCache) { if (noBackendCache) {
await srv.withNoBackendCache(async () => { await srv.withNoBackendCache(async () => {
@@ -377,7 +377,7 @@ describe('backendSrv', () => {
requestId: 'A', requestId: 'A',
}; };
let slowError: any = null; let slowError = null;
backendSrv.request(options).catch((err) => { backendSrv.request(options).catch((err) => {
slowError = err; slowError = err;
}); });
@@ -415,7 +415,7 @@ describe('backendSrv', () => {
.mockResolvedValue({ ok: true, status: 200, statusText: 'OK', data: { message: 'Ok' } }); .mockResolvedValue({ ok: true, status: 200, statusText: 'OK', data: { message: 'Ok' } });
const url = '/api/dashboard/'; const url = '/api/dashboard/';
let inspectorPacket: any = null; let inspectorPacket: FetchResponse | FetchError;
backendSrv.getInspectorStream().subscribe({ backendSrv.getInspectorStream().subscribe({
next: (rsp) => (inspectorPacket = rsp), next: (rsp) => (inspectorPacket = rsp),
}); });
@@ -536,7 +536,7 @@ describe('backendSrv', () => {
method: 'GET', method: 'GET',
}; };
let inspectorPacket: any = null; let inspectorPacket: FetchResponse | FetchError;
backendSrv.getInspectorStream().subscribe({ backendSrv.getInspectorStream().subscribe({
next: (rsp) => (inspectorPacket = rsp), next: (rsp) => (inspectorPacket = rsp),
}); });
@@ -563,7 +563,7 @@ describe('backendSrv', () => {
describe('when called with 2 separate requests and then cancelAllInFlightRequests is called', () => { describe('when called with 2 separate requests and then cancelAllInFlightRequests is called', () => {
const url = '/api/dashboard/'; const url = '/api/dashboard/';
const getRequestObservable = (message: string, unsubscribe: any) => const getRequestObservable = (message: string, unsubscribe: jest.Mock) =>
new Observable((subscriber) => { new Observable((subscriber) => {
subscriber.next({ subscriber.next({
ok: true, ok: true,

View File

@@ -2,18 +2,15 @@ import flatten from 'app/core/utils/flatten';
describe('flatten', () => { describe('flatten', () => {
it('should return flatten object', () => { it('should return flatten object', () => {
const flattened = flatten( const flattened = flatten({
{ level1: 'level1-value',
level1: 'level1-value', deeper: {
level2: 'level2-value',
deeper: { deeper: {
level2: 'level2-value', level3: 'level3-value',
deeper: {
level3: 'level3-value',
},
}, },
}, },
null as unknown as { delimiter?: any; maxDepth?: any; safe?: any } });
);
expect(flattened['level1']).toBe('level1-value'); expect(flattened['level1']).toBe('level1-value');
expect(flattened['deeper.level2']).toBe('level2-value'); expect(flattened['deeper.level2']).toBe('level2-value');

View File

@@ -2,22 +2,21 @@ import * as ticks from '../utils/ticks';
describe('ticks', () => { describe('ticks', () => {
describe('getFlotTickDecimals()', () => { describe('getFlotTickDecimals()', () => {
const ctx: any = {}; const axis = {
min: null,
beforeEach(() => { max: null,
ctx.axis = {}; };
});
it('should calculate decimals precision based on graph height', () => { 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.tickDecimals).toBe(1);
expect(dec.scaledDecimals).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.tickDecimals).toBe(0);
expect(dec.scaledDecimals).toBe(-1); 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.tickDecimals).toBe(2);
expect(dec.scaledDecimals).toBe(3); expect(dec.scaledDecimals).toBe(3);
}); });

View File

@@ -1,8 +1,8 @@
import TimeSeries, { updateLegendValues } from 'app/core/time_series2'; import TimeSeries, { updateLegendValues } from 'app/core/time_series2';
describe('TimeSeries', () => { describe('TimeSeries', () => {
let points, series: any; let points: any[][];
const yAxisFormats = ['short', 'ms']; let series: TimeSeries;
let testData: { alias?: string; datapoints: any }; let testData: { alias?: string; datapoints: any };
beforeEach(() => { beforeEach(() => {
@@ -20,13 +20,13 @@ describe('TimeSeries', () => {
describe('when getting flot pairs', () => { describe('when getting flot pairs', () => {
it('with connected style, should ignore nulls', () => { it('with connected style, should ignore nulls', () => {
series = new TimeSeries(testData); series = new TimeSeries(testData);
points = series.getFlotPairs('connected', yAxisFormats); points = series.getFlotPairs('connected');
expect(points.length).toBe(3); expect(points.length).toBe(3);
}); });
it('with null as zero style, should replace nulls with zero', () => { it('with null as zero style, should replace nulls with zero', () => {
series = new TimeSeries(testData); series = new TimeSeries(testData);
points = series.getFlotPairs('null as zero', yAxisFormats); points = series.getFlotPairs('null as zero');
expect(points.length).toBe(4); expect(points.length).toBe(4);
expect(points[1][1]).toBe(0); expect(points[1][1]).toBe(0);
}); });
@@ -38,7 +38,7 @@ describe('TimeSeries', () => {
[null, 2], [null, 2],
], ],
}); });
series.getFlotPairs('null', yAxisFormats); series.getFlotPairs('null');
expect(series.stats.current).toBe(10); expect(series.stats.current).toBe(10);
}); });
@@ -49,13 +49,13 @@ describe('TimeSeries', () => {
[-4, 2], [-4, 2],
], ],
}); });
series.getFlotPairs('null', yAxisFormats); series.getFlotPairs('null');
expect(series.stats.max).toBe(-4); expect(series.stats.max).toBe(-4);
}); });
it('average value should ignore nulls', () => { it('average value should ignore nulls', () => {
series = new TimeSeries(testData); series = new TimeSeries(testData);
series.getFlotPairs('null', yAxisFormats); series.getFlotPairs('null');
expect(series.stats.avg).toBe(6.333333333333333); expect(series.stats.avg).toBe(6.333333333333333);
}); });
@@ -69,7 +69,7 @@ describe('TimeSeries', () => {
[15, 6], [15, 6],
], ],
}); });
series.getFlotPairs('null', yAxisFormats); series.getFlotPairs('null');
expect(series.stats.delta).toBe(14); expect(series.stats.delta).toBe(14);
}); });
@@ -82,7 +82,7 @@ describe('TimeSeries', () => {
[15, 5], [15, 5],
], ],
}); });
series.getFlotPairs('null', yAxisFormats); series.getFlotPairs('null');
expect(series.stats.delta).toBe(14); expect(series.stats.delta).toBe(14);
}); });
@@ -95,7 +95,7 @@ describe('TimeSeries', () => {
[null, 5], [null, 5],
], ],
}); });
series.getFlotPairs('null', yAxisFormats); series.getFlotPairs('null');
expect(series.stats.delta).toBe(9); expect(series.stats.delta).toBe(9);
}); });
@@ -109,7 +109,7 @@ describe('TimeSeries', () => {
[10, 6], [10, 6],
], ],
}); });
series.getFlotPairs('null', yAxisFormats); series.getFlotPairs('null');
expect(series.stats.delta).toBe(19); expect(series.stats.delta).toBe(19);
}); });
@@ -122,19 +122,19 @@ describe('TimeSeries', () => {
[8, 5], [8, 5],
], ],
}); });
series.getFlotPairs('null', yAxisFormats); series.getFlotPairs('null');
expect(series.stats.delta).toBe(17); expect(series.stats.delta).toBe(17);
}); });
it('the range value should be max - min', () => { it('the range value should be max - min', () => {
series = new TimeSeries(testData); series = new TimeSeries(testData);
series.getFlotPairs('null', yAxisFormats); series.getFlotPairs('null');
expect(series.stats.range).toBe(9); expect(series.stats.range).toBe(9);
}); });
it('first value should ingone nulls', () => { it('first value should ingone nulls', () => {
series = new TimeSeries(testData); series = new TimeSeries(testData);
series.getFlotPairs('null', yAxisFormats); series.getFlotPairs('null');
expect(series.stats.first).toBe(1); expect(series.stats.first).toBe(1);
series = new TimeSeries({ series = new TimeSeries({
datapoints: [ datapoints: [
@@ -144,13 +144,13 @@ describe('TimeSeries', () => {
[8, 5], [8, 5],
], ],
}); });
series.getFlotPairs('null', yAxisFormats); series.getFlotPairs('null');
expect(series.stats.first).toBe(1); expect(series.stats.first).toBe(1);
}); });
it('with null as zero style, average value should treat nulls as 0', () => { it('with null as zero style, average value should treat nulls as 0', () => {
series = new TimeSeries(testData); series = new TimeSeries(testData);
series.getFlotPairs('null as zero', yAxisFormats); series.getFlotPairs('null as zero');
expect(series.stats.avg).toBe(4.75); expect(series.stats.avg).toBe(4.75);
}); });
@@ -238,7 +238,7 @@ describe('TimeSeries', () => {
}); });
describe('can detect if series contains ms precision', () => { describe('can detect if series contains ms precision', () => {
let fakedata: any; let fakedata: typeof testData;
beforeEach(() => { beforeEach(() => {
fakedata = testData; fakedata = testData;
@@ -258,7 +258,7 @@ describe('TimeSeries', () => {
}); });
describe('series overrides', () => { describe('series overrides', () => {
let series: any; let series: TimeSeries;
beforeEach(() => { beforeEach(() => {
series = new TimeSeries(testData); series = new TimeSeries(testData);
}); });
@@ -390,14 +390,14 @@ describe('TimeSeries', () => {
}); });
describe('value formatter', () => { describe('value formatter', () => {
let series: any; let series: TimeSeries;
beforeEach(() => { beforeEach(() => {
series = new TimeSeries(testData); series = new TimeSeries(testData);
}); });
it('should format non-numeric values as empty string', () => { it('should format non-numeric values as empty string', () => {
expect(series.formatValue(null)).toBe(''); 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(NaN)).toBe('');
expect(series.formatValue(Infinity)).toBe(''); expect(series.formatValue(Infinity)).toBe('');
expect(series.formatValue(-Infinity)).toBe(''); expect(series.formatValue(-Infinity)).toBe('');
@@ -405,7 +405,8 @@ describe('TimeSeries', () => {
}); });
describe('legend decimals', () => { describe('legend decimals', () => {
let series: any, panel: any; let series: TimeSeries;
let panel: any;
const height = 200; const height = 200;
beforeEach(() => { beforeEach(() => {
testData = { testData = {
@@ -418,7 +419,7 @@ describe('TimeSeries', () => {
], ],
}; };
series = new TimeSeries(testData); series = new TimeSeries(testData);
series.getFlotPairs(); series.getFlotPairs('connected');
panel = { panel = {
decimals: null, decimals: null,
yaxes: [ yaxes: [

View File

@@ -46,7 +46,7 @@ describe('errors functions', () => {
describe('when getMessageFromError gets an error object', () => { describe('when getMessageFromError gets an error object', () => {
beforeEach(() => { beforeEach(() => {
message = getMessageFromError({ customError: 'error string' } as any); message = getMessageFromError({ customError: 'error string' });
}); });
it('should return the stringified error', () => { it('should return the stringified error', () => {

View File

@@ -41,7 +41,7 @@ const datasourceSrv = new DatasourceSrvMock(defaultDs, {
const getDataSourceSrvMock = jest.fn().mockReturnValue(datasourceSrv); const getDataSourceSrvMock = jest.fn().mockReturnValue(datasourceSrv);
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => getDataSourceSrvMock(), getDataSourceSrv: () => getDataSourceSrvMock(),
})); }));
@@ -291,10 +291,11 @@ describe('hasRefId', () => {
describe('when called with an object that has refId somewhere in the object tree', () => { describe('when called with an object that has refId somewhere in the object tree', () => {
it('then it should return the object', () => { 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); 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'; } from './fetch';
jest.mock('@grafana/data', () => ({ jest.mock('@grafana/data', () => ({
...(jest.requireActual('@grafana/data') as unknown as object), ...jest.requireActual('@grafana/data'),
deprecationWarning: () => {}, 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'; import { getShiftedTimeRange, getZoomedTimeRange } from './timePicker';
export const setup = (options?: any) => { export const setup = (options?: { direction?: number; range?: TimeRange }) => {
const defaultOptions = { const defaultOptions = {
range: { range: {
from: toUtc('2019-01-01 10:00:00'), 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'; import { AlertTabCtrl } from './AlertTabCtrl';
interface Args { interface Args {
@@ -16,9 +19,9 @@ function setupTestContext({ notifications = [] }: Args = {}) {
render: jest.fn(), render: jest.fn(),
}, },
}; };
const dashboardSrv: any = {}; const dashboardSrv = {} as DashboardSrv;
const uiSegmentSrv: any = {}; const uiSegmentSrv = {};
const datasourceSrv: any = {}; const datasourceSrv = {} as DatasourceSrv;
const controller = new AlertTabCtrl($scope, dashboardSrv, uiSegmentSrv, datasourceSrv); const controller = new AlertTabCtrl($scope, dashboardSrv, uiSegmentSrv, datasourceSrv);
controller.notifications = notifications; controller.notifications = notifications;

View File

@@ -35,8 +35,8 @@ describe('getAlertingValidationMessage', () => {
getList(): DataSourceInstanceSettings[] { getList(): DataSourceInstanceSettings[] {
return []; return [];
}, },
getInstanceSettings: (() => {}) as any, getInstanceSettings: jest.fn(),
reload: () => jest.fn(), reload: jest.fn(),
}; };
const targets: ElasticsearchQuery[] = [ const targets: ElasticsearchQuery[] = [
{ refId: 'A', query: '@hostname:$hostname' }, { refId: 'A', query: '@hostname:$hostname' },
@@ -75,11 +75,11 @@ describe('getAlertingValidationMessage', () => {
return Promise.resolve(alertingDatasource); return Promise.resolve(alertingDatasource);
}, },
getInstanceSettings: (() => {}) as any, getInstanceSettings: jest.fn(),
getList(): DataSourceInstanceSettings[] { getList(): DataSourceInstanceSettings[] {
return []; return [];
}, },
reload: () => jest.fn(), reload: jest.fn(),
}; };
const targets: any[] = [ const targets: any[] = [
{ refId: 'A', query: 'some query', datasource: 'alertingDatasource' }, { refId: 'A', query: 'some query', datasource: 'alertingDatasource' },
@@ -107,11 +107,11 @@ describe('getAlertingValidationMessage', () => {
get: (ref: DataSourceRef) => { get: (ref: DataSourceRef) => {
return getMock(ref.uid); return getMock(ref.uid);
}, },
getInstanceSettings: (() => {}) as any, getInstanceSettings: jest.fn(),
getList(): DataSourceInstanceSettings[] { getList(): DataSourceInstanceSettings[] {
return []; return [];
}, },
reload: () => jest.fn(), reload: jest.fn(),
}; };
const targets: ElasticsearchQuery[] = [ const targets: ElasticsearchQuery[] = [
{ refId: 'A', query: '@hostname:$hostname' }, { refId: 'A', query: '@hostname:$hostname' },
@@ -142,11 +142,11 @@ describe('getAlertingValidationMessage', () => {
get: (ref: DataSourceRef) => { get: (ref: DataSourceRef) => {
return getMock(ref.uid); return getMock(ref.uid);
}, },
getInstanceSettings: (() => {}) as any, getInstanceSettings: jest.fn(),
getList(): DataSourceInstanceSettings[] { getList(): DataSourceInstanceSettings[] {
return []; return [];
}, },
reload: () => jest.fn(), reload: jest.fn(),
}; };
const targets: ElasticsearchQuery[] = [ const targets: ElasticsearchQuery[] = [
{ refId: 'A', query: '@hostname:hostname' }, { refId: 'A', query: '@hostname:hostname' },
@@ -176,11 +176,11 @@ describe('getAlertingValidationMessage', () => {
get: (ref: DataSourceRef) => { get: (ref: DataSourceRef) => {
return getMock(ref.uid); return getMock(ref.uid);
}, },
getInstanceSettings: (() => {}) as any, getInstanceSettings: jest.fn(),
getList(): DataSourceInstanceSettings[] { getList(): DataSourceInstanceSettings[] {
return []; return [];
}, },
reload: () => jest.fn(), reload: jest.fn(),
}; };
const targets: ElasticsearchQuery[] = [ const targets: ElasticsearchQuery[] = [
{ refId: 'A', query: '@hostname:hostname' }, { refId: 'A', query: '@hostname:hostname' },

View File

@@ -1,3 +1,5 @@
import { PanelModel } from 'app/features/dashboard/state';
import { hiddenReducerTypes, ThresholdMapper } from './ThresholdMapper'; import { hiddenReducerTypes, ThresholdMapper } from './ThresholdMapper';
import alertDef from './alertDef'; import alertDef from './alertDef';
@@ -8,7 +10,7 @@ const visibleReducerTypes = alertDef.reducerTypes
describe('ThresholdMapper', () => { describe('ThresholdMapper', () => {
describe('with greater than evaluator', () => { describe('with greater than evaluator', () => {
it('can map query conditions to thresholds', () => { it('can map query conditions to thresholds', () => {
const panel: any = { const panel = {
type: 'graph', type: 'graph',
options: { alertThresholds: true }, options: { alertThresholds: true },
alert: { alert: {
@@ -19,7 +21,7 @@ describe('ThresholdMapper', () => {
}, },
], ],
}, },
}; } as unknown as PanelModel;
const updated = ThresholdMapper.alertToGraphThresholds(panel); const updated = ThresholdMapper.alertToGraphThresholds(panel);
expect(updated).toBe(true); expect(updated).toBe(true);
@@ -30,7 +32,7 @@ describe('ThresholdMapper', () => {
describe('with outside range evaluator', () => { describe('with outside range evaluator', () => {
it('can map query conditions to thresholds', () => { it('can map query conditions to thresholds', () => {
const panel: any = { const panel = {
type: 'graph', type: 'graph',
options: { alertThresholds: true }, options: { alertThresholds: true },
alert: { alert: {
@@ -41,7 +43,7 @@ describe('ThresholdMapper', () => {
}, },
], ],
}, },
}; } as unknown as PanelModel;
const updated = ThresholdMapper.alertToGraphThresholds(panel); const updated = ThresholdMapper.alertToGraphThresholds(panel);
expect(updated).toBe(true); expect(updated).toBe(true);
@@ -55,7 +57,7 @@ describe('ThresholdMapper', () => {
describe('with inside range evaluator', () => { describe('with inside range evaluator', () => {
it('can map query conditions to thresholds', () => { it('can map query conditions to thresholds', () => {
const panel: any = { const panel = {
type: 'graph', type: 'graph',
options: { alertThresholds: true }, options: { alertThresholds: true },
alert: { alert: {
@@ -66,7 +68,7 @@ describe('ThresholdMapper', () => {
}, },
], ],
}, },
}; } as unknown as PanelModel;
const updated = ThresholdMapper.alertToGraphThresholds(panel); const updated = ThresholdMapper.alertToGraphThresholds(panel);
expect(updated).toBe(true); expect(updated).toBe(true);
@@ -120,7 +122,7 @@ describe('ThresholdMapper', () => {
}); });
function getPanel({ reducerType }: { reducerType?: string } = {}) { function getPanel({ reducerType }: { reducerType?: string } = {}) {
const panel: any = { const panel = {
type: 'graph', type: 'graph',
options: { alertThreshold: true }, options: { alertThreshold: true },
alert: { alert: {
@@ -132,7 +134,7 @@ function getPanel({ reducerType }: { reducerType?: string } = {}) {
}, },
], ],
}, },
}; } as unknown as PanelModel;
return panel; return panel;
} }

View File

@@ -1,9 +1,11 @@
import { AlertRulesState, StoreState } from 'app/types';
import { getSearchQuery, getAlertRuleItems } from './selectors'; import { getSearchQuery, getAlertRuleItems } from './selectors';
describe('Get search query', () => { describe('Get search query', () => {
it('should get search query', () => { it('should get search query', () => {
const state = { searchQuery: 'dashboard' }; const state: AlertRulesState = { searchQuery: 'dashboard', items: [], isLoading: false };
const result = getSearchQuery(state as any); const result = getSearchQuery(state);
expect(result).toEqual(state.searchQuery); expect(result).toEqual(state.searchQuery);
}); });
@@ -29,9 +31,9 @@ describe('Get alert rule items', () => {
], ],
searchQuery: '', searchQuery: '',
}, },
}; } as unknown as StoreState;
const result = getAlertRuleItems(state as any); const result = getAlertRuleItems(state);
expect(result.length).toEqual(1); expect(result.length).toEqual(1);
}); });
@@ -90,9 +92,9 @@ describe('Get alert rule items', () => {
], ],
searchQuery: 'dashboard', searchQuery: 'dashboard',
}, },
}; } as unknown as StoreState;
const result = getAlertRuleItems(state as any); const result = getAlertRuleItems(state);
expect(result.length).toEqual(3); expect(result.length).toEqual(3);
}); });
}); });

View File

@@ -5,7 +5,7 @@ import { TestProvider } from 'test/helpers/TestProvider';
import { selectOptionInTest } from 'test/helpers/selectOptionInTest'; import { selectOptionInTest } from 'test/helpers/selectOptionInTest';
import { byLabelText, byRole, byTestId, byText } from 'testing-library-selector'; 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 { contextSrv } from 'app/core/services/context_srv';
import { import {
AlertManagerCortexConfig, AlertManagerCortexConfig,
@@ -201,7 +201,7 @@ describe('AmRoutes', () => {
afterEach(() => { afterEach(() => {
jest.resetAllMocks(); jest.resetAllMocks();
setDataSourceSrv(undefined as any); setDataSourceSrv(undefined as unknown as DataSourceSrv);
}); });
it('loads and shows routes', async () => { it('loads and shows routes', async () => {

View File

@@ -5,7 +5,7 @@ import React from 'react';
import { TestProvider } from 'test/helpers/TestProvider'; import { TestProvider } from 'test/helpers/TestProvider';
import { byRole, byTestId, byText } from 'testing-library-selector'; 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 { backendSrv } from 'app/core/services/backend_srv';
import { contextSrv } from 'app/core/services/context_srv'; import { contextSrv } from 'app/core/services/context_srv';
import * as ruleActionButtons from 'app/features/alerting/unified/components/rules/RuleActionsButtons'; import * as ruleActionButtons from 'app/features/alerting/unified/components/rules/RuleActionsButtons';
@@ -140,7 +140,7 @@ describe('RuleList', () => {
afterEach(() => { afterEach(() => {
jest.resetAllMocks(); jest.resetAllMocks();
setDataSourceSrv(undefined as any); setDataSourceSrv(undefined as unknown as DataSourceSrv);
}); });
it('load & show rule groups from multiple cloud data sources', async () => { 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.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: () => { getDataSourceSrv: () => {
return { return {
get: (v: any) => { get: (v: any) => {

View File

@@ -1,6 +1,6 @@
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks'; 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 { PanelModel } from '../../state/PanelModel';
import { createDashboardModelFixture, createPanelJSONFixture } from '../../state/__fixtures__/dashboardFixtures'; import { createDashboardModelFixture, createPanelJSONFixture } from '../../state/__fixtures__/dashboardFixtures';
@@ -32,7 +32,7 @@ function getDefaultDashboardModel() {
} }
function getTestContext() { function getTestContext() {
const contextSrv: any = { isSignedIn: true, isEditor: true }; const contextSrv = { isSignedIn: true, isEditor: true } as ContextSrv;
setContextSrv(contextSrv); setContextSrv(contextSrv);
const dash = getDefaultDashboardModel(); const dash = getDefaultDashboardModel();
const original = dash.getSaveModelClone(); const original = dash.getSaveModelClone();

View File

@@ -10,6 +10,7 @@ import {
PanelData, PanelData,
standardEditorsRegistry, standardEditorsRegistry,
standardFieldConfigEditorRegistry, standardFieldConfigEditorRegistry,
TimeRange,
toDataFrame, toDataFrame,
} from '@grafana/data'; } from '@grafana/data';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks'; import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
@@ -42,7 +43,7 @@ class OptionsPaneOptionsTestScenario {
panelData: PanelData = { panelData: PanelData = {
series: [], series: [],
state: LoadingState.Done, state: LoadingState.Done,
timeRange: {} as any, timeRange: {} as TimeRange,
}; };
plugin = getPanelPlugin({ plugin = getPanelPlugin({

View File

@@ -1,4 +1,6 @@
import { PanelPlugin } from '@grafana/data';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks'; import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { LibraryElementDTOMeta } from '@grafana/schema';
import { createDashboardModelFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures'; import { createDashboardModelFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures';
import { panelModelAndPluginReady, removePanel } from 'app/features/panel/state/reducers'; import { panelModelAndPluginReady, removePanel } from 'app/features/panel/state/reducers';
@@ -104,7 +106,7 @@ describe('panelEditor actions', () => {
const sourcePanel = new PanelModel({ id: 12, type: 'graph' }); const sourcePanel = new PanelModel({ id: 12, type: 'graph' });
sourcePanel.plugin = { sourcePanel.plugin = {
customFieldConfigs: {}, customFieldConfigs: {},
} as any; } as unknown as PanelPlugin;
const dashboard = createDashboardModelFixture({ const dashboard = createDashboardModelFixture({
panels: [{ id: 12, type: 'graph' }], panels: [{ id: 12, type: 'graph' }],
@@ -242,9 +244,9 @@ describe('panelEditor actions', () => {
describe('skipPanelUpdate', () => { describe('skipPanelUpdate', () => {
describe('when called with panel with an library uid different from the modified panel', () => { describe('when called with panel with an library uid different from the modified panel', () => {
it('then it should return true', () => { it('then it should return true', () => {
const meta: any = {}; const meta = {} as LibraryElementDTOMeta;
const modified: any = { libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }; const modified = new PanelModel({ libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } });
const panel: any = { libraryPanel: { uid: '456', name: 'Name', meta, version: 1 } }; const panel = new PanelModel({ libraryPanel: { uid: '456', name: 'Name', meta, version: 1 } });
expect(skipPanelUpdate(modified, panel)).toEqual(true); 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', () => { describe('when called with a panel that is the same as the modified panel', () => {
it('then it should return true', () => { it('then it should return true', () => {
const meta: any = {}; const meta = {} as LibraryElementDTOMeta;
const modified: any = { id: 14, libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }; const modified = new PanelModel({ id: 14, libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } });
const panel: any = { 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); expect(skipPanelUpdate(modified, panel)).toEqual(true);
}); });
@@ -262,9 +264,12 @@ describe('panelEditor actions', () => {
describe('when called with a panel that is repeated', () => { describe('when called with a panel that is repeated', () => {
it('then it should return true', () => { it('then it should return true', () => {
const meta: any = {}; const meta = {} as LibraryElementDTOMeta;
const modified: any = { libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }; const modified = new PanelModel({ libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } });
const panel: any = { repeatPanelId: 14, 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); 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', () => { describe('when called with a panel that is a duplicate of the modified panel', () => {
it('then it should return false', () => { it('then it should return false', () => {
const meta: any = {}; const meta = {} as LibraryElementDTOMeta;
const modified: any = { libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } }; const modified = new PanelModel({ libraryPanel: { uid: '123', name: 'Name', meta, version: 1 } });
const panel: any = { 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); expect(skipPanelUpdate(modified, panel)).toEqual(false);
}); });

View File

@@ -12,8 +12,8 @@ import { SaveDashboardForm } from './SaveDashboardForm';
const prepareDashboardMock = ( const prepareDashboardMock = (
timeChanged: boolean, timeChanged: boolean,
variableValuesChanged: boolean, variableValuesChanged: boolean,
resetTimeSpy: any, resetTimeSpy: jest.Mock,
resetVarsSpy: any resetVarsSpy: jest.Mock
) => { ) => {
const json = { const json = {
title: 'name', title: 'name',
@@ -29,12 +29,12 @@ const prepareDashboardMock = (
meta: {}, meta: {},
...json, ...json,
getSaveModelClone: () => json, getSaveModelClone: () => json,
}; } as unknown as DashboardModel;
}; };
const renderAndSubmitForm = async (dashboard: any, submitSpy: any) => { const renderAndSubmitForm = async (dashboard: DashboardModel, submitSpy: jest.Mock) => {
render( render(
<SaveDashboardForm <SaveDashboardForm
dashboard={dashboard as DashboardModel} dashboard={dashboard}
onCancel={() => {}} onCancel={() => {}}
onSuccess={() => {}} onSuccess={() => {}}
onSubmit={async (jsonModel) => { onSubmit={async (jsonModel) => {
@@ -62,14 +62,14 @@ describe('SaveDashboardAsForm', () => {
it('renders switches when variables or timerange', () => { it('renders switches when variables or timerange', () => {
render( render(
<SaveDashboardForm <SaveDashboardForm
dashboard={prepareDashboardMock(true, true, jest.fn(), jest.fn()) as any} dashboard={prepareDashboardMock(true, true, jest.fn(), jest.fn())}
onCancel={() => {}} onCancel={() => {}}
onSuccess={() => {}} onSuccess={() => {}}
onSubmit={async () => { onSubmit={async () => {
return {}; return {};
}} }}
saveModel={{ saveModel={{
clone: prepareDashboardMock(true, true, jest.fn(), jest.fn()) as any, clone: prepareDashboardMock(true, true, jest.fn(), jest.fn()),
diff: {}, diff: {},
diffCount: 0, diffCount: 0,
hasChanges: true, hasChanges: true,
@@ -99,7 +99,7 @@ describe('SaveDashboardAsForm', () => {
const resetVarsSpy = jest.fn(); const resetVarsSpy = jest.fn();
const submitSpy = 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(resetTimeSpy).not.toBeCalled();
expect(resetVarsSpy).not.toBeCalled(); expect(resetVarsSpy).not.toBeCalled();
@@ -112,7 +112,7 @@ describe('SaveDashboardAsForm', () => {
const resetTimeSpy = jest.fn(); const resetTimeSpy = jest.fn();
const resetVarsSpy = jest.fn(); const resetVarsSpy = jest.fn();
const submitSpy = 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(resetTimeSpy).toBeCalledTimes(0);
expect(resetVarsSpy).toBeCalledTimes(0); expect(resetVarsSpy).toBeCalledTimes(0);

View File

@@ -24,7 +24,7 @@ import { PublicDashboard } from './SharePublicDashboardUtils';
const server = setupServer(); const server = setupServer();
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => backendSrv, 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 { DashboardSearchItem, DashboardSearchItemType } from '../../../search/types';
import { DashboardLink } from '../../state/DashboardModel'; import { DashboardLink } from '../../state/DashboardModel';
@@ -18,9 +21,7 @@ describe('searchForTags', () => {
type: 'dashboards', type: 'dashboards',
url: '/d/6ieouugGk/DashLinks', url: '/d/6ieouugGk/DashLinks',
}; };
const backendSrv: any = { jest.spyOn(backendSrv, 'search').mockResolvedValue([]);
search: jest.fn((args) => []),
};
return { link, backendSrv }; return { link, backendSrv };
}; };
@@ -64,9 +65,9 @@ describe('resolveLinks', () => {
type: DashboardSearchItemType.DashDB, type: DashboardSearchItemType.DashDB,
}, },
]; ];
const linkSrv: any = { const linkSrv = {
getLinkUrl: jest.fn((args) => args.url), getLinkUrl: jest.fn((args) => args.url),
}; } as unknown as LinkSrv;
const sanitize = jest.fn((args) => args); const sanitize = jest.fn((args) => args);
const sanitizeUrl = jest.fn((args) => args); const sanitizeUrl = jest.fn((args) => args);

View File

@@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import React from 'react'; import React from 'react';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { Router } from 'react-router-dom'; import { match, Router } from 'react-router-dom';
import { useEffectOnce } from 'react-use'; import { useEffectOnce } from 'react-use';
import { AutoSizerProps } from 'react-virtualized-auto-sizer'; import { AutoSizerProps } from 'react-virtualized-auto-sizer';
import { mockToolkitActionCreator } from 'test/core/redux/mocks'; import { mockToolkitActionCreator } from 'test/core/redux/mocks';
@@ -10,9 +10,11 @@ import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock';
import { createTheme } from '@grafana/data'; import { createTheme } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors'; import { selectors } from '@grafana/e2e-selectors';
import { config, locationService, setDataSourceSrv } from '@grafana/runtime'; import { config, locationService, setDataSourceSrv } from '@grafana/runtime';
import { Dashboard } from '@grafana/schema';
import { notifyApp } from 'app/core/actions'; import { notifyApp } from 'app/core/actions';
import { GrafanaContext } from 'app/core/context/GrafanaContext'; import { GrafanaContext } from 'app/core/context/GrafanaContext';
import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps'; 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 { HOME_NAV_ID } from 'app/core/reducers/navModel';
import { DashboardInitPhase, DashboardMeta, DashboardRoutes } from 'app/types'; import { DashboardInitPhase, DashboardMeta, DashboardRoutes } from 'app/types';
@@ -20,6 +22,7 @@ import { configureStore } from '../../../store/configureStore';
import { Props as LazyLoaderProps } from '../dashgrid/LazyLoader'; import { Props as LazyLoaderProps } from '../dashgrid/LazyLoader';
import { DashboardSrv, setDashboardSrv } from '../services/DashboardSrv'; import { DashboardSrv, setDashboardSrv } from '../services/DashboardSrv';
import { DashboardModel } from '../state'; import { DashboardModel } from '../state';
import { createDashboardModelFixture } from '../state/__fixtures__/dashboardFixtures';
import { Props, UnthemedDashboardPage } from './DashboardPage'; import { Props, UnthemedDashboardPage } from './DashboardPage';
@@ -73,7 +76,7 @@ interface ScenarioContext {
setup: (fn: () => void) => 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( const data = Object.assign(
{ {
title: 'My dashboard', title: 'My dashboard',
@@ -89,8 +92,7 @@ function getTestDashboard(overrides?: any, metaOverrides?: Partial<DashboardMeta
overrides overrides
); );
const meta = Object.assign({ canSave: true, canEdit: true }, metaOverrides); return createDashboardModelFixture(data, metaOverrides);
return new DashboardModel(data, meta);
} }
function dashboardPageScenario(description: string, scenarioFn: (ctx: ScenarioContext) => void) { function dashboardPageScenario(description: string, scenarioFn: (ctx: ScenarioContext) => void) {
@@ -110,8 +112,8 @@ function dashboardPageScenario(description: string, scenarioFn: (ctx: ScenarioCo
const store = configureStore(); const store = configureStore();
const props: Props = { const props: Props = {
...getRouteComponentProps({ ...getRouteComponentProps({
match: { params: { slug: 'my-dash', uid: '11' } } as any, match: { params: { slug: 'my-dash', uid: '11' } } as unknown as match,
route: { routeName: DashboardRoutes.Normal } as any, route: { routeName: DashboardRoutes.Normal } as RouteDescriptor,
}), }),
navIndex: { navIndex: {
dashboards: { text: 'Dashboards', id: 'dashboards', parentItem: { text: 'Home', id: HOME_NAV_ID } }, dashboards: { text: 'Dashboards', id: 'dashboards', parentItem: { text: 'Home', id: HOME_NAV_ID } },
@@ -279,7 +281,7 @@ describe('DashboardPage', () => {
ctx.rerender({ ctx.rerender({
match: { match: {
params: { uid: 'new-uid' }, params: { uid: 'new-uid' },
} as any, } as unknown as match,
dashboard: getTestDashboard({ title: 'Another dashboard' }), dashboard: getTestDashboard({ title: 'Another dashboard' }),
}); });
}); });

View File

@@ -1,13 +1,17 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import React from 'react'; import React from 'react';
import { match } from 'react-router-dom';
import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock'; import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock';
import { Dashboard } from '@grafana/schema';
import { GrafanaContext } from 'app/core/context/GrafanaContext'; import { GrafanaContext } from 'app/core/context/GrafanaContext';
import { RouteDescriptor } from 'app/core/navigation/types';
import { DashboardMeta, DashboardRoutes } from 'app/types'; import { DashboardMeta, DashboardRoutes } from 'app/types';
import { getRouteComponentProps } from '../../../core/navigation/__mocks__/routeProps'; import { getRouteComponentProps } from '../../../core/navigation/__mocks__/routeProps';
import { Props as DashboardPanelProps } from '../dashgrid/DashboardPanel'; import { Props as DashboardPanelProps } from '../dashgrid/DashboardPanel';
import { DashboardModel } from '../state'; import { DashboardModel } from '../state';
import { createDashboardModelFixture } from '../state/__fixtures__/dashboardFixtures';
import { Props, SoloPanelPage } from './SoloPanelPage'; import { Props, SoloPanelPage } from './SoloPanelPage';
@@ -26,14 +30,14 @@ jest.mock('app/features/dashboard/dashgrid/DashboardPanel', () => {
interface ScenarioContext { interface ScenarioContext {
dashboard?: DashboardModel | null; dashboard?: DashboardModel | null;
secondaryDashboard?: DashboardModel | null; secondaryDashboard?: DashboardModel | null;
setDashboard: (overrides?: any, metaOverrides?: Partial<DashboardMeta>) => void; setDashboard: (overrides?: Partial<Dashboard>, metaOverrides?: Partial<DashboardMeta>) => void;
setSecondaryDashboard: (overrides?: any, metaOverrides?: Partial<DashboardMeta>) => void; setSecondaryDashboard: (overrides?: Partial<Dashboard>, metaOverrides?: Partial<DashboardMeta>) => void;
mount: (propOverrides?: Partial<Props>) => void; mount: (propOverrides?: Partial<Props>) => void;
rerender: (propOverrides?: Partial<Props>) => void; rerender: (propOverrides?: Partial<Props>) => void;
setup: (fn: () => void) => 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( const data = Object.assign(
{ {
title: 'My dashboard', title: 'My dashboard',
@@ -49,8 +53,7 @@ function getTestDashboard(overrides?: any, metaOverrides?: Partial<DashboardMeta
overrides overrides
); );
const meta = Object.assign({ canSave: true, canEdit: true }, metaOverrides); return createDashboardModelFixture(data, metaOverrides);
return new DashboardModel(data, meta);
} }
function soloPanelPageScenario(description: string, scenarioFn: (ctx: ScenarioContext) => void) { function soloPanelPageScenario(description: string, scenarioFn: (ctx: ScenarioContext) => void) {
@@ -61,10 +64,10 @@ function soloPanelPageScenario(description: string, scenarioFn: (ctx: ScenarioCo
setup: (fn) => { setup: (fn) => {
setupFn = fn; setupFn = fn;
}, },
setDashboard: (overrides?: any, metaOverrides?: Partial<DashboardMeta>) => { setDashboard: (overrides, metaOverrides) => {
ctx.dashboard = getTestDashboard(overrides, metaOverrides); ctx.dashboard = getTestDashboard(overrides, metaOverrides);
}, },
setSecondaryDashboard: (overrides?: any, metaOverrides?: Partial<DashboardMeta>) => { setSecondaryDashboard: (overrides, metaOverrides) => {
ctx.secondaryDashboard = getTestDashboard(overrides, metaOverrides); ctx.secondaryDashboard = getTestDashboard(overrides, metaOverrides);
}, },
mount: (propOverrides?: Partial<Props>) => { mount: (propOverrides?: Partial<Props>) => {
@@ -72,11 +75,11 @@ function soloPanelPageScenario(description: string, scenarioFn: (ctx: ScenarioCo
...getRouteComponentProps({ ...getRouteComponentProps({
match: { match: {
params: { slug: 'my-dash', uid: '11' }, params: { slug: 'my-dash', uid: '11' },
} as any, } as unknown as match,
queryParams: { queryParams: {
panelId: '1', panelId: '1',
}, },
route: { routeName: DashboardRoutes.Normal } as any, route: { routeName: DashboardRoutes.Normal } as RouteDescriptor,
}), }),
initDashboard: jest.fn(), initDashboard: jest.fn(),
dashboard: null, dashboard: null,
@@ -148,8 +151,8 @@ describe('SoloPanelPage', () => {
soloPanelPageScenario('When user navigates to other SoloPanelPage', (ctx) => { soloPanelPageScenario('When user navigates to other SoloPanelPage', (ctx) => {
ctx.setup(() => { ctx.setup(() => {
ctx.mount(); ctx.mount();
ctx.setDashboard({ uid: 1, panels: [{ id: 1, type: 'graph', title: 'Panel 1' }] }); 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.setSecondaryDashboard({ uid: '2', panels: [{ id: 1, type: 'graph', title: 'Panel 2' }] });
}); });
it('Should show other graph', () => { it('Should show other graph', () => {

View File

@@ -1,9 +1,11 @@
import { render } from '@testing-library/react'; import { render } from '@testing-library/react';
import React from 'react'; import React from 'react';
import { Dashboard } from '@grafana/schema';
import { DashboardMeta } from 'app/types'; import { DashboardMeta } from 'app/types';
import { DashboardModel } from '../state'; import { DashboardModel } from '../state';
import { createDashboardModelFixture } from '../state/__fixtures__/dashboardFixtures';
import { DashboardGrid, Props } from './DashboardGrid'; import { DashboardGrid, Props } from './DashboardGrid';
@@ -14,7 +16,7 @@ jest.mock('app/features/dashboard/dashgrid/LazyLoader', () => {
return { LazyLoader }; return { LazyLoader };
}); });
function getTestDashboard(overrides?: any, metaOverrides?: Partial<DashboardMeta>): DashboardModel { function getTestDashboard(overrides?: Partial<Dashboard>, metaOverrides?: Partial<DashboardMeta>): DashboardModel {
const data = Object.assign( const data = Object.assign(
{ {
title: 'My dashboard', title: 'My dashboard',
@@ -48,8 +50,7 @@ function getTestDashboard(overrides?: any, metaOverrides?: Partial<DashboardMeta
overrides overrides
); );
const meta = Object.assign({ canSave: true, canEdit: true }, metaOverrides); return createDashboardModelFixture(data, metaOverrides);
return new DashboardModel(data, meta);
} }
describe('DashboardGrid', () => { describe('DashboardGrid', () => {

View File

@@ -4,6 +4,8 @@ import { ContextSrvStub } from 'test/specs/helpers';
import { dateTime, isDateTime } from '@grafana/data'; import { dateTime, isDateTime } from '@grafana/data';
import { config, HistoryWrapper, locationService, setLocationService } from '@grafana/runtime'; import { config, HistoryWrapper, locationService, setLocationService } from '@grafana/runtime';
import { TimeModel } from '../state/TimeModel';
import { TimeSrv } from './TimeSrv'; import { TimeSrv } from './TimeSrv';
jest.mock('app/core/core', () => ({ jest.mock('app/core/core', () => ({
@@ -14,7 +16,7 @@ jest.mock('app/core/core', () => ({
describe('timeSrv', () => { describe('timeSrv', () => {
let timeSrv: TimeSrv; let timeSrv: TimeSrv;
let _dashboard: any; let _dashboard: TimeModel;
let locationUpdates: H.Location[] = []; let locationUpdates: H.Location[] = [];
beforeEach(() => { beforeEach(() => {
@@ -23,9 +25,10 @@ describe('timeSrv', () => {
getTimezone: jest.fn(() => 'browser'), getTimezone: jest.fn(() => 'browser'),
refresh: false, refresh: false,
timeRangeUpdated: jest.fn(() => {}), timeRangeUpdated: jest.fn(() => {}),
timepicker: {},
}; };
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
locationUpdates = []; locationUpdates = [];
@@ -54,7 +57,7 @@ describe('timeSrv', () => {
it('should handle relative times', () => { it('should handle relative times', () => {
locationService.push('/d/id?from=now-2d&to=now'); locationService.push('/d/id?from=now-2d&to=now');
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
const time = timeSrv.timeRange(); const time = timeSrv.timeRange();
@@ -65,7 +68,7 @@ describe('timeSrv', () => {
it('should handle formatted dates', () => { it('should handle formatted dates', () => {
locationService.push('/d/id?from=20140410T052010&to=20140520T031022'); locationService.push('/d/id?from=20140410T052010&to=20140520T031022');
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
const time = timeSrv.timeRange(); const time = timeSrv.timeRange();
@@ -76,7 +79,7 @@ describe('timeSrv', () => {
it('should ignore refresh if time absolute', () => { it('should ignore refresh if time absolute', () => {
locationService.push('/d/id?from=20140410T052010&to=20140520T031022'); 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 saved with refresh on
_dashboard.refresh = true; _dashboard.refresh = true;
@@ -92,6 +95,7 @@ describe('timeSrv', () => {
getTimezone: jest.fn(() => 'browser'), getTimezone: jest.fn(() => 'browser'),
refresh: false, refresh: false,
timeRangeUpdated: jest.fn(() => {}), timeRangeUpdated: jest.fn(() => {}),
timepicker: {},
}; };
locationService.push('/d/id?from=now-24h&to=now'); locationService.push('/d/id?from=now-24h&to=now');
@@ -119,7 +123,7 @@ describe('timeSrv', () => {
it('should handle formatted dates without time', () => { it('should handle formatted dates without time', () => {
locationService.push('/d/id?from=20140410&to=20140520'); locationService.push('/d/id?from=20140410&to=20140520');
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
const time = timeSrv.timeRange(); const time = timeSrv.timeRange();
@@ -130,7 +134,7 @@ describe('timeSrv', () => {
it('should handle epochs', () => { it('should handle epochs', () => {
locationService.push('/d/id?from=1410337646373&to=1410337665699'); locationService.push('/d/id?from=1410337646373&to=1410337665699');
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
const time = timeSrv.timeRange(); const time = timeSrv.timeRange();
@@ -141,7 +145,7 @@ describe('timeSrv', () => {
it('should handle epochs that look like formatted date without time', () => { it('should handle epochs that look like formatted date without time', () => {
locationService.push('/d/id?from=20149999&to=20159999'); locationService.push('/d/id?from=20149999&to=20159999');
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
const time = timeSrv.timeRange(); const time = timeSrv.timeRange();
@@ -152,7 +156,7 @@ describe('timeSrv', () => {
it('should handle epochs that look like formatted date', () => { it('should handle epochs that look like formatted date', () => {
locationService.push('/d/id?from=201499991234567&to=201599991234567'); locationService.push('/d/id?from=201499991234567&to=201599991234567');
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
const time = timeSrv.timeRange(); const time = timeSrv.timeRange();
@@ -163,7 +167,7 @@ describe('timeSrv', () => {
it('should handle bad dates', () => { it('should handle bad dates', () => {
locationService.push('/d/id?from=20151126T00010%3C%2Fp%3E%3Cspan%20class&to=now'); 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'; _dashboard.time.from = 'now-6h';
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
@@ -174,7 +178,7 @@ describe('timeSrv', () => {
it('should handle refresh_intervals=null when refresh is enabled', () => { it('should handle refresh_intervals=null when refresh is enabled', () => {
locationService.push('/d/id?refresh=30s'); locationService.push('/d/id?refresh=30s');
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
_dashboard.timepicker = { _dashboard.timepicker = {
refresh_intervals: null, refresh_intervals: null,
@@ -186,7 +190,7 @@ describe('timeSrv', () => {
it('handles time window specfied as interval string', () => { it('handles time window specfied as interval string', () => {
locationService.push('/d/id?time=1410337645000&time.window=10s'); locationService.push('/d/id?time=1410337645000&time.window=10s');
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
const time = timeSrv.timeRange(); const time = timeSrv.timeRange();
@@ -197,7 +201,7 @@ describe('timeSrv', () => {
it('handles time window specified in ms', () => { it('handles time window specified in ms', () => {
locationService.push('/d/id?time=1410337645000&time.window=10000'); locationService.push('/d/id?time=1410337645000&time.window=10000');
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
const time = timeSrv.timeRange(); const time = timeSrv.timeRange();
@@ -208,7 +212,7 @@ describe('timeSrv', () => {
it('corrects inverted from/to dates in ms', () => { it('corrects inverted from/to dates in ms', () => {
locationService.push('/d/id?from=1621436828909&to=1621436818909'); locationService.push('/d/id?from=1621436828909&to=1621436818909');
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
const time = timeSrv.timeRange(); const time = timeSrv.timeRange();
@@ -219,7 +223,7 @@ describe('timeSrv', () => {
it('corrects inverted from/to dates as relative times', () => { it('corrects inverted from/to dates as relative times', () => {
locationService.push('/d/id?from=now&to=now-1h'); locationService.push('/d/id?from=now&to=now-1h');
timeSrv = new TimeSrv(new ContextSrvStub() as any); timeSrv = new TimeSrv(new ContextSrvStub());
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
const time = timeSrv.timeRange(); const time = timeSrv.timeRange();

View File

@@ -1,6 +1,6 @@
import { appEvents } from '../../../core/core'; import { appEvents } from '../../../core/core';
import { VariablesChanged } from '../../variables/types'; import { VariablesChanged } from '../../variables/types';
import { getTimeSrv, setTimeSrv } from '../services/TimeSrv'; import { getTimeSrv, setTimeSrv, TimeSrv } from '../services/TimeSrv';
import { PanelModel } from './PanelModel'; import { PanelModel } from './PanelModel';
import { createDashboardModelFixture } from './__fixtures__/dashboardFixtures'; import { createDashboardModelFixture } from './__fixtures__/dashboardFixtures';
@@ -58,7 +58,7 @@ describe('Strict panel refresh', () => {
beforeEach(() => { beforeEach(() => {
setTimeSrv({ setTimeSrv({
isRefreshOutsideThreshold: () => isRefreshOutsideThreshold, isRefreshOutsideThreshold: () => isRefreshOutsideThreshold,
} as any); } as unknown as TimeSrv);
}); });
afterEach(() => { afterEach(() => {

View File

@@ -329,7 +329,7 @@ describe('DashboardModel', () => {
}, },
{}, {},
// getVariablesFromState stub to return a variable // getVariablesFromState stub to return a variable
() => [{} as any] jest.fn().mockImplementation(() => [{}])
); );
}); });
@@ -653,8 +653,8 @@ describe('DashboardModel', () => {
expect(saveModel.panels[1].scopedVars).toBe(undefined); expect(saveModel.panels[1].scopedVars).toBe(undefined);
model.collapseRows(); model.collapseRows();
const savedModelWithCollapsedRows: any = model.getSaveModelClone(); const savedModelWithCollapsedRows = model.getSaveModelClone();
expect(savedModelWithCollapsedRows.panels[0].panels.length).toBe(1); expect(savedModelWithCollapsedRows.panels[0].panels!.length).toBe(1);
}); });
it('getSaveModelClone should not remove repeated panels and scopedVars during snapshot', () => { 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'); expect(saveModel.panels.find((x) => x.type !== 'row')?.scopedVars?.app.value).toBe('se1');
model.collapseRows(); model.collapseRows();
const savedModelWithCollapsedRows: any = model.getSaveModelClone(); const savedModelWithCollapsedRows = model.getSaveModelClone();
expect(savedModelWithCollapsedRows.panels[0].panels.length).toBe(2); expect(savedModelWithCollapsedRows.panels[0].panels!.length).toBe(2);
}); });
}); });
@@ -1106,7 +1106,7 @@ describe('DashboardModel', () => {
describe('exitViewPanel', () => { describe('exitViewPanel', () => {
function getTestContext() { function getTestContext() {
const panel: any = { setIsViewing: jest.fn() }; const panel = new PanelModel({ setIsViewing: jest.fn() });
const dashboard = createDashboardModelFixture(); const dashboard = createDashboardModelFixture();
dashboard.startRefresh = jest.fn(); dashboard.startRefresh = jest.fn();
dashboard.panelInView = panel; dashboard.panelInView = panel;
@@ -1143,7 +1143,7 @@ describe('exitViewPanel', () => {
describe('exitPanelEditor', () => { describe('exitPanelEditor', () => {
function getTestContext(pauseAutoRefresh = false) { function getTestContext(pauseAutoRefresh = false) {
const panel: any = { destroy: jest.fn() }; const panel = new PanelModel({ destroy: jest.fn() });
const dashboard = createDashboardModelFixture(); const dashboard = createDashboardModelFixture();
const timeSrvMock = { const timeSrvMock = {
pauseAutoRefresh: jest.fn(), pauseAutoRefresh: jest.fn(),

View File

@@ -69,7 +69,7 @@ describe('Merge dashbaord panels', () => {
rawPanels.push({ rawPanels.push({
id: 7, id: 7,
type: 'canvas', type: 'canvas',
} as any); } as PanelModel);
const info = dashboard.updatePanels(rawPanels); const info = dashboard.updatePanels(rawPanels);
expect(info.changed).toBeTruthy(); expect(info.changed).toBeTruthy();
@@ -85,16 +85,16 @@ describe('Merge dashbaord panels', () => {
}); });
it('should allow change in key order for nested elements', () => { it('should allow change in key order for nested elements', () => {
(rawPanels[2] as any).fieldConfig = { rawPanels[2].fieldConfig = {
defaults: { defaults: {
color: { mode: 'thresholds' }, color: { mode: 'thresholds' },
mappings: [], mappings: [],
thresholds: { thresholds: {
steps: [ steps: [
{ color: 'green', value: null }, { color: 'green', value: -Infinity },
{ color: 'red', value: 80 }, { color: 'red', value: 80 },
], ],
mode: 'absolute', mode: ThresholdsMode.Absolute,
}, },
}, },
overrides: [], overrides: [],
@@ -112,7 +112,7 @@ describe('Merge dashbaord panels', () => {
}); });
it('should replace a type change', () => { it('should replace a type change', () => {
(rawPanels[1] as any).type = 'canvas'; rawPanels[1].type = 'canvas';
const info = dashboard.updatePanels(rawPanels); const info = dashboard.updatePanels(rawPanels);
expect(info.changed).toBeTruthy(); expect(info.changed).toBeTruthy();

View File

@@ -7,7 +7,7 @@ import { getDataSourceByIdOrUid } from './api';
jest.mock('app/core/services/backend_srv'); jest.mock('app/core/services/backend_srv');
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: jest.fn(), getBackendSrv: jest.fn(),
})); }));

View File

@@ -32,7 +32,7 @@ jest.mock('../api');
jest.mock('app/core/services/backend_srv'); jest.mock('app/core/services/backend_srv');
jest.mock('app/core/core'); jest.mock('app/core/core');
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getDataSourceSrv: jest.fn().mockReturnValue({ reload: jest.fn() }), getDataSourceSrv: jest.fn().mockReturnValue({ reload: jest.fn() }),
getBackendSrv: jest.fn().mockReturnValue({ get: 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 userEvent from '@testing-library/user-event';
import React from 'react'; import React from 'react';
import { createTheme, ThresholdsMode } from '@grafana/data'; import { createTheme, Threshold, ThresholdsMode } from '@grafana/data';
import { mockThemeContext } from '@grafana/ui'; import { mockThemeContext } from '@grafana/ui';
import { ThresholdsEditor, Props } from './ThresholdsEditor'; import { ThresholdsEditor, Props } from './ThresholdsEditor';
@@ -151,9 +151,9 @@ describe('ThresholdsEditor', () => {
const thresholds = { const thresholds = {
mode: ThresholdsMode.Absolute, mode: ThresholdsMode.Absolute,
steps: [ steps: [
{ value: -Infinity, color: '#7EB26D', key: 1 }, { value: -Infinity, color: '#7EB26D' },
{ value: 50, color: '#EAB839', key: 2 }, { value: 50, color: '#EAB839' },
{ value: 75, color: '#6ED0E0', key: 3 }, { value: 75, color: '#6ED0E0' },
], ],
}; };
setup({ thresholds }); setup({ thresholds });
@@ -173,12 +173,12 @@ describe('ThresholdsEditor', () => {
thresholds: { thresholds: {
mode: ThresholdsMode.Absolute, mode: ThresholdsMode.Absolute,
steps: [ steps: [
{ value: -Infinity, color: '#7EB26D', key: 1 }, { value: -Infinity, color: '#7EB26D' },
{ value: 75, color: '#6ED0E0', key: 2 }, { value: 75, color: '#6ED0E0' },
{ color: '#7EB26D', key: 3 } as any, { color: '#7EB26D' } as unknown as Threshold,
{ value: 78, color: '#EAB839', key: 4 }, { value: 78, color: '#EAB839' },
{ value: null, color: '#7EB26D', key: 5 } as any, { value: null, color: '#7EB26D' } as unknown as Threshold,
{ value: null, color: '#7EB26D', key: 6 } as any, { value: null, color: '#7EB26D' } as unknown as Threshold,
], ],
}, },
}); });

View File

@@ -1,17 +1,13 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import React from 'react'; import React from 'react';
import { MappingType } from '@grafana/data'; import { MappingType, StandardEditorsRegistryItem } from '@grafana/data';
import { ValueMappingsEditor, Props } from './ValueMappingsEditor'; import { ValueMappingsEditor, Props } from './ValueMappingsEditor';
const setup = (spy?: any, propOverrides?: object) => { const setup = (propOverrides?: Partial<Props>) => {
const props: Props = { const props: Props = {
onChange: (mappings: any) => { onChange: jest.fn(),
if (spy) {
spy(mappings);
}
},
value: [ value: [
{ {
type: MappingType.ValueToText, type: MappingType.ValueToText,
@@ -28,8 +24,10 @@ const setup = (spy?: any, propOverrides?: object) => {
}, },
}, },
], ],
item: {} as any, item: {} as StandardEditorsRegistryItem,
context: {} as any, context: {
data: [],
},
}; };
Object.assign(props, propOverrides); 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', () => { it('should render icon picker when icon exists and icon setting is set to true', () => {
const propOverrides = { const propOverrides: Partial<Props> = {
item: { settings: { icon: true } }, item: { settings: { icon: true } } as StandardEditorsRegistryItem,
value: [ value: [
{ {
type: MappingType.ValueToText, type: MappingType.ValueToText,
@@ -56,7 +54,7 @@ describe('Render', () => {
}, },
], ],
}; };
setup({}, propOverrides); setup(propOverrides);
const iconPicker = screen.getByTestId('iconPicker'); const iconPicker = screen.getByTestId('iconPicker');

View File

@@ -7,10 +7,10 @@ import { selectors } from '@grafana/e2e-selectors';
import { ValueMappingsEditorModal, Props } from './ValueMappingsEditorModal'; import { ValueMappingsEditorModal, Props } from './ValueMappingsEditorModal';
const setup = (spy?: any, propOverrides?: object) => { const setup = (spy?: jest.Mock, propOverrides?: Partial<Props>) => {
const props: Props = { const props: Props = {
onClose: jest.fn(), onClose: jest.fn(),
onChange: (mappings: any) => { onChange: (mappings) => {
if (spy) { if (spy) {
spy(mappings); spy(mappings);
} }

View File

@@ -1,10 +1,11 @@
import { ArrayVector, DataFrame, FieldType } from '@grafana/data'; import { ArrayVector, DataFrame, FieldType } from '@grafana/data';
import { ScaleDimensionConfig } from '@grafana/schema';
import { getScaledDimension, validateScaleConfig } from './scale'; import { getScaledDimension, validateScaleConfig } from './scale';
describe('scale dimensions', () => { describe('scale dimensions', () => {
it('should validate empty input', () => { it('should validate empty input', () => {
const out = validateScaleConfig({} as any, { const out = validateScaleConfig({} as ScaleDimensionConfig, {
min: 5, min: 5,
max: 10, 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 fields.map(([name, values]) => {
return { name, values }; return { name, values };
}); });

View File

@@ -23,7 +23,7 @@ const setup = (activeDatasourceOnly = false) => {
queries: [], queries: [],
loading: false, loading: false,
totalQueries: 0, totalQueries: 0,
activeDatasourceInstance: {} as any, activeDatasourceInstance: '',
updateFilters: jest.fn(), updateFilters: jest.fn(),
loadMoreRichHistory: jest.fn(), loadMoreRichHistory: jest.fn(),
clearRichHistoryResults: jest.fn(), clearRichHistoryResults: jest.fn(),

View File

@@ -4,7 +4,7 @@ import React, { createRef } from 'react';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { DataFrame, MutableDataFrame, getDefaultTimeRange, LoadingState } from '@grafana/data'; 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 { ExploreId } from 'app/types';
import { configureStore } from '../../../store/configureStore'; import { configureStore } from '../../../store/configureStore';
@@ -62,7 +62,7 @@ describe('TraceView', () => {
getInstanceSettings() { getInstanceSettings() {
return undefined; return undefined;
}, },
} as any); } as DataSourceSrv);
}); });
it('renders TraceTimelineViewer', () => { it('renders TraceTimelineViewer', () => {

View File

@@ -19,7 +19,7 @@ jest.mock('../../dashboard/services/TimeSrv', () => ({
const { testRange, defaultInitialState } = createDefaultInitialState(); const { testRange, defaultInitialState } = createDefaultInitialState();
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getTemplateSrv: () => ({ getTemplateSrv: () => ({
updateTimeRange: jest.fn(), 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 = { const urlStateDefaults: ExploreUrlState = {
datasource: 'some-datasource', datasource: 'some-datasource',
queries: [], queries: [],

View File

@@ -26,7 +26,7 @@ import {
jest.mock('@grafana/data', () => ({ jest.mock('@grafana/data', () => ({
...jest.requireActual('@grafana/data'), ...jest.requireActual('@grafana/data'),
dateTimeFormat: () => 'format() jest mocked', dateTimeFormat: () => 'format() jest mocked',
dateTimeFormatTimeAgo: (ts: any) => 'fromNow() jest mocked', dateTimeFormatTimeAgo: () => 'fromNow() jest mocked',
})); }));
const getTestContext = () => { const getTestContext = () => {

View File

@@ -6,14 +6,13 @@ import {
Field, Field,
FieldType, FieldType,
InterpolateFunction, InterpolateFunction,
LinkModel,
TimeRange, TimeRange,
toDataFrame, toDataFrame,
} from '@grafana/data'; } from '@grafana/data';
import { setTemplateSrv } from '@grafana/runtime'; import { setTemplateSrv } from '@grafana/runtime';
import { initTemplateSrv } from '../../../../test/helpers/initTemplateSrv'; 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 { setLinkSrv } from '../../panel/panellinks/link_srv';
import { getFieldLinksForExplore } from './links'; import { getFieldLinksForExplore } from './links';
@@ -266,7 +265,7 @@ function setup(
dataFrameOtherFieldOverride?: Field[] dataFrameOtherFieldOverride?: Field[]
) { ) {
setLinkSrv({ setLinkSrv({
getDataLinkUIModel(link: DataLink, replaceVariables: InterpolateFunction | undefined, origin: any): LinkModel<any> { getDataLinkUIModel(link: DataLink, replaceVariables: InterpolateFunction | undefined, origin) {
return { return {
href: link.url, href: link.url,
title: link.title, title: link.title,
@@ -274,17 +273,17 @@ function setup(
origin: origin, origin: origin,
}; };
}, },
getAnchorInfo(link: any) { getAnchorInfo(link) {
return { ...link }; return { ...link };
}, },
getLinkUrl(link: any) { getLinkUrl(link) {
return link.url; return link.url;
}, },
}); });
setContextSrv({ setContextSrv({
hasAccessToExplore: () => hasAccess, hasAccessToExplore: () => hasAccess,
} as any); } as ContextSrv);
const field: Field<string | null> = { const field: Field<string | null> = {
name: 'flux-dimensions', name: 'flux-dimensions',

View File

@@ -5,7 +5,7 @@ import { ExpressionDatasourceApi } from './ExpressionDatasource';
import { ExpressionQueryType } from './types'; import { ExpressionQueryType } from './types';
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => backendSrv, getBackendSrv: () => backendSrv,
getTemplateSrv: () => ({ getTemplateSrv: () => ({
replace: (val: string) => (val ? val.replace('$input', '10').replace('$window', '10s') : val), replace: (val: string) => (val ? val.replace('$input', '10').replace('$window', '10s') : val),

View File

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

View File

@@ -2,7 +2,7 @@ import { getCenterPointWGS84 } from 'app/features/transformers/spatial/utils';
import { getGazetteer } from './gazetteer'; import { getGazetteer } from './gazetteer';
let backendResults: any = { hello: 'world' }; let backendResults: Record<string, unknown> = { hello: 'world' };
const geojsonObject = { const geojsonObject = {
type: 'FeatureCollection', type: 'FeatureCollection',
@@ -44,7 +44,7 @@ const geojsonObject = {
}; };
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => ({ getBackendSrv: () => ({
get: jest.fn().mockResolvedValue(backendResults), get: jest.fn().mockResolvedValue(backendResults),
}), }),

View File

@@ -7,7 +7,7 @@ import { getGazetteer } from './gazetteer';
let backendResults: any = { hello: 'world' }; let backendResults: any = { hello: 'world' };
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => ({ getBackendSrv: () => ({
get: jest.fn().mockResolvedValue(backendResults), get: jest.fn().mockResolvedValue(backendResults),
}), }),

View File

@@ -1,6 +1,7 @@
import { render, screen, waitFor, within } from '@testing-library/react'; import { render, screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import React from 'react'; import React from 'react';
import { match } from 'react-router-dom';
import { TestProvider } from 'test/helpers/TestProvider'; import { TestProvider } from 'test/helpers/TestProvider';
import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps'; import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps';
@@ -16,7 +17,7 @@ jest.mock('app/core/core', () => ({
})); }));
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => backendSrv, getBackendSrv: () => backendSrv,
})); }));
@@ -40,7 +41,7 @@ async function setupTestContext({ get = defaultGet }: { get?: typeof defaultGet
...getRouteComponentProps({ ...getRouteComponentProps({
match: { match: {
params: { code: 'some code' }, params: { code: 'some code' },
} as any, } as unknown as match,
}), }),
}; };

View File

@@ -1,4 +1,5 @@
import { LoadingState } from '@grafana/data'; import { LoadingState } from '@grafana/data';
import { DashboardSearchItem } from 'app/features/search/types';
import { reducerTester } from '../../../../../test/core/redux/reducerTester'; import { reducerTester } from '../../../../../test/core/redux/reducerTester';
@@ -24,7 +25,7 @@ describe('deleteLibraryPanelModalReducer', () => {
describe('when searchCompleted is dispatched', () => { describe('when searchCompleted is dispatched', () => {
it('then state should be correct', () => { it('then state should be correct', () => {
const dashboards: any[] = [{ title: 'A' }, { title: 'B' }]; const dashboards = [{ title: 'A' }, { title: 'B' }] as DashboardSearchItem[];
reducerTester<DeleteLibraryPanelModalState>() reducerTester<DeleteLibraryPanelModalState>()
.givenReducer(deleteLibraryPanelModalReducer, initialDeleteLibraryPanelModalState) .givenReducer(deleteLibraryPanelModalReducer, initialDeleteLibraryPanelModalState)
.whenActionIsDispatched(searchCompleted({ dashboards })) .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 userEvent from '@testing-library/user-event';
import React from 'react'; import React from 'react';
import { PanelPluginMeta, PluginType } from '@grafana/data'; import { PanelPluginMeta, PluginMetaInfo, PluginType } from '@grafana/data';
import { config } from '@grafana/runtime'; import { config } from '@grafana/runtime';
import { Panel } from '@grafana/schema'; import { Panel } from '@grafana/schema';
import { getGrafanaSearcher } from 'app/features/search/service'; import { getGrafanaSearcher } from 'app/features/search/service';
@@ -16,7 +16,7 @@ import { LibraryElementsSearchResult } from '../../types';
import { LibraryPanelsSearch, LibraryPanelsSearchProps } from './LibraryPanelsSearch'; import { LibraryPanelsSearch, LibraryPanelsSearchProps } from './LibraryPanelsSearch';
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
config: { config: {
panels: { panels: {
timeseries: { timeseries: {
@@ -28,7 +28,7 @@ jest.mock('@grafana/runtime', () => ({
})); }));
jest.mock('debounce-promise', () => { jest.mock('debounce-promise', () => {
const debounce = (fn: any) => { const debounce = () => {
const debounced = () => const debounced = () =>
Promise.resolve([ Promise.resolve([
{ label: 'General', value: { uid: '', title: 'General' } }, { label: 'General', value: { uid: '', title: 'General' } },
@@ -46,7 +46,7 @@ async function getTestContext(
searchResult: LibraryElementsSearchResult = { elements: [], perPage: 40, page: 1, totalCount: 0 } searchResult: LibraryElementsSearchResult = { elements: [], perPage: 40, page: 1, totalCount: 0 }
) { ) {
jest.clearAllMocks(); jest.clearAllMocks();
const pluginInfo: any = { logos: { small: '', large: '' } }; const pluginInfo = { logos: { small: '', large: '' } } as PluginMetaInfo;
const graph: PanelPluginMeta = { const graph: PanelPluginMeta = {
name: 'Graph', name: 'Graph',
id: 'graph', id: 'graph',

View File

@@ -1,21 +1,23 @@
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { DataQueryResponse, FieldType, LiveChannelScope } from '@grafana/data'; 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 { StreamingDataFrame } from './data/StreamingDataFrame';
import { StreamingResponseDataType } from './data/utils'; import { StreamingResponseDataType } from './data/utils';
import { GrafanaLiveService } from './live'; import { GrafanaLiveService } from './live';
describe('GrafanaLiveService', () => { describe('GrafanaLiveService', () => {
const mockGetDataStream = jest.fn();
const deps = { const deps = {
backendSrv: {}, backendSrv: {} as BackendSrv,
centrifugeSrv: { centrifugeSrv: {
getDataStream: jest.fn(), getDataStream: mockGetDataStream,
}, } as unknown as CentrifugeSrv,
}; };
const liveService = new GrafanaLiveService(deps as any); const liveService = new GrafanaLiveService(deps);
const liveDataStreamOptions = { const liveDataStreamOptions = {
addr: { addr: {
@@ -31,7 +33,7 @@ describe('GrafanaLiveService', () => {
it('should map response from Centrifuge Service to a streaming data frame', async () => { it('should map response from Centrifuge Service to a streaming data frame', async () => {
const dummySubject = new Subject<StreamingDataQueryResponse>(); const dummySubject = new Subject<StreamingDataQueryResponse>();
deps.centrifugeSrv.getDataStream.mockReturnValueOnce(dummySubject); mockGetDataStream.mockReturnValueOnce(dummySubject);
let response: DataQueryResponse | undefined; let response: DataQueryResponse | undefined;
liveService.getDataStream(liveDataStreamOptions).subscribe((next) => { liveService.getDataStream(liveDataStreamOptions).subscribe((next) => {
@@ -53,7 +55,7 @@ describe('GrafanaLiveService', () => {
it('should add partial streaming data to the buffer', async () => { it('should add partial streaming data to the buffer', async () => {
const dummySubject = new Subject<StreamingDataQueryResponse>(); const dummySubject = new Subject<StreamingDataQueryResponse>();
deps.centrifugeSrv.getDataStream.mockReturnValueOnce(dummySubject); mockGetDataStream.mockReturnValueOnce(dummySubject);
let response: DataQueryResponse | undefined; let response: DataQueryResponse | undefined;
liveService.getDataStream(liveDataStreamOptions).subscribe((next) => { 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 () => { it('should return an empty frame if first message was not a full frame', async () => {
jest.spyOn(console, 'warn').mockImplementation(jest.fn); jest.spyOn(console, 'warn').mockImplementation(jest.fn);
const dummySubject = new Subject<StreamingDataQueryResponse>(); const dummySubject = new Subject<StreamingDataQueryResponse>();
deps.centrifugeSrv.getDataStream.mockReturnValueOnce(dummySubject); mockGetDataStream.mockReturnValueOnce(dummySubject);
let response: DataQueryResponse | undefined; let response: DataQueryResponse | undefined;
liveService.getDataStream(liveDataStreamOptions).subscribe((next) => { liveService.getDataStream(liveDataStreamOptions).subscribe((next) => {

View File

@@ -57,7 +57,7 @@ const server = setupServer(
); );
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => backendSrv, getBackendSrv: () => backendSrv,
})); }));

View File

@@ -3,7 +3,7 @@ import { locationService } from '@grafana/runtime';
import { getSnapshots } from './SnapshotListTable'; import { getSnapshots } from './SnapshotListTable';
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => ({ getBackendSrv: () => ({
get: jest.fn().mockResolvedValue([ get: jest.fn().mockResolvedValue([
{ {
@@ -24,7 +24,7 @@ jest.mock('@grafana/runtime', () => ({
})); }));
describe('getSnapshots', () => { describe('getSnapshots', () => {
(global as any).window = Object.create(window); global.window = Object.create(window);
Object.defineProperty(window, 'location', { Object.defineProperty(window, 'location', {
value: { value: {
href: 'http://localhost:3000/grafana/dashboard/snapshots', href: 'http://localhost:3000/grafana/dashboard/snapshots',

View File

@@ -1,6 +1,7 @@
import { thunkTester } from 'test/core/thunk/thunkTester'; 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'; import { validateDashboardJson } from '../utils/validation';
@@ -20,7 +21,7 @@ describe('importDashboard', () => {
uid: 'ds-uid', uid: 'ds-uid',
name: 'ds-name', name: 'ds-name',
type: 'prometheus', type: 'prometheus',
} as any, } as DataSourceInstanceSettings,
], ],
elements: [], elements: [],
folder: { folder: {
@@ -32,13 +33,13 @@ describe('importDashboard', () => {
let postArgs: any; let postArgs: any;
setBackendSrv({ setBackendSrv({
post: (url: string, args: any) => { post: (url, args) => {
postArgs = args; postArgs = args;
return Promise.resolve({ return Promise.resolve({
importedUrl: '/my/dashboard', importedUrl: '/my/dashboard',
}); });
}, },
} as any); } as BackendSrv);
await thunkTester({ await thunkTester({
importDashboard: { importDashboard: {

View File

@@ -1,5 +1,6 @@
import { thunkTester } from 'test/core/thunk/thunkTester'; import { thunkTester } from 'test/core/thunk/thunkTester';
import { BackendSrv } from '@grafana/runtime';
import { updateConfigurationSubtitle } from 'app/core/actions'; import { updateConfigurationSubtitle } from 'app/core/actions';
import { OrgRole } from 'app/types'; import { OrgRole } from 'app/types';
@@ -25,10 +26,10 @@ describe('updateOrganization', () => {
describe('when updateOrganization thunk is dispatched', () => { describe('when updateOrganization thunk is dispatched', () => {
const getMock = jest.fn().mockResolvedValue({ id: 1, name: 'New Org Name' }); const getMock = jest.fn().mockResolvedValue({ id: 1, name: 'New Org Name' });
const putMock = 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, get: getMock,
put: putMock, put: putMock,
}; } as unknown as BackendSrv;
it('then it should dispatch updateConfigurationSubtitle', async () => { it('then it should dispatch updateConfigurationSubtitle', async () => {
const { initialState } = setup(); const { initialState } = setup();
@@ -47,9 +48,9 @@ describe('setUserOrganization', () => {
describe('when setUserOrganization thunk is dispatched', () => { describe('when setUserOrganization thunk is dispatched', () => {
const postMock = jest.fn().mockResolvedValue({ id: 1, name: 'New Org Name' }); const postMock = jest.fn().mockResolvedValue({ id: 1, name: 'New Org Name' });
const backendSrvMock: any = { const backendSrvMock = {
post: postMock, post: postMock,
}; } as unknown as BackendSrv;
const orgId = 1; const orgId = 1;
@@ -69,9 +70,9 @@ describe('setUserOrganization', () => {
describe('getUserOrganizations', () => { describe('getUserOrganizations', () => {
describe('when getUserOrganizations thunk is dispatched', () => { describe('when getUserOrganizations thunk is dispatched', () => {
const getMock = jest.fn().mockResolvedValue({ orgId: 1, name: 'New Org Name', role: OrgRole.Editor }); const getMock = jest.fn().mockResolvedValue({ orgId: 1, name: 'New Org Name', role: OrgRole.Editor });
const backendSrvMock: any = { const backendSrvMock = {
get: getMock, get: getMock,
}; } as unknown as BackendSrv;
it('then it should dispatch updateConfigurationSubtitle', async () => { it('then it should dispatch updateConfigurationSubtitle', async () => {
const { initialState } = setup(); 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 { setTemplateSrv } from '@grafana/runtime';
import { ContextSrv } from 'app/core/services/context_srv';
import { getTimeSrv, setTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv'; 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 { TemplateSrv } from 'app/features/templating/template_srv';
import { variableAdapters } from 'app/features/variables/adapters'; import { variableAdapters } from 'app/features/variables/adapters';
import { createQueryVariableAdapter } from 'app/features/variables/query/adapter'; import { createQueryVariableAdapter } from 'app/features/variables/query/adapter';
@@ -21,13 +23,13 @@ describe('linkSrv', () => {
let originalTimeService: TimeSrv; let originalTimeService: TimeSrv;
function initLinkSrv() { function initLinkSrv() {
const _dashboard: any = { const _dashboard = {
time: { from: 'now-6h', to: 'now' }, time: { from: 'now-6h', to: 'now' },
getTimezone: jest.fn(() => 'browser'), getTimezone: jest.fn(() => 'browser'),
timeRangeUpdated: () => {}, timeRangeUpdated: () => {},
}; } as unknown as TimeModel;
const timeSrv = new TimeSrv({} as any); const timeSrv = new TimeSrv({} as ContextSrv);
timeSrv.init(_dashboard); timeSrv.init(_dashboard);
timeSrv.setTime({ from: 'now-1h', to: 'now' }); timeSrv.setTime({ from: 'now-1h', to: 'now' });
_dashboard.refresh = false; _dashboard.refresh = false;
@@ -127,9 +129,9 @@ describe('linkSrv', () => {
"when link '$url' and config.appSubUrl set to '$appSubUrl' then result should be '$expected'", "when link '$url' and config.appSubUrl set to '$appSubUrl' then result should be '$expected'",
({ url, appSubUrl, expected }) => { ({ url, appSubUrl, expected }) => {
locationUtil.initialize({ locationUtil.initialize({
config: { appSubUrl } as any, config: { appSubUrl } as GrafanaConfig,
getVariablesUrlParams: (() => {}) as any, getVariablesUrlParams: jest.fn(),
getTimeRangeForUrl: (() => {}) as any, getTimeRangeForUrl: jest.fn(),
}); });
const link = linkSrv.getDataLinkUIModel( const link = linkSrv.getDataLinkUIModel(

View File

@@ -19,7 +19,7 @@ jest.unmock('app/features/plugins/plugin_loader');
for (const pluginId of panelsToCheckFirst) { for (const pluginId of panelsToCheckFirst) {
config.panels[pluginId] = { config.panels[pluginId] = {
module: `app/plugins/panel/${pluginId}/module`, module: `app/plugins/panel/${pluginId}/module`,
} as any; } as PanelPluginMeta;
} }
config.panels['text'] = { config.panels['text'] = {

View File

@@ -4,23 +4,23 @@ import { filterPluginList } from './util';
describe('panel state utils', () => { describe('panel state utils', () => {
it('should include timeseries in a graph query', async () => { it('should include timeseries in a graph query', async () => {
const pluginsList: PanelPluginMeta[] = [ const pluginsList = [
{ id: 'graph', name: 'Graph (old)' } as any, { id: 'graph', name: 'Graph (old)' },
{ id: 'timeseries', name: 'Graph (old)' }, { id: 'timeseries', name: 'Graph (old)' },
{ id: 'timeline', name: 'Timeline' }, { id: 'timeline', name: 'Timeline' },
]; ] as PanelPluginMeta[];
const found = filterPluginList(pluginsList, escapeStringForRegex('gra'), { id: 'xyz' } as any); const found = filterPluginList(pluginsList, escapeStringForRegex('gra'), { id: 'xyz' } as PanelPluginMeta);
expect(found.map((v) => v.id)).toEqual(['graph', 'timeseries']); expect(found.map((v) => v.id)).toEqual(['graph', 'timeseries']);
}); });
it('should handle escaped regex characters in the search query (e.g. -)', async () => { it('should handle escaped regex characters in the search query (e.g. -)', async () => {
const pluginsList: PanelPluginMeta[] = [ const pluginsList = [
{ id: 'graph', name: 'Graph (old)' } as any, { id: 'graph', name: 'Graph (old)' },
{ id: 'timeseries', name: 'Graph (old)' }, { id: 'timeseries', name: 'Graph (old)' },
{ id: 'timeline', name: 'Timeline' }, { id: 'timeline', name: 'Timeline' },
{ id: 'panelwithdashes', name: 'Panel-With-Dashes' }, { id: 'panelwithdashes', name: 'Panel-With-Dashes' },
]; ] as PanelPluginMeta[];
const found = filterPluginList(pluginsList, escapeStringForRegex('panel-'), { id: 'xyz' } as any); const found = filterPluginList(pluginsList, escapeStringForRegex('panel-'), { id: 'xyz' } as PanelPluginMeta);
expect(found.map((v) => v.id)).toEqual(['panelwithdashes']); expect(found.map((v) => v.id)).toEqual(['panelwithdashes']);
}); });
}); });

View File

@@ -1,12 +1,15 @@
import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import { History, Location } from 'history';
import React from 'react'; import React from 'react';
import { type match } from 'react-router-dom';
import { TestProvider } from 'test/helpers/TestProvider'; import { TestProvider } from 'test/helpers/TestProvider';
import { locationService } from '@grafana/runtime'; import { locationService } from '@grafana/runtime';
import { RouteDescriptor } from 'app/core/navigation/types';
import { backendSrv } from 'app/core/services/backend_srv'; import { backendSrv } from 'app/core/services/backend_srv';
import { PlaylistEditPage } from './PlaylistEditPage'; import { PlaylistEditPage, RouteParams } from './PlaylistEditPage';
import { Playlist } from './types'; import { Playlist } from './types';
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
@@ -24,10 +27,10 @@ async function getTestContext({ name, interval, items, uid }: Partial<Playlist>
jest.clearAllMocks(); jest.clearAllMocks();
const playlist = { name, items, interval, uid } as unknown as Playlist; const playlist = { name, items, interval, uid } as unknown as Playlist;
const queryParams = {}; const queryParams = {};
const route: any = {}; const route = {} as RouteDescriptor;
const match: any = { params: { uid: 'foo' } }; const match = { params: { uid: 'foo' } } as unknown as match<RouteParams>;
const location: any = {}; const location = {} as Location;
const history: any = {}; const history = {} as History;
const getMock = jest.spyOn(backendSrv, 'get'); const getMock = jest.spyOn(backendSrv, 'get');
const putMock = jest.spyOn(backendSrv, 'put'); const putMock = jest.spyOn(backendSrv, 'put');

View File

@@ -9,7 +9,7 @@ import { PlaylistPage } from './PlaylistPage';
const fnMock = jest.fn(); const fnMock = jest.fn();
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => ({ getBackendSrv: () => ({
get: fnMock, get: fnMock,
}), }),

View File

@@ -6,6 +6,7 @@ import { TestProvider } from 'test/helpers/TestProvider';
import { PluginType, escapeStringForRegex } from '@grafana/data'; import { PluginType, escapeStringForRegex } from '@grafana/data';
import { locationService } from '@grafana/runtime'; import { locationService } from '@grafana/runtime';
import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps'; import { getRouteComponentProps } from 'app/core/navigation/__mocks__/routeProps';
import { RouteDescriptor } from 'app/core/navigation/types';
import { configureStore } from 'app/store/configureStore'; import { configureStore } from 'app/store/configureStore';
import { getCatalogPluginMock, getPluginsStateMock } from '../__mocks__'; import { getCatalogPluginMock, getPluginsStateMock } from '../__mocks__';
@@ -32,7 +33,7 @@ const renderBrowse = (
const store = configureStore({ plugins: pluginsStateOverride || getPluginsStateMock(plugins) }); const store = configureStore({ plugins: pluginsStateOverride || getPluginsStateMock(plugins) });
locationService.push(path); locationService.push(path);
const props = getRouteComponentProps({ const props = getRouteComponentProps({
route: { routeName: PluginAdminRoutes.Home } as any, route: { routeName: PluginAdminRoutes.Home } as RouteDescriptor,
}); });
return render( return render(

View File

@@ -9,6 +9,7 @@ import { getMockPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { locationService, setEchoSrv } from '@grafana/runtime'; import { locationService, setEchoSrv } from '@grafana/runtime';
import { GrafanaContext } from 'app/core/context/GrafanaContext'; import { GrafanaContext } from 'app/core/context/GrafanaContext';
import { GrafanaRoute } from 'app/core/navigation/GrafanaRoute'; import { GrafanaRoute } from 'app/core/navigation/GrafanaRoute';
import { RouteDescriptor } from 'app/core/navigation/types';
import { Echo } from 'app/core/services/echo/Echo'; import { Echo } from 'app/core/services/echo/Echo';
import { configureStore } from 'app/store/configureStore'; import { configureStore } from 'app/store/configureStore';
@@ -90,14 +91,16 @@ function renderUnderRouter() {
appPluginNavItem.parentItem = appsSection; appPluginNavItem.parentItem = appsSection;
const store = configureStore(); 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'); locationService.push('/a/my-awesome-plugin');
render( render(
<Router history={locationService.getHistory()}> <Router history={locationService.getHistory()}>
<Provider store={store}> <Provider store={store}>
<GrafanaContext.Provider value={getGrafanaContextMock()}> <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> </GrafanaContext.Provider>
</Provider> </Provider>
</Router> </Router>

View File

@@ -1,10 +1,6 @@
// Use the real plugin_loader (stubbed by default) // Use the real plugin_loader (stubbed by default)
jest.unmock('app/features/plugins/plugin_loader'); jest.unmock('app/features/plugins/plugin_loader');
(global as any).ace = {
define: jest.fn(),
};
jest.mock('app/core/core', () => { jest.mock('app/core/core', () => {
return { return {
coreModule: { coreModule: {

View File

@@ -17,7 +17,7 @@ import {
} from './reducers'; } from './reducers';
describe('userReducer', () => { describe('userReducer', () => {
let dateNow: any; let dateNow: jest.SpyInstance;
beforeAll(() => { beforeAll(() => {
dateNow = jest.spyOn(Date, 'now').mockImplementation(() => 1609470000000); // 2021-01-01 04:00:00 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'; import { DashboardQueryRunnerOptions } from './types';
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => backendSrv, getBackendSrv: () => backendSrv,
})); }));

View File

@@ -1,6 +1,7 @@
import { Observable, of, throwError } from 'rxjs'; 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 { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
import * as store from '../../../../store/store'; import * as store from '../../../../store/store';
@@ -11,12 +12,12 @@ import { toAsyncOfResult } from './testHelpers';
import { AnnotationQueryRunnerOptions } from './types'; import { AnnotationQueryRunnerOptions } from './types';
function getDefaultOptions(): AnnotationQueryRunnerOptions { function getDefaultOptions(): AnnotationQueryRunnerOptions {
const annotation: any = {}; const annotation = {} as AnnotationQuery;
const dashboard: any = {}; const dashboard = createDashboardModelFixture();
const datasource: any = { const datasource = {
annotationQuery: {}, annotationQuery: {},
annotations: {}, annotations: {},
}; } as unknown as DataSourceApi;
const range = getDefaultTimeRange(); const range = getDefaultTimeRange();
return { annotation, datasource, dashboard, range }; return { annotation, datasource, dashboard, range };
@@ -36,10 +37,10 @@ describe('AnnotationsQueryRunner', () => {
describe('when canWork is called with correct props', () => { describe('when canWork is called with correct props', () => {
it('then it should return true', () => { it('then it should return true', () => {
const datasource: any = { const datasource = {
annotationQuery: jest.fn(), annotationQuery: jest.fn(),
annotations: {}, annotations: {},
}; } as unknown as DataSourceApi;
expect(runner.canRun(datasource)).toBe(true); expect(runner.canRun(datasource)).toBe(true);
}); });
@@ -47,7 +48,7 @@ describe('AnnotationsQueryRunner', () => {
describe('when canWork is called without datasource', () => { describe('when canWork is called without datasource', () => {
it('then it should return false', () => { it('then it should return false', () => {
const datasource: any = undefined; const datasource = undefined;
expect(runner.canRun(datasource)).toBe(false); expect(runner.canRun(datasource)).toBe(false);
}); });
@@ -55,9 +56,9 @@ describe('AnnotationsQueryRunner', () => {
describe('when canWork is called with incorrect props', () => { describe('when canWork is called with incorrect props', () => {
it('then it should return false', () => { it('then it should return false', () => {
const datasource: any = { const datasource = {
annotationQuery: jest.fn(), annotationQuery: jest.fn(),
}; } as unknown as DataSourceApi;
expect(runner.canRun(datasource)).toBe(false); expect(runner.canRun(datasource)).toBe(false);
}); });
@@ -65,9 +66,9 @@ describe('AnnotationsQueryRunner', () => {
describe('when run is called with unsupported props', () => { describe('when run is called with unsupported props', () => {
it('then it should return the correct results', async () => { it('then it should return the correct results', async () => {
const datasource: any = { const datasource = {
annotationQuery: jest.fn(), annotationQuery: jest.fn(),
}; } as unknown as DataSourceApi;
const { options, executeAnnotationQueryMock } = getTestContext(); const { options, executeAnnotationQueryMock } = getTestContext();
await expect(runner.run({ ...options, datasource })).toEmitValuesWith((received) => { 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 { delay } from 'rxjs/operators';
import { AnnotationQuery } from '@grafana/data'; 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 { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
import * as annotationsSrv from '../../../annotations/executeAnnotationQuery'; import * as annotationsSrv from '../../../annotations/executeAnnotationQuery';
import { AnnotationsWorker } from './AnnotationsWorker'; 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 { getDefaultOptions, LEGACY_DS_NAME, NEXT_GEN_DS_NAME, toAsyncOfResult } from './testHelpers';
import { DashboardQueryRunnerOptions, DashboardQueryRunnerWorkerResult } from './types'; import { DashboardQueryRunnerOptions, DashboardQueryRunnerWorkerResult } from './types';
import { emptyResult } from './utils'; import { emptyResult } from './utils';
@@ -23,12 +28,12 @@ function getTestContext(dataSourceSrvRejects = false) {
cancellations: () => cancellations, cancellations: () => cancellations,
destroy: () => undefined, destroy: () => undefined,
})); }));
createDashboardQueryRunner({} as any); createDashboardQueryRunner({} as DashboardQueryRunnerFactoryArgs);
const executeAnnotationQueryMock = jest const executeAnnotationQueryMock = jest
.spyOn(annotationsSrv, 'executeAnnotationQuery') .spyOn(annotationsSrv, 'executeAnnotationQuery')
.mockReturnValue(toAsyncOfResult({ events: [{ id: 'NextGen' }] })); .mockReturnValue(toAsyncOfResult({ events: [{ id: 'NextGen' }] }));
const annotationQueryMock = jest.fn().mockResolvedValue([{ id: 'Legacy' }]); const annotationQueryMock = jest.fn().mockResolvedValue([{ id: 'Legacy' }]);
const dataSourceSrvMock: any = { const dataSourceSrvMock = {
get: async (name: string) => { get: async (name: string) => {
if (dataSourceSrvRejects) { if (dataSourceSrvRejects) {
return Promise.reject(`Could not find datasource with name: ${name}`); return Promise.reject(`Could not find datasource with name: ${name}`);
@@ -47,7 +52,7 @@ function getTestContext(dataSourceSrvRejects = false) {
return {}; return {};
}, },
}; } as DataSourceSrv;
setDataSourceSrv(dataSourceSrvMock); setDataSourceSrv(dataSourceSrvMock);
const options = getDefaultOptions(); const options = getDefaultOptions();
@@ -97,7 +102,7 @@ describe('AnnotationsWorker', () => {
describe('when canWork is called with incorrect props', () => { describe('when canWork is called with incorrect props', () => {
it('then it should return false', () => { it('then it should return false', () => {
const dashboard: any = { annotations: { list: [] } }; const dashboard = { annotations: { list: [] } } as unknown as DashboardModel;
const options = { ...getDefaultOptions(), dashboard }; const options = { ...getDefaultOptions(), dashboard };
expect(worker.canWork(options)).toBe(false); expect(worker.canWork(options)).toBe(false);
@@ -106,7 +111,7 @@ describe('AnnotationsWorker', () => {
describe('when run is called with incorrect props', () => { describe('when run is called with incorrect props', () => {
it('then it should return the correct results', async () => { 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 }; const options = { ...getDefaultOptions(), dashboard };
await expect(worker.work(options)).toEmitValues([{ alertStates: [], annotations: [] }]); 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 { delay, first } from 'rxjs/operators';
import { AlertState, AlertStateInfo } from '@grafana/data'; 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 { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
import { backendSrv } from '../../../../core/services/backend_srv'; 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'; import { DashboardQueryRunner, DashboardQueryRunnerResult } from './types';
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => backendSrv, getBackendSrv: () => backendSrv,
})); }));
function getTestContext() { function getTestContext() {
jest.clearAllMocks(); jest.clearAllMocks();
const timeSrvMock: any = { timeRange: jest.fn() }; const timeSrvMock = { timeRange: jest.fn() } as unknown as TimeSrv;
const options = getDefaultOptions(); 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 // 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 }); const runner = createDashboardQueryRunner({ dashboard: options.dashboard, timeSrv: timeSrvMock });
@@ -33,7 +34,7 @@ function getTestContext() {
.spyOn(annotationsSrv, 'executeAnnotationQuery') .spyOn(annotationsSrv, 'executeAnnotationQuery')
.mockReturnValue(toAsyncOfResult({ events: [{ id: 'NextGen' }] })); .mockReturnValue(toAsyncOfResult({ events: [{ id: 'NextGen' }] }));
const annotationQueryMock = jest.fn().mockResolvedValue([{ id: 'Legacy' }]); const annotationQueryMock = jest.fn().mockResolvedValue([{ id: 'Legacy' }]);
const dataSourceSrvMock: any = { const dataSourceSrvMock = {
get: async (name: string) => { get: async (name: string) => {
if (name === LEGACY_DS_NAME) { if (name === LEGACY_DS_NAME) {
return { return {
@@ -49,7 +50,7 @@ function getTestContext() {
return {}; return {};
}, },
}; } as DataSourceSrv;
setDataSourceSrv(dataSourceSrvMock); setDataSourceSrv(dataSourceSrvMock);
return { runner, options, annotationQueryMock, executeAnnotationQueryMock, getMock }; 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 { silenceConsoleOutput } from '../../../../../test/core/utils/silenceConsoleOutput';
import * as store from '../../../../store/store'; import * as store from '../../../../store/store';
@@ -7,11 +8,11 @@ import { LegacyAnnotationQueryRunner } from './LegacyAnnotationQueryRunner';
import { AnnotationQueryRunnerOptions } from './types'; import { AnnotationQueryRunnerOptions } from './types';
function getDefaultOptions(annotationQuery?: jest.Mock): AnnotationQueryRunnerOptions { function getDefaultOptions(annotationQuery?: jest.Mock): AnnotationQueryRunnerOptions {
const annotation: any = {}; const annotation = {} as AnnotationQuery;
const dashboard: any = {}; const dashboard = createDashboardModelFixture();
const datasource: any = { const datasource = {
annotationQuery: annotationQuery ?? jest.fn().mockResolvedValue([{ id: '1' }]), annotationQuery: annotationQuery ?? jest.fn().mockResolvedValue([{ id: '1' }]),
}; } as unknown as DataSourceApi;
const range = getDefaultTimeRange(); const range = getDefaultTimeRange();
return { annotation, datasource, dashboard, range }; return { annotation, datasource, dashboard, range };
@@ -31,9 +32,9 @@ describe('LegacyAnnotationQueryRunner', () => {
describe('when canWork is called with correct props', () => { describe('when canWork is called with correct props', () => {
it('then it should return true', () => { it('then it should return true', () => {
const datasource: any = { const datasource = {
annotationQuery: jest.fn(), annotationQuery: jest.fn(),
}; } as unknown as DataSourceApi;
expect(runner.canRun(datasource)).toBe(true); expect(runner.canRun(datasource)).toBe(true);
}); });
@@ -41,7 +42,7 @@ describe('LegacyAnnotationQueryRunner', () => {
describe('when canWork is called without datasource', () => { describe('when canWork is called without datasource', () => {
it('then it should return false', () => { it('then it should return false', () => {
const datasource: any = undefined; const datasource = undefined;
expect(runner.canRun(datasource)).toBe(false); expect(runner.canRun(datasource)).toBe(false);
}); });
@@ -49,10 +50,10 @@ describe('LegacyAnnotationQueryRunner', () => {
describe('when canWork is called with incorrect props', () => { describe('when canWork is called with incorrect props', () => {
it('then it should return false', () => { it('then it should return false', () => {
const datasource: any = { const datasource = {
annotationQuery: jest.fn(), annotationQuery: jest.fn(),
annotations: {}, annotations: {},
}; } as unknown as DataSourceApi;
expect(runner.canRun(datasource)).toBe(false); expect(runner.canRun(datasource)).toBe(false);
}); });
@@ -60,10 +61,10 @@ describe('LegacyAnnotationQueryRunner', () => {
describe('when run is called with unsupported props', () => { describe('when run is called with unsupported props', () => {
it('then it should return the correct results', async () => { it('then it should return the correct results', async () => {
const datasource: any = { const datasource = {
annotationQuery: jest.fn(), annotationQuery: jest.fn(),
annotations: {}, annotations: {},
}; } as unknown as DataSourceApi;
const options = { ...getDefaultOptions(), datasource }; const options = { ...getDefaultOptions(), datasource };
await expect(runner.run(options)).toEmitValuesWith((received) => { 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 { SnapshotWorker } from './SnapshotWorker';
import { DashboardQueryRunnerOptions } from './types'; import { DashboardQueryRunnerOptions } from './types';
function getDefaultOptions(): DashboardQueryRunnerOptions { function getDefaultOptions(): DashboardQueryRunnerOptions {
const dashboard: any = {}; const dashboard = new DashboardModel({} as Dashboard);
const range = getDefaultTimeRange(); const range = getDefaultTimeRange();
return { dashboard, range }; 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 }]; return [{ annotation, source: {}, timeEnd, time: 1 }];
} }
function getAnnotation(timeEnd: number | undefined = undefined) { function getAnnotation(timeEnd: number | undefined = undefined): AnnotationQuery {
const annotation = { const annotation = {
enable: true, enable: true,
hide: false, hide: false,
@@ -33,7 +35,7 @@ describe('SnapshotWorker', () => {
describe('when canWork is called with correct props', () => { describe('when canWork is called with correct props', () => {
it('then it should return true', () => { 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 }; const options = { ...getDefaultOptions(), dashboard };
expect(worker.canWork(options)).toBe(true); expect(worker.canWork(options)).toBe(true);
@@ -42,7 +44,7 @@ describe('SnapshotWorker', () => {
describe('when canWork is called with incorrect props', () => { describe('when canWork is called with incorrect props', () => {
it('then it should return false', () => { it('then it should return false', () => {
const dashboard: any = { annotations: { list: [{}] } }; const dashboard = { annotations: { list: [{}] } } as unknown as DashboardModel;
const options = { ...getDefaultOptions(), dashboard }; const options = { ...getDefaultOptions(), dashboard };
expect(worker.canWork(options)).toBe(false); expect(worker.canWork(options)).toBe(false);
@@ -51,7 +53,7 @@ describe('SnapshotWorker', () => {
describe('when run is called with incorrect props', () => { describe('when run is called with incorrect props', () => {
it('then it should return the correct results', async () => { 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 }; const options = { ...getDefaultOptions(), dashboard };
await expect(worker.work(options)).toEmitValues([{ alertStates: [], annotations: [] }]); await expect(worker.work(options)).toEmitValues([{ alertStates: [], annotations: [] }]);
@@ -64,7 +66,9 @@ describe('SnapshotWorker', () => {
const noRegionEqualTime = getAnnotation(1); const noRegionEqualTime = getAnnotation(1);
const region = getAnnotation(2); const region = getAnnotation(2);
const noSnapshotData = { ...getAnnotation(), snapshotData: undefined }; 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 }; const options = { ...getDefaultOptions(), dashboard };
await expect(worker.work(options)).toEmitValuesWith((received) => { 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 { backendSrv } from 'app/core/services/backend_srv';
import { disableRBAC, enableRBAC, grantUserPermissions } from 'app/features/alerting/unified/mocks'; import { disableRBAC, enableRBAC, grantUserPermissions } from 'app/features/alerting/unified/mocks';
import { Annotation } from 'app/features/alerting/unified/utils/constants'; 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 { AccessControlAction } from 'app/types/accessControl';
import { PromAlertingRuleState, PromRuleDTO, PromRulesResponse, PromRuleType } from 'app/types/unified-alerting-dto'; import { PromAlertingRuleState, PromRuleDTO, PromRulesResponse, PromRuleType } from 'app/types/unified-alerting-dto';
@@ -14,12 +15,20 @@ import { UnifiedAlertStatesWorker } from './UnifiedAlertStatesWorker';
import { DashboardQueryRunnerOptions } from './types'; import { DashboardQueryRunnerOptions } from './types';
jest.mock('@grafana/runtime', () => ({ jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as unknown as object), ...jest.requireActual('@grafana/runtime'),
getBackendSrv: () => backendSrv, getBackendSrv: () => backendSrv,
})); }));
function getDefaultOptions(): DashboardQueryRunnerOptions { 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(); const range = getDefaultTimeRange();
return { dashboard, range }; return { dashboard, range };
@@ -60,7 +69,7 @@ describe('UnifiedAlertStatesWorker', () => {
describe('when canWork is called with no dashboard id', () => { describe('when canWork is called with no dashboard id', () => {
it('then it should return false', () => { it('then it should return false', () => {
const dashboard: any = {}; const dashboard = createDashboardModelFixture({});
const options = { ...getDefaultOptions(), dashboard }; const options = { ...getDefaultOptions(), dashboard };
expect(worker.canWork(options)).toBe(false); expect(worker.canWork(options)).toBe(false);
@@ -80,7 +89,7 @@ describe('UnifiedAlertStatesWorker', () => {
describe('when run is called with incorrect props', () => { describe('when run is called with incorrect props', () => {
it('then it should return the correct results', async () => { it('then it should return the correct results', async () => {
const { getMock, options } = getTestContext(); const { getMock, options } = getTestContext();
const dashboard: any = {}; const dashboard = createDashboardModelFixture({});
await expect(worker.work({ ...options, dashboard })).toEmitValuesWith((received) => { await expect(worker.work({ ...options, dashboard })).toEmitValuesWith((received) => {
expect(received).toHaveLength(1); expect(received).toHaveLength(1);
@@ -168,8 +177,8 @@ describe('UnifiedAlertStatesWorker', () => {
const results = received[0]; const results = received[0];
expect(results).toEqual({ expect(results).toEqual({
alertStates: [ alertStates: [
{ id: 0, state: AlertState.Alerting, dashboardId: 'an id', panelId: 1 }, { id: 0, state: AlertState.Alerting, dashboardId: 12345, panelId: 1 },
{ id: 1, state: AlertState.Pending, dashboardId: 'an id', panelId: 2 }, { id: 1, state: AlertState.Pending, dashboardId: 12345, panelId: 2 },
], ],
annotations: [], annotations: [],
}); });
@@ -179,7 +188,7 @@ describe('UnifiedAlertStatesWorker', () => {
expect(getMock).toHaveBeenCalledWith( expect(getMock).toHaveBeenCalledWith(
'/api/prometheus/grafana/api/v1/rules', '/api/prometheus/grafana/api/v1/rules',
{ dashboard_uid: 'a uid' }, { 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 // Importing this way to be able to spy on grafana/data
import * as grafanaData from '@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 { Echo } from '../../../core/services/echo/Echo';
import { createDashboardModelFixture } from '../../dashboard/state/__fixtures__/dashboardFixtures'; import { createDashboardModelFixture } from '../../dashboard/state/__fixtures__/dashboardFixtures';
import { import {
createDashboardQueryRunner, createDashboardQueryRunner,
DashboardQueryRunnerFactoryArgs,
setDashboardQueryRunnerFactory, setDashboardQueryRunnerFactory,
} from './DashboardQueryRunner/DashboardQueryRunner'; } from './DashboardQueryRunner/DashboardQueryRunner';
import { emptyResult } from './DashboardQueryRunner/utils'; import { emptyResult } from './DashboardQueryRunner/utils';
import { PanelQueryRunner } from './PanelQueryRunner'; import { PanelQueryRunner, QueryRunnerOptions } from './PanelQueryRunner';
jest.mock('@grafana/data', () => ({ jest.mock('@grafana/data', () => ({
__esModule: true, __esModule: true,
@@ -83,7 +85,7 @@ function describeQueryRunnerScenario(
}, },
}; };
const response: any = { const response = {
data: [ data: [
{ {
target: 'hello', target: 'hello',
@@ -95,21 +97,21 @@ function describeQueryRunnerScenario(
], ],
}; };
setDataSourceSrv({} as any); setDataSourceSrv({} as DataSourceSrv);
setDashboardQueryRunnerFactory(() => ({ setDashboardQueryRunnerFactory(() => ({
getResult: emptyResult, getResult: emptyResult,
run: () => undefined, run: () => undefined,
cancel: () => undefined, cancel: () => undefined,
cancellations: () => new Subject<any>(), cancellations: () => new Subject(),
destroy: () => undefined, destroy: () => undefined,
})); }));
createDashboardQueryRunner({} as any); createDashboardQueryRunner({} as DashboardQueryRunnerFactoryArgs);
beforeEach(async () => { beforeEach(async () => {
setEchoSrv(new Echo()); setEchoSrv(new Echo());
setupFn(); setupFn();
const datasource: any = { const datasource = {
name: 'TestDB', name: 'TestDB',
uid: 'TestDB-uid', uid: 'TestDB-uid',
interval: ctx.dsInterval, interval: ctx.dsInterval,
@@ -119,21 +121,21 @@ function describeQueryRunnerScenario(
}, },
getRef: () => ({ type: 'test', uid: 'TestDB-uid' }), getRef: () => ({ type: 'test', uid: 'TestDB-uid' }),
testDatasource: jest.fn(), testDatasource: jest.fn(),
}; } as unknown as DataSourceApi;
const args: any = { const args = {
datasource, datasource,
scopedVars: ctx.scopedVars, scopedVars: ctx.scopedVars,
minInterval: ctx.minInterval, minInterval: ctx.minInterval,
maxDataPoints: ctx.maxDataPoints, maxDataPoints: ctx.maxDataPoints ?? Infinity,
timeRange: { timeRange: {
from: grafanaData.dateTime().subtract(1, 'days'), from: grafanaData.dateTime().subtract(1, 'days'),
to: grafanaData.dateTime(), to: grafanaData.dateTime(),
raw: { from: '1d', to: 'now' }, raw: { from: '1d', to: 'now' },
}, },
panelId: 1, panelId: 1,
queries: [{ refId: 'A', test: 1 }], queries: [{ refId: 'A' }],
}; } as QueryRunnerOptions;
ctx.runner = new PanelQueryRunner(panelConfig || defaultPanelConfig); ctx.runner = new PanelQueryRunner(panelConfig || defaultPanelConfig);
ctx.runner.getData({ withTransforms: true, withFieldConfig: true }).subscribe({ 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) { function runRequestScenarioThatThrows(desc: string, fn: (ctx: ScenarioCtx) => void) {
describe(desc, () => { describe(desc, () => {
const ctx = new ScenarioCtx(); const ctx = new ScenarioCtx();
let consoleSpy: jest.SpyInstance<any>; let consoleSpy: jest.SpyInstance;
beforeEach(() => { beforeEach(() => {
consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});

View File

@@ -1,5 +1,5 @@
import { fireEvent, render, screen, waitFor } from '@testing-library/react'; import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import React from 'react'; import React, { KeyboardEvent } from 'react';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ArrayVector, DataFrame, DataFrameView, FieldType } from '@grafana/data'; import { ArrayVector, DataFrame, DataFrameView, FieldType } from '@grafana/data';
@@ -38,7 +38,7 @@ describe('SearchResultsGrid', () => {
height: 600, height: 600,
clearSelection: jest.fn(), clearSelection: jest.fn(),
onTagSelected: jest.fn(), onTagSelected: jest.fn(),
keyboardEvents: new Observable<any>(), keyboardEvents: new Observable<KeyboardEvent<Element>>(),
}; };
it('should render grid of dashboards', () => { it('should render grid of dashboards', () => {

View File

@@ -1,8 +1,10 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import userEvent from '@testing-library/user-event';
import { History, Location } from 'history';
import React from 'react'; import React from 'react';
import { TestProvider } from 'test/helpers/TestProvider'; import { TestProvider } from 'test/helpers/TestProvider';
import { RouteDescriptor } from 'app/core/navigation/types';
import { ApiKey, OrgRole, ServiceAccountDTO } from 'app/types'; import { ApiKey, OrgRole, ServiceAccountDTO } from 'app/types';
import { ServiceAccountPageUnconnected, Props } from './ServiceAccountPage'; import { ServiceAccountPageUnconnected, Props } from './ServiceAccountPage';
@@ -35,10 +37,10 @@ const setup = (propOverrides: Partial<Props>) => {
path: '/org/serviceaccounts/1', path: '/org/serviceaccounts/1',
url: 'http://localhost:3000/org/serviceaccounts/1', url: 'http://localhost:3000/org/serviceaccounts/1',
}, },
history: {} as any, history: {} as History,
location: {} as any, location: {} as Location,
queryParams: {}, queryParams: {},
route: {} as any, route: {} as RouteDescriptor,
timezone: '', timezone: '',
createServiceAccountToken: createServiceAccountTokenMock, createServiceAccountToken: createServiceAccountTokenMock,
deleteServiceAccount: deleteServiceAccountMock, deleteServiceAccount: deleteServiceAccountMock,

View File

@@ -1,5 +1,6 @@
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import React from 'react'; import React from 'react';
import { match } from 'react-router-dom';
import { TestProvider } from 'test/helpers/TestProvider'; import { TestProvider } from 'test/helpers/TestProvider';
import { createTheme } from '@grafana/data'; import { createTheme } from '@grafana/data';
@@ -70,7 +71,7 @@ const setup = (propOverrides?: object) => {
id: '1', id: '1',
page: null, page: null,
}, },
} as any, } as unknown as match,
}), }),
pageNav: { text: 'Cool team ' }, pageNav: { text: 'Cool team ' },
teamId: 1, teamId: 1,

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