@@ -797,6 +797,22 @@ describe('runCloudPi', () => {
797797 expect ( result . prUrl ) . toBe ( 'https://github.com/octo/demo/pull/7' )
798798 } )
799799
800+ it ( 'fails when a second PR for the branch appears during authoring' , async ( ) => {
801+ mockExistingBranchPullRequest ( )
802+ mockExecuteTool . mockResolvedValueOnce ( {
803+ success : true ,
804+ output : { items : [ { number : 7 } , { number : 8 } ] , count : 2 } ,
805+ } )
806+
807+ await expect ( runCloudBranchPi ( branchParams ( ) , { onEvent : vi . fn ( ) } ) ) . rejects . toThrow (
808+ / m u l t i p l e o p e n p u l l r e q u e s t s /
809+ )
810+ expect (
811+ mockExecuteTool . mock . calls . some ( ( [ tool ] : [ string ] ) => tool === 'github_update_pr' )
812+ ) . toBe ( false )
813+ expect ( mockRunBabysit ) . not . toHaveBeenCalled ( )
814+ } )
815+
800816 it ( 'does not claim a push happened when no-op authoring is followed by a PR error' , async ( ) => {
801817 mockRun . mockImplementation ( ( command : string ) => {
802818 if ( command . includes ( 'git clone' ) ) {
@@ -840,6 +856,12 @@ describe('runCloudPi', () => {
840856 return Promise . resolve ( { stdout : '__NO_CHANGES__=1' , stderr : '' , exitCode : 0 } )
841857 } )
842858 mockExecuteTool . mockImplementation ( ( tool : string ) => {
859+ if ( tool === 'github_list_prs_v2' ) {
860+ return Promise . resolve ( {
861+ success : true ,
862+ output : { items : [ { number : 7 } ] , count : 1 } ,
863+ } )
864+ }
843865 if ( tool === 'github_pr_v2' ) {
844866 return Promise . resolve ( existingPullRequestOutput ( ) )
845867 }
0 commit comments