adminUser = User::factory()->create(['role' => Role::ADMIN]); $this->managerUser = User::factory()->create(['role' => Role::MANAGER]); $this->brigadierUser = User::factory()->create(['role' => Role::BRIGADIER]); } public function test_guest_cannot_access_reports_index(): void { $response = $this->get(route('reports.index')); $response->assertRedirect(route('login')); } public function test_brigadier_cannot_access_reports(): void { $response = $this->actingAs($this->brigadierUser)->get(route('reports.index')); $response->assertStatus(403); } public function test_admin_can_access_reports_index(): void { $response = $this->actingAs($this->adminUser)->get(route('reports.index')); $response->assertStatus(200); $response->assertViewIs('reports.index'); } public function test_manager_can_access_reports_index(): void { $response = $this->actingAs($this->managerUser)->get(route('reports.index')); $response->assertStatus(200); $response->assertViewIs('reports.index'); } public function test_reports_index_contains_required_view_data(): void { $response = $this->actingAs($this->adminUser)->get(route('reports.index')); $response->assertViewHas('totalOrders'); $response->assertViewHas('totalMafs'); $response->assertViewHas('managers'); } public function test_reports_index_has_done_orders_count(): void { $response = $this->actingAs($this->adminUser)->get(route('reports.index')); $response->assertViewHas('doneOrders', fn($v) => $v >= 0); } public function test_reports_index_has_mount_orders_count(): void { $response = $this->actingAs($this->adminUser)->get(route('reports.index')); $response->assertViewHas('mountOrders', fn($v) => $v >= 0); } public function test_reports_index_has_reclamations_data(): void { $response = $this->actingAs($this->adminUser)->get(route('reports.index')); $response->assertViewHas('totalReclamations'); $response->assertViewHas('reclamationStatuses'); } public function test_reports_index_has_by_district_data(): void { $response = $this->actingAs($this->adminUser)->get(route('reports.index')); $response->assertViewHas('byDistrict', fn($v) => is_array($v)); } public function test_reports_index_has_total_sum(): void { $response = $this->actingAs($this->adminUser)->get(route('reports.index')); $response->assertViewHas('totalSum'); $response->assertViewHas('totalDoneSum'); } }