<?php

declare(strict_types=1);

use App\Models\ManagedEnvironment;
use App\Support\Links\RequiredPermissionsLinks;

it('renders guidance, admin consent link, re-run verification, and copy actions on the required permissions page', function (): void {
    $tenant = ManagedEnvironment::factory()->create([
        'external_id' => 'tenant-copy-actions-a',
        'app_client_id' => null,
    ]);

    [$user, $tenant] = createUserWithTenant(tenant: $tenant, role: 'readonly', ensureDefaultMicrosoftProviderConnection: false);

    $this->actingAs($user)
        ->get(RequiredPermissionsLinks::requiredPermissions($tenant))
        ->assertSuccessful()
        ->assertSee('Guidance')
        ->assertSee('Who can fix this?', false)
        ->assertSee('Admin consent guide')
        ->assertSee('learn.microsoft.com/en-us/entra/identity/enterprise-apps/grant-admin-consent', false)
        ->assertSee('Re-run verification')
        ->assertSee('Copy missing application permissions')
        ->assertSee('Copy missing delegated permissions');
});
