diff --git a/src/Http/PendingTurboStreamResponse.php b/src/Http/PendingTurboStreamResponse.php index 167ac3e..a51cc1e 100644 --- a/src/Http/PendingTurboStreamResponse.php +++ b/src/Http/PendingTurboStreamResponse.php @@ -327,7 +327,7 @@ private function contentAsRendering() */ public function toResponse($request) { - if (! in_array($this->useAction, ['remove', 'refresh']) && ! $this->partialView && ! $this->inlineContent) { + if (! in_array($this->useAction, ['remove', 'refresh']) && ! $this->partialView && $this->inlineContent === null) { throw TurboStreamResponseFailedException::missingPartial(); } diff --git a/tests/Http/ResponseMacrosTest.php b/tests/Http/ResponseMacrosTest.php index 68031b0..7263442 100644 --- a/tests/Http/ResponseMacrosTest.php +++ b/tests/Http/ResponseMacrosTest.php @@ -981,6 +981,23 @@ public function response_builder_fails_when_partial_is_missing_and_not_a_remove_ ->toResponse(new Request); } + /** @test */ + public function response_builder_doesnt_fail_when_partial_is_empty_string() + { + $response = response() + ->turboStream() + ->update('example_target', '') + ->toResponse(new Request); + + $expected = view('turbo-laravel::turbo-stream', [ + 'action' => 'update', + 'target' => 'example_target', + 'content' => '', + ])->render(); + + $this->assertEquals(trim($expected), trim($response->getContent())); + } + /** @test */ public function refresh_shorthand() {