Files
portal/app/tests/Feature/Notifications/InAppNotificationTest.php
T
Дмитрий ebca32a212 refactor(billing): Phase 2 — remove legacy ProcessWebhookJob + cascade test cleanup
Удалён рудимент pre-sharing эпохи:
- app/app/Jobs/ProcessWebhookJob.php (job целиком, 342 строки)
- app/tests/Feature/ProcessWebhookJobTest.php (тест целиком, 362 строки)

Каскадная чистка 4 тест-файлов:
- BalanceNotificationsTest: -128 строк (оставлены topup_success/invoice_paid)
- InAppNotificationTest: -168 строк (остался notifyInApp direct)
- NewLeadNotificationTest: целиком удалён (-199 строк)
- DealCreatePdLogTest: -36 строк webhook-кейса (остались API+Route)

Локальный smoke (7 тестов без --parallel): 7 passed / 20 assertions.

Phase 2 плана 2026-05-24-legacy-direct-webhook-removal.md.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 18:51:12 +03:00

39 lines
1.4 KiB
PHP

<?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);
});