@@ -64,7 +64,7 @@ describe("release_control tool", () => {
6464 extra : Record < string , unknown > = { } ,
6565 ) {
6666 const tool = createReleaseControlTool ( { projectDir : dir } )
67- return tool . execute ( { op, ...extra } , { } as any )
67+ return tool . execute ( { op, ...extra } as any , { } as any )
6868 }
6969
7070 it ( "rejects an unknown op" , async ( ) => {
@@ -204,43 +204,64 @@ describe("release_control tool", () => {
204204 const ghCalls : string [ ] = [ ]
205205 mockGh ( {
206206 "pr list --head release/v1.5.0 --json number --jq '.[0].number'" : "12" ,
207- "pr checks 12" : "" ,
207+ "pr view 12 --json statusCheckRollup --jq '[.statusCheckRollup[] | select(.conclusion != null)] | map(.conclusion) | unique'" :
208+ '["SUCCESS"]' ,
208209 "pr merge 12 --squash --delete-branch" : "" ,
209210 "pr view 12 --json mergeCommit --jq '.mergeCommit.oid'" : "deadbeef" ,
210211 "api repos/{owner}/{repo}/tags --jq '.[] | select(.name == \"v1.5.0\") | .commit.sha'" : "" ,
211212 "api repos/{owner}/{repo}/git/refs -f ref=refs/tags/v1.5.0 -f sha=deadbeef" : "" ,
212213 } , ghCalls )
213214
214- const out = String ( await call ( dir , "merge-release-pr" , { proposed_version : "1.5.0" } ) )
215+ const out = String ( await call ( dir , "merge-release-pr" , { proposed_version : "1.5.0" , user_confirmed : true } ) )
215216 expect ( out ) . toContain ( "Merged #12" )
216217 expect ( out ) . toContain ( "tagged v1.5.0" )
217218 expect ( out ) . toContain ( "deadbee" )
218- expect ( ghCalls . some ( c => c . startsWith ( "pr checks ") ) ) . toBe ( true )
219+ expect ( ghCalls . some ( c => c . includes ( "statusCheckRollup ") ) ) . toBe ( true )
219220 expect ( ghCalls . some ( c => c . includes ( "git/refs" ) ) ) . toBe ( true )
220221 } )
221222 } )
222223
224+ it ( "refuses without human approval (user_confirmed)" , async ( ) => {
225+ await withProject ( PROFILE , { version : "1.4.2" } , async dir => {
226+ const out = String ( await call ( dir , "merge-release-pr" , { proposed_version : "1.5.0" } ) )
227+ expect ( out ) . toContain ( "Error" )
228+ expect ( out ) . toContain ( "user_confirmed" )
229+ } )
230+ } )
231+
223232 it ( "refuses when the release PR does not exist" , async ( ) => {
224233 await withProject ( PROFILE , { version : "1.4.2" } , async dir => {
225234 mockGh ( { "pr list --head release/v1.5.0 --json number --jq '.[0].number'" : "" } )
226- const out = String ( await call ( dir , "merge-release-pr" , { proposed_version : "1.5.0" } ) )
235+ const out = String ( await call ( dir , "merge-release-pr" , { proposed_version : "1.5.0" , user_confirmed : true } ) )
227236 expect ( out ) . toContain ( "Error" )
228237 } )
229238 } )
230239
231- it ( "refuses when CI checks have not passed " , async ( ) => {
240+ it ( "refuses when CI checks have failed " , async ( ) => {
232241 await withProject ( PROFILE , { version : "1.4.2" } , async dir => {
233242 mockGh ( {
234243 "pr list --head release/v1.5.0 --json number --jq '.[0].number'" : "12" ,
235- "pr checks 12" : ( ) => {
236- throw new Error ( "checks failed" )
237- } ,
244+ "pr view 12 --json statusCheckRollup --jq '[.statusCheckRollup[] | select(.conclusion != null)] | map(.conclusion) | unique'" :
245+ '["FAILURE"]' ,
238246 } )
239- const out = String ( await call ( dir , "merge-release-pr" , { proposed_version : "1.5.0" } ) )
247+ const out = String ( await call ( dir , "merge-release-pr" , { proposed_version : "1.5.0" , user_confirmed : true } ) )
240248 expect ( out ) . toContain ( "Error" )
241249 expect ( out ) . toContain ( "CI" )
242250 } )
243251 } )
252+
253+ it ( "refuses when no CI checks are reported" , async ( ) => {
254+ await withProject ( PROFILE , { version : "1.4.2" } , async dir => {
255+ mockGh ( {
256+ "pr list --head release/v1.5.0 --json number --jq '.[0].number'" : "12" ,
257+ "pr view 12 --json statusCheckRollup --jq '[.statusCheckRollup[] | select(.conclusion != null)] | map(.conclusion) | unique'" :
258+ "[]" ,
259+ } )
260+ const out = String ( await call ( dir , "merge-release-pr" , { proposed_version : "1.5.0" , user_confirmed : true } ) )
261+ expect ( out ) . toContain ( "Error" )
262+ expect ( out ) . toContain ( "没有任何 CI checks" )
263+ } )
264+ } )
244265 } )
245266
246267 describe ( "monitor" , ( ) => {
0 commit comments