<?php

declare(strict_types=1);

use App\Filament\Resources\ManagedEnvironmentResource\Pages\ViewManagedEnvironment;
use Livewire\Livewire;

it('renders humanized RBAC reasons while keeping the diagnostic code in tenant governance details', function (): void {
    [$user, $tenant] = createUserWithTenant(role: 'owner');

    $tenant->forceFill([
        'rbac_status' => 'manual_assignment_required',
        'rbac_status_reason' => 'manual_assignment_required',
    ])->save();

    Livewire::actingAs($user)
        ->test(ViewManagedEnvironment::class, ['record' => $tenant->getRouteKey()])
        ->assertSee('Manual role assignment required')
        ->assertSee('This tenant requires a manual Intune RBAC role assignment outside the automated API path.')
        ->assertSee('manual_assignment_required');
});
