TenantAtlas/tests/Feature/TenantOnboardingVerifyOperationRunTest.php
2026-02-01 12:20:09 +01:00

46 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
use App\Filament\Pages\TenantOnboardingWizard;
use App\Jobs\TenantOnboardingVerifyJob;
use App\Models\OperationRun;
use Illuminate\Support\Facades\Bus;
use Livewire\Livewire;
it('creates and dedupes a verification OperationRun and dispatches a job', function (): void {
config()->set('tenantpilot.onboarding.credentials_required', false);
Bus::fake();
[$user, $portfolioTenant] = createUserWithTenant(role: 'owner');
$this->actingAs($user);
$tenantGuid = fake()->uuid();
$component = Livewire::withQueryParams([
'tenant' => (string) $portfolioTenant->external_id,
])->test(TenantOnboardingWizard::class)
->goToNextWizardStep()
->fillForm([
'name' => 'Acme',
'environment' => 'other',
'tenant_id' => $tenantGuid,
'domain' => 'acme.example',
], 'form')
->goToNextWizardStep();
$component->call('enqueueVerification');
expect(OperationRun::query()->where('type', 'tenant.rbac.verify')->count())->toBe(1);
Bus::assertDispatched(TenantOnboardingVerifyJob::class, 1);
$component->call('enqueueVerification');
expect(OperationRun::query()->where('type', 'tenant.rbac.verify')->count())->toBe(1);
Bus::assertDispatched(TenantOnboardingVerifyJob::class, 1);
});