QueryEditor: Fix setting panel state to done if query had no error (#45453)

This commit is contained in:
Zoltán Bedi 2022-02-16 11:48:22 +01:00 committed by GitHub
parent 78deffb2e0
commit da91c93f4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -74,4 +74,21 @@ describe('filterPanelDataToQuery', () => {
expect(panelDataA?.series[0].refId).toBe('A');
expect(panelDataA?.state).toBe(LoadingState.Done);
});
it('should not set the state to done if the frame is loading and has no errors', () => {
const loadingData: PanelData = {
state: LoadingState.Loading,
series: [
toDataFrame({ refId: 'A', fields: [{ name: 'AAA' }], meta: {} }),
toDataFrame({ refId: 'B', fields: [{ name: 'B111' }], meta: {} }),
],
timeRange: { from: dateTime(), to: dateTime(), raw: { from: 'now-1d', to: 'now' } },
};
const panelDataB = filterPanelDataToQuery(loadingData, 'B');
expect(panelDataB?.state).toBe(LoadingState.Loading);
const panelDataA = filterPanelDataToQuery(loadingData, 'A');
expect(panelDataA?.state).toBe(LoadingState.Loading);
});
});

View File

@ -480,7 +480,7 @@ export function filterPanelDataToQuery(data: PanelData, refId: string): PanelDat
const error = data.error && data.error.refId === refId ? data.error : undefined;
if (error) {
state = LoadingState.Error;
} else {
} else if (!error && data.state === LoadingState.Error) {
state = LoadingState.Done;
}