@@ -21,6 +21,7 @@ import {
2121 partitionFailureResults ,
2222 computeSafeOutputsStatus ,
2323 setSafeOutputsStatusOutputs ,
24+ processSyntheticUpdates ,
2425} from "./safe_output_handler_manager.cjs" ;
2526
2627const require = createRequire ( import . meta. url ) ;
@@ -162,7 +163,14 @@ describe("Safe Output Handler Manager", () => {
162163 vi . fn ( async ( _message , resolvedTemporaryIds ) => {
163164 callOrder . push ( "add_comment" ) ;
164165 expect ( resolvedTemporaryIds ) . toEqual ( { } ) ;
165- return { success : true , commentId : 123 , itemNumber : 42 , repo : "owner/repo" , isDiscussion : false } ;
166+ return {
167+ success : true ,
168+ commentId : 123 ,
169+ itemNumber : 42 ,
170+ repo : "owner/repo" ,
171+ isDiscussion : false ,
172+ body : "Tracking issue: #aw_track1\n\nHandler footer marker" ,
173+ } ;
166174 } ) ,
167175 ] ,
168176 [
@@ -186,11 +194,48 @@ describe("Safe Output Handler Manager", () => {
186194 {
187195 type : "add_comment" ,
188196 message : { type : "add_comment" , item_number : 42 , body : "Tracking issue: #aw_track1" } ,
189- result : { commentId : 123 , itemNumber : 42 , repo : "owner/repo" , isDiscussion : false } ,
197+ result : {
198+ success : true ,
199+ commentId : 123 ,
200+ itemNumber : 42 ,
201+ repo : "owner/repo" ,
202+ isDiscussion : false ,
203+ body : "Tracking issue: #aw_track1\n\nHandler footer marker" ,
204+ } ,
190205 originalTempIdMapSize : 0 ,
191206 } ,
192207 ] ) ;
193208 } ) ;
209+
210+ it ( "updates the posted comment body while retaining handler metadata" , async ( ) => {
211+ const updateComment = vi . fn ( ) . mockResolvedValue ( { } ) ;
212+ const github = { rest : { issues : { updateComment } } } ;
213+ const trackedOutputs = [
214+ {
215+ type : "add_comment" ,
216+ message : { type : "add_comment" , body : "Tracking issue: #aw_track1" } ,
217+ result : {
218+ success : true ,
219+ commentId : 123 ,
220+ itemNumber : 42 ,
221+ repo : "owner/repo" ,
222+ isDiscussion : false ,
223+ body : "Tracking issue: #aw_track1\n\nHandler footer marker" ,
224+ } ,
225+ originalTempIdMapSize : 0 ,
226+ } ,
227+ ] ;
228+
229+ const updateCount = await processSyntheticUpdates ( github , { } , trackedOutputs , new Map ( [ [ "aw_track1" , { repo : "owner/tracker" , number : 99 } ] ] ) , new Map ( ) ) ;
230+
231+ expect ( updateCount ) . toBe ( 1 ) ;
232+ expect ( updateComment ) . toHaveBeenCalledWith ( {
233+ owner : "owner" ,
234+ repo : "repo" ,
235+ comment_id : 123 ,
236+ body : "Tracking issue: owner/tracker#99\n\nHandler footer marker" ,
237+ } ) ;
238+ } ) ;
194239 } ) ;
195240
196241 describe ( "logCreatedItemFromResult" , ( ) => {
0 commit comments