@ -3,7 +3,7 @@ import { getDefaultTimeRange, LoadingState } from '@grafana/data';
import { variableAdapters } from '../adapters' ;
import { createQueryVariableAdapter } from './adapter' ;
import { reduxTester } from '../../../../test/core/redux/reduxTester' ;
import { getRootReducer } from '../state/helpers' ;
import { getRootReducer , RootReducerType } from '../state/helpers' ;
import { QueryVariableModel , VariableHide , VariableRefresh , VariableSort } from '../types' ;
import { ALL_VARIABLE_TEXT , ALL_VARIABLE_VALUE , toVariablePayload } from '../state/types' ;
import {
@ -14,7 +14,6 @@ import {
variableStateFailed ,
variableStateFetching ,
} from '../state/sharedReducer' ;
import { TemplatingState } from '../state/reducers' ;
import {
changeQueryVariableDataSource ,
changeQueryVariableQuery ,
@ -87,7 +86,7 @@ describe('query actions', () => {
mockDatasourceMetrics ( variable , optionsMetrics , tagsMetrics ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( updateQueryVariableOptions ( toVariablePayload ( variable ) ) , true ) ;
@ -111,7 +110,7 @@ describe('query actions', () => {
mockDatasourceMetrics ( variable , optionsMetrics , tagsMetrics ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( updateQueryVariableOptions ( toVariablePayload ( variable ) ) , true ) ;
@ -138,7 +137,7 @@ describe('query actions', () => {
mockDatasourceMetrics ( variable , optionsMetrics , [ ] ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( updateQueryVariableOptions ( toVariablePayload ( variable ) ) , true ) ;
@ -160,7 +159,7 @@ describe('query actions', () => {
mockDatasourceMetrics ( variable , optionsMetrics , [ ] ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( updateQueryVariableOptions ( toVariablePayload ( variable ) ) , true ) ;
@ -186,7 +185,7 @@ describe('query actions', () => {
mockDatasourceMetrics ( variable , optionsMetrics , [ ] ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenActionIsDispatched ( setIdInEditor ( { id : variable.id } ) )
@ -214,7 +213,7 @@ describe('query actions', () => {
mockDatasourceMetrics ( variable , optionsMetrics , [ ] ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenActionIsDispatched ( setIdInEditor ( { id : variable.id } ) )
@ -241,7 +240,7 @@ describe('query actions', () => {
mocks [ variable . datasource ! ] . metricFindQuery = jest . fn ( ( ) = > Promise . reject ( error ) ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenActionIsDispatched ( setIdInEditor ( { id : variable.id } ) )
@ -277,7 +276,7 @@ describe('query actions', () => {
components : { VariableQueryEditor : editor } ,
} ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( initQueryVariableEditor ( toVariablePayload ( variable ) ) , true ) ;
@ -306,7 +305,7 @@ describe('query actions', () => {
components : { VariableQueryEditor : editor } ,
} ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( initQueryVariableEditor ( toVariablePayload ( variable ) ) , true ) ;
@ -334,7 +333,7 @@ describe('query actions', () => {
components : { VariableQueryEditor : editor } ,
} ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( initQueryVariableEditor ( toVariablePayload ( variable ) ) , true ) ;
@ -356,7 +355,7 @@ describe('query actions', () => {
it ( 'then correct actions are dispatched' , async ( ) = > {
const variable = createVariable ( { datasource : undefined } ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( initQueryVariableEditor ( toVariablePayload ( variable ) ) , true ) ;
@ -380,7 +379,7 @@ describe('query actions', () => {
components : { VariableQueryEditor : editor } ,
} ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( changeQueryVariableDataSource ( toVariablePayload ( variable ) , 'datasource' ) , true ) ;
@ -410,7 +409,7 @@ describe('query actions', () => {
components : { } ,
} ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( changeQueryVariableDataSource ( toVariablePayload ( variable ) , 'datasource' ) , true ) ;
@ -442,7 +441,7 @@ describe('query actions', () => {
mockDatasourceMetrics ( { . . . variable , query } , optionsMetrics , tagsMetrics ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( changeQueryVariableQuery ( toVariablePayload ( variable ) , query , definition ) , true ) ;
@ -473,7 +472,7 @@ describe('query actions', () => {
mockDatasourceMetrics ( { . . . variable , query } , optionsMetrics , [ ] ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( changeQueryVariableQuery ( toVariablePayload ( variable ) , query , definition ) , true ) ;
@ -502,7 +501,7 @@ describe('query actions', () => {
mockDatasourceMetrics ( { . . . variable , query } , optionsMetrics , [ ] ) ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( changeQueryVariableQuery ( toVariablePayload ( variable ) , query , definition ) , true ) ;
@ -528,7 +527,7 @@ describe('query actions', () => {
const query = ` $ ${ variable . name } ` ;
const definition = 'depends on datasource variable' ;
const tester = await reduxTester < { templating : TemplatingState } > ( )
const tester = await reduxTester < RootReducerType > ( )
. givenRootReducer ( getRootReducer ( ) )
. whenActionIsDispatched ( addVariable ( toVariablePayload ( variable , { global : false , index : 0 , model : variable } ) ) )
. whenAsyncActionIsDispatched ( changeQueryVariableQuery ( toVariablePayload ( variable ) , query , definition ) , true ) ;