File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
tests/Functional/Controller Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,10 @@ public function onKernelResponse(ResponseEvent $event): void
282282 $ request = $ event ->getRequest ();
283283 $ response = $ event ->getResponse ();
284284
285+ if (!$ event ->isMainRequest ()) {
286+ return ;
287+ }
288+
285289 if (!$ this ->isLiveComponentRequest ($ request )) {
286290 return ;
287291 }
Original file line number Diff line number Diff line change @@ -154,6 +154,40 @@ public function testRedirect(): void
154154 ;
155155 }
156156
157+ public function testRedirectWithAcceptHeader (): void
158+ {
159+ $ dehydrated = $ this ->dehydrateComponent ($ this ->mountComponent ('with_actions ' ));
160+
161+ $ this ->browser ()
162+ ->throwExceptions ()
163+ ->get ('/_components/with_actions ' , ['query ' => ['props ' => json_encode ($ dehydrated ->getProps ())]])
164+ ->assertSuccessful ()
165+ ->interceptRedirects ()
166+ ->use (function (Crawler $ crawler , KernelBrowser $ browser ) {
167+ $ rootElement = $ crawler ->filter ('ul ' )->first ();
168+ $ liveProps = json_decode ($ rootElement ->attr ('data-live-props-value ' ), true );
169+
170+ $ browser ->post ('/_components/with_actions/_batch ' , [
171+ 'body ' => [
172+ 'data ' => json_encode ([
173+ 'props ' => $ liveProps ,
174+ 'actions ' => [
175+ ['name ' => 'redirect ' ],
176+ ['name ' => 'exception ' ],
177+ ],
178+ ]),
179+ ],
180+ 'headers ' => [
181+ 'Accept ' => ['application/vnd.live-component+html ' ],
182+ 'X-CSRF-TOKEN ' => $ crawler ->filter ('ul ' )->first ()->attr ('data-live-csrf-value ' ),
183+ ],
184+ ]);
185+ })
186+ ->assertStatus (204 )
187+ ->assertHeaderContains ('X-Live-Redirect ' , '1 ' )
188+ ;
189+ }
190+
157191 public function testException (): void
158192 {
159193 $ dehydrated = $ this ->dehydrateComponent ($ this ->mountComponent ('with_actions ' ));
You can’t perform that action at this time.
0 commit comments