/usr/share/grafana/public/app/plugins/datasource/elasticsearch/components/QueryEditor
import { ElasticsearchDataQuery } from '../../dataquery.gen'; import { reducerTester } from '../reducerTester'; import { aliasPatternReducer, changeAliasPattern, changeQuery, initQuery, queryReducer } from './state'; describe('Query Reducer', () => { describe('On Init', () => { it('Should maintain the previous `query` if present', () => { const initialQuery: ElasticsearchDataQuery['query'] = 'Some lucene query'; reducerTester<ElasticsearchDataQuery['query']>() .givenReducer(queryReducer, initialQuery) .whenActionIsDispatched(initQuery()) .thenStateShouldEqual(initialQuery); }); it('Should set an empty `query` if it is not already set', () => { const initialQuery: ElasticsearchDataQuery['query'] = undefined; const expectedQuery = ''; reducerTester<ElasticsearchDataQuery['query']>() .givenReducer(queryReducer, initialQuery) .whenActionIsDispatched(initQuery()) .thenStateShouldEqual(expectedQuery); }); }); it('Should correctly set `query`', () => { const expectedQuery: ElasticsearchDataQuery['query'] = 'Some lucene query'; reducerTester<ElasticsearchDataQuery['query']>() .givenReducer(queryReducer, '') .whenActionIsDispatched(changeQuery(expectedQuery)) .thenStateShouldEqual(expectedQuery); }); it('Should not change state with other action types', () => { const initialState: ElasticsearchDataQuery['query'] = 'Some lucene query'; reducerTester<ElasticsearchDataQuery['query']>() .givenReducer(queryReducer, initialState) .whenActionIsDispatched({ type: 'THIS ACTION SHOULD NOT HAVE ANY EFFECT IN THIS REDUCER' }) .thenStateShouldEqual(initialState); }); }); describe('Alias Pattern Reducer', () => { it('Should correctly set `alias`', () => { const expectedAlias: ElasticsearchDataQuery['alias'] = 'Some alias pattern'; reducerTester<ElasticsearchDataQuery['query']>() .givenReducer(aliasPatternReducer, '') .whenActionIsDispatched(changeAliasPattern(expectedAlias)) .thenStateShouldEqual(expectedAlias); }); it('Should not change state with other action types', () => { const initialState: ElasticsearchDataQuery['alias'] = 'Some alias pattern'; reducerTester<ElasticsearchDataQuery['query']>() .givenReducer(aliasPatternReducer, initialState) .whenActionIsDispatched({ type: 'THIS ACTION SHOULD NOT HAVE ANY EFFECT IN THIS REDUCER' }) .thenStateShouldEqual(initialState); }); });
.
Edit
..
Edit
AnnotationQueryEditor.tsx
Edit
BucketAggregationsEditor
Edit
ElasticsearchQueryContext.test.tsx
Edit
ElasticsearchQueryContext.tsx
Edit
MetricAggregationsEditor
Edit
QueryEditorRow.tsx
Edit
QueryEditorSpecialMetricRow.tsx
Edit
QueryTypeSelector.tsx
Edit
SettingsEditorContainer.tsx
Edit
index.test.tsx
Edit
index.tsx
Edit
state.test.ts
Edit
state.ts
Edit
styles.ts
Edit