mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Flamegraph * Updated flame graph width/height values * Fix top table rendering issue * Add feature toggle for flamegraph in explore * Update tests * Hide flamegraph from dash panel viz list if feature toggle not enabled * Show table if no flameGraphFrames * Add flame graph to testdata ds * Minor improvement
87 lines
2.1 KiB
TypeScript
87 lines
2.1 KiB
TypeScript
import { ArrayVector, Field, FieldType } from '@grafana/data';
|
|
|
|
import { getTooltipData } from './FlameGraphTooltip';
|
|
|
|
describe('should get tooltip data correctly', () => {
|
|
it('for bytes', () => {
|
|
const tooltipData = getTooltipData(makeField('bytes'), 'total', 8_624_078_250, 8_624_078_250);
|
|
expect(tooltipData).toEqual({
|
|
name: 'total',
|
|
percentTitle: '% of total',
|
|
percentValue: 100,
|
|
unitTitle: 'RAM',
|
|
unitValue: '8.03 GiB',
|
|
samples: '8,624,078,250',
|
|
});
|
|
});
|
|
|
|
it('with none unit', () => {
|
|
const tooltipData = getTooltipData(makeField('none'), 'total', 8_624_078_250, 8_624_078_250);
|
|
expect(tooltipData).toEqual({
|
|
name: 'total',
|
|
percentTitle: '% of total',
|
|
percentValue: 100,
|
|
unitTitle: 'Count',
|
|
unitValue: '8624078250',
|
|
samples: '8,624,078,250',
|
|
});
|
|
});
|
|
|
|
it('without unit', () => {
|
|
const tooltipData = getTooltipData(
|
|
{
|
|
name: 'test',
|
|
type: FieldType.number,
|
|
values: new ArrayVector(),
|
|
config: {},
|
|
},
|
|
'total',
|
|
8_624_078_250,
|
|
8_624_078_250
|
|
);
|
|
expect(tooltipData).toEqual({
|
|
name: 'total',
|
|
percentTitle: '% of total',
|
|
percentValue: 100,
|
|
unitTitle: 'Count',
|
|
unitValue: '8624078250',
|
|
samples: '8,624,078,250',
|
|
});
|
|
});
|
|
|
|
it('for objects', () => {
|
|
const tooltipData = getTooltipData(makeField('short'), 'total', 8_624_078_250, 8_624_078_250);
|
|
expect(tooltipData).toEqual({
|
|
name: 'total',
|
|
percentTitle: '% of total',
|
|
percentValue: 100,
|
|
unitTitle: 'Count',
|
|
unitValue: '8.62 Bil',
|
|
samples: '8,624,078,250',
|
|
});
|
|
});
|
|
|
|
it('for nanoseconds', () => {
|
|
const tooltipData = getTooltipData(makeField('ns'), 'total', 8_624_078_250, 8_624_078_250);
|
|
expect(tooltipData).toEqual({
|
|
name: 'total',
|
|
percentTitle: '% of total time',
|
|
percentValue: 100,
|
|
unitTitle: 'Time',
|
|
unitValue: '8.62 s',
|
|
samples: '8,624,078,250',
|
|
});
|
|
});
|
|
});
|
|
|
|
function makeField(unit: string): Field {
|
|
return {
|
|
name: 'test',
|
|
type: FieldType.number,
|
|
config: {
|
|
unit,
|
|
},
|
|
values: new ArrayVector(),
|
|
};
|
|
}
|