From 524249d4d707a62067e52e503c4dbcbb577da606 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 30 Mar 2023 16:58:16 -0700 Subject: [PATCH] Implement tests for webhook notifications on accessory checkout --- ...cessoryCheckoutWebhookNotificationTest.php | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/Feature/Notifications/AccessoryCheckoutWebhookNotificationTest.php 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); + } +}