Files
portal/app/tests/Feature/Notifications/InAppNotificationTest.php
T

39 lines
1.4 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
use App\Models\InAppNotification;
use App\Models\Tenant;
use App\Models\User;
use App\Services\NotificationService;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Mail;
/**
* Тесты in-app канала уведомлений (schema v8.10 in_app_notifications).
*
* Тесты через ProcessWebhookJob удалены — job убран как legacy-рудимент.
* Оставлен прямой вызов NotificationService::notifyInApp.
*/
uses(DatabaseTransactions::class);
beforeEach(function () {
Mail::fake();
});
test('NotificationService::notifyInApp: вызов напрямую создаёт row', function () {
$tenant = Tenant::factory()->create();
$user = User::factory()->create(['tenant_id' => $tenant->id]);
$service = app(NotificationService::class);
$service->notifyInApp($user, 'reminder', 'Срок касания', 'Перезвонить клиенту через 30 мин', ['deal_id' => 42]);
$notif = InAppNotification::query()->first();
expect($notif)->not->toBeNull();
expect($notif->event)->toBe('reminder');
expect($notif->title)->toBe('Срок касания');
expect($notif->body)->toBe('Перезвонить клиенту через 30 мин');
expect($notif->deal_id)->toBe(42);
expect($notif->payload['deal_id'])->toBe(42);
});