TenantAtlas/tests/Feature/Onboarding/OnboardingRoleGuidanceTest.php
2026-02-01 12:20:18 +01:00

39 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\OnboardingSession;
use App\Models\Tenant;
use App\Models\TenantMembership;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('renders role-aware guidance for tenant members without run permission', function () {
$tenant = Tenant::factory()->create(['status' => 'active']);
$onboardingUrl = "/admin/t/{$tenant->external_id}/onboarding";
$readonly = User::factory()->create();
TenantMembership::query()->create([
'tenant_id' => $tenant->getKey(),
'user_id' => $readonly->getKey(),
'role' => 'readonly',
'source' => 'manual',
'source_ref' => null,
'created_by_user_id' => null,
]);
OnboardingSession::factory()->create([
'tenant_id' => $tenant->getKey(),
'status' => 'in_progress',
'current_step' => 4,
]);
$this->actingAs($readonly);
$this->get($onboardingUrl)
->assertSuccessful()
->assertSee('permission', escape: false);
});