Add browser XHR forwarding

This commit is contained in:
2026-08-05 16:19:43 +02:00
parent f2757c9b1c
commit 06f99b0c17
5 changed files with 701 additions and 1 deletions
+32
View File
@@ -128,6 +128,38 @@ class WebhookInspectorTest extends TestCase
->assertSee('Save response');
}
public function test_selected_requests_expose_browser_xhr_forwarding_controls(): void
{
$endpoint = WebhookEndpoint::factory()->create();
$webhookRequest = WebhookRequest::factory()->forEndpoint($endpoint)->create([
'method' => 'POST',
'request_uri' => '/hook/test?source=browser',
'headers' => ['content-type' => ['application/json'], 'x-request-id' => ['req-123']],
'body' => '{"event":"created"}',
]);
$payload = new Inspector;
$payload->mount($endpoint);
$this->assertSame($endpoint->getKey(), $payload->xhrRequestPayload($webhookRequest->getKey())['endpointId']);
$this->assertSame(base64_encode($webhookRequest->body), $payload->xhrRequestPayload($webhookRequest->getKey())['body']);
Livewire::test(Inspector::class, ['endpoint' => $endpoint])
->call('selectRequest', $webhookRequest->getKey())
->assertSee('Send via XHR')
->assertSee('data-xhr-redirect-modal', false)
->assertSee('data-xhr-request-headers', false)
->call('requestReceived', [
'endpointId' => (string) $endpoint->getKey(),
'requestId' => (string) $webhookRequest->getKey(),
])
->assertDispatched(
'xhr-request-available',
endpointId: (string) $endpoint->getKey(),
requestId: (string) $webhookRequest->getKey(),
);
}
public function test_request_body_is_escaped_in_the_inspector(): void
{
$endpoint = WebhookEndpoint::factory()->create();