@@ -271,6 +271,23 @@ describe("GitCafePullRequestProvider", () => {
271271 } ) . pipe ( Effect . provide ( server . layer ) ) ;
272272 } ) ;
273273
274+ it . effect ( "keeps the timeline when GitCafe no longer has the head's commits" , ( ) => {
275+ const comment = { ...root , id : "c1" , threadId : "c1" , body : "Looks good" , path : null } ;
276+ const server = fakeGitCafe ( {
277+ "GET /repos/owner/repo/pulls/7" : { ...pull , state : "closed" , closedAt : timestamp } ,
278+ "GET /repos/owner/repo/pulls/7/comments" : { items : [ comment ] , next : null } ,
279+ "GET /repos/owner/repo/pulls/7/reviews" : { items : [ ] , next : null } ,
280+ } ) ;
281+ return Effect . gen ( function * ( ) {
282+ const provider = yield * GitCafePullRequestProvider . make ;
283+ const activity = yield * provider . getChangeRequestActivity ( target ) ;
284+ assert . deepStrictEqual (
285+ activity . comments . map ( ( entry ) => entry . body ) ,
286+ [ "Looks good" ] ,
287+ ) ;
288+ } ) . pipe ( Effect . provide ( server . layer ) ) ;
289+ } ) ;
290+
274291 it . effect ( "submits a review against the pull request's current head" , ( ) => {
275292 const server = fakeGitCafe ( {
276293 "GET /repos/owner/repo/pulls/7" : pull ,
@@ -381,9 +398,7 @@ describe("GitCafePullRequestProvider", () => {
381398 [ "reviewing" , "reviewers" ] ,
382399 ] as const ) ( "filters %s pull requests by the viewer's actor on GitCafe" , ( [ involvement , key ] ) => {
383400 const server = fakeGitCafe ( {
384- "GET /repos/owner/repo/filter-options" : {
385- actors : [ { actorId : "act_one" , handle : "Alice" } ] ,
386- } ,
401+ "GET /auth/principal" : { actorId : "act_one" , handle : "Alice" } ,
387402 "GET /repos/owner/repo/pulls" : { items : [ pull ] , next : null } ,
388403 } ) ;
389404 return Effect . gen ( function * ( ) {
@@ -403,9 +418,9 @@ describe("GitCafePullRequestProvider", () => {
403418 } ) . pipe ( Effect . provide ( server . layer ) ) ;
404419 } ) ;
405420
406- it . effect ( "lists nothing for a viewer GitCafe has no actor for " , ( ) => {
421+ it . effect ( "lists nothing for a viewer the token does not belong to " , ( ) => {
407422 const server = fakeGitCafe ( {
408- "GET /repos/owner/repo/filter-options " : { actors : [ ] } ,
423+ "GET /auth/principal " : { actorId : "act_two" , handle : "bob" } ,
409424 } ) ;
410425 return Effect . gen ( function * ( ) {
411426 const provider = yield * GitCafePullRequestProvider . make ;
@@ -419,7 +434,7 @@ describe("GitCafePullRequestProvider", () => {
419434 assert . deepStrictEqual ( page . items , [ ] ) ;
420435 assert . deepStrictEqual (
421436 server . sent . map ( ( request ) => request . path ) ,
422- [ "/repos/owner/repo/filter-options " ] ,
437+ [ "/auth/principal " ] ,
423438 ) ;
424439 } ) . pipe ( Effect . provide ( server . layer ) ) ;
425440 } ) ;
@@ -557,6 +572,59 @@ describe("GitCafePullRequestProvider", () => {
557572 } ) . pipe ( Effect . provide ( server . layer ) ) ;
558573 } ) ;
559574
575+ const detailWith = ( overrides : Record < string , unknown > , reasons : ReadonlyArray < string > = [ ] ) =>
576+ fakeGitCafe ( {
577+ "GET /repos/owner/repo/pulls/7" : { ...pull , headOid : null , ...overrides } ,
578+ "GET /repos/owner/repo/pulls/7/reviewers" : { items : [ ] , next : null } ,
579+ "GET /repos/owner/repo/pulls/7/labels" : { items : [ ] , next : null } ,
580+ "GET /repos/owner/repo/pulls/7/status" : {
581+ merge : { conflicts : "none" , fastForward : null , strategies : [ "squash" ] , reasons } ,
582+ checks : { pending : 0 , failing : 0 , total : 0 } ,
583+ } ,
584+ } ) ;
585+
586+ it . effect ( "shows a merge GitCafe accepted as armed until it lands" , ( ) => {
587+ const server = detailWith ( { } , [ "provider-merge-pending" ] ) ;
588+ return Effect . gen ( function * ( ) {
589+ const provider = yield * GitCafePullRequestProvider . make ;
590+ const detail = yield * provider . getChangeRequest ( target ) ;
591+ assert . strictEqual ( detail . autoMergeEnabled , true ) ;
592+ assert . notInclude ( detail . viewerPermissions ?. actions ?? [ ] , "merge" ) ;
593+ } ) . pipe ( Effect . provide ( server . layer ) ) ;
594+ } ) ;
595+
596+ it . effect ( "reads a pull request GitHub merged as merged before the sync reports it" , ( ) => {
597+ const mergedAt = "2026-09-12T13:00:00Z" ;
598+ const server = detailWith ( { providerMerge : { mergedAt } } ) ;
599+ return Effect . gen ( function * ( ) {
600+ const provider = yield * GitCafePullRequestProvider . make ;
601+ const detail = yield * provider . getChangeRequest ( target ) ;
602+ assert . strictEqual ( detail . state , "merged" ) ;
603+ assert . strictEqual ( detail . mergedAt , mergedAt ) ;
604+ } ) . pipe ( Effect . provide ( server . layer ) ) ;
605+ } ) ;
606+
607+ it . effect . each ( [
608+ [ "their own pull request" , actor ] ,
609+ [
610+ "the pull request GitHub sync opened for them" ,
611+ {
612+ kind : "github" ,
613+ actorId : "act_github" ,
614+ login : "alice" ,
615+ avatarUrl : null ,
616+ linkedProfile : { handle : "alice" , actorId : "act_one" } ,
617+ } ,
618+ ] ,
619+ ] as const ) ( "leaves the author only a comment on %s" , ( [ , author ] ) => {
620+ const server = detailWith ( { author, viewerActorId : "act_one" } ) ;
621+ return Effect . gen ( function * ( ) {
622+ const provider = yield * GitCafePullRequestProvider . make ;
623+ const detail = yield * provider . getChangeRequest ( target ) ;
624+ assert . deepStrictEqual ( detail . viewerPermissions ?. verdicts , [ "comment" ] ) ;
625+ } ) . pipe ( Effect . provide ( server . layer ) ) ;
626+ } ) ;
627+
560628 it . effect ( "requests and withdraws reviewers by rewriting the whole list" , ( ) => {
561629 const bob = { ...actor , actorId : "act_two" , handle : "bob" } ;
562630 let requested = [ { id : "act_two" , actor : bob } ] ;
0 commit comments