@@ -3,7 +3,7 @@ import sinon from "sinon";
3
3
import test from "ava" ;
4
4
import fetchMock from "fetch-mock" ;
5
5
6
- import { ISSUE_ID } from "../lib/definitions/constants.js" ;
6
+ import { ISSUE_ID , RELEASE_FAIL_LABEL } from "../lib/definitions/constants.js" ;
7
7
import { TestOctokit } from "./helpers/test-octokit.js" ;
8
8
9
9
/* eslint camelcase: ["error", {properties: "never"}] */
@@ -41,6 +41,13 @@ test("Open a new issue with the list of errors", async (t) => {
41
41
. getOnce ( "https://api.github.local/repos/test_user/test_repo" , {
42
42
full_name : `${ redirectedOwner } /${ redirectedRepo } ` ,
43
43
} )
44
+ . postOnce ( "https://api.github.local/graphql" , {
45
+ data : {
46
+ repository : {
47
+ issues : { nodes : [ ] } ,
48
+ } ,
49
+ } ,
50
+ } )
44
51
. getOnce (
45
52
`https://api.github.local/search/issues?q=${ encodeURIComponent (
46
53
"in:title" ,
@@ -64,7 +71,7 @@ test("Open a new issue with the list of errors", async (t) => {
64
71
data . body ,
65
72
/ - - - \n \n # # # E r r o r m e s s a g e 1 \n \n E r r o r 1 d e t a i l s \n \n - - - \n \n # # # E r r o r m e s s a g e 2 \n \n E r r o r 2 d e t a i l s \n \n - - - \n \n # # # E r r o r m e s s a g e 3 \n \n E r r o r 3 d e t a i l s \n \n - - - / ,
66
73
) ;
67
- t . deepEqual ( data . labels , [ "semantic-release" ] ) ;
74
+ t . deepEqual ( data . labels , [ "semantic-release" , RELEASE_FAIL_LABEL ] ) ;
68
75
return true ;
69
76
} ,
70
77
{
@@ -122,6 +129,13 @@ test("Open a new issue with the list of errors and custom title and comment", as
122
129
full_name : `${ owner } /${ repo } ` ,
123
130
clone_url : `https://api.github.local/${ owner } /${ repo } .git` ,
124
131
} )
132
+ . postOnce ( "https://api.github.local/graphql" , {
133
+ data : {
134
+ repository : {
135
+ issues : { nodes : [ ] } ,
136
+ } ,
137
+ } ,
138
+ } )
125
139
. getOnce (
126
140
`https://api.github.local/search/issues?q=${ encodeURIComponent (
127
141
"in:title" ,
@@ -137,7 +151,7 @@ test("Open a new issue with the list of errors and custom title and comment", as
137
151
body : {
138
152
title : failTitle ,
139
153
body : `branch master Error message 1 Error message 2 Error message 3\n\n${ ISSUE_ID } ` ,
140
- labels : [ "semantic-release" ] ,
154
+ labels : [ "semantic-release" , RELEASE_FAIL_LABEL ] ,
141
155
} ,
142
156
} ,
143
157
) ;
@@ -190,6 +204,13 @@ test("Open a new issue with assignees and the list of errors", async (t) => {
190
204
full_name : `${ owner } /${ repo } ` ,
191
205
clone_url : `https://api.github.local/${ owner } /${ repo } .git` ,
192
206
} )
207
+ . postOnce ( "https://api.github.local/graphql" , {
208
+ data : {
209
+ repository : {
210
+ issues : { nodes : [ ] } ,
211
+ } ,
212
+ } ,
213
+ } )
193
214
. getOnce (
194
215
`https://api.github.local/search/issues?q=${ encodeURIComponent (
195
216
"in:title" ,
@@ -208,7 +229,7 @@ test("Open a new issue with assignees and the list of errors", async (t) => {
208
229
data . body ,
209
230
/ - - - \n \n # # # E r r o r m e s s a g e 1 \n \n E r r o r 1 d e t a i l s \n \n - - - \n \n # # # E r r o r m e s s a g e 2 \n \n E r r o r 2 d e t a i l s \n \n - - - / ,
210
231
) ;
211
- t . deepEqual ( data . labels , [ "semantic-release" ] ) ;
232
+ t . deepEqual ( data . labels , [ "semantic-release" , RELEASE_FAIL_LABEL ] ) ;
212
233
t . deepEqual ( data . assignees , [ "user1" , "user2" ] ) ;
213
234
return true ;
214
235
} ,
@@ -263,6 +284,13 @@ test("Open a new issue without labels and the list of errors", async (t) => {
263
284
full_name : `${ owner } /${ repo } ` ,
264
285
clone_url : `https://api.github.local/${ owner } /${ repo } .git` ,
265
286
} )
287
+ . postOnce ( "https://api.github.local/graphql" , {
288
+ data : {
289
+ repository : {
290
+ issues : { nodes : [ ] } ,
291
+ } ,
292
+ } ,
293
+ } )
266
294
. getOnce (
267
295
`https://api.github.local/search/issues?q=${ encodeURIComponent (
268
296
"in:title" ,
@@ -281,7 +309,7 @@ test("Open a new issue without labels and the list of errors", async (t) => {
281
309
data . body ,
282
310
/ - - - \n \n # # # E r r o r m e s s a g e 1 \n \n E r r o r 1 d e t a i l s \n \n - - - \n \n # # # E r r o r m e s s a g e 2 \n \n E r r o r 2 d e t a i l s \n \n - - - / ,
283
311
) ;
284
- t . deepEqual ( data . labels , [ ] ) ;
312
+ t . deepEqual ( data . labels , [ RELEASE_FAIL_LABEL ] ) ;
285
313
return true ;
286
314
} ,
287
315
{ html_url : "https://github.com/issues/1" , number : 1 } ,
@@ -340,14 +368,13 @@ test("Update the first existing issue with the list of errors", async (t) => {
340
368
full_name : `${ owner } /${ repo } ` ,
341
369
clone_url : `https://api.github.local/${ owner } /${ repo } .git` ,
342
370
} )
343
- . getOnce (
344
- `https://api.github.local/search/issues?q=${ encodeURIComponent (
345
- "in:title" ,
346
- ) } +${ encodeURIComponent ( `repo:${ owner } /${ repo } ` ) } +${ encodeURIComponent (
347
- "type:issue" ,
348
- ) } +${ encodeURIComponent ( "state:open" ) } +${ encodeURIComponent ( failTitle ) } `,
349
- { items : issues } ,
350
- )
371
+ . postOnce ( "https://api.github.local/graphql" , {
372
+ data : {
373
+ repository : {
374
+ issues : { nodes : issues } ,
375
+ } ,
376
+ } ,
377
+ } )
351
378
. postOnce (
352
379
( url , { body } ) => {
353
380
t . is (
@@ -506,13 +533,17 @@ test('Does not post comments on existing issues when "failCommentCondition" is "
506
533
. getOnce ( `https://api.github.local/repos/${ owner } /${ repo } ` , {
507
534
full_name : `${ owner } /${ repo } ` ,
508
535
} )
509
- . getOnce (
510
- `https://api.github.local/search/issues?q=${ encodeURIComponent (
511
- "in:title" ,
512
- ) } +${ encodeURIComponent ( `repo:${ owner } /${ repo } ` ) } +${ encodeURIComponent (
513
- "type:issue" ,
514
- ) } +${ encodeURIComponent ( "state:open" ) } +${ encodeURIComponent ( failTitle ) } `,
515
- { items : issues } ,
536
+ . postOnce (
537
+ ( url , { body } ) =>
538
+ url === "https://api.github.local/graphql" &&
539
+ JSON . parse ( body ) . query . includes ( "query getSRIssues(" ) ,
540
+ {
541
+ data : {
542
+ repository : {
543
+ issues : { nodes : issues } ,
544
+ } ,
545
+ } ,
546
+ } ,
516
547
) ;
517
548
518
549
await fail (
@@ -556,6 +587,18 @@ test(`Post new issue if none exists yet, but don't comment on existing issues wh
556
587
. getOnce ( `https://api.github.local/repos/${ owner } /${ repo } ` , {
557
588
full_name : `${ owner } /${ repo } ` ,
558
589
} )
590
+ . postOnce (
591
+ ( url , { body } ) =>
592
+ url === "https://api.github.local/graphql" &&
593
+ JSON . parse ( body ) . query . includes ( "query getSRIssues(" ) ,
594
+ {
595
+ data : {
596
+ repository : {
597
+ issues : { nodes : [ ] } ,
598
+ } ,
599
+ } ,
600
+ } ,
601
+ )
559
602
. getOnce (
560
603
`https://api.github.local/search/issues?q=${ encodeURIComponent (
561
604
"in:title" ,
0 commit comments