mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Elasticsearch: Fix query initialization action (#29652)
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { defaultBucketAgg } from 'app/plugins/datasource/elasticsearch/query_def';
|
||||||
import { reducerTester } from 'test/core/redux/reducerTester';
|
import { reducerTester } from 'test/core/redux/reducerTester';
|
||||||
import { changeMetricType } from '../../MetricAggregationsEditor/state/actions';
|
import { changeMetricType } from '../../MetricAggregationsEditor/state/actions';
|
||||||
import { BucketAggregation, DateHistogram } from '../aggregations';
|
import { BucketAggregation, DateHistogram } from '../aggregations';
|
||||||
@@ -10,6 +11,7 @@ import {
|
|||||||
removeBucketAggregation,
|
removeBucketAggregation,
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import { reducer } from './reducer';
|
import { reducer } from './reducer';
|
||||||
|
import { initQuery } from '../../state';
|
||||||
|
|
||||||
describe('Bucket Aggregations Reducer', () => {
|
describe('Bucket Aggregations Reducer', () => {
|
||||||
it('Should correctly add new aggregations', () => {
|
it('Should correctly add new aggregations', () => {
|
||||||
@@ -140,4 +142,11 @@ describe('Bucket Aggregations Reducer', () => {
|
|||||||
)
|
)
|
||||||
.thenStateShouldEqual([{ ...firstAggregation, settings: expectedSettings }, secondAggregation]);
|
.thenStateShouldEqual([{ ...firstAggregation, settings: expectedSettings }, secondAggregation]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should correctly initialize first Bucket Aggregation', () => {
|
||||||
|
reducerTester()
|
||||||
|
.givenReducer(reducer, [])
|
||||||
|
.whenActionIsDispatched(initQuery())
|
||||||
|
.thenStateShouldEqual([defaultBucketAgg('2')]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export const reducer = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
case INIT:
|
case INIT:
|
||||||
return [defaultBucketAgg()];
|
return [defaultBucketAgg('2')];
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
import { Derivative, ExtendedStats, MetricAggregation } from '../aggregations';
|
import { Derivative, ExtendedStats, MetricAggregation } from '../aggregations';
|
||||||
import { defaultMetricAgg } from '../../../../query_def';
|
import { defaultMetricAgg } from '../../../../query_def';
|
||||||
import { metricAggregationConfig } from '../utils';
|
import { metricAggregationConfig } from '../utils';
|
||||||
|
import { initQuery } from '../../state';
|
||||||
|
|
||||||
describe('Metric Aggregations Reducer', () => {
|
describe('Metric Aggregations Reducer', () => {
|
||||||
it('should correctly add new aggregations', () => {
|
it('should correctly add new aggregations', () => {
|
||||||
@@ -219,4 +220,11 @@ describe('Metric Aggregations Reducer', () => {
|
|||||||
.whenActionIsDispatched({ type: 'THIS ACTION SHOULD NOT HAVE ANY EFFECT IN THIS REDUCER' })
|
.whenActionIsDispatched({ type: 'THIS ACTION SHOULD NOT HAVE ANY EFFECT IN THIS REDUCER' })
|
||||||
.thenStateShouldEqual(initialState);
|
.thenStateShouldEqual(initialState);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should correctly initialize first Metric Aggregation', () => {
|
||||||
|
reducerTester()
|
||||||
|
.givenReducer(reducer, [])
|
||||||
|
.whenActionIsDispatched(initQuery())
|
||||||
|
.thenStateShouldEqual([defaultMetricAgg('1')]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ export const reducer = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
case INIT:
|
case INIT:
|
||||||
return [defaultMetricAgg()];
|
return [defaultMetricAgg('1')];
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
|
|||||||
Reference in New Issue
Block a user