@@ -287,4 +287,57 @@ public function testShowsDateOfLastSubmission(): void
287287 });
288288 });
289289 }
290+
291+ public function testPaginationLoadsAllProjects (): void
292+ {
293+ $ this ->users ['admin ' ] = $ this ->makeAdminUser ();
294+
295+ // Create 110 public projects, each with a recent build so they appear on the active tab
296+ for ($ i = 1 ; $ i <= 110 ; $ i ++) {
297+ $ project = $ this ->makePublicProject ();
298+ $ this ->projects ["project {$ i }" ] = $ project ;
299+
300+ $ project ->builds ()->create ([
301+ 'siteid ' => $ this ->site ->id ,
302+ 'name ' => Str::uuid ()->toString (),
303+ 'uuid ' => Str::uuid ()->toString (),
304+ 'submittime ' => Carbon::now (),
305+ ]);
306+
307+ $ project ->users ()->attach ($ this ->users ['admin ' ], ['role ' => Project::PROJECT_USER ]);
308+ }
309+
310+ // The first project created has the lowest ID (first pagination page) and the last has
311+ // the highest ID (final pagination page). Waiting for the last project's name guarantees
312+ // all pages have been fetched before asserting.
313+ $ firstProjectName = $ this ->projects ['project1 ' ]->name ;
314+ $ lastProjectName = $ this ->projects ['project110 ' ]->name ;
315+
316+ $ this ->browse (function (Browser $ browser ) use ($ firstProjectName , $ lastProjectName ): void {
317+ $ browser ->loginAs ($ this ->users ['admin ' ])
318+ ->visit ('/projects ' )
319+ ->whenAvailable ('@projects-page ' , function (Browser $ browser ) use ($ firstProjectName , $ lastProjectName ): void {
320+ // Test "All" tab shows projects with lowest and highest IDs
321+ $ browser ->click ('@all-tab ' )
322+ ->waitFor ('@projects-table ' )
323+ ->waitForText ($ lastProjectName )
324+ ->assertSeeIn ('@projects-table ' , $ firstProjectName )
325+ ->assertSeeIn ('@projects-table ' , $ lastProjectName );
326+
327+ // Test "Active" tab shows projects with lowest and highest IDs
328+ $ browser ->click ('@active-tab ' )
329+ ->waitFor ('@projects-table ' )
330+ ->waitForText ($ lastProjectName )
331+ ->assertSeeIn ('@projects-table ' , $ firstProjectName )
332+ ->assertSeeIn ('@projects-table ' , $ lastProjectName );
333+
334+ // Test "Member" tab shows projects with lowest and highest IDs
335+ $ browser ->click ('@member-tab ' )
336+ ->waitFor ('@projects-table ' )
337+ ->waitForText ($ lastProjectName )
338+ ->assertSeeIn ('@projects-table ' , $ firstProjectName )
339+ ->assertSeeIn ('@projects-table ' , $ lastProjectName );
340+ });
341+ });
342+ }
290343}
0 commit comments