@@ -639,6 +639,125 @@ test('toNextState omits webhook_reply on existing trigger when not specified', (
639639 t . false ( 'webhook_reply' in result . workflows . w . triggers . t ) ;
640640} ) ;
641641
642+ test ( 'toNextState sets webhook_response_config when specified' , ( t ) => {
643+ const state = { workflows : { } } ;
644+ const spec = {
645+ name : 'my project' ,
646+ workflows : {
647+ w : {
648+ name : 'workflow' ,
649+ jobs : { } ,
650+ triggers : {
651+ t : {
652+ type : 'webhook' ,
653+ webhook_response_config : { success_code : 200 , error_code : 400 } ,
654+ } ,
655+ } ,
656+ edges : { } ,
657+ } ,
658+ } ,
659+ } ;
660+
661+ const result = mergeSpecIntoState ( state , spec ) ;
662+ t . deepEqual ( result . workflows . w . triggers . t . webhook_response_config , {
663+ success_code : 200 ,
664+ error_code : 400 ,
665+ } ) ;
666+ } ) ;
667+
668+ test ( 'toNextState omits webhook_response_config when not specified' , ( t ) => {
669+ const state = { workflows : { } } ;
670+ const spec = {
671+ name : 'my project' ,
672+ workflows : {
673+ w : {
674+ name : 'workflow' ,
675+ jobs : { } ,
676+ triggers : {
677+ t : { type : 'webhook' } ,
678+ } ,
679+ edges : { } ,
680+ } ,
681+ } ,
682+ } ;
683+
684+ const result = mergeSpecIntoState ( state , spec ) ;
685+ t . false ( 'webhook_response_config' in result . workflows . w . triggers . t ) ;
686+ } ) ;
687+
688+ test ( 'toNextState sets webhook_response_config on existing trigger' , ( t ) => {
689+ const triggerId = 'aaa-bbb-ccc' ;
690+ const state = {
691+ workflows : {
692+ w : {
693+ id : 'wf-1' ,
694+ name : 'workflow' ,
695+ jobs : { } ,
696+ triggers : {
697+ t : { id : triggerId , type : 'webhook' , enabled : true } ,
698+ } ,
699+ edges : { } ,
700+ } ,
701+ } ,
702+ } ;
703+ const spec = {
704+ name : 'my project' ,
705+ workflows : {
706+ w : {
707+ name : 'workflow' ,
708+ jobs : { } ,
709+ triggers : {
710+ t : {
711+ type : 'webhook' ,
712+ webhook_response_config : { success_code : 201 , error_code : 500 } ,
713+ } ,
714+ } ,
715+ edges : { } ,
716+ } ,
717+ } ,
718+ } ;
719+
720+ const result = mergeSpecIntoState ( state , spec ) ;
721+ t . is ( result . workflows . w . triggers . t . id , triggerId ) ;
722+ t . deepEqual ( result . workflows . w . triggers . t . webhook_response_config , {
723+ success_code : 201 ,
724+ error_code : 500 ,
725+ } ) ;
726+ } ) ;
727+
728+ test ( 'toNextState omits webhook_response_config on existing trigger when not specified' , ( t ) => {
729+ const triggerId = 'aaa-bbb-ccc' ;
730+ const state = {
731+ workflows : {
732+ w : {
733+ id : 'wf-1' ,
734+ name : 'workflow' ,
735+ jobs : { } ,
736+ triggers : {
737+ t : { id : triggerId , type : 'webhook' , enabled : true } ,
738+ } ,
739+ edges : { } ,
740+ } ,
741+ } ,
742+ } ;
743+ const spec = {
744+ name : 'my project' ,
745+ workflows : {
746+ w : {
747+ name : 'workflow' ,
748+ jobs : { } ,
749+ triggers : {
750+ t : { type : 'webhook' } ,
751+ } ,
752+ edges : { } ,
753+ } ,
754+ } ,
755+ } ;
756+
757+ const result = mergeSpecIntoState ( state , spec ) ;
758+ t . false ( 'webhook_response_config' in result . workflows . w . triggers . t ) ;
759+ } ) ;
760+
642761test ( 'toNextState sets cron_cursor_job_id on existing trigger' , ( t ) => {
643762 const triggerId = 'aaa-bbb-ccc' ;
644763 const jobId = 'job-uuid-111' ;
@@ -663,10 +782,18 @@ test('toNextState sets cron_cursor_job_id on existing trigger', (t) => {
663782 w : {
664783 name : 'workflow' ,
665784 jobs : {
666- 'job-a' : { name : 'job a' , adaptor : '@openfn/language-http' , body : 'fn()' } ,
785+ 'job-a' : {
786+ name : 'job a' ,
787+ adaptor : '@openfn/language-http' ,
788+ body : 'fn()' ,
789+ } ,
667790 } ,
668791 triggers : {
669- t : { type : 'cron' , cron_expression : '0 * * * *' , cron_cursor_job : 'job-a' } ,
792+ t : {
793+ type : 'cron' ,
794+ cron_expression : '0 * * * *' ,
795+ cron_cursor_job : 'job-a' ,
796+ } ,
670797 } ,
671798 edges : { } ,
672799 } ,
@@ -702,7 +829,11 @@ test('toNextState omits cron_cursor_job_id on existing trigger when not specifie
702829 w : {
703830 name : 'workflow' ,
704831 jobs : {
705- 'job-a' : { name : 'job a' , adaptor : '@openfn/language-http' , body : 'fn()' } ,
832+ 'job-a' : {
833+ name : 'job a' ,
834+ adaptor : '@openfn/language-http' ,
835+ body : 'fn()' ,
836+ } ,
706837 } ,
707838 triggers : {
708839 t : { type : 'cron' , cron_expression : '0 * * * *' } ,
0 commit comments