<?php

namespace Tests\Feature\Authorization;

use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class RoleMiddlewareTest extends TestCase
{
    use RefreshDatabase;

    public function test_non_sekretariat_user_cannot_access_reports_page(): void
    {
        $user = User::factory()->create([
            'role' => 'user',
        ]);

        $response = $this->actingAs($user)->get(route('reports.index'));

        $response->assertForbidden();
    }

    public function test_regular_user_cannot_export_reports_excel(): void
    {
        $user = User::factory()->create([
            'role' => 'user',
        ]);

        $response = $this->actingAs($user)->get(route('reports.export.excel'));

        $response->assertForbidden();
    }

    public function test_staff_bidang_cannot_export_reports_pdf(): void
    {
        $staffBidang = User::factory()->create([
            'role' => 'staff_bidang',
        ]);

        $response = $this->actingAs($staffBidang)->get(route('reports.export.pdf'));

        $response->assertForbidden();
    }
}
