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
282
282
$ request = $ event ->getRequest ();
283
283
$ response = $ event ->getResponse ();
284
284
285
+ if (!$ event ->isMainRequest ()) {
286
+ return ;
287
+ }
288
+
285
289
if (!$ this ->isLiveComponentRequest ($ request )) {
286
290
return ;
287
291
}
Original file line number Diff line number Diff line change @@ -154,6 +154,40 @@ public function testRedirect(): void
154
154
;
155
155
}
156
156
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
+
157
191
public function testException (): void
158
192
{
159
193
$ dehydrated = $ this ->dehydrateComponent ($ this ->mountComponent ('with_actions ' ));
You can’t perform that action at this time.
0 commit comments