mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
Existing querying was grouped together before handed over to the datasource. This slowed down result display to however long the slowest query took. - create one query transaction per result viewer (graph, table, etc.) and query row - track latencies for each transaction - show results as soon as they are being received - loading indicator on graph and query button to indicate that queries are still running and that results are incomplete - properly discard transactions when removing or changing queries
48 lines
1.0 KiB
TypeScript
48 lines
1.0 KiB
TypeScript
import React from 'react';
|
|
import { shallow } from 'enzyme';
|
|
import { Graph } from './Graph';
|
|
import { mockData } from './__mocks__/mockData';
|
|
|
|
const setup = (propOverrides?: object) => {
|
|
const props = {
|
|
data: mockData().slice(0, 19),
|
|
range: { from: 'now-6h', to: 'now' },
|
|
...propOverrides,
|
|
};
|
|
|
|
// Enzyme.shallow did not work well with jquery.flop. Mocking the draw function.
|
|
Graph.prototype.draw = jest.fn();
|
|
|
|
const wrapper = shallow(<Graph {...props} />);
|
|
const instance = wrapper.instance() as Graph;
|
|
|
|
return {
|
|
wrapper,
|
|
instance,
|
|
};
|
|
};
|
|
|
|
describe('Render', () => {
|
|
it('should render component', () => {
|
|
const { wrapper } = setup();
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render component with disclaimer', () => {
|
|
const { wrapper } = setup({
|
|
data: mockData(),
|
|
});
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
it('should show query return no time series', () => {
|
|
const { wrapper } = setup({
|
|
data: [],
|
|
});
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
});
|