<?php

namespace Tests\Feature\Role;

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

class ListTest extends TestCase
{
   use RefreshDatabase, WithFaker;

    public function test_unauthenticated_user_cannot_access(): void
    {
        $response = $this->getJson(route('roles.list'));
        $response->assertUnauthorized();
    }

    public function test_roles_list_returns_correct_structure(): void
    {
        $user = User::factory()->create();

        Role::factory()->count(3)->create();

        $response = $this->actingAs($user)->getJson(route('roles.list'));

        $response->assertOk()
            ->assertJsonStructure([
                'data' => [
                    '*' => [
                        'id',
                        'name',
                        'name_fa',
                    ]
                ]
            ]);
    }
}
