Files
famous-ly4-ev/app-modules/identity/tests/Feature/CustomerResourceTest.php
T

36 lines
1.0 KiB
PHP
Raw Normal View History

<?php
use App\Models\User;
use Livewire\Livewire;
use Modules\Identity\Database\Seeders\RolePermissionSeeder;
use Modules\Identity\Filament\Resources\Customers\Pages\ListCustomers;
beforeEach(function () {
$this->seed(RolePermissionSeeder::class);
$this->staff = User::factory()->create();
$this->staff->assignRole('support');
});
test('staff with view_customers can list customers', function () {
$this->actingAs($this->staff)->get('/admin/customers')->assertSuccessful();
});
test('the customer resource only lists users without any role', function () {
$customer = User::factory()->create();
$this->actingAs($this->staff);
Livewire::test(ListCustomers::class)
->assertCanSeeTableRecords([$customer])
->assertCanNotSeeTableRecords([$this->staff]);
});
test('a customer view page loads for staff', function () {
$customer = User::factory()->create();
$this->actingAs($this->staff)
->get("/admin/customers/{$customer->id}")
->assertSuccessful();
});