File tree Expand file tree Collapse file tree 7 files changed +102
-1
lines changed
apps/qwikcity-test/src/routes
issue-route-with-search-params-and-action-redirect-without-search-params
action-redirect-without-search-params-target
action-redirect-without-search-params Expand file tree Collapse file tree 7 files changed +102
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { useLocation } from "@builder.io/qwik-city" ;
2
+ import { component$ } from "@builder.io/qwik" ;
3
+
4
+ export default component$ ( ( ) => {
5
+ const location = useLocation ( ) ;
6
+
7
+ return (
8
+ < div >
9
+ < h1 >
10
+ Should < strong > not</ strong > have searchParams
11
+ </ h1 >
12
+ < pre > { JSON . stringify ( location . url . searchParams . get ( "id" ) ) } </ pre >
13
+ </ div >
14
+ ) ;
15
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { routeAction$ , Form } from "@builder.io/qwik-city" ;
2
+ import { component$ } from "@builder.io/qwik" ;
3
+
4
+ export const useAction = routeAction$ ( ( _ , event ) => {
5
+ throw event . redirect (
6
+ 302 ,
7
+ "/qwikcity-test/action-redirect-without-search-params-target/" ,
8
+ ) ;
9
+ } ) ;
10
+
11
+ export default component$ ( ( ) => {
12
+ const action = useAction ( ) ;
13
+
14
+ return (
15
+ < Form action = { action } >
16
+ < h1 > Should have searchParams on the url</ h1 >
17
+ < button type = "submit" > Submit</ button >
18
+ </ Form >
19
+ ) ;
20
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { component$ } from "@builder.io/qwik" ;
2
+
3
+ export default component$ ( ( ) => {
4
+ return < div > empty default route A</ div > ;
5
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { component$ } from "@builder.io/qwik" ;
2
+ import type { RequestHandler } from "@builder.io/qwik-city" ;
3
+
4
+ export const onGet : RequestHandler < void > = ( { redirect } ) => {
5
+ throw redirect ( 302 , `/qwikcity-test/issue7732/c/?redirected=true` ) ;
6
+ } ;
7
+
8
+ export default component$ ( ( ) => {
9
+ return < div > B route with redirect</ div > ;
10
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { component$ } from "@builder.io/qwik" ;
2
+
3
+ export default component$ ( ( ) => {
4
+ return < div > route C should have redirected=true params</ div > ;
5
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { component$ , Slot } from "@builder.io/qwik" ;
2
+ import { Link } from "@builder.io/qwik-city" ;
3
+
4
+ export default component$ ( ( ) => {
5
+ return (
6
+ < >
7
+ < div style = { { display : "flex" , gap : "10px" } } >
8
+ < Link href = "/issue7732/a/" id = "issue7732-link-a" >
9
+ A
10
+ </ Link >
11
+
12
+ < Link
13
+ href = "/qwikcity-test/issue7732/b/?shouldOverrideRedirect=no"
14
+ id = "issue7732-link-b"
15
+ >
16
+ B
17
+ </ Link >
18
+ < Link href = "/issue7732/c/" id = "issue7732-link-c" >
19
+ C
20
+ </ Link >
21
+ </ div >
22
+ < Slot />
23
+ </ >
24
+ ) ;
25
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { $ } from "bun" ;
1
2
import {
2
3
assertPage ,
3
4
getScrollHeight ,
@@ -447,7 +448,27 @@ test.describe("actions", () => {
447
448
await expect ( result ) . toHaveText ( "3" ) ;
448
449
}
449
450
} ) ;
450
-
451
+ test ( "issue7732 link/useNavigate should not override loader/middleware redirect" , async ( {
452
+ page,
453
+ } ) => {
454
+ await page . goto ( "/qwikcity-test/issue7732/a/" ) ;
455
+ const link = page . locator ( "#issue7732-link-b" ) ;
456
+ await link . click ( ) ;
457
+ await expect ( page ) . toHaveURL (
458
+ "/qwikcity-test/issue7732/c/?redirected=true" ,
459
+ ) ;
460
+ } ) ;
461
+ // TODO: Fix this test (currently not working because the action redirect adds a `/q-data.json` at the end of the path)
462
+ // test("action with redirect without query params in a route with query param should redirect to route without query params", async ({
463
+ // page,
464
+ // }) => {
465
+ // await page.goto("/qwikcity-test/action-redirect-without-search-params/?test=test");
466
+ // const button = page.locator("button");
467
+ // await button.click();
468
+ // await page.waitForURL(
469
+ // "/qwikcity-test/action-redirect-without-search-params-target/",
470
+ // );
471
+ // });
451
472
test ( "media in home page" , async ( { page } ) => {
452
473
await page . goto ( "/qwikcity-test/" ) ;
453
474
You can’t perform that action at this time.
0 commit comments