99use Illuminate \Http \Response ;
1010use Illuminate \Support \Facades \Facade ;
1111use PHPUnit \Framework \TestCase ;
12+ use Symfony \Component \HttpFoundation \Response as SymfonyResponse ;
1213
1314class VitePreloadingTest extends TestCase
1415{
@@ -20,7 +21,7 @@ protected function tearDown(): void
2021
2122 public function testItDoesNotSetLinkTagWhenNoTagsHaveBeenPreloaded ()
2223 {
23- $ app = new Container () ;
24+ $ app = new Container ;
2425 $ app ->instance (Vite::class, new class extends Vite
2526 {
2627 protected $ preloadedAssets = [];
@@ -36,7 +37,7 @@ public function testItDoesNotSetLinkTagWhenNoTagsHaveBeenPreloaded()
3637
3738 public function testItAddsPreloadLinkHeader ()
3839 {
39- $ app = new Container () ;
40+ $ app = new Container ;
4041 $ app ->instance (Vite::class, new class extends Vite
4142 {
4243 protected $ preloadedAssets = [
@@ -57,4 +58,25 @@ public function testItAddsPreloadLinkHeader()
5758 '<https://laravel.com/app.js>; rel="modulepreload"; foo="bar" '
5859 );
5960 }
61+
62+ public function testItDoesNotAttachHeadersToNonIlluminateResponses ()
63+ {
64+ $ app = new Container ;
65+ $ app ->instance (Vite::class, new class extends Vite
66+ {
67+ protected $ preloadedAssets = [
68+ 'https://laravel.com/app.js ' => [
69+ 'rel="modulepreload" ' ,
70+ 'foo="bar" ' ,
71+ ],
72+ ];
73+ });
74+ Facade::setFacadeApplication ($ app );
75+
76+ $ response = (new AddLinkHeadersForPreloadedAssets )->handle (new Request , function () {
77+ return new SymfonyResponse ('Hello Laravel ' );
78+ });
79+
80+ $ this ->assertNull ($ response ->headers ->get ('Link ' ));
81+ }
6082}
0 commit comments