Refactor notification event payloads and listener naming
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
namespace Tests\Feature\Notifications;
|
||||
|
||||
use App\Actions\Notifications\DeliverNotificationAction;
|
||||
use App\Actions\Notifications\TicketStatusChanged;
|
||||
use App\Actions\Notifications\TicketStatusChangedPayload;
|
||||
use App\Enums\NotificationDeliveryStatus;
|
||||
use App\Enums\NotificationEventType;
|
||||
use App\Models\NotificationAction;
|
||||
use App\Models\NotificationDeliveryLog;
|
||||
use Carbon\CarbonImmutable;
|
||||
@@ -35,7 +35,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
|
||||
(new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(),
|
||||
event: $this->event(),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->handle();
|
||||
|
||||
@@ -77,7 +77,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
|
||||
(new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(),
|
||||
event: $this->event(),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->handle();
|
||||
|
||||
@@ -162,7 +162,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
$deliveryLog = $this->createPendingDeliveryLog($notificationAction);
|
||||
$job = (new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(),
|
||||
event: $this->event(),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->withFakeQueueInteractions();
|
||||
|
||||
@@ -200,7 +200,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
$deliveryLog = $this->createPendingDeliveryLog($notificationAction);
|
||||
$job = (new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(),
|
||||
event: $this->event(),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->withFakeQueueInteractions();
|
||||
|
||||
@@ -237,7 +237,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
$deliveryLog = $this->createPendingDeliveryLog($notificationAction);
|
||||
$job = (new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(),
|
||||
event: $this->event(),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->withFakeQueueInteractions();
|
||||
|
||||
@@ -274,7 +274,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
$deliveryLog = $this->createPendingDeliveryLog($notificationAction);
|
||||
$job = (new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(),
|
||||
event: $this->event(),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->withFakeQueueInteractions();
|
||||
|
||||
@@ -310,7 +310,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
$deliveryLog = $this->createPendingDeliveryLog($notificationAction);
|
||||
$job = (new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(),
|
||||
event: $this->event(),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->withFakeQueueInteractions();
|
||||
|
||||
@@ -349,7 +349,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
$deliveryLog = $this->createPendingDeliveryLog($notificationAction);
|
||||
$job = (new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(),
|
||||
event: $this->event(),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->withFakeQueueInteractions();
|
||||
|
||||
@@ -385,7 +385,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
$deliveryLog = $this->createPendingDeliveryLog($notificationAction);
|
||||
$job = (new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(),
|
||||
event: $this->event(),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->withFakeQueueInteractions();
|
||||
|
||||
@@ -413,7 +413,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
$deliveryLog = $this->createPendingDeliveryLog($notificationAction);
|
||||
$job = (new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(actorName: null),
|
||||
event: $this->event(actorName: null),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->withFakeQueueInteractions();
|
||||
|
||||
@@ -445,7 +445,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
$deliveryLog = $this->createPendingDeliveryLog($notificationAction);
|
||||
$job = (new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(ticketTitle: str_repeat('A', 2001)),
|
||||
event: $this->event(ticketTitle: str_repeat('A', 2001)),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->withFakeQueueInteractions();
|
||||
|
||||
@@ -482,7 +482,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
$deliveryLog = $this->createPendingDeliveryLog($notificationAction);
|
||||
$job = (new DeliverNotificationAction(
|
||||
notificationActionId: $notificationAction->id,
|
||||
payload: $this->payload(),
|
||||
event: $this->event(),
|
||||
notificationDeliveryLogId: $deliveryLog->id,
|
||||
))->withFakeQueueInteractions();
|
||||
|
||||
@@ -508,7 +508,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
{
|
||||
$job = new DeliverNotificationAction(
|
||||
notificationActionId: 1,
|
||||
payload: $this->payload(),
|
||||
event: $this->event(),
|
||||
notificationDeliveryLogId: 1,
|
||||
);
|
||||
|
||||
@@ -530,12 +530,11 @@ class DeliverNotificationActionTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
private function payload(
|
||||
private function event(
|
||||
?string $actorName = 'Erica Example',
|
||||
string $ticketTitle = 'Fix webhook delivery',
|
||||
): TicketStatusChangedPayload {
|
||||
return new TicketStatusChangedPayload(
|
||||
eventType: NotificationEventType::TicketStatusChanged,
|
||||
): TicketStatusChanged {
|
||||
return new TicketStatusChanged(new TicketStatusChangedPayload(
|
||||
projectId: 10,
|
||||
projectKey: 'CORE',
|
||||
projectName: 'Core Platform',
|
||||
@@ -550,7 +549,7 @@ class DeliverNotificationActionTest extends TestCase
|
||||
toStatusId: 2,
|
||||
toStatusLabel: 'Doing',
|
||||
occurredAt: CarbonImmutable::parse('2026-04-24T09:15:30+00:00'),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user