Add browser XHR forwarding
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user