@@ -6,33 +6,41 @@ function freshRequire() {
66 const helpersPath = require . resolve ( './helpers/index.js' ) ;
77 const labelsPath = require . resolve ( './helpers/labels.js' ) ;
88 const constantsPath = require . resolve ( './helpers/constants.js' ) ;
9+ const draftPath = require . resolve ( './helpers/draft.js' ) ;
910
1011 delete require . cache [ indexPath ] ;
1112 delete require . cache [ helpersPath ] ;
1213 delete require . cache [ labelsPath ] ;
1314 delete require . cache [ constantsPath ] ;
15+ delete require . cache [ draftPath ] ;
1416
1517 return require ( './index.js' ) ;
1618}
1719
1820function createGithubMock ( ) {
1921 const removedLabels = [ ] ;
20- const pullUpdates = [ ] ;
22+ const graphqlCalls = [ ] ;
2123
2224 return {
2325 removedLabels,
24- pullUpdates,
26+ graphqlCalls,
27+ graphql : async ( query , variables ) => {
28+ graphqlCalls . push ( { query, variables } ) ;
29+ return {
30+ convertPullRequestToDraft : {
31+ pullRequest : {
32+ id : variables . pullRequestId ,
33+ isDraft : true ,
34+ } ,
35+ } ,
36+ } ;
37+ } ,
2538 rest : {
2639 issues : {
2740 removeLabel : async ( { name } ) => {
2841 removedLabels . push ( name ) ;
2942 } ,
3043 } ,
31- pulls : {
32- update : async ( params ) => {
33- pullUpdates . push ( params ) ;
34- } ,
35- } ,
3644 } ,
3745 } ;
3846}
@@ -74,9 +82,9 @@ describe('revision-guard index', () => {
7482
7583 await handler ( { github, context, core : { info ( ) { } } } ) ;
7684
77- assert . deepEqual ( github . pullUpdates , [
78- { owner : 'hiero-ledger' , repo : 'hiero-sdk-python' , pull_number : 42 , draft : true } ,
79- ] ) ;
85+ assert . equal ( github . graphqlCalls . length , 1 ) ;
86+ assert . match ( github . graphqlCalls [ 0 ] . query , / c o n v e r t P u l l R e q u e s t T o D r a f t / ) ;
87+ assert . deepEqual ( github . graphqlCalls [ 0 ] . variables , { pullRequestId : 'PR_node_42' } ) ;
8088 assert . deepEqual ( github . removedLabels , [
8189 'queue:committers' ,
8290 'status: ready-to-merge' ,
@@ -98,7 +106,7 @@ describe('revision-guard index', () => {
98106
99107 await handler ( { github, context, core : { info ( ) { } } } ) ;
100108
101- assert . equal ( github . pullUpdates . length , 0 ) ;
109+ assert . equal ( github . graphqlCalls . length , 0 ) ;
102110 assert . equal ( github . removedLabels . length , 0 ) ;
103111 } ) ;
104112
@@ -117,7 +125,7 @@ describe('revision-guard index', () => {
117125
118126 await handler ( { github, context, core : { info ( ) { } } } ) ;
119127
120- assert . equal ( github . pullUpdates . length , 0 ) ;
128+ assert . equal ( github . graphqlCalls . length , 0 ) ;
121129 assert . equal ( github . removedLabels . length , 0 ) ;
122130 } ) ;
123131
@@ -142,9 +150,8 @@ describe('revision-guard index', () => {
142150 await handler ( { github, context, core : { info ( ) { } } } ) ;
143151
144152 // Draft conversion must also fire for configurable-label scenarios.
145- assert . deepEqual ( github . pullUpdates , [
146- { owner : 'hiero-ledger' , repo : 'hiero-sdk-python' , pull_number : 45 , draft : true } ,
147- ] ) ;
153+ assert . equal ( github . graphqlCalls . length , 1 ) ;
154+ assert . deepEqual ( github . graphqlCalls [ 0 ] . variables , { pullRequestId : 'PR_node_45' } ) ;
148155 // Custom labels AND the matching default (queue:committers) must both be removed.
149156 assert . deepEqual ( github . removedLabels , [ 'queue:committers' , 'custom: one' , 'custom: two' ] ) ;
150157 } ) ;
0 commit comments