74 lines
2.4 KiB
PHP
74 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\Onboarding\TenantOnboardingWizard;
|
|
use App\Models\OnboardingSession;
|
|
use App\Models\ProviderConnection;
|
|
use Filament\Facades\Filament;
|
|
use Livewire\Livewire;
|
|
|
|
it('mounts destructive-like onboarding actions for modal confirmation', function () {
|
|
[$userA, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
[$userB] = createUserWithTenant(tenant: $tenant, role: 'operator');
|
|
|
|
$connection = ProviderConnection::factory()->for($tenant)->create([
|
|
'provider' => 'microsoft',
|
|
'is_default' => true,
|
|
]);
|
|
|
|
$session = OnboardingSession::query()->create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
'provider_connection_id' => $connection->getKey(),
|
|
'status' => 'in_progress',
|
|
'current_step' => 4,
|
|
'assigned_to_user_id' => $userA->getKey(),
|
|
'locked_by_user_id' => $userB->getKey(),
|
|
'locked_until' => now()->addMinutes(10),
|
|
'metadata' => [],
|
|
]);
|
|
|
|
$this->actingAs($userA);
|
|
Filament::setTenant($tenant, true);
|
|
|
|
Livewire::test(TenantOnboardingWizard::class)
|
|
->assertSuccessful()
|
|
->assertSet('session.id', (int) $session->getKey())
|
|
->assertActionVisible('takeover_onboarding_session')
|
|
->mountAction('takeover_onboarding_session')
|
|
->assertActionMounted('takeover_onboarding_session');
|
|
});
|
|
|
|
it('mounts legacy credential migration action for modal confirmation', function () {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
$tenant->forceFill([
|
|
'app_client_id' => '00000000-0000-0000-0000-000000000000',
|
|
'app_client_secret' => 'TENANT_SECRET_NOT_RENDERED',
|
|
])->save();
|
|
|
|
$connection = ProviderConnection::factory()->for($tenant)->create([
|
|
'provider' => 'microsoft',
|
|
'is_default' => true,
|
|
]);
|
|
|
|
OnboardingSession::query()->create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
'provider_connection_id' => $connection->getKey(),
|
|
'status' => 'in_progress',
|
|
'current_step' => 2,
|
|
'assigned_to_user_id' => $user->getKey(),
|
|
'metadata' => [],
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
Filament::setTenant($tenant, true);
|
|
|
|
Livewire::test(TenantOnboardingWizard::class)
|
|
->assertSuccessful()
|
|
->assertActionVisible('migrate_legacy_credentials')
|
|
->mountAction('migrate_legacy_credentials')
|
|
->assertActionMounted('migrate_legacy_credentials');
|
|
});
|