actingAs($user); Filament::setTenant($tenant, true); $longMessage = "This is a very long failure message that should not be allowed to flood the notification UI.\n\n". str_repeat('x', 400); $run = OperationRun::factory()->create([ 'tenant_id' => $tenant->getKey(), 'user_id' => $user->getKey(), 'initiator_name' => $user->name, 'type' => 'inventory.sync', 'status' => 'running', 'outcome' => 'pending', 'context' => ['scope' => 'all'], ]); /** @var OperationRunService $service */ $service = app(OperationRunService::class); $service->updateRun( $run, status: 'completed', outcome: 'failed', summaryCounts: ['total' => 1], failures: [[ 'code' => 'example.failure', 'message' => $longMessage, ]], ); $notification = $user->notifications()->latest('id')->first(); expect($notification)->not->toBeNull(); $body = (string) ($notification->data['body'] ?? ''); expect($body)->toContain('Failed.'); expect($body)->toContain('This is a very long failure message'); // Ensure message is not full-length / multiline. expect($body)->not->toContain(str_repeat('x', 200)); expect($body)->not->toContain("\n\nThis is a very long failure message"); })->group('ops-ux');