Add tenant lifecycle view and limit controls
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Tests\Feature;
|
||||
use App\Filament\Resources\TenantResource\Pages\ListTenants;
|
||||
use App\Jobs\AnonymizeAccount;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\TenantLifecycleEvent;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Testing\TestAction;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -45,6 +46,10 @@ class TenantLifecycleActionsTest extends TestCase
|
||||
$plannedDeletion->toDateTimeString(),
|
||||
$tenant->pending_deletion_at?->toDateTimeString()
|
||||
);
|
||||
$this->assertTrue(TenantLifecycleEvent::query()
|
||||
->where('tenant_id', $tenant->id)
|
||||
->where('type', 'deletion_scheduled')
|
||||
->exists());
|
||||
|
||||
Livewire::test(ListTenants::class)
|
||||
->callAction(TestAction::make('cancel_deletion')->table($tenant));
|
||||
@@ -53,6 +58,10 @@ class TenantLifecycleActionsTest extends TestCase
|
||||
|
||||
$this->assertNull($tenant->pending_deletion_at);
|
||||
$this->assertNull($tenant->deletion_warning_sent_at);
|
||||
$this->assertTrue(TenantLifecycleEvent::query()
|
||||
->where('tenant_id', $tenant->id)
|
||||
->where('type', 'deletion_cancelled')
|
||||
->exists());
|
||||
}
|
||||
|
||||
public function test_superadmin_can_toggle_tenant_status_flags(): void
|
||||
@@ -70,24 +79,40 @@ class TenantLifecycleActionsTest extends TestCase
|
||||
|
||||
$tenant->refresh();
|
||||
$this->assertFalse((bool) $tenant->is_active);
|
||||
$this->assertTrue(TenantLifecycleEvent::query()
|
||||
->where('tenant_id', $tenant->id)
|
||||
->where('type', 'deactivated')
|
||||
->exists());
|
||||
|
||||
Livewire::test(ListTenants::class)
|
||||
->callAction(TestAction::make('activate')->table($tenant));
|
||||
|
||||
$tenant->refresh();
|
||||
$this->assertTrue((bool) $tenant->is_active);
|
||||
$this->assertTrue(TenantLifecycleEvent::query()
|
||||
->where('tenant_id', $tenant->id)
|
||||
->where('type', 'activated')
|
||||
->exists());
|
||||
|
||||
Livewire::test(ListTenants::class)
|
||||
->callAction(TestAction::make('suspend')->table($tenant));
|
||||
|
||||
$tenant->refresh();
|
||||
$this->assertTrue((bool) $tenant->is_suspended);
|
||||
$this->assertTrue(TenantLifecycleEvent::query()
|
||||
->where('tenant_id', $tenant->id)
|
||||
->where('type', 'suspended')
|
||||
->exists());
|
||||
|
||||
Livewire::test(ListTenants::class)
|
||||
->callAction(TestAction::make('unsuspend')->table($tenant));
|
||||
|
||||
$tenant->refresh();
|
||||
$this->assertFalse((bool) $tenant->is_suspended);
|
||||
$this->assertTrue(TenantLifecycleEvent::query()
|
||||
->where('tenant_id', $tenant->id)
|
||||
->where('type', 'unsuspended')
|
||||
->exists());
|
||||
}
|
||||
|
||||
public function test_superadmin_can_dispatch_tenant_anonymization(): void
|
||||
@@ -105,6 +130,10 @@ class TenantLifecycleActionsTest extends TestCase
|
||||
Queue::assertPushed(AnonymizeAccount::class, function (AnonymizeAccount $job) use ($tenant) {
|
||||
return $job->tenantId() === $tenant->id;
|
||||
});
|
||||
$this->assertTrue(TenantLifecycleEvent::query()
|
||||
->where('tenant_id', $tenant->id)
|
||||
->where('type', 'anonymize_requested')
|
||||
->exists());
|
||||
}
|
||||
|
||||
private function bootSuperAdminPanel(User $user): void
|
||||
|
||||
Reference in New Issue
Block a user