Add integrations health monitoring
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Jobs\ProcessRevenueCatWebhook;
|
||||
use App\Models\IntegrationWebhookEvent;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Tests\TestCase;
|
||||
@@ -17,6 +18,7 @@ class RevenueCatWebhookTest extends TestCase
|
||||
|
||||
$payload = [
|
||||
'event' => [
|
||||
'type' => 'INITIAL_PURCHASE',
|
||||
'app_user_id' => 'tenant-123',
|
||||
'product_id' => 'pro_month',
|
||||
],
|
||||
@@ -28,12 +30,20 @@ class RevenueCatWebhookTest extends TestCase
|
||||
Bus::fake();
|
||||
|
||||
$response = $this->postJson('/api/v1/webhooks/revenuecat', $payload, [
|
||||
'X-Event-Id' => 'evt_123',
|
||||
'X-Signature' => $signature,
|
||||
]);
|
||||
|
||||
$response->assertStatus(202)
|
||||
->assertJson(['status' => 'accepted']);
|
||||
|
||||
$this->assertDatabaseHas('integration_webhook_events', [
|
||||
'provider' => 'revenuecat',
|
||||
'event_id' => 'evt_123',
|
||||
'event_type' => 'INITIAL_PURCHASE',
|
||||
'status' => IntegrationWebhookEvent::STATUS_RECEIVED,
|
||||
]);
|
||||
|
||||
Bus::assertDispatched(ProcessRevenueCatWebhook::class);
|
||||
}
|
||||
|
||||
@@ -53,6 +63,8 @@ class RevenueCatWebhookTest extends TestCase
|
||||
->assertJsonPath('error.code', 'signature_invalid')
|
||||
->assertJsonPath('error.title', 'Invalid Signature');
|
||||
|
||||
$this->assertDatabaseCount('integration_webhook_events', 0);
|
||||
|
||||
Bus::assertNotDispatched(ProcessRevenueCatWebhook::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user