user pagination
This commit is contained in:
@@ -15,11 +15,33 @@ test('authenticated users can view the users page', function () {
|
||||
->assertViewIs('users.index');
|
||||
});
|
||||
|
||||
test('users page lists all users', function () {
|
||||
$users = User::factory()->count(3)->create();
|
||||
test('users page passes paginated users to view', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($users->first())
|
||||
$this->actingAs($user)
|
||||
->get('/users')
|
||||
->assertOk()
|
||||
->assertViewHas('users', fn ($viewUsers) => $viewUsers->count() === User::count());
|
||||
->assertViewHas('users');
|
||||
});
|
||||
|
||||
test('ajax request returns table partial', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->withHeader('X-Requested-With', 'XMLHttpRequest')
|
||||
->get('/users')
|
||||
->assertOk()
|
||||
->assertViewIs('users._table');
|
||||
});
|
||||
|
||||
test('ajax pagination returns correct page', function () {
|
||||
$user = User::factory()->create();
|
||||
User::factory()->count(15)->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->withHeader('X-Requested-With', 'XMLHttpRequest')
|
||||
->get('/users?page=2')
|
||||
->assertOk()
|
||||
->assertViewIs('users._table')
|
||||
->assertViewHas('users', fn ($users) => $users->currentPage() === 2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user