@@ -997,4 +997,37 @@ describe('ProductActionScreenComponent', () => {
997997 expect ( paramNames ) . toContain ( 'visible_param' ) ;
998998 expect ( paramNames ) . toContain ( 'another_visible_param' ) ;
999999 } ) ;
1000+
1001+ it ( 'should re-enable only non-disabled params when HTTP POST fails' , ( ) => {
1002+ const actionParams : ProductActionParameter [ ] = [
1003+ { name : 'project_key' , type : 'string' , required : true , disabled : true } as ProductActionParameter ,
1004+ { name : 'param_1' , type : 'string' , required : true , disabled : false } as ProductActionParameter ,
1005+ { name : 'param_2' , type : 'string' , required : false } as ProductActionParameter ,
1006+ ] ;
1007+ component . action = {
1008+ id : 'fakeAction' ,
1009+ url : '/api/action' ,
1010+ parameters : actionParams ,
1011+ triggerMessage : '' ,
1012+ requestable : true ,
1013+ restrictionMessage : '' ,
1014+ label : 'Fake Action'
1015+ } as ProductAction ;
1016+ component . product = { id : 'fakeId' , title : 'fakeProduct' } as AppProduct ;
1017+ component . actionParams = actionParams ;
1018+ component . formGroup = component [ 'fb' ] . group ( {
1019+ project_key : [ { value : 'project 1' , disabled : true } ] ,
1020+ param_1 : [ 'value1' ] ,
1021+ param_2 : [ 'value2' ]
1022+ } ) ;
1023+
1024+ component . onActionClick ( ) ;
1025+
1026+ const req : TestRequest = httpTesting . expectOne ( '/api/action' ) ;
1027+ req . flush ( 'error' , { status : 500 , statusText : 'Internal Server Error' } ) ;
1028+
1029+ expect ( component . formGroup . get ( 'project_key' ) ?. disabled ) . toBeTrue ( ) ;
1030+ expect ( component . formGroup . get ( 'param_1' ) ?. enabled ) . toBeTrue ( ) ;
1031+ expect ( component . formGroup . get ( 'param_2' ) ?. enabled ) . toBeTrue ( ) ;
1032+ } ) ;
10001033} ) ;
0 commit comments