mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Add GraphView component * Add service map panel * Add more metadata visuals * Add context menu on click * Add context menu for services * Fix service map in dashboard * Add field proxy in explore linkSupplier * Refactor the link creation * Remove test file * Fix scale change when view is panned * Fix node centering * Don't show context menu if no links * Fix service map containers * Add collapsible around the service map * Fix stats computation * Remove debug log * Fix time stats * Allow string timestamp * Make panning bounded * Add zooming by mouse wheel * Clean up the colors * Fix stats for single trace graph * Don't show debug config * Add more complex layout * Update layout with better fixing of the root nodes * Code cleanup * Change how we pass in link creation function and some more cleanup * Refactor the panel section into separate render methods * Make the edge hover more readable * Move stats computation to data source * Put edge labels to front * Simplify layout for better multi graph layout * Update for dark theme * Move function to utils * Visual improvements * Improve context menu detail * Allow custom details * Rename to NodeGraph * Remove unused dependencies * Use named color palette and add some fallbacks for missing data * Add test data scenario * Rename plugin * Switch scroll zoom direction to align with google maps * Do some perf optimisations and rise the node limit * Update alert styling * Rename function * Add tests * Add more tests * Change data frame column mapping to use column names * Fix test * Fix type errors * Don't show context menu without links * Add beta status to panel * Fix tests * Changed function to standard methods * Fix typing * Clean up yarn.lock * Add some UI improvements - better styling of the zoom buttons - disable buttons when max reached * Fix panel references after rename * Add panel icon
147 lines
3.6 KiB
TypeScript
147 lines
3.6 KiB
TypeScript
import React from 'react';
|
|
import { DataSourceApi, LoadingState, toUtc, DataQueryError, DataQueryRequest, CoreApp } from '@grafana/data';
|
|
import { getFirstNonQueryRowSpecificError } from 'app/core/utils/explore';
|
|
import { ExploreId } from 'app/types/explore';
|
|
import { shallow } from 'enzyme';
|
|
import { Explore, ExploreProps } from './Explore';
|
|
import { scanStopAction } from './state/query';
|
|
import { SecondaryActions } from './SecondaryActions';
|
|
import { getTheme } from '@grafana/ui';
|
|
|
|
const dummyProps: ExploreProps = {
|
|
changeSize: jest.fn(),
|
|
datasourceInstance: {
|
|
meta: {
|
|
metrics: true,
|
|
logs: true,
|
|
},
|
|
components: {
|
|
ExploreStartPage: {},
|
|
},
|
|
} as DataSourceApi,
|
|
datasourceMissing: false,
|
|
exploreId: ExploreId.left,
|
|
initializeExplore: jest.fn(),
|
|
initialized: true,
|
|
modifyQueries: jest.fn(),
|
|
update: {
|
|
datasource: false,
|
|
queries: false,
|
|
range: false,
|
|
mode: false,
|
|
},
|
|
refreshExplore: jest.fn(),
|
|
scanning: false,
|
|
scanRange: {
|
|
from: '0',
|
|
to: '0',
|
|
},
|
|
scanStart: jest.fn(),
|
|
scanStopAction: scanStopAction,
|
|
setQueries: jest.fn(),
|
|
split: false,
|
|
queryKeys: [],
|
|
initialDatasource: 'test',
|
|
initialQueries: [],
|
|
initialRange: {
|
|
from: toUtc('2019-01-01 10:00:00'),
|
|
to: toUtc('2019-01-01 16:00:00'),
|
|
raw: {
|
|
from: 'now-6h',
|
|
to: 'now',
|
|
},
|
|
},
|
|
isLive: false,
|
|
syncedTimes: false,
|
|
updateTimeRange: jest.fn(),
|
|
graphResult: [],
|
|
absoluteRange: {
|
|
from: 0,
|
|
to: 0,
|
|
},
|
|
timeZone: 'UTC',
|
|
onHiddenSeriesChanged: jest.fn(),
|
|
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: {
|
|
from: toUtc('2019-01-01 10:00:00'),
|
|
to: toUtc('2019-01-01 16:00:00'),
|
|
raw: {
|
|
from: 'now-6h',
|
|
to: 'now',
|
|
},
|
|
},
|
|
},
|
|
originPanelId: 1,
|
|
addQueryRow: jest.fn(),
|
|
theme: getTheme(),
|
|
showMetrics: true,
|
|
showLogs: true,
|
|
showTable: true,
|
|
showTrace: true,
|
|
showNodeGraph: true,
|
|
splitOpen: (() => {}) as any,
|
|
};
|
|
|
|
const setupErrors = (hasRefId?: boolean) => {
|
|
return [
|
|
{
|
|
message: 'Error message',
|
|
status: '400',
|
|
statusText: 'Bad Request',
|
|
refId: hasRefId ? 'A' : '',
|
|
},
|
|
];
|
|
};
|
|
|
|
describe('Explore', () => {
|
|
it('should render component', () => {
|
|
const wrapper = shallow(<Explore {...dummyProps} />);
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
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);
|
|
});
|
|
|
|
it('should filter out a query-row-specific error when looking for non-query-row-specific errors', async () => {
|
|
const queryErrors = setupErrors(true);
|
|
const queryError = getFirstNonQueryRowSpecificError(queryErrors);
|
|
expect(queryError).toBeUndefined();
|
|
});
|
|
|
|
it('should not filter out a generic error when looking for non-query-row-specific errors', async () => {
|
|
const queryErrors = setupErrors();
|
|
const queryError = getFirstNonQueryRowSpecificError(queryErrors);
|
|
expect(queryError).toEqual({
|
|
message: 'Error message',
|
|
status: '400',
|
|
statusText: 'Bad Request',
|
|
refId: '',
|
|
});
|
|
});
|
|
});
|