Teren-app/tests/Feature/Reports/ReportsIndexTest.php
Simon Pocrnjič 63e0958b66 Dev branch
2025-11-02 12:31:01 +01:00

23 lines
716 B
PHP

<?php
use App\Models\Permission;
use App\Models\Role;
use App\Models\User;
it('shows reports index', function (): void {
$user = User::factory()->create();
// grant reports-view permission
$role = Role::create(['name' => 'Reporter', 'slug' => 'reporter']);
$perm = Permission::firstOrCreate(['slug' => 'reports-view'], ['name' => 'Reports View']);
$role->permissions()->syncWithoutDetaching($perm->id);
$role->users()->syncWithoutDetaching($user->id);
$this->actingAs($user);
$response = $this->get(route('reports.index'));
$response->assertSuccessful();
$response->assertInertia(fn ($page) => $page
->component('Reports/Index')
->has('reports')
);
});