Update webhook tests for current payload format

This commit is contained in:
Lance Pioch
2026-06-12 10:26:53 -04:00
parent 07f1dfe8b8
commit 476ce81ebc
2 changed files with 8 additions and 5 deletions

View File

@@ -68,7 +68,7 @@ class DispatchWebhooksTest extends TestCase
'events' => ['eloquent.created: '.Server::class],
]);
$webhookConfig->update(['events' => 'eloquent.deleted: '.Server::class]);
$webhookConfig->update(['events' => ['eloquent.deleted: '.Server::class]]);
$this->createServer();

View File

@@ -64,7 +64,7 @@ class ProcessWebhooksTest extends TestCase
ProcessWebhook::dispatchSync(
$webhook,
'eloquent.created: '.Server::class,
$data,
[$data],
);
$this->assertCount(1, cache()->get("webhooks.$eventName"));
@@ -73,7 +73,7 @@ class ProcessWebhooksTest extends TestCase
Http::assertSentCount(1);
Http::assertSent(function (Request $request) use ($webhook, $data) {
return $webhook->endpoint === $request->url()
&& $request->data() === $data;
&& $request->data() === array_merge($data, ['event' => 'created: Server']);
});
}
@@ -143,7 +143,7 @@ class ProcessWebhooksTest extends TestCase
$this->assertDatabaseCount(Webhook::class, 1);
$webhook = Webhook::query()->first();
$this->assertEquals($server->uuid, $webhook->payload[0]['uuid']);
$this->assertEquals($server->uuid, $webhook->payload['uuid']);
$this->assertDatabaseHas(Webhook::class, [
'endpoint' => $webhookConfig->endpoint,
@@ -165,8 +165,11 @@ class ProcessWebhooksTest extends TestCase
$server = $this->createServer();
$this->assertDatabaseCount(Webhook::class, 1);
$webhook = Webhook::query()->first();
$this->assertEquals($server->uuid, $webhook->payload['uuid']);
$this->assertDatabaseHas(Webhook::class, [
'payload' => json_encode([$server->toArray()]),
'endpoint' => $webhookConfig->endpoint,
'successful_at' => null,
'event' => 'eloquent.created: '.Server::class,