46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Filament\Resources\TenantResource;
|
|
use App\Models\Tenant;
|
|
use App\Models\TenantNotificationLog;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class TenantLifecycleViewTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_view_page_shows_lifecycle_timeline(): void
|
|
{
|
|
$user = User::factory()->create(['role' => 'super_admin']);
|
|
$tenant = Tenant::factory()->create([
|
|
'last_activity_at' => now()->subDay(),
|
|
'pending_deletion_at' => now()->addDays(10),
|
|
'deletion_warning_sent_at' => now()->subHours(2),
|
|
]);
|
|
|
|
TenantNotificationLog::query()->create([
|
|
'tenant_id' => $tenant->id,
|
|
'type' => 'retention_warning',
|
|
'channel' => 'mail',
|
|
'recipient' => 'owner@example.com',
|
|
'status' => 'sent',
|
|
'context' => ['source' => 'test'],
|
|
'sent_at' => now()->subHour(),
|
|
]);
|
|
|
|
$this->actingAs($user, 'super_admin');
|
|
|
|
$url = TenantResource::getUrl('lifecycle', ['record' => $tenant], panel: 'superadmin');
|
|
|
|
$this->get($url)
|
|
->assertOk()
|
|
->assertSee(__('admin.tenants.timeline.created'))
|
|
->assertSee(__('admin.tenants.timeline.deletion_scheduled'))
|
|
->assertSee(__('admin.tenants.timeline.notification_sent'));
|
|
}
|
|
}
|