Add guest push notifications and queue alerts

This commit is contained in:
Codex Agent
2025-11-12 20:38:49 +01:00
parent 2c412e3764
commit 574aa47ce7
34 changed files with 1806 additions and 74 deletions

View File

@@ -2,9 +2,11 @@
namespace Tests\Feature\Console;
use App\Enums\GuestNotificationType;
use App\Models\Event;
use App\Models\EventMediaAsset;
use App\Models\MediaStorageTarget;
use App\Models\Tenant;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Queue\QueueManager;
use Illuminate\Support\Facades\Cache;
@@ -24,6 +26,10 @@ class CheckUploadQueuesCommandTest extends TestCase
]);
config()->set('storage-monitor.queue_health.stalled_minutes', 5);
config()->set('storage-monitor.queue_health.cache_minutes', 5);
config()->set('storage-monitor.queue_health.pending_event_threshold', 1);
config()->set('storage-monitor.queue_health.pending_event_minutes', 5);
config()->set('storage-monitor.queue_health.failed_event_threshold', 1);
config()->set('storage-monitor.queue_health.failed_event_minutes', 5);
$manager = Mockery::mock(QueueManager::class);
$connection = Mockery::mock(\Illuminate\Contracts\Queue\Queue::class);
@@ -51,7 +57,8 @@ class CheckUploadQueuesCommandTest extends TestCase
'priority' => 100,
]);
$event = Event::factory()->create();
$tenant = Tenant::factory()->create();
$event = Event::factory()->for($tenant)->create(['status' => 'published']);
$asset = EventMediaAsset::create([
'event_id' => $event->id,
'media_storage_target_id' => $target->id,
@@ -66,6 +73,16 @@ class CheckUploadQueuesCommandTest extends TestCase
'updated_at' => now()->subMinutes(10),
]);
EventMediaAsset::create([
'event_id' => $event->id,
'media_storage_target_id' => $target->id,
'variant' => 'original',
'disk' => 'local-hot',
'path' => 'events/'.$event->id.'/failed.jpg',
'size_bytes' => 256,
'status' => 'failed',
]);
$this->artisan('storage:check-upload-queues')
->expectsOutput('Checked 1 queue(s); 3 alert(s).')
->assertExitCode(0);
@@ -74,5 +91,15 @@ class CheckUploadQueuesCommandTest extends TestCase
$this->assertNotNull($snapshot);
$this->assertSame('critical', $snapshot['queues'][0]['severity']);
$this->assertGreaterThanOrEqual(1, count($snapshot['alerts']));
$this->assertDatabaseHas('guest_notifications', [
'event_id' => $event->id,
'type' => GuestNotificationType::UPLOAD_ALERT->value,
]);
$this->assertDatabaseHas('guest_notifications', [
'event_id' => $event->id,
'type' => GuestNotificationType::SUPPORT_TIP->value,
]);
}
}