@@ -10,8 +10,9 @@ import {
1010import {
1111 ChartKeyJoiner ,
1212 convertToNumberChartConfig ,
13- convertToPromqlNumberChartConfig ,
13+ convertToPromqlSparklineChartConfig ,
1414 convertToPromqlTableChartConfig ,
15+ convertToReducedPromqlChartConfig ,
1516 convertToTableChartConfig ,
1617 convertToTimeChartConfig ,
1718 findNearestSeriesKey ,
@@ -1318,7 +1319,7 @@ describe('ChartUtils', () => {
13181319 } ) ;
13191320 } ) ;
13201321
1321- describe ( 'convertToPromqlNumberChartConfig ' , ( ) => {
1322+ describe ( 'convertToReducedPromqlChartConfig and convertToPromqlSparklineChartConfig ' , ( ) => {
13221323 const promqlConfig = {
13231324 configType : 'promql' as const ,
13241325 displayType : DisplayType . Number ,
@@ -1337,9 +1338,7 @@ describe('ChartUtils', () => {
13371338 // unresolved step puts the samples between the buckets the sparkline plots
13381339 // on -- which the empty-bucket filler then fills with zeros.
13391340 it ( 'aligns the date range and resolves the granularity' , ( ) => {
1340- const result = convertToPromqlNumberChartConfig ( promqlConfig , {
1341- withReducer : true ,
1342- } ) ;
1341+ const result = convertToReducedPromqlChartConfig ( promqlConfig ) ;
13431342
13441343 expect ( result . dateRange ) . toEqual ( [
13451344 new Date ( '2025-11-26T00:00:00Z' ) ,
@@ -1349,17 +1348,14 @@ describe('ChartUtils', () => {
13491348 } ) ;
13501349
13511350 it ( 'leaves the date range unaligned for an instant query' , ( ) => {
1352- const result = convertToPromqlNumberChartConfig (
1353- {
1354- ...promqlConfig ,
1355- promqlExpression : [ { expression : 'up' , queryType : 'instant' } ] ,
1356- dateRange : [
1357- new Date ( '2025-11-26T00:00:14.076Z' ) ,
1358- new Date ( '2025-11-27T00:00:14.076Z' ) ,
1359- ] ,
1360- } ,
1361- { withReducer : true } ,
1362- ) ;
1351+ const result = convertToReducedPromqlChartConfig ( {
1352+ ...promqlConfig ,
1353+ promqlExpression : [ { expression : 'up' , queryType : 'instant' } ] ,
1354+ dateRange : [
1355+ new Date ( '2025-11-26T00:00:14.076Z' ) ,
1356+ new Date ( '2025-11-27T00:00:14.076Z' ) ,
1357+ ] ,
1358+ } ) ;
13631359
13641360 expect ( result . dateRange ) . toEqual ( [
13651361 new Date ( '2025-11-26T00:00:14.076Z' ) ,
@@ -1369,9 +1365,7 @@ describe('ChartUtils', () => {
13691365 } ) ;
13701366
13711367 it ( 'names the reducer, defaulting it, and queries one expression' , ( ) => {
1372- const result = convertToPromqlNumberChartConfig ( promqlConfig , {
1373- withReducer : true ,
1374- } ) ;
1368+ const result = convertToReducedPromqlChartConfig ( promqlConfig ) ;
13751369
13761370 expect ( result ) . toEqual (
13771371 expect . objectContaining ( {
@@ -1387,19 +1381,16 @@ describe('ChartUtils', () => {
13871381 } ) ;
13881382
13891383 it ( 'keeps a chosen reducer' , ( ) => {
1390- const result = convertToPromqlNumberChartConfig (
1391- {
1392- ...promqlConfig ,
1393- promqlExpression : [
1394- {
1395- expression : 'up' ,
1396- queryType : 'range' as const ,
1397- reducer : PromqlReducer . Max ,
1398- } ,
1399- ] ,
1400- } ,
1401- { withReducer : true } ,
1402- ) ;
1384+ const result = convertToReducedPromqlChartConfig ( {
1385+ ...promqlConfig ,
1386+ promqlExpression : [
1387+ {
1388+ expression : 'up' ,
1389+ queryType : 'range' as const ,
1390+ reducer : PromqlReducer . Max ,
1391+ } ,
1392+ ] ,
1393+ } ) ;
14031394
14041395 expect ( result ) . toEqual (
14051396 expect . objectContaining ( {
@@ -1417,12 +1408,8 @@ describe('ChartUtils', () => {
14171408 // Without a reducer named, the hook leaves the buckets alone -- which is
14181409 // how the sparkline reads the same response as the value.
14191410 it ( 'names no reducer for the sparkline, otherwise matching the value' , ( ) => {
1420- const value = convertToPromqlNumberChartConfig ( promqlConfig , {
1421- withReducer : true ,
1422- } ) ;
1423- const sparkline = convertToPromqlNumberChartConfig ( promqlConfig , {
1424- withReducer : false ,
1425- } ) ;
1411+ const value = convertToReducedPromqlChartConfig ( promqlConfig ) ;
1412+ const sparkline = convertToPromqlSparklineChartConfig ( promqlConfig ) ;
14261413
14271414 expect ( sparkline ) . toEqual ( {
14281415 ...value ,
0 commit comments