diff --git a/tests/Feature/Notifications/AccessoryCheckoutWebhookNotificationTest.php b/tests/Feature/Notifications/AccessoryCheckoutWebhookNotificationTest.php new file mode 100644 index 0000000000..04bb0f2186 --- /dev/null +++ b/tests/Feature/Notifications/AccessoryCheckoutWebhookNotificationTest.php @@ -0,0 +1,54 @@ +withWebhookEnabled()->create(); + + event(new CheckoutableCheckedOut( + Accessory::factory()->appleBtKeyboard()->create(), + User::factory()->create(), + User::factory()->superuser()->create(), + '' + )); + + Notification::assertSentTo( + new AnonymousNotifiable, + CheckoutAccessoryNotification::class, + function ($notification, $channels, $notifiable) { + return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint; + } + ); + } + + public function testWebhookNotificationsAreNotSentOnAccessoryCheckoutWhenWebhookSettingNotEnabled() + { + Notification::fake(); + + Setting::factory()->withWebhookDisabled()->create(); + + event(new CheckoutableCheckedOut( + Accessory::factory()->appleBtKeyboard()->create(), + User::factory()->create(), + User::factory()->superuser()->create(), + '' + )); + + Notification::assertNotSentTo(new AnonymousNotifiable, CheckoutAccessoryNotification::class); + } +}