@@ -1992,13 +1992,13 @@ test("Ignore missing and forbidden issues/PRs", async (t) => {
19921992 ) ;
19931993 t . true (
19941994 t . context . error . calledWith (
1995- "Failed to add a comment to the issue/PR #%d as it doesn't exist." ,
1995+ "Failed to add a comment/label to the issue/PR #%d as it doesn't exist." ,
19961996 2 ,
19971997 ) ,
19981998 ) ;
19991999 t . true (
20002000 t . context . error . calledWith (
2001- "Not allowed to add a comment to the issue/PR #%d." ,
2001+ "Not allowed to add a comment/label to the issue/PR #%d." ,
20022002 3 ,
20032003 ) ,
20042004 ) ;
@@ -3225,7 +3225,7 @@ test("Ignore errors when adding comments and closing issues", async (t) => {
32253225 t . is ( error2 . status , 500 ) ;
32263226 t . true (
32273227 t . context . error . calledWith (
3228- "Failed to add a comment to the issue/PR #%d." ,
3228+ "Failed to add a comment/label to the issue/PR #%d." ,
32293229 1 ,
32303230 ) ,
32313231 ) ;
@@ -3396,6 +3396,10 @@ test('Skip comment on on issues/PR if "successComment" is "false"', async (t) =>
33963396 repository : {
33973397 commit123 : {
33983398 associatedPullRequests : {
3399+ pageInfo : {
3400+ endCursor : "NI" ,
3401+ hasNextPage : false ,
3402+ } ,
33993403 nodes : [ prs [ 0 ] ] ,
34003404 } ,
34013405 } ,
@@ -3411,6 +3415,32 @@ test('Skip comment on on issues/PR if "successComment" is "false"', async (t) =>
34113415 { } ,
34123416 { labels : [ "released" ] } ,
34133417 )
3418+ . postOnce (
3419+ ( url , { body } ) => {
3420+ t . is ( url , "https://api.github.local/graphql" ) ;
3421+ t . regex ( JSON . parse ( body ) . query , / q u e r y g e t R e l a t e d I s s u e s \( / ) ;
3422+ return true ;
3423+ } ,
3424+ {
3425+ data : {
3426+ repository : { } ,
3427+ } ,
3428+ } ,
3429+ )
3430+ . postOnce (
3431+ ( url , { body } ) => {
3432+ t . is ( url , "https://api.github.local/graphql" ) ;
3433+ t . regex ( JSON . parse ( body ) . query , / q u e r y g e t S R I s s u e s \( / ) ;
3434+ return true ;
3435+ } ,
3436+ {
3437+ data : {
3438+ repository : {
3439+ issues : { nodes : [ ] } ,
3440+ } ,
3441+ } ,
3442+ } ,
3443+ )
34143444 . getOnce (
34153445 `https://api.github.local/search/issues?q=${ encodeURIComponent (
34163446 "in:title" ,
@@ -3522,7 +3552,9 @@ test('Skip comment on issues/PR and skip label if "successComment" is "false" /
35223552 ) ;
35233553
35243554 t . true (
3525- t . context . log . calledWith ( "Skip commenting on issues and pull requests." ) ,
3555+ t . context . log . calledWith (
3556+ "Skip commenting / adding labels on issues and pull requests." ,
3557+ ) ,
35263558 ) ;
35273559 t . true ( fetch . done ( ) ) ;
35283560} ) ;
@@ -3553,13 +3585,53 @@ test('Does not comment/label on issues/PR if "successCommentCondition" is "false
35533585 . getOnce ( `https://api.github.local/repos/${ owner } /${ repo } ` , {
35543586 full_name : `${ owner } /${ repo } ` ,
35553587 } )
3556- . postOnce ( "https://api.github.local/graphql" , {
3557- data : {
3558- repository : {
3559- issues : { nodes : [ ] } ,
3588+ . postOnce (
3589+ ( url , { body } ) =>
3590+ url === "https://api.github.local/graphql" &&
3591+ JSON . parse ( body ) . query . includes ( "query getAssociatedPRs(" ) ,
3592+ {
3593+ data : {
3594+ repository : {
3595+ commit123 : {
3596+ oid : "123" ,
3597+ associatedPullRequests : {
3598+ pageInfo : {
3599+ endCursor : "NI" ,
3600+ hasNextPage : false ,
3601+ } ,
3602+ nodes : [ ] ,
3603+ } ,
3604+ } ,
3605+ } ,
35603606 } ,
35613607 } ,
3562- } )
3608+ )
3609+ . postOnce (
3610+ ( url , { body } ) => {
3611+ t . is ( url , "https://api.github.local/graphql" ) ;
3612+ t . regex ( JSON . parse ( body ) . query , / q u e r y g e t R e l a t e d I s s u e s \( / ) ;
3613+ return true ;
3614+ } ,
3615+ {
3616+ data : {
3617+ repository : { } ,
3618+ } ,
3619+ } ,
3620+ )
3621+ . postOnce (
3622+ ( url , { body } ) => {
3623+ t . is ( url , "https://api.github.local/graphql" ) ;
3624+ t . regex ( JSON . parse ( body ) . query , / q u e r y g e t S R I s s u e s \( / ) ;
3625+ return true ;
3626+ } ,
3627+ {
3628+ data : {
3629+ repository : {
3630+ issues : { nodes : [ ] } ,
3631+ } ,
3632+ } ,
3633+ } ,
3634+ )
35633635 . getOnce (
35643636 `https://api.github.local/search/issues?q=${ encodeURIComponent (
35653637 "in:title" ,
@@ -3592,7 +3664,7 @@ test('Does not comment/label on issues/PR if "successCommentCondition" is "false
35923664 t . true ( fetch . done ( ) ) ;
35933665} ) ;
35943666
3595- test ( 'Add comment and label to found issues/associatedPR using the "successCommentCondition": if specific label is found' , async ( t ) => {
3667+ test ( 'Add comment and label to found issues/associated PR using the "successCommentCondition": if specific label is found' , async ( t ) => {
35963668 const owner = "test_user" ;
35973669 const repo = "test_repo" ;
35983670 const env = { GITHUB_TOKEN : "github_token" } ;
0 commit comments