@@ -1992,13 +1992,13 @@ test("Ignore missing and forbidden issues/PRs", async (t) => {
1992
1992
) ;
1993
1993
t . true (
1994
1994
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." ,
1996
1996
2 ,
1997
1997
) ,
1998
1998
) ;
1999
1999
t . true (
2000
2000
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." ,
2002
2002
3 ,
2003
2003
) ,
2004
2004
) ;
@@ -3225,7 +3225,7 @@ test("Ignore errors when adding comments and closing issues", async (t) => {
3225
3225
t . is ( error2 . status , 500 ) ;
3226
3226
t . true (
3227
3227
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." ,
3229
3229
1 ,
3230
3230
) ,
3231
3231
) ;
@@ -3396,6 +3396,10 @@ test('Skip comment on on issues/PR if "successComment" is "false"', async (t) =>
3396
3396
repository : {
3397
3397
commit123 : {
3398
3398
associatedPullRequests : {
3399
+ pageInfo : {
3400
+ endCursor : "NI" ,
3401
+ hasNextPage : false ,
3402
+ } ,
3399
3403
nodes : [ prs [ 0 ] ] ,
3400
3404
} ,
3401
3405
} ,
@@ -3411,6 +3415,32 @@ test('Skip comment on on issues/PR if "successComment" is "false"', async (t) =>
3411
3415
{ } ,
3412
3416
{ labels : [ "released" ] } ,
3413
3417
)
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
+ )
3414
3444
. getOnce (
3415
3445
`https://api.github.local/search/issues?q=${ encodeURIComponent (
3416
3446
"in:title" ,
@@ -3522,7 +3552,9 @@ test('Skip comment on issues/PR and skip label if "successComment" is "false" /
3522
3552
) ;
3523
3553
3524
3554
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
+ ) ,
3526
3558
) ;
3527
3559
t . true ( fetch . done ( ) ) ;
3528
3560
} ) ;
@@ -3553,13 +3585,53 @@ test('Does not comment/label on issues/PR if "successCommentCondition" is "false
3553
3585
. getOnce ( `https://api.github.local/repos/${ owner } /${ repo } ` , {
3554
3586
full_name : `${ owner } /${ repo } ` ,
3555
3587
} )
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
+ } ,
3560
3606
} ,
3561
3607
} ,
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
+ )
3563
3635
. getOnce (
3564
3636
`https://api.github.local/search/issues?q=${ encodeURIComponent (
3565
3637
"in:title" ,
@@ -3592,7 +3664,7 @@ test('Does not comment/label on issues/PR if "successCommentCondition" is "false
3592
3664
t . true ( fetch . done ( ) ) ;
3593
3665
} ) ;
3594
3666
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 ) => {
3596
3668
const owner = "test_user" ;
3597
3669
const repo = "test_repo" ;
3598
3670
const env = { GITHUB_TOKEN : "github_token" } ;
0 commit comments