@@ -416,8 +416,8 @@ describe('Options', () => {
416416 } ) ;
417417 } ) ;
418418
419- describe ( 'when the noDataText is set' , ( ) => {
420- it ( 'should render this text' , async ( ) => {
419+ describe ( 'when noDataText is set' , ( ) => {
420+ it ( 'should render this text (initial render) ' , async ( ) => {
421421 const { component } = await createDataGrid ( {
422422 dataSource : [
423423 { id : 1 , name : 'Name 1' , value : 10 } ,
@@ -454,10 +454,56 @@ describe('Options', () => {
454454 expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
455455 expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
456456 } ) ;
457+
458+ it ( 'should render this text (runtime change)' , async ( ) => {
459+ const { component } = await createDataGrid ( {
460+ dataSource : [
461+ { id : 1 , name : 'Name 1' , value : 10 } ,
462+ { id : 2 , name : 'Name 2' , value : 20 } ,
463+ ] ,
464+ keyExpr : 'id' ,
465+ columns : [
466+ { dataField : 'id' , caption : 'ID' } ,
467+ { dataField : 'name' , caption : 'Name' } ,
468+ { dataField : 'value' , caption : 'Value' } ,
469+ {
470+ type : 'ai' ,
471+ caption : 'AI Column' ,
472+ name : 'myColumn' ,
473+ cssClass : 'custom-class' ,
474+ ai : {
475+ prompt : 'Initial Prompt' ,
476+ aiIntegration : new AIIntegration ( {
477+ sendRequest ( ) : RequestResult {
478+ return {
479+ promise : new Promise < string > ( ( resolve ) => {
480+ resolve ( '{"1":"","2":""}' ) ;
481+ } ) ,
482+ abort : ( ) : void => { } ,
483+ } ;
484+ } ,
485+ } ) ,
486+ } ,
487+ } ,
488+ ] ,
489+ } ) ;
490+
491+ await Promise . resolve ( ) ;
492+
493+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
494+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
495+
496+ component . apiColumnOption ( 'myColumn' , 'ai.noDataText' , 'Test - No Data' ) ;
497+
498+ await Promise . resolve ( ) ;
499+
500+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
501+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
502+ } ) ;
457503 } ) ;
458504
459- describe ( 'when the emptyText is set' , ( ) => {
460- it ( 'should render this text' , async ( ) => {
505+ describe ( 'when emptyText is set' , ( ) => {
506+ it ( 'should render this text (initial render) ' , async ( ) => {
461507 const { component } = await createDataGrid ( {
462508 keyExpr : 'id' ,
463509 dataSource : [
@@ -493,10 +539,55 @@ describe('Options', () => {
493539 expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - Empty Data' ) ;
494540 expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - Empty Data' ) ;
495541 } ) ;
542+
543+ it ( 'should render this text (runtime change)' , async ( ) => {
544+ const { component } = await createDataGrid ( {
545+ keyExpr : 'id' ,
546+ dataSource : [
547+ { id : 1 , name : 'Name 1' , value : 10 } ,
548+ { id : 2 , name : 'Name 2' , value : 20 } ,
549+ ] ,
550+ columns : [
551+ { dataField : 'id' , caption : 'ID' } ,
552+ { dataField : 'name' , caption : 'Name' } ,
553+ { dataField : 'value' , caption : 'Value' } ,
554+ {
555+ type : 'ai' ,
556+ caption : 'AI Column' ,
557+ name : 'myColumn' ,
558+ cssClass : 'custom-class' ,
559+ ai : {
560+ aiIntegration : new AIIntegration ( {
561+ sendRequest ( ) : RequestResult {
562+ return {
563+ promise : new Promise < string > ( ( resolve ) => {
564+ resolve ( '{"1":"","2":""}' ) ;
565+ } ) ,
566+ abort : ( ) : void => { } ,
567+ } ;
568+ } ,
569+ } ) ,
570+ } ,
571+ } ,
572+ ] ,
573+ } ) ;
574+
575+ await Promise . resolve ( ) ;
576+
577+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
578+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
579+
580+ component . apiColumnOption ( 'myColumn' , 'ai.emptyText' , 'Test - Empty Data' ) ;
581+
582+ await Promise . resolve ( ) ;
583+
584+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - Empty Data' ) ;
585+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - Empty Data' ) ;
586+ } ) ;
496587 } ) ;
497588
498589 describe ( 'when the noDataText is set and mode = "manual"' , ( ) => {
499- it ( 'should render this text' , async ( ) => {
590+ it ( 'should render this text (initial render) ' , async ( ) => {
500591 const { component, instance } = await createDataGrid ( {
501592 dataSource : [
502593 { id : 1 , name : 'Name 1' , value : 10 } ,
@@ -540,10 +631,61 @@ describe('Options', () => {
540631 expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
541632 expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
542633 } ) ;
634+
635+ it ( 'should render this text (runtime change)' , async ( ) => {
636+ const { component, instance } = await createDataGrid ( {
637+ dataSource : [
638+ { id : 1 , name : 'Name 1' , value : 10 } ,
639+ { id : 2 , name : 'Name 2' , value : 20 } ,
640+ ] ,
641+ keyExpr : 'id' ,
642+ columns : [
643+ { dataField : 'id' , caption : 'ID' } ,
644+ { dataField : 'name' , caption : 'Name' } ,
645+ { dataField : 'value' , caption : 'Value' } ,
646+ {
647+ type : 'ai' ,
648+ caption : 'AI Column' ,
649+ name : 'myColumn' ,
650+ cssClass : 'custom-class' ,
651+ ai : {
652+ prompt : 'Initial Prompt' ,
653+ mode : 'manual' ,
654+ aiIntegration : new AIIntegration ( {
655+ sendRequest ( ) : RequestResult {
656+ return {
657+ promise : new Promise < string > ( ( resolve ) => {
658+ resolve ( '{"1":"","2":""}' ) ;
659+ } ) ,
660+ abort : ( ) : void => { } ,
661+ } ;
662+ } ,
663+ } ) ,
664+ } ,
665+ } ,
666+ ] ,
667+ } ) ;
668+
669+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
670+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
671+
672+ instance . sendAIColumnRequest ( 'myColumn' ) ;
673+ await Promise . resolve ( ) ;
674+
675+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
676+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
677+
678+ component . apiColumnOption ( 'myColumn' , 'ai.noDataText' , 'Test - No Data' ) ;
679+ instance . sendAIColumnRequest ( 'myColumn' ) ;
680+ await Promise . resolve ( ) ;
681+
682+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
683+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
684+ } ) ;
543685 } ) ;
544686
545687 describe ( 'when the emptyText is set and mode = "manual"' , ( ) => {
546- it ( 'should render this text' , async ( ) => {
688+ it ( 'should render this text (initial render) ' , async ( ) => {
547689 const { component, instance } = await createDataGrid ( {
548690 keyExpr : 'id' ,
549691 dataSource : [
@@ -588,6 +730,63 @@ describe('Options', () => {
588730 expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
589731 expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
590732 } ) ;
733+
734+ it ( 'should render this text (runtime change)' , async ( ) => {
735+ const { component, instance } = await createDataGrid ( {
736+ keyExpr : 'id' ,
737+ dataSource : [
738+ { id : 1 , name : 'Name 1' , value : 10 } ,
739+ { id : 2 , name : 'Name 2' , value : 20 } ,
740+ ] ,
741+ columns : [
742+ { dataField : 'id' , caption : 'ID' } ,
743+ { dataField : 'name' , caption : 'Name' } ,
744+ { dataField : 'value' , caption : 'Value' } ,
745+ {
746+ type : 'ai' ,
747+ caption : 'AI Column' ,
748+ name : 'myColumn' ,
749+ cssClass : 'custom-class' ,
750+ ai : {
751+ mode : 'manual' ,
752+ aiIntegration : new AIIntegration ( {
753+ sendRequest ( ) : RequestResult {
754+ return {
755+ promise : new Promise < string > ( ( resolve ) => {
756+ resolve ( '{"1":"","2":""}' ) ;
757+ } ) ,
758+ abort : ( ) : void => { } ,
759+ } ;
760+ } ,
761+ } ) ,
762+ } ,
763+ } ,
764+ ] ,
765+ } ) ;
766+
767+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
768+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
769+
770+ instance . columnOption ( 'myColumn' , 'ai.emptyText' , 'Test - Empty Data' ) ;
771+ await Promise . resolve ( ) ;
772+
773+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - Empty Data' ) ;
774+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - Empty Data' ) ;
775+
776+ instance . columnOption ( 'myColumn' , 'ai.prompt' , 'Updated Prompt' ) ;
777+ instance . sendAIColumnRequest ( 'myColumn' ) ;
778+ await Promise . resolve ( ) ;
779+
780+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
781+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( EMPTY_CELL_TEXT ) ;
782+
783+ instance . columnOption ( 'myColumn' , 'ai.noDataText' , 'Test - No Data' ) ;
784+ instance . sendAIColumnRequest ( 'myColumn' ) ;
785+ await Promise . resolve ( ) ;
786+
787+ expect ( component . getDataCell ( 0 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
788+ expect ( component . getDataCell ( 1 , 3 ) . getText ( ) ) . toBe ( 'Test - No Data' ) ;
789+ } ) ;
591790 } ) ;
592791
593792 describe ( 'when the keyExpr is not set' , ( ) => {
0 commit comments