@@ -251,22 +251,6 @@ describe('Metadata', () => {
251251 ] ,
252252 } ) ,
253253 } ) ;
254-
255- // Mock getColumns to return columns including materialized ones
256- mockCache . getOrFetch . mockImplementation ( ( key , queryFn ) => {
257- if ( key . includes ( '.columns' ) ) {
258- return Promise . resolve ( [
259- { name : 'regular_column' , type : 'String' , default_type : '' } ,
260- {
261- name : 'materialized_column' ,
262- type : 'String' ,
263- default_type : 'MATERIALIZED' ,
264- } ,
265- { name : 'default_column' , type : 'String' , default_type : 'DEFAULT' } ,
266- ] ) ;
267- }
268- return queryFn ( ) ;
269- } ) ;
270254 } ) ;
271255
272256 it ( 'should apply row limit when disableRowLimit is false' , async ( ) => {
@@ -355,71 +339,20 @@ describe('Metadata', () => {
355339 expect ( result ) . toEqual ( [ { key : 'column1' , value : [ 'value1' , 'value2' ] } ] ) ;
356340 } ) ;
357341
358- it ( 'should include materialized fields when selecting all columns' , async ( ) => {
359- const renderChartConfigSpy = jest . spyOn (
360- renderChartConfigModule ,
361- 'renderChartConfig' ,
362- ) ;
363-
364- await metadata . getKeyValues ( {
365- chartConfig : mockChartConfig ,
366- keys : [ 'column1' ] ,
367- limit : 10 ,
368- } ) ;
369-
370- // Verify that renderChartConfig was called with the expanded select list
371- // that includes all columns by name (including materialized ones)
372- expect ( renderChartConfigSpy ) . toHaveBeenCalledWith (
373- expect . objectContaining ( {
374- with : [
375- expect . objectContaining ( {
376- name : 'sampledData' ,
377- chartConfig : expect . objectContaining ( {
378- // Should expand to all column names instead of using '*'
379- select :
380- '`regular_column`, `materialized_column`, `default_column`' ,
381- } ) ,
382- } ) ,
383- ] ,
384- } ) ,
385- metadata ,
386- ) ;
387- } ) ;
388-
389- it ( 'should fallback to * when no columns are found' , async ( ) => {
390- // Mock getColumns to return empty array
391- mockCache . getOrFetch . mockImplementation ( ( key , queryFn ) => {
392- if ( key . includes ( '.columns' ) ) {
393- return Promise . resolve ( [ ] ) ;
394- }
395- return queryFn ( ) ;
396- } ) ;
397-
342+ it ( 'should return an empty list when no keys are provided' , async ( ) => {
398343 const renderChartConfigSpy = jest . spyOn (
399344 renderChartConfigModule ,
400345 'renderChartConfig' ,
401346 ) ;
402347
403- await metadata . getKeyValues ( {
348+ const results = await metadata . getKeyValues ( {
404349 chartConfig : mockChartConfig ,
405- keys : [ 'column1' ] ,
350+ keys : [ ] ,
406351 limit : 10 ,
407352 } ) ;
408353
409- // Should fallback to '*' when no columns are found
410- expect ( renderChartConfigSpy ) . toHaveBeenCalledWith (
411- expect . objectContaining ( {
412- with : [
413- expect . objectContaining ( {
414- name : 'sampledData' ,
415- chartConfig : expect . objectContaining ( {
416- select : '*' ,
417- } ) ,
418- } ) ,
419- ] ,
420- } ) ,
421- metadata ,
422- ) ;
354+ expect ( results ) . toEqual ( [ ] ) ;
355+ expect ( renderChartConfigSpy ) . not . toHaveBeenCalled ( ) ;
423356 } ) ;
424357 } ) ;
425358
0 commit comments