create(); $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.show', 'field-jobs-completed')); $response->assertSuccessful(); $response->assertInertia(fn ($page) => $page ->component('Reports/Show') ->where('slug', 'field-jobs-completed') ->has('inputs') ->has('columns') ); }); it('returns data json for report', function (): void { $user = User::factory()->create(); $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.data', 'field-jobs-completed')); $response->assertSuccessful(); $json = $response->json(); expect($json)->toHaveKeys(['data', 'total', 'current_page', 'last_page']); });