|
|
@@ -10,7 +10,6 @@ import {
|
|
|
ExploreItemState,
|
|
|
ExploreUrlState,
|
|
|
ExploreState,
|
|
|
- QueryTransaction,
|
|
|
RangeScanner,
|
|
|
ExploreMode,
|
|
|
} from 'app/types/explore';
|
|
|
@@ -25,6 +24,7 @@ import {
|
|
|
splitOpenAction,
|
|
|
splitCloseAction,
|
|
|
changeModeAction,
|
|
|
+ runQueriesAction,
|
|
|
} from './actionTypes';
|
|
|
import { Reducer } from 'redux';
|
|
|
import { ActionOf } from 'app/core/redux/actionCreatorFactory';
|
|
|
@@ -36,7 +36,7 @@ import { DataSourceApi, DataQuery } from '@grafana/ui';
|
|
|
|
|
|
describe('Explore item reducer', () => {
|
|
|
describe('scanning', () => {
|
|
|
- test('should start scanning', () => {
|
|
|
+ it('should start scanning', () => {
|
|
|
const scanner = jest.fn();
|
|
|
const initalState = {
|
|
|
...makeExploreItemState(),
|
|
|
@@ -53,7 +53,7 @@ describe('Explore item reducer', () => {
|
|
|
scanner,
|
|
|
});
|
|
|
});
|
|
|
- test('should stop scanning', () => {
|
|
|
+ it('should stop scanning', () => {
|
|
|
const scanner = jest.fn();
|
|
|
const initalState = {
|
|
|
...makeExploreItemState(),
|
|
|
@@ -96,7 +96,6 @@ describe('Explore item reducer', () => {
|
|
|
describe('when testDataSourceFailureAction is dispatched', () => {
|
|
|
it('then it should set correct state', () => {
|
|
|
const error = 'some error';
|
|
|
- const queryTransactions: QueryTransaction[] = [];
|
|
|
const initalState: Partial<ExploreItemState> = {
|
|
|
datasourceError: null,
|
|
|
graphResult: [],
|
|
|
@@ -111,7 +110,6 @@ describe('Explore item reducer', () => {
|
|
|
};
|
|
|
const expectedState = {
|
|
|
datasourceError: error,
|
|
|
- queryTransactions,
|
|
|
graphResult: undefined as any[],
|
|
|
tableResult: undefined as TableModel,
|
|
|
logsResult: undefined as LogsModel,
|
|
|
@@ -144,9 +142,9 @@ describe('Explore item reducer', () => {
|
|
|
const StartPage = {};
|
|
|
const datasourceInstance = {
|
|
|
meta: {
|
|
|
- metrics: {},
|
|
|
- logs: {},
|
|
|
- tables: {},
|
|
|
+ metrics: true,
|
|
|
+ logs: true,
|
|
|
+ tables: true,
|
|
|
},
|
|
|
components: {
|
|
|
ExploreStartPage: StartPage,
|
|
|
@@ -175,6 +173,11 @@ describe('Explore item reducer', () => {
|
|
|
queryKeys,
|
|
|
supportedModes: [ExploreMode.Metrics, ExploreMode.Logs],
|
|
|
mode: ExploreMode.Metrics,
|
|
|
+ graphIsLoading: false,
|
|
|
+ tableIsLoading: false,
|
|
|
+ logIsLoading: false,
|
|
|
+ latency: 0,
|
|
|
+ queryErrors: [],
|
|
|
};
|
|
|
|
|
|
reducerTester()
|
|
|
@@ -185,6 +188,28 @@ describe('Explore item reducer', () => {
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ describe('run queries', () => {
|
|
|
+ describe('when runQueriesAction is dispatched', () => {
|
|
|
+ it('then it should set correct state', () => {
|
|
|
+ const initalState: Partial<ExploreItemState> = {
|
|
|
+ showingStartPage: true,
|
|
|
+ };
|
|
|
+ const expectedState = {
|
|
|
+ queryIntervals: {
|
|
|
+ interval: '1s',
|
|
|
+ intervalMs: 1000,
|
|
|
+ },
|
|
|
+ showingStartPage: false,
|
|
|
+ };
|
|
|
+
|
|
|
+ reducerTester()
|
|
|
+ .givenReducer(itemReducer, initalState)
|
|
|
+ .whenActionIsDispatched(runQueriesAction({ exploreId: ExploreId.left }))
|
|
|
+ .thenStateShouldEqual(expectedState);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
export const setup = (urlStateOverrides?: any) => {
|
|
|
@@ -529,46 +554,8 @@ describe('Explore reducer', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe('and refreshInterval differs', () => {
|
|
|
- it('then it should return update refreshInterval', () => {
|
|
|
- const { initalState, serializedUrlState } = setup();
|
|
|
- const expectedState = {
|
|
|
- ...initalState,
|
|
|
- left: {
|
|
|
- ...initalState.left,
|
|
|
- update: {
|
|
|
- ...initalState.left.update,
|
|
|
- refreshInterval: true,
|
|
|
- },
|
|
|
- },
|
|
|
- };
|
|
|
- const stateWithDifferentDataSource = {
|
|
|
- ...initalState,
|
|
|
- left: {
|
|
|
- ...initalState.left,
|
|
|
- urlState: {
|
|
|
- ...initalState.left.urlState,
|
|
|
- refreshInterval: '5s',
|
|
|
- },
|
|
|
- },
|
|
|
- };
|
|
|
-
|
|
|
- reducerTester()
|
|
|
- .givenReducer(exploreReducer, stateWithDifferentDataSource)
|
|
|
- .whenActionIsDispatched(
|
|
|
- updateLocation({
|
|
|
- query: {
|
|
|
- left: serializedUrlState,
|
|
|
- },
|
|
|
- path: '/explore',
|
|
|
- })
|
|
|
- )
|
|
|
- .thenStateShouldEqual(expectedState);
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
describe('and nothing differs', () => {
|
|
|
- fit('then it should return update ui', () => {
|
|
|
+ it('then it should return update ui', () => {
|
|
|
const { initalState, serializedUrlState } = setup();
|
|
|
const expectedState = { ...initalState };
|
|
|
|