43 lines
1.2 KiB
PHP
43 lines
1.2 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('auto-links the default provider connection to the active session when legacy credentials exist', function () {
|
|
[$user, $tenant] = createUserWithTenant(role: 'owner');
|
|
|
|
$tenant->forceFill([
|
|
'app_client_id' => '00000000-0000-0000-0000-000000000000',
|
|
'app_client_secret' => 'TENANT_SECRET_FOR_RESUME',
|
|
])->save();
|
|
|
|
$connection = ProviderConnection::factory()->for($tenant)->create([
|
|
'provider' => 'microsoft',
|
|
'is_default' => true,
|
|
]);
|
|
|
|
$session = OnboardingSession::query()->create([
|
|
'tenant_id' => $tenant->getKey(),
|
|
'provider_connection_id' => null,
|
|
'status' => 'draft',
|
|
'current_step' => 1,
|
|
'assigned_to_user_id' => $user->getKey(),
|
|
'metadata' => [],
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
Filament::setTenant($tenant, true);
|
|
|
|
Livewire::test(TenantOnboardingWizard::class)
|
|
->assertSuccessful();
|
|
|
|
$session->refresh();
|
|
|
|
expect($session->provider_connection_id)->toBe((int) $connection->getKey());
|
|
});
|