@@ -136,10 +136,6 @@ describe("workflow comment-spam hardening", () => {
136136 const checkoutStep = job ?. steps ?. find (
137137 step => step . name === "Checkout trusted PR-quality scripts" ,
138138 ) ;
139- // Trusted scripts come from a fixed set of integration branches, never
140- // from the pull request itself. `status` keeps the default-branch
141- // boundary that owns the event; a `main`-targeting PR matches the workflow
142- // definition loaded from `main`; every other base resolves to `dev`.
143139 expect ( checkoutStep ?. with ?. ref ) . toBe (
144140 "${{ github.event_name == 'status' && github.event.repository.default_branch || (github.event.pull_request.base.ref == 'main' && 'main' || 'dev') }}" ,
145141 ) ;
@@ -221,6 +217,40 @@ describe("workflow comment-spam hardening", () => {
221217 expect ( graphqlCalls . some ( call => call . query . includes ( "markPullRequestReadyForReview" ) ) ) . toBe ( false ) ;
222218 } ) ;
223219
220+ test ( "a repeated draft-conversion failure restores the failure body after its checkpoint write" , async ( ) => {
221+ const script = await readGateScript ( ) ;
222+ const body = completedChecklistBody ( ) . replace (
223+ "- [x] My PR is ready for review." ,
224+ "- [ ] My PR is ready for review." ,
225+ ) ;
226+
227+ const firstFailure = await runEnforcePrTarget ( script , {
228+ pr : { base : { ref : "dev" } , draft : false , body } ,
229+ maintainersFile : MAINTAINERS_FIXTURE ,
230+ failGraphqlOn : [ "convertPullRequestToDraft" ] ,
231+ } ) ;
232+ const previousFailureBody = gateBodyFrom ( firstFailure ) ;
233+ expect ( previousFailureBody ) . toContain ( '"autoDraftedByBot":false' ) ;
234+ expect ( previousFailureBody ) . toContain ( "Automatic draft conversion failed" ) ;
235+
236+ const repeatedFailure = await runEnforcePrTarget ( script , {
237+ pr : { base : { ref : "dev" } , draft : false , body } ,
238+ maintainersFile : MAINTAINERS_FIXTURE ,
239+ failGraphqlOn : [ "convertPullRequestToDraft" ] ,
240+ comments : [ {
241+ id : 7 ,
242+ user : { login : "github-actions[bot]" } ,
243+ body : previousFailureBody ,
244+ } ] ,
245+ } ) ;
246+
247+ const updates = callsTo ( repeatedFailure , "issues.updateComment" ) as Array < { body : string } > ;
248+ expect ( updates ) . toHaveLength ( 2 ) ;
249+ expect ( updates [ 0 ] ?. body ) . toContain ( '"autoDraftedByBot":true' ) ;
250+ expect ( updates [ 1 ] ?. body ) . toContain ( '"autoDraftedByBot":false' ) ;
251+ expect ( updates [ 1 ] ?. body ) . toContain ( "Automatic draft conversion failed" ) ;
252+ } ) ;
253+
224254 test ( "issue-comment translation rejects PR and bot comments before runner allocation" , async ( ) => {
225255 const text = await Bun . file (
226256 new URL ( "../.github/workflows/enforce-issue-quality.yml" , import . meta. url ) ,
0 commit comments