@@ -487,6 +487,101 @@ describe('Options', () => {
487487 expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - Empty Data' ) ;
488488 } ) ;
489489 } ) ;
490+
491+ describe ( 'when the noDataText is set and mode = "manual"' , ( ) => {
492+ it ( 'should render this text' , async ( ) => {
493+ const { component, instance } = await createDataGrid ( {
494+ dataSource : [
495+ { id : 1 , name : 'Name 1' , value : 10 } ,
496+ { id : 2 , name : 'Name 2' , value : 20 } ,
497+ ] ,
498+ keyExpr : 'id' ,
499+ columns : [
500+ { dataField : 'id' , caption : 'ID' } ,
501+ { dataField : 'name' , caption : 'Name' } ,
502+ { dataField : 'value' , caption : 'Value' } ,
503+ {
504+ type : 'ai' ,
505+ caption : 'AI Column' ,
506+ name : 'myColumn' ,
507+ cssClass : 'custom-class' ,
508+ ai : {
509+ prompt : 'Initial Prompt' ,
510+ noDataText : 'Test - No Data' ,
511+ mode : 'manual' ,
512+ aiIntegration : new AIIntegration ( {
513+ sendRequest ( ) : RequestResult {
514+ return {
515+ promise : new Promise < string > ( ( resolve ) => {
516+ resolve ( '{"1":"","2":""}' ) ;
517+ } ) ,
518+ abort : ( ) : void => { } ,
519+ } ;
520+ } ,
521+ } ) ,
522+ } ,
523+ } ,
524+ ] ,
525+ } ) ;
526+
527+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
528+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
529+
530+ instance . sendAIColumnRequest ( 'myColumn' ) ;
531+ await Promise . resolve ( ) ;
532+
533+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
534+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
535+ } ) ;
536+ } ) ;
537+
538+ describe ( 'when the emptyText is set and mode = "manual"' , ( ) => {
539+ it ( 'should render this text' , async ( ) => {
540+ const { component, instance } = await createDataGrid ( {
541+ keyExpr : 'id' ,
542+ dataSource : [
543+ { id : 1 , name : 'Name 1' , value : 10 } ,
544+ { id : 2 , name : 'Name 2' , value : 20 } ,
545+ ] ,
546+ columns : [
547+ { dataField : 'id' , caption : 'ID' } ,
548+ { dataField : 'name' , caption : 'Name' } ,
549+ { dataField : 'value' , caption : 'Value' } ,
550+ {
551+ type : 'ai' ,
552+ caption : 'AI Column' ,
553+ name : 'myColumn' ,
554+ cssClass : 'custom-class' ,
555+ ai : {
556+ emptyText : 'Test - Empty Data' ,
557+ noDataText : 'Test - No Data' ,
558+ mode : 'manual' ,
559+ aiIntegration : new AIIntegration ( {
560+ sendRequest ( ) : RequestResult {
561+ return {
562+ promise : new Promise < string > ( ( resolve ) => {
563+ resolve ( '{"1":"","2":""}' ) ;
564+ } ) ,
565+ abort : ( ) : void => { } ,
566+ } ;
567+ } ,
568+ } ) ,
569+ } ,
570+ } ,
571+ ] ,
572+ } ) ;
573+
574+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - Empty Data' ) ;
575+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - Empty Data' ) ;
576+
577+ instance . columnOption ( 'myColumn' , 'ai.prompt' , 'Updated Prompt' ) ;
578+ instance . sendAIColumnRequest ( 'myColumn' ) ;
579+ await Promise . resolve ( ) ;
580+
581+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
582+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
583+ } ) ;
584+ } ) ;
490585} ) ;
491586
492587describe ( 'columnOption' , ( ) => {
@@ -3750,12 +3845,12 @@ describe('Cache', () => {
37503845 instance . sendAIColumnRequest ( 'myColumn' ) ;
37513846 await Promise . resolve ( ) ;
37523847 expect ( sendRequestSpy ) . toHaveBeenCalledTimes ( 1 ) ;
3753- expect ( instance . getAIColumnText ( 'myColumn' , 1 ) ) . toBeUndefined ( ) ;
3848+ expect ( instance . getAIColumnText ( 'myColumn' , 1 ) ) . toBe ( '' ) ;
37543849
37553850 instance . sendAIColumnRequest ( 'myColumn' ) ;
37563851 await Promise . resolve ( ) ;
37573852 expect ( sendRequestSpy ) . toHaveBeenCalledTimes ( 2 ) ;
3758- expect ( instance . getAIColumnText ( 'myColumn' , 1 ) ) . toBeUndefined ( ) ;
3853+ expect ( instance . getAIColumnText ( 'myColumn' , 1 ) ) . toBe ( '' ) ;
37593854 } ) ;
37603855 } ) ;
37613856} ) ;
0 commit comments