@@ -248,6 +248,40 @@ describe("resolveThreadPullRequestChains", () => {
248248} ) ;
249249
250250describe ( "chain selection and badge state" , ( ) => {
251+ it . each ( [
252+ [ "open" , false , "open" , false , "open" ] ,
253+ [ "closed" , false , "closed" , false , "closed" ] ,
254+ [ "open" , true , "open" , true , "draft" ] ,
255+ [ "open" , false , "open" , true , "open" ] ,
256+ [ "closed" , false , "open" , true , "open" ] ,
257+ [ "merged" , false , "merged" , false , "merged" ] ,
258+ [ "merged" , false , "closed" , true , "closed" ] ,
259+ ] as const ) (
260+ "aggregates %s (draft %s) and %s (draft %s) as %s" ,
261+ ( firstState , firstDraft , secondState , secondDraft , state ) => {
262+ for ( const stacked of [ false , true ] ) {
263+ const links = [
264+ link ( 1 , {
265+ snapshot : snapshot ( { state : firstState , isDraft : firstDraft , headBranch : "base" } ) ,
266+ } ) ,
267+ link ( 2 , {
268+ snapshot : snapshot ( {
269+ state : secondState ,
270+ isDraft : secondDraft ,
271+ baseBranch : stacked ? "base" : "main" ,
272+ } ) ,
273+ } ) ,
274+ link ( 3 , { source : "stack-dismissed" } ) ,
275+ ] ;
276+ expect ( resolveThreadPullRequestBadge ( links ) ) . toEqual (
277+ stacked
278+ ? { kind : "stack" , layers : 2 , state }
279+ : { kind : "pull-request" , others : 1 , state } ,
280+ ) ;
281+ }
282+ } ,
283+ ) ;
284+
251285 it . each ( [ "open" , "merged" , "closed" ] as const ) (
252286 "targets the top of a derived %s chain despite a later bottom update and link" ,
253287 ( state ) => {
@@ -309,6 +343,7 @@ describe("chain selection and badge state", () => {
309343 expect ( resolveThreadPullRequestBadge ( [ bottom , top , link ( 3 ) ] ) ) . toEqual ( {
310344 kind : "pull-request" ,
311345 others : 2 ,
346+ state : "open" ,
312347 } ) ;
313348 expect ( resolveThreadPullRequestBadge ( [ link ( 3 , { source : "stack-dismissed" } ) ] ) ) . toBeNull ( ) ;
314349 } ) ;
@@ -340,7 +375,11 @@ describe("chain selection and badge state", () => {
340375 kind : "stack" ,
341376 top : { number : 2 } ,
342377 } ) ;
343- expect ( resolveThreadPullRequestBadge ( links ) ) . toEqual ( { kind : "pull-request" , others : 1 } ) ;
378+ expect ( resolveThreadPullRequestBadge ( links ) ) . toEqual ( {
379+ kind : "pull-request" ,
380+ others : 1 ,
381+ state : "open" ,
382+ } ) ;
344383 } ) ;
345384
346385 it ( "does not guess a parent when a head branch was reused" , ( ) => {
0 commit comments