2020-03-11 04:01:58 -05:00
|
|
|
import React from 'react';
|
2021-08-13 01:02:49 -05:00
|
|
|
import {
|
|
|
|
DataSourceApi,
|
|
|
|
LoadingState,
|
|
|
|
toUtc,
|
|
|
|
DataQueryError,
|
|
|
|
DataQueryRequest,
|
|
|
|
CoreApp,
|
|
|
|
createTheme,
|
|
|
|
} from '@grafana/data';
|
2020-03-11 04:01:58 -05:00
|
|
|
import { ExploreId } from 'app/types/explore';
|
|
|
|
import { shallow } from 'enzyme';
|
2021-06-22 04:43:13 -05:00
|
|
|
import { Explore, Props } from './Explore';
|
2020-11-09 07:48:24 -06:00
|
|
|
import { scanStopAction } from './state/query';
|
2020-04-02 06:34:16 -05:00
|
|
|
import { SecondaryActions } from './SecondaryActions';
|
2020-03-11 04:01:58 -05:00
|
|
|
|
2021-06-22 04:43:13 -05:00
|
|
|
const dummyProps: Props = {
|
|
|
|
logsResult: undefined,
|
2020-04-02 06:34:16 -05:00
|
|
|
changeSize: jest.fn(),
|
|
|
|
datasourceInstance: {
|
|
|
|
meta: {
|
|
|
|
metrics: true,
|
|
|
|
logs: true,
|
2020-03-11 04:01:58 -05:00
|
|
|
},
|
2020-04-02 06:34:16 -05:00
|
|
|
components: {
|
2021-01-19 16:52:09 -06:00
|
|
|
QueryEditorHelp: {},
|
2020-03-11 04:01:58 -05:00
|
|
|
},
|
2020-04-02 06:34:16 -05:00
|
|
|
} as DataSourceApi,
|
|
|
|
datasourceMissing: false,
|
|
|
|
exploreId: ExploreId.left,
|
2021-01-22 11:15:06 -06:00
|
|
|
loading: false,
|
2020-04-02 06:34:16 -05:00
|
|
|
modifyQueries: jest.fn(),
|
|
|
|
scanStart: jest.fn(),
|
|
|
|
scanStopAction: scanStopAction,
|
|
|
|
setQueries: jest.fn(),
|
|
|
|
queryKeys: [],
|
|
|
|
isLive: false,
|
|
|
|
syncedTimes: false,
|
|
|
|
updateTimeRange: jest.fn(),
|
|
|
|
graphResult: [],
|
|
|
|
absoluteRange: {
|
|
|
|
from: 0,
|
|
|
|
to: 0,
|
|
|
|
},
|
|
|
|
timeZone: 'UTC',
|
|
|
|
queryResponse: {
|
|
|
|
state: LoadingState.NotStarted,
|
|
|
|
series: [],
|
|
|
|
request: ({
|
|
|
|
requestId: '1',
|
|
|
|
dashboardId: 0,
|
|
|
|
interval: '1s',
|
|
|
|
panelId: 1,
|
|
|
|
scopedVars: {
|
|
|
|
apps: {
|
|
|
|
value: 'value',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targets: [
|
|
|
|
{
|
|
|
|
refId: 'A',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
timezone: 'UTC',
|
|
|
|
app: CoreApp.Explore,
|
|
|
|
startTime: 0,
|
|
|
|
} as unknown) as DataQueryRequest,
|
|
|
|
error: {} as DataQueryError,
|
|
|
|
timeRange: {
|
2020-03-11 04:01:58 -05:00
|
|
|
from: toUtc('2019-01-01 10:00:00'),
|
|
|
|
to: toUtc('2019-01-01 16:00:00'),
|
|
|
|
raw: {
|
|
|
|
from: 'now-6h',
|
|
|
|
to: 'now',
|
|
|
|
},
|
|
|
|
},
|
2020-04-02 06:34:16 -05:00
|
|
|
},
|
|
|
|
addQueryRow: jest.fn(),
|
2021-08-13 01:02:49 -05:00
|
|
|
theme: createTheme(),
|
2020-07-09 09:14:55 -05:00
|
|
|
showMetrics: true,
|
|
|
|
showLogs: true,
|
|
|
|
showTable: true,
|
|
|
|
showTrace: true,
|
2021-01-19 09:34:43 -06:00
|
|
|
showNodeGraph: true,
|
2020-10-14 17:03:14 -05:00
|
|
|
splitOpen: (() => {}) as any,
|
2021-09-30 08:46:11 -05:00
|
|
|
logsVolumeData: undefined,
|
|
|
|
loadLogsVolumeData: () => {},
|
2020-03-11 04:01:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
describe('Explore', () => {
|
|
|
|
it('should render component', () => {
|
2020-04-16 07:28:46 -05:00
|
|
|
const wrapper = shallow(<Explore {...dummyProps} />);
|
2020-03-11 04:01:58 -05:00
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2020-04-02 06:34:16 -05:00
|
|
|
it('renders SecondaryActions and add row button', () => {
|
|
|
|
const wrapper = shallow(<Explore {...dummyProps} />);
|
|
|
|
expect(wrapper.find(SecondaryActions)).toHaveLength(1);
|
|
|
|
expect(wrapper.find(SecondaryActions).props().addQueryRowButtonHidden).toBe(false);
|
|
|
|
});
|
2020-03-11 04:01:58 -05:00
|
|
|
});
|