Combine responses: do not combine frames with different names (#90464)

This commit is contained in:
Matias Chomicki 2024-07-16 15:34:08 +02:00 committed by GitHub
parent 1ee9df8ac6
commit 8547148623
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 1 deletions

View File

@ -495,6 +495,36 @@ describe('combineResponses', () => {
expect(combineResponses(responseA, responseB).data[0].meta.stats).toHaveLength(0);
});
});
it('does not combine frames with different refId', () => {
const { metricFrameA, metricFrameB } = getMockFrames();
metricFrameA.refId = 'A';
metricFrameB.refId = 'B';
const responseA: DataQueryResponse = {
data: [metricFrameA],
};
const responseB: DataQueryResponse = {
data: [metricFrameB],
};
expect(combineResponses(responseA, responseB)).toEqual({
data: [metricFrameA, metricFrameB],
});
});
it('does not combine frames with different refId', () => {
const { metricFrameA, metricFrameB } = getMockFrames();
metricFrameA.name = 'A';
metricFrameB.name = 'B';
const responseA: DataQueryResponse = {
data: [metricFrameA],
};
const responseB: DataQueryResponse = {
data: [metricFrameB],
};
expect(combineResponses(responseA, responseB)).toEqual({
data: [metricFrameA, metricFrameB],
});
});
});
describe('combinePanelData', () => {

View File

@ -130,7 +130,7 @@ function cloneDataFrame(frame: DataQueryResponseData): DataQueryResponseData {
}
function shouldCombine(frame1: DataFrame, frame2: DataFrame): boolean {
if (frame1.refId !== frame2.refId) {
if (frame1.refId !== frame2.refId || frame1.name !== frame2.name) {
return false;
}