Explore: table result should not override display property (#27411)

This commit is contained in:
Zoltán Bedi 2020-09-08 11:04:25 +02:00 committed by GitHub
parent 10141c5e6c
commit 09c9571462
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 5 deletions

View File

@ -197,6 +197,24 @@ describe('ResultProcessor', () => {
expect(result.fields[1].values.toArray()).toEqual([4, 5, 6]);
expect(result.fields[2].values.toArray()).toEqual([4, 5, 6]);
});
it('should not override fields display property when filled', () => {
const { resultProcessor, dataFrames } = testContext({
dataFrames: [
toDataFrame({
name: 'A-series',
refId: 'A',
fields: [{ name: 'Text', type: FieldType.string, values: ['someText'] }],
}),
],
});
const displayFunctionMock = jest.fn();
dataFrames[0].fields[0].display = displayFunctionMock;
const data = resultProcessor.getTableResult();
expect(data?.fields[0].display).toBe(displayFunctionMock);
});
});
describe('when calling getLogsResult', () => {

View File

@ -99,11 +99,13 @@ export class ResultProcessor {
// set display processor
for (const field of data.fields) {
field.display = getDisplayProcessor({
field,
theme: config.theme,
timeZone: this.timeZone,
});
field.display =
field.display ??
getDisplayProcessor({
field,
theme: config.theme,
timeZone: this.timeZone,
});
}
return data;