mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 09:05:45 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import React from 'react';
|
|
|
|
import { getDefaultTimeRange, MutableDataFrame } from '@grafana/data';
|
|
|
|
import { ExploreId } from '../../types';
|
|
|
|
import { UnconnectedNodeGraphContainer } from './NodeGraphContainer';
|
|
|
|
describe('NodeGraphContainer', () => {
|
|
it('is collapsed if shown with traces', () => {
|
|
const { container } = render(
|
|
<UnconnectedNodeGraphContainer
|
|
dataFrames={[emptyFrame]}
|
|
exploreId={ExploreId.left}
|
|
range={getDefaultTimeRange()}
|
|
splitOpen={(() => {}) as any}
|
|
withTraceView={true}
|
|
/>
|
|
);
|
|
|
|
// Make sure we only show header in the collapsible
|
|
expect(container.firstChild?.childNodes.length).toBe(1);
|
|
});
|
|
|
|
it('shows the graph if not with trace view', async () => {
|
|
const { container } = render(
|
|
<UnconnectedNodeGraphContainer
|
|
dataFrames={[nodes]}
|
|
exploreId={ExploreId.left}
|
|
range={getDefaultTimeRange()}
|
|
splitOpen={(() => {}) as any}
|
|
/>
|
|
);
|
|
|
|
expect(container.firstChild?.childNodes.length).toBe(2);
|
|
expect(container.querySelector('svg')).toBeInTheDocument();
|
|
await screen.findByLabelText(/Node: tempo-querier/);
|
|
});
|
|
});
|
|
|
|
const emptyFrame = new MutableDataFrame();
|
|
|
|
const nodes = new MutableDataFrame({
|
|
fields: toFields([
|
|
['id', ['3fa414edcef6ad90']],
|
|
['title', ['tempo-querier']],
|
|
['subTitle', ['HTTP GET - api_traces_traceid']],
|
|
['mainStat', ['1049.14ms (100%)']],
|
|
['secondaryStat', ['1047.29ms (99.82%)']],
|
|
['color', [0.9982395121342127]],
|
|
]),
|
|
});
|
|
|
|
function toFields(fields: Array<[string, any[]]>) {
|
|
return fields.map(([name, values]) => {
|
|
return { name, values };
|
|
});
|
|
}
|