create(['status' => 'active']); $archivedTenant = Tenant::factory()->create(['status' => 'active']); [$user] = createUserWithTenant($activeTenant, role: 'owner'); $user->tenants()->syncWithoutDetaching([ $archivedTenant->getKey() => [ 'role' => 'readonly', 'source' => 'manual', 'created_by_user_id' => $user->getKey(), ], ]); $archivedTenant->delete(); $this->actingAs($user); $activeTenant->makeCurrent(); Filament::setTenant($activeTenant, true); $this->withSession([ ManagedTenantContext::ARCHIVED_TENANT_ID_SESSION_KEY => $archivedTenant->getKey(), ]); Livewire::test(ArchivedStatus::class) ->assertActionVisible('restore') ->assertActionDisabled('restore') ->assertActionExists('restore', fn (Action $action): bool => $action->isConfirmationRequired()) ->assertActionVisible('force_delete') ->assertActionDisabled('force_delete') ->assertActionExists('force_delete', fn (Action $action): bool => $action->isConfirmationRequired()) ->mountAction('restore') ->callMountedAction() ->assertSuccessful(); expect(Tenant::withTrashed()->find($archivedTenant->getKey())?->trashed())->toBeTrue(); Livewire::test(ArchivedStatus::class) ->mountAction('force_delete') ->callMountedAction() ->assertSuccessful(); expect(Tenant::withTrashed()->find($archivedTenant->getKey()))->not->toBeNull(); });