mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Add scopedVars support in legend formatting for repeated variables (#27046)
* Pass scoped vars to createMetricLabel * Add tests * Refacotr * Update tests * Update test
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { CircularDataFrame, FieldCache, FieldType, MutableDataFrame } from '@grafana/data';
|
||||
import { LokiStreamResult, LokiTailResponse, LokiStreamResponse, LokiResultType } from './types';
|
||||
import { LokiStreamResult, LokiTailResponse, LokiStreamResponse, LokiResultType, TransformerOptions } from './types';
|
||||
import * as ResultTransformer from './result_transformer';
|
||||
import { enhanceDataFrame } from './result_transformer';
|
||||
|
||||
@@ -114,6 +114,15 @@ describe('loki result transformer', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('createMetricLabel', () => {
|
||||
it('should create correct label based on passed variables', () => {
|
||||
const label = ResultTransformer.createMetricLabel({}, ({
|
||||
scopedVars: { testLabel: { selected: true, text: 'label1', value: 'label1' } },
|
||||
legendFormat: '{{$testLabel}}',
|
||||
} as unknown) as TransformerOptions);
|
||||
expect(label).toBe('label1');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('enhanceDataFrame', () => {
|
||||
|
||||
Reference in New Issue
Block a user