From e4bfabfabed7e0c8fbc841e290260fac87180bbc Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 13 May 2025 14:12:51 -0700 Subject: [PATCH] Add failing tests --- .../SlackNotificationsUponCheckinTest.php | 18 ++++++++++++++++++ .../SlackNotificationsUponCheckoutTest.php | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php index adaede07ec..b2fb4b3828 100644 --- a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php +++ b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php @@ -2,6 +2,8 @@ namespace Tests\Feature\Notifications\Webhooks; +use App\Models\AssetModel; +use App\Models\Category; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use App\Events\CheckoutableCheckedIn; @@ -95,6 +97,22 @@ class SlackNotificationsUponCheckinTest extends TestCase $this->assertNoSlackNotificationSent(CheckinAssetNotification::class); } + public function testSlackNotificationIsStillSentWhenCategoryEmailIsNotSetToSendEmails() + { + $this->settings->enableSlackWebhook(); + + $category = Category::factory()->create(['checkin_email' => false]); + $assetModel = AssetModel::factory()->create(['category_id' => $category->id]); + $asset = Asset::factory()->assignedToUser()->create(['model_id' => $assetModel->id]); + + $this->fireCheckInEvent( + $asset, + User::factory()->create(), + ); + + $this->assertSlackNotificationSent(CheckinAssetNotification::class); + } + public function testComponentCheckinDoesNotSendSlackNotification() { $this->settings->enableSlackWebhook(); diff --git a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.php b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.php index 4f34da2857..b9f8fb6523 100644 --- a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.php +++ b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.php @@ -2,6 +2,8 @@ namespace Tests\Feature\Notifications\Webhooks; +use App\Models\AssetModel; +use App\Models\Category; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; use App\Events\CheckoutableCheckedOut; @@ -97,6 +99,22 @@ class SlackNotificationsUponCheckoutTest extends TestCase $this->assertNoSlackNotificationSent(CheckoutAssetNotification::class); } + public function testSlackNotificationIsStillSentWhenCategoryEmailIsNotSetToSendEmails() + { + $this->settings->enableSlackWebhook(); + + $category = Category::factory()->create(['checkin_email' => false]); + $assetModel = AssetModel::factory()->create(['category_id' => $category->id]); + $asset = Asset::factory()->create(['model_id' => $assetModel->id]); + + $this->fireCheckOutEvent( + $asset, + User::factory()->create(), + ); + + $this->assertSlackNotificationSent(CheckoutAssetNotification::class); + } + public function testComponentCheckoutDoesNotSendSlackNotification() { $this->settings->enableSlackWebhook();