@@ -33,6 +33,7 @@ import {
3333 clickActionButton ,
3434 getBottomToolbarItems ,
3535 findButtonByName ,
36+ getButtonInstance ,
3637 getCommandSelectBoxInstance ,
3738 getItemByName ,
3839 getLoadIndicator ,
@@ -210,6 +211,11 @@ QUnit.module('AIDialog', () => {
210211 this . promise . then ( ( ) => {
211212 this . setDialogState ( element . state ) ;
212213
214+ if ( element . name === 'generate button' ) {
215+ const promptTextAreaInstance = getPromptTextAreaInstance ( this . $element ) ;
216+ promptTextAreaInstance . option ( 'value' , 'some question' ) ;
217+ }
218+
213219 const $element = $ ( `.${ element . domClass } ` ) . eq ( element . index ) ;
214220 const instance = $element [ element . class ] ( 'instance' ) ;
215221
@@ -410,6 +416,9 @@ QUnit.module('AIDialog', () => {
410416 } ,
411417 } ) ;
412418
419+ const promptTextAreaInstance = getPromptTextAreaInstance ( this . $element ) ;
420+ promptTextAreaInstance . option ( 'value' , 'some question' ) ;
421+
413422 const $generateButton = findButtonByName ( this . aiDialogPopup , 'generate' ) ;
414423 $generateButton . trigger ( 'dxclick' ) ;
415424
@@ -501,6 +510,28 @@ QUnit.module('AIDialog', () => {
501510 assert . strictEqual ( bottomToolbarItems . length , 1 , '1 button is rendered' ) ;
502511 assert . strictEqual ( bottomToolbarItems [ 0 ] . name , 'generate' , 'generate button is shown' ) ;
503512 } ) ;
513+
514+ QUnit . test ( 'generate button should be disabled when textArea is empty' , function ( assert ) {
515+ showAIDialog ( this , {
516+ config : { currentCommand : 'askAI' }
517+ } ) ;
518+
519+ let generateButton = getButtonInstance ( findButtonByName ( this . aiDialogPopup , 'generate' ) ) ;
520+
521+ assert . strictEqual ( generateButton . option ( 'disabled' ) , true , 'generate button is disabled on init' ) ;
522+
523+ const promptTextAreaInstance = getPromptTextAreaInstance ( this . $element ) ;
524+
525+ promptTextAreaInstance . option ( 'value' , 'f' ) ;
526+ generateButton = getButtonInstance ( findButtonByName ( this . aiDialogPopup , 'generate' ) ) ;
527+
528+ assert . strictEqual ( generateButton . option ( 'disabled' ) , false , 'generate button is enabled after input some text' ) ;
529+
530+ promptTextAreaInstance . option ( 'value' , '' ) ;
531+ generateButton = getButtonInstance ( findButtonByName ( this . aiDialogPopup , 'generate' ) ) ;
532+
533+ assert . strictEqual ( generateButton . option ( 'disabled' ) , true , 'generate button is disabled after input is cleared' ) ;
534+ } ) ;
504535 } ) ;
505536
506537 QUnit . module ( 'integration execution and parameter checks' , integrationModuleConfig , ( ) => {
@@ -804,6 +835,9 @@ QUnit.module('AIDialog', () => {
804835
805836 this . showDialog ( { currentCommand : 'askAI' } ) ;
806837
838+ const promptTextAreaInstance = getPromptTextAreaInstance ( this . $element ) ;
839+ promptTextAreaInstance . option ( 'value' , 'some question' ) ;
840+
807841 const $generateButton = findButtonByName ( this . aiDialogPopup , 'generate' ) ;
808842 $generateButton . trigger ( 'dxclick' ) ;
809843
@@ -900,8 +934,9 @@ QUnit.module('AIDialog', () => {
900934 this . showDialog ( { currentCommand : 'askAI' } ) ;
901935
902936 const promptTextAreaInstance = getPromptTextAreaInstance ( this . $element ) ;
903- const generateButton = findButtonByName ( this . aiDialogPopup , 'generate ' ) ;
937+ promptTextAreaInstance . option ( 'value' , 'some question ' ) ;
904938
939+ const generateButton = findButtonByName ( this . aiDialogPopup , 'generate' ) ;
905940 generateButton . trigger ( 'dxclick' ) ;
906941
907942 assert . strictEqual ( promptTextAreaInstance . option ( 'disabled' ) , true , 'disabled during generating' ) ;
0 commit comments