role listing
This commit is contained in:
41
tests/Feature/RoleIndexTest.php
Normal file
41
tests/Feature/RoleIndexTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
|
||||
test('guests are redirected to login from roles page', function () {
|
||||
$this->get('/roles')->assertRedirect('/login');
|
||||
});
|
||||
|
||||
test('authenticated users can view the roles page', function () {
|
||||
$this->actingAs(User::factory()->create())
|
||||
->get('/roles')
|
||||
->assertOk()
|
||||
->assertViewIs('roles.index');
|
||||
});
|
||||
|
||||
test('roles page passes paginated roles to view', function () {
|
||||
$this->actingAs(User::factory()->create())
|
||||
->get('/roles')
|
||||
->assertOk()
|
||||
->assertViewHas('roles');
|
||||
});
|
||||
|
||||
test('ajax request returns roles table partial', function () {
|
||||
$this->actingAs(User::factory()->create())
|
||||
->withHeader('X-Requested-With', 'XMLHttpRequest')
|
||||
->get('/roles')
|
||||
->assertOk()
|
||||
->assertViewIs('roles._table');
|
||||
});
|
||||
|
||||
test('ajax pagination returns correct page', function () {
|
||||
Role::factory()->count(15)->create();
|
||||
|
||||
$this->actingAs(User::factory()->create())
|
||||
->withHeader('X-Requested-With', 'XMLHttpRequest')
|
||||
->get('/roles?page=2')
|
||||
->assertOk()
|
||||
->assertViewIs('roles._table')
|
||||
->assertViewHas('roles', fn ($roles) => $roles->currentPage() === 2);
|
||||
});
|
||||
Reference in New Issue
Block a user