@@ -1230,7 +1230,8 @@ describe("GitCafePullRequestProvider", () => {
12301230 let comparisonBaseOid = baseOid ;
12311231 let tips = { targetBranch : "main" , observedBaseOid : baseOid } ;
12321232 let pullReads = 0 ;
1233- let hunksDown = true ;
1233+ let listingCut = true ;
1234+ let hunksDown = false ;
12341235 const hunks = ( request : SentRequest ) => ( {
12351236 version : 4 ,
12361237 headOid,
@@ -1244,12 +1245,15 @@ describe("GitCafePullRequestProvider", () => {
12441245 const server = fakeGitCafe ( {
12451246 // A comment moves the version without moving the compared commits.
12461247 "GET /repos/owner/repo/pulls/7" : ( ) => ( { ...pull , ...tips , version : 4 + pullReads ++ } ) ,
1247- "GET /repos/owner/repo/pulls/7/changes" : ( ) => ( {
1248+ "GET /repos/owner/repo/pulls/7/changes" : ( request : SentRequest ) => ( {
12481249 version : 4 ,
12491250 headOid,
12501251 comparisonBaseOid,
1251- items : [ { path : "a.ts" } , { path : "b.ts" } ] ,
1252- next : null ,
1252+ ...( ! listingCut
1253+ ? { items : [ { path : "a.ts" } , { path : "b.ts" } ] , next : null }
1254+ : request . query . has ( "after" )
1255+ ? { items : [ ] , next : "more" }
1256+ : { items : [ { path : "a.ts" } ] , next : "more" } ) ,
12531257 } ) ,
12541258 get "POST /repos/owner/repo/pulls/7/diff-files" ( ) {
12551259 return hunksDown
@@ -1261,6 +1265,10 @@ describe("GitCafePullRequestProvider", () => {
12611265 server . sent . filter ( ( request ) => request . path . endsWith ( suffix ) ) . length ;
12621266 return Effect . gen ( function * ( ) {
12631267 const provider = yield * GitCafePullRequestProvider . make ;
1268+ // A listing that stops before its last page holds nothing for its commits.
1269+ yield * provider . getChangeRequestSummary ! ( target ) ;
1270+ listingCut = false ;
1271+ hunksDown = true ;
12641272 // Unread hunks leave the lines unknown, and are read again next time.
12651273 const unread = yield * provider . getChangeRequestSummary ! ( target ) ;
12661274 assert . strictEqual ( unread . additions , undefined ) ;
@@ -1270,18 +1278,18 @@ describe("GitCafePullRequestProvider", () => {
12701278 assert . deepInclude ( first , { additions : 6 , deletions : 2 , changedFiles : 2 } ) ;
12711279 assert . deepInclude ( second , { additions : 6 , deletions : 2 , changedFiles : 2 } ) ;
12721280 // Neither the head nor the target tip moved, so the file list is not read again.
1273- assert . deepStrictEqual ( [ reads ( "/changes" ) , reads ( "/diff-files" ) ] , [ 2 , 2 ] ) ;
1281+ assert . deepStrictEqual ( [ reads ( "/changes" ) , reads ( "/diff-files" ) ] , [ 4 , 3 ] ) ;
12741282 // The target branch advancing keeps the merge base, so only the file list is read.
12751283 tips = { ...tips , observedBaseOid : mainTip } ;
12761284 const third = yield * provider . getChangeRequestSummary ! ( target ) ;
12771285 assert . deepInclude ( third , { additions : 6 , deletions : 2 , changedFiles : 2 } ) ;
1278- assert . deepStrictEqual ( [ reads ( "/changes" ) , reads ( "/diff-files" ) ] , [ 3 , 2 ] ) ;
1286+ assert . deepStrictEqual ( [ reads ( "/changes" ) , reads ( "/diff-files" ) ] , [ 5 , 3 ] ) ;
12791287 // A landed parent layer retargets the pull and moves the comparison base under the same head.
12801288 comparisonBaseOid = landedBase ;
12811289 tips = { targetBranch : "trunk" , observedBaseOid : mainTip } ;
12821290 const fourth = yield * provider . getChangeRequestSummary ! ( target ) ;
12831291 assert . deepInclude ( fourth , { additions : 2 , deletions : 2 , changedFiles : 2 } ) ;
1284- assert . deepStrictEqual ( [ reads ( "/changes" ) , reads ( "/diff-files" ) ] , [ 4 , 3 ] ) ;
1292+ assert . deepStrictEqual ( [ reads ( "/changes" ) , reads ( "/diff-files" ) ] , [ 6 , 4 ] ) ;
12851293 } ) . pipe ( Effect . provide ( server . layer ) ) ;
12861294 } ) ;
12871295
0 commit comments