Commit e6e8611d by Torkel Ödegaard Committed by GitHub

Explore: Fixed issue in PanelQuery state arround cancellation (#18771)

* Explore: Fixed issue in PanelQuery state arround cancellation

* Added unit test

* Fixed typescript issues in test
parent 22c9575a
import { toDataQueryError, PanelQueryState, getProcessedDataFrames } from './PanelQueryState';
import { MockDataSourceApi } from 'test/mocks/datasource_srv';
import { LoadingState, getDataFrameRow } from '@grafana/data';
import { DataQueryResponse } from '@grafana/ui';
import { DataQueryResponse, DataQueryRequest, DataQuery } from '@grafana/ui';
import { getQueryOptions } from 'test/helpers/getQueryOptions';
describe('PanelQueryState', () => {
......@@ -54,6 +54,19 @@ describe('PanelQueryState', () => {
});
});
describe('When cancelling request', () => {
it('Should call rejector', () => {
const state = new PanelQueryState();
state.request = {} as DataQueryRequest<DataQuery>;
(state as any).rejector = (obj: any) => {
expect(obj.cancelled).toBe(true);
expect(obj.message).toBe('OHH');
};
state.cancel('OHH');
});
});
describe('getProcessedDataFrame', () => {
it('converts timeseries to table skipping nulls', () => {
const input1 = {
......
......@@ -79,7 +79,7 @@ export class PanelQueryState {
// call rejector to reject the executor promise
if (!request.endTime) {
request.endTime = Date.now();
this.rejector('Canceled:' + reason);
this.rejector({ cancelled: true, message: reason });
}
// Cancel any open HTTP request with the same ID
......
......@@ -62,6 +62,7 @@ export default class QueryEditor extends PureComponent<QueryEditorProps, any> {
this.component = loader.load(this.element, scopeProps, template);
this.angularScope = scopeProps.ctrl;
setTimeout(() => {
this.props.onQueryChange(target);
this.props.onExecuteQuery();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment