@@ -90,24 +90,32 @@ describe("update_activation_comment.cjs", () => {
9090 ( ( createFunctionFromScript = createTestableFunction ( scriptContent ) ) ,
9191 ( mockDependencies = { github : { graphql : vi . fn ( ) , request : vi . fn ( ) } , core : { info : vi . fn ( ) , warning : vi . fn ( ) , setFailed : vi . fn ( ) } , context : { repo : { owner : "testowner" , repo : "testrepo" } } , process : { env : { } } } ) ) ;
9292 } ) ,
93- it ( "should create new comment on target PR when GH_AW_COMMENT_ID is not set " , async ( ) => {
93+ it ( "should skip comment when no activation comment ID or triggering context exists " , async ( ) => {
9494 mockDependencies . process . env . GH_AW_COMMENT_ID = "" ;
95+ const { updateActivationComment } = createFunctionFromScript ( mockDependencies ) ;
96+ await updateActivationComment ( mockDependencies . github , mockDependencies . context , mockDependencies . core , "https://github.com/testowner/testrepo/pull/42" , 42 ) ;
97+ expect ( mockDependencies . core . info ) . toHaveBeenCalledWith ( "No activation comment to update (GH_AW_COMMENT_ID not set)" ) ;
98+ expect ( mockDependencies . github . request ) . not . toHaveBeenCalled ( ) ;
99+ } ) ,
100+ it ( "should create new comment on triggering PR when GH_AW_COMMENT_ID is not set" , async ( ) => {
101+ mockDependencies . process . env . GH_AW_COMMENT_ID = "" ;
102+ mockDependencies . context . payload = { pull_request : { number : 10 } } ;
95103 mockDependencies . github . request . mockResolvedValue ( {
96- data : { id : 789012 , html_url : "https://github.com/testowner/testrepo/issues/42 #issuecomment-789012" } ,
104+ data : { id : 789012 , html_url : "https://github.com/testowner/testrepo/issues/10 #issuecomment-789012" } ,
97105 } ) ;
98106 const { updateActivationComment } = createFunctionFromScript ( mockDependencies ) ;
99107 await updateActivationComment ( mockDependencies . github , mockDependencies . context , mockDependencies . core , "https://github.com/testowner/testrepo/pull/42" , 42 ) ;
100- expect ( mockDependencies . core . info ) . toHaveBeenCalledWith ( "No activation comment to update (GH_AW_COMMENT_ID not set), creating new comment on #42 " ) ;
108+ expect ( mockDependencies . core . info ) . toHaveBeenCalledWith ( "No activation comment to update (GH_AW_COMMENT_ID not set), creating new comment on #10 " ) ;
101109 expect ( mockDependencies . github . request ) . toHaveBeenCalledWith (
102110 "POST /repos/{owner}/{repo}/issues/{issue_number}/comments" ,
103111 expect . objectContaining ( {
104112 owner : "testowner" ,
105113 repo : "testrepo" ,
106- issue_number : 42 ,
114+ issue_number : 10 ,
107115 body : expect . stringContaining ( "Pull request created: [#42]" ) ,
108116 } )
109117 ) ;
110- expect ( mockDependencies . core . info ) . toHaveBeenCalledWith ( "Successfully created comment with pull request link on #42 " ) ;
118+ expect ( mockDependencies . core . info ) . toHaveBeenCalledWith ( "Successfully created comment with pull request link on #10 " ) ;
111119 } ) ,
112120 it ( "should skip update when GH_AW_COMMENT_ID is not set and no target issue number" , async ( ) => {
113121 mockDependencies . process . env . GH_AW_COMMENT_ID = "" ;
0 commit comments