set('tenantpilot.onboarding.credentials_required', false); [$user] = createUserWithTenant(role: 'owner'); $this->actingAs($user); $tenant = Tenant::factory()->create([ 'name' => 'Existing Tenant', 'tenant_id' => fake()->uuid(), 'environment' => 'other', 'status' => 'active', 'onboarding_status' => 'in_progress', ]); $user->tenants()->syncWithoutDetaching([ $tenant->getKey() => ['role' => 'owner'], ]); $existingSession = TenantOnboardingSession::factory()->create([ 'tenant_id' => $tenant->getKey(), 'created_by_user_id' => $user->getKey(), 'status' => 'active', 'current_step' => 'permissions', 'payload' => [ 'name' => $tenant->name, 'tenant_id' => $tenant->tenant_id, 'environment' => $tenant->environment, ], ]); $component = Livewire::withQueryParams([ 'tenant' => (string) $tenant->external_id, ])->test(TenantOnboardingWizard::class); expect($component->get('sessionId'))->toBe((string) $existingSession->getKey()); expect(TenantOnboardingSession::query() ->where('tenant_id', $tenant->getKey()) ->where('status', 'active') ->count())->toBe(1); });