@@ -74,15 +74,26 @@ describe('useChartConfig', () => {
7474 expect (
7575 getGranularityAlignedTimeWindows ( {
7676 granularity : '1 hour' ,
77- } ) ,
77+ timestampValueExpression : 'TimestampTime' ,
78+ } as ChartConfigWithOptDateRange ) ,
7879 ) . toEqual ( [ undefined ] ) ;
7980 } ) ;
8081
8182 it ( 'returns [undefined] if no granularity is provided' , ( ) => {
8283 expect (
8384 getGranularityAlignedTimeWindows ( {
8485 dateRange : [ new Date ( '2023-01-01' ) , new Date ( '2023-01-02' ) ] ,
85- } ) ,
86+ timestampValueExpression : 'TimestampTime' ,
87+ } as ChartConfigWithOptDateRange ) ,
88+ ) . toEqual ( [ undefined ] ) ;
89+ } ) ;
90+
91+ it ( 'returns [undefined] if no timestampValueExpression is provided' , ( ) => {
92+ expect (
93+ getGranularityAlignedTimeWindows ( {
94+ dateRange : [ new Date ( '2023-01-01' ) , new Date ( '2023-01-02' ) ] ,
95+ granularity : '1 hour' ,
96+ } as ChartConfigWithOptDateRange ) ,
8697 ) . toEqual ( [ undefined ] ) ;
8798 } ) ;
8899
@@ -95,7 +106,8 @@ describe('useChartConfig', () => {
95106 new Date ( '2023-01-10 00:10:00' ) ,
96107 ] ,
97108 granularity : '1 minute' ,
98- } ,
109+ timestampValueExpression : 'TimestampTime' ,
110+ } as ChartConfigWithOptDateRange ,
99111 [
100112 30 , // 30s
101113 60 , // 1m
@@ -143,7 +155,8 @@ describe('useChartConfig', () => {
143155 new Date ( '2023-01-10 00:10:00' ) ,
144156 ] ,
145157 granularity : '1 minute' ,
146- } ,
158+ timestampValueExpression : 'TimestampTime' ,
159+ } as ChartConfigWithOptDateRange ,
147160 [
148161 15 , // 15s
149162 ] ,
@@ -175,8 +188,9 @@ describe('useChartConfig', () => {
175188 new Date ( '2023-01-10 00:00:30' ) ,
176189 ] ,
177190 granularity : '1 minute' ,
191+ timestampValueExpression : 'TimestampTime' ,
178192 dateRangeEndInclusive : true ,
179- } ,
193+ } as ChartConfigWithOptDateRange ,
180194 [
181195 15 * 60 , // 15m
182196 30 * 60 , // 30m
@@ -230,7 +244,8 @@ describe('useChartConfig', () => {
230244 new Date ( '2023-01-10 00:02:00' ) ,
231245 ] ,
232246 granularity : '1 minute' ,
233- } ,
247+ timestampValueExpression : 'TimestampTime' ,
248+ } as ChartConfigWithOptDateRange ,
234249 [
235250 60 , // 1m
236251 ] ,
@@ -373,6 +388,104 @@ describe('useChartConfig', () => {
373388 expect ( result . current . isPending ) . toBe ( false ) ;
374389 } ) ;
375390
391+ it ( 'fetches data without chunking when no timestampValueExpression is provided' , async ( ) => {
392+ const config = createMockChartConfig ( {
393+ dateRange : [
394+ new Date ( '2025-10-01 00:00:00Z' ) ,
395+ new Date ( '2025-10-02 00:00:00Z' ) ,
396+ ] ,
397+ granularity : '1 hour' ,
398+ timestampValueExpression : undefined ,
399+ } ) ;
400+
401+ const mockResponse = createMockQueryResponse ( [
402+ {
403+ 'count()' : '71' ,
404+ SeverityText : 'info' ,
405+ __hdx_time_bucket : '2025-10-01T00:00:00Z' ,
406+ } ,
407+ {
408+ 'count()' : '73' ,
409+ SeverityText : 'info' ,
410+ __hdx_time_bucket : '2025-10-02T00:00:00Z' ,
411+ } ,
412+ ] ) ;
413+
414+ mockClickhouseClient . queryChartConfig . mockResolvedValue ( mockResponse ) ;
415+
416+ const { result } = renderHook ( ( ) => useQueriedChartConfig ( config ) , {
417+ wrapper,
418+ } ) ;
419+
420+ await waitFor ( ( ) => expect ( result . current . isSuccess ) . toBe ( true ) ) ;
421+ await waitFor ( ( ) => expect ( result . current . isFetching ) . toBe ( false ) ) ;
422+
423+ // Should only be called once since chunking is disabled without timestampValueExpression
424+ expect ( mockClickhouseClient . queryChartConfig ) . toHaveBeenCalledTimes ( 1 ) ;
425+ expect ( mockClickhouseClient . queryChartConfig ) . toHaveBeenCalledWith ( {
426+ config,
427+ metadata : expect . any ( Object ) ,
428+ opts : {
429+ abort_signal : expect . any ( AbortSignal ) ,
430+ } ,
431+ } ) ;
432+ expect ( result . current . data ) . toEqual ( {
433+ data : mockResponse . data ,
434+ meta : mockResponse . meta ,
435+ rows : mockResponse . rows ,
436+ } ) ;
437+ } ) ;
438+
439+ it ( 'fetches data without chunking when disableQueryChunking is true' , async ( ) => {
440+ const config = createMockChartConfig ( {
441+ dateRange : [
442+ new Date ( '2025-10-01 00:00:00Z' ) ,
443+ new Date ( '2025-10-02 00:00:00Z' ) ,
444+ ] ,
445+ granularity : '1 hour' ,
446+ } ) ;
447+
448+ const mockResponse = createMockQueryResponse ( [
449+ {
450+ 'count()' : '71' ,
451+ SeverityText : 'info' ,
452+ __hdx_time_bucket : '2025-10-01T00:00:00Z' ,
453+ } ,
454+ {
455+ 'count()' : '73' ,
456+ SeverityText : 'info' ,
457+ __hdx_time_bucket : '2025-10-02T00:00:00Z' ,
458+ } ,
459+ ] ) ;
460+
461+ mockClickhouseClient . queryChartConfig . mockResolvedValue ( mockResponse ) ;
462+
463+ const { result } = renderHook (
464+ ( ) => useQueriedChartConfig ( config , { disableQueryChunking : true } ) ,
465+ {
466+ wrapper,
467+ } ,
468+ ) ;
469+
470+ await waitFor ( ( ) => expect ( result . current . isSuccess ) . toBe ( true ) ) ;
471+ await waitFor ( ( ) => expect ( result . current . isFetching ) . toBe ( false ) ) ;
472+
473+ // Should only be called once since chunking is explicitly disabled
474+ expect ( mockClickhouseClient . queryChartConfig ) . toHaveBeenCalledTimes ( 1 ) ;
475+ expect ( mockClickhouseClient . queryChartConfig ) . toHaveBeenCalledWith ( {
476+ config,
477+ metadata : expect . any ( Object ) ,
478+ opts : {
479+ abort_signal : expect . any ( AbortSignal ) ,
480+ } ,
481+ } ) ;
482+ expect ( result . current . data ) . toEqual ( {
483+ data : mockResponse . data ,
484+ meta : mockResponse . meta ,
485+ rows : mockResponse . rows ,
486+ } ) ;
487+ } ) ;
488+
376489 it ( 'fetches data with chunking when granularity and date range are provided' , async ( ) => {
377490 const config = createMockChartConfig ( {
378491 dateRange : [
@@ -521,6 +634,8 @@ describe('useChartConfig', () => {
521634 rows : 4 ,
522635 } ) ;
523636 expect ( result . current . isFetching ) . toBe ( true ) ;
637+ expect ( result . current . isLoading ) . toBe ( false ) ; // isLoading is false because we have partial data
638+ expect ( result . current . isSuccess ) . toBe ( true ) ; // isSuccess is true because we have partial data
524639
525640 // Resolve the final promise to simulate data arriving
526641 const mockResponse3Data = createMockQueryResponse ( [
0 commit comments