File tree 12 files changed +127
-71
lines changed
21_create-pages/src/components
22_define-router/src/components
43_weave-render/src/components
12 files changed +127
-71
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,19 @@ for (const mode of ['DEV', 'PRD'] as const) {
127
127
( { port, stopApp } = await startApp ( mode ) ) ;
128
128
} ) ;
129
129
130
+ // https://github.com/dai-shi/waku/issues/1255
131
+ test ( 'long suspense' , async ( { page } ) => {
132
+ await page . goto ( `http://localhost:${ port } /long-suspense/1` ) ;
133
+ await expect (
134
+ page . getByRole ( 'heading' , { name : 'Long Suspense Page 1' } ) ,
135
+ ) . toBeVisible ( ) ;
136
+ await page . click ( "a[href='/long-suspense/2']" ) ;
137
+ await expect ( page . getByTestId ( 'long-suspense' ) ) . toHaveText ( 'Loading...' ) ;
138
+ await expect (
139
+ page . getByRole ( 'heading' , { name : 'Long Suspense Page 2' } ) ,
140
+ ) . toBeVisible ( ) ;
141
+ } ) ;
142
+
130
143
test ( 'api hi' , async ( ) => {
131
144
const res = await fetch ( `http://localhost:${ port } /api/hi` ) ;
132
145
expect ( res . status ) . toBe ( 200 ) ;
Original file line number Diff line number Diff line change @@ -23,17 +23,17 @@ const HomeLayout = ({ children }: { children: ReactNode }) => (
23
23
< li >
24
24
< Link
25
25
to = "/"
26
- pending = { < Pending isPending /> }
27
- notPending = { < Pending isPending = { false } /> }
26
+ unstable_pending = { < Pending isPending /> }
27
+ unstable_notPending = { < Pending isPending = { false } /> }
28
28
>
29
29
Home
30
30
</ Link >
31
31
</ li >
32
32
< li >
33
33
< Link
34
34
to = "/foo"
35
- pending = { < Pending isPending /> }
36
- notPending = { < Pending isPending = { false } /> }
35
+ unstable_pending = { < Pending isPending /> }
36
+ unstable_notPending = { < Pending isPending = { false } /> }
37
37
>
38
38
Foo
39
39
</ Link >
Original file line number Diff line number Diff line change
1
+ import { Suspense } from 'react' ;
2
+ import type { ReactNode } from 'react' ;
3
+ import { Link } from 'waku' ;
4
+
5
+ const SlowComponent = async ( ) => {
6
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
7
+ return < div > Slow Component</ div > ;
8
+ } ;
9
+
10
+ const LongSuspenseLayout = ( { children } : { children : ReactNode } ) => {
11
+ return (
12
+ < div >
13
+ < h2 > Long Suspense Layout</ h2 >
14
+ < Link to = "/long-suspense/2" > Click Me</ Link >
15
+ < Suspense fallback = { < div data-testid = "long-suspense" > Loading...</ div > } >
16
+ < SlowComponent />
17
+ </ Suspense >
18
+ { children }
19
+ </ div >
20
+ ) ;
21
+ } ;
22
+
23
+ export default LongSuspenseLayout ;
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import NestedBazPage from './components/NestedBazPage.js';
9
9
import NestedLayout from './components/NestedLayout.js' ;
10
10
import { DeeplyNestedLayout } from './components/DeeplyNestedLayout.js' ;
11
11
import ErrorPage from './components/ErrorPage.js' ;
12
+ import LongSuspenseLayout from './components/LongSuspenseLayout.js' ;
12
13
import { readFile } from 'node:fs/promises' ;
13
14
14
15
const pages : ReturnType < typeof createPages > = createPages (
@@ -89,6 +90,24 @@ const pages: ReturnType<typeof createPages> = createPages(
89
90
component : ErrorPage ,
90
91
} ) ,
91
92
93
+ createLayout ( {
94
+ render : 'dynamic' ,
95
+ path : '/long-suspense' ,
96
+ component : LongSuspenseLayout ,
97
+ } ) ,
98
+
99
+ createPage ( {
100
+ render : 'static' ,
101
+ path : '/long-suspense/1' ,
102
+ component : ( ) => < h3 > Long Suspense Page 1</ h3 > ,
103
+ } ) ,
104
+
105
+ createPage ( {
106
+ render : 'static' ,
107
+ path : '/long-suspense/2' ,
108
+ component : ( ) => < h3 > Long Suspense Page 2</ h3 > ,
109
+ } ) ,
110
+
92
111
createPage ( {
93
112
render : 'dynamic' ,
94
113
path : '/any/[...all]' ,
Original file line number Diff line number Diff line change @@ -20,17 +20,17 @@ const HomeLayout = ({ children }: { children: ReactNode }) => (
20
20
< li >
21
21
< Link
22
22
to = "/"
23
- pending = { < Pending isPending /> }
24
- notPending = { < Pending isPending = { false } /> }
23
+ unstable_pending = { < Pending isPending /> }
24
+ unstable_notPending = { < Pending isPending = { false } /> }
25
25
>
26
26
Home
27
27
</ Link >
28
28
</ li >
29
29
< li >
30
30
< Link
31
31
to = "/foo"
32
- pending = { < Pending isPending /> }
33
- notPending = { < Pending isPending = { false } /> }
32
+ unstable_pending = { < Pending isPending /> }
33
+ unstable_notPending = { < Pending isPending = { false } /> }
34
34
>
35
35
Foo
36
36
</ Link >
Original file line number Diff line number Diff line change @@ -21,17 +21,17 @@ const HomeLayout = ({ children }: { children: ReactNode }) => (
21
21
< li >
22
22
< Link
23
23
to = "/"
24
- pending = { < Pending isPending /> }
25
- notPending = { < Pending isPending = { false } /> }
24
+ unstable_pending = { < Pending isPending /> }
25
+ unstable_notPending = { < Pending isPending = { false } /> }
26
26
>
27
27
Home
28
28
</ Link >
29
29
</ li >
30
30
< li >
31
31
< Link
32
32
to = "/foo"
33
- pending = { < Pending isPending /> }
34
- notPending = { < Pending isPending = { false } /> }
33
+ unstable_pending = { < Pending isPending /> }
34
+ unstable_notPending = { < Pending isPending = { false } /> }
35
35
>
36
36
Foo
37
37
</ Link >
@@ -40,26 +40,26 @@ const HomeLayout = ({ children }: { children: ReactNode }) => (
40
40
< Link
41
41
to = "/bar"
42
42
unstable_prefetchOnEnter
43
- pending = { < Pending isPending /> }
44
- notPending = { < Pending isPending = { false } /> }
43
+ unstable_pending = { < Pending isPending /> }
44
+ unstable_notPending = { < Pending isPending = { false } /> }
45
45
>
46
46
Bar
47
47
</ Link >
48
48
</ li >
49
49
< li >
50
50
< Link
51
51
to = "/nested/baz"
52
- pending = { < Pending isPending /> }
53
- notPending = { < Pending isPending = { false } /> }
52
+ unstable_pending = { < Pending isPending /> }
53
+ unstable_notPending = { < Pending isPending = { false } /> }
54
54
>
55
55
Nested / Baz
56
56
</ Link >
57
57
</ li >
58
58
< li >
59
59
< Link
60
60
to = "/nested/qux"
61
- pending = { < Pending isPending /> }
62
- notPending = { < Pending isPending = { false } /> }
61
+ unstable_pending = { < Pending isPending /> }
62
+ unstable_notPending = { < Pending isPending = { false } /> }
63
63
>
64
64
Nested / Qux
65
65
</ Link >
Original file line number Diff line number Diff line change @@ -21,17 +21,17 @@ const HomeLayout = ({ children }: { children: ReactNode }) => (
21
21
< li >
22
22
< Link
23
23
to = "/"
24
- pending = { < Pending isPending /> }
25
- notPending = { < Pending isPending = { false } /> }
24
+ unstable_pending = { < Pending isPending /> }
25
+ unstable_notPending = { < Pending isPending = { false } /> }
26
26
>
27
27
Home
28
28
</ Link >
29
29
</ li >
30
30
< li >
31
31
< Link
32
32
to = "/foo"
33
- pending = { < Pending isPending /> }
34
- notPending = { < Pending isPending = { false } /> }
33
+ unstable_pending = { < Pending isPending /> }
34
+ unstable_notPending = { < Pending isPending = { false } /> }
35
35
>
36
36
Foo
37
37
</ Link >
@@ -40,26 +40,26 @@ const HomeLayout = ({ children }: { children: ReactNode }) => (
40
40
< Link
41
41
to = "/bar"
42
42
unstable_prefetchOnEnter
43
- pending = { < Pending isPending /> }
44
- notPending = { < Pending isPending = { false } /> }
43
+ unstable_pending = { < Pending isPending /> }
44
+ unstable_notPending = { < Pending isPending = { false } /> }
45
45
>
46
46
Bar
47
47
</ Link >
48
48
</ li >
49
49
< li >
50
50
< Link
51
51
to = "/nested/baz"
52
- pending = { < Pending isPending /> }
53
- notPending = { < Pending isPending = { false } /> }
52
+ unstable_pending = { < Pending isPending /> }
53
+ unstable_notPending = { < Pending isPending = { false } /> }
54
54
>
55
55
Nested / Baz
56
56
</ Link >
57
57
</ li >
58
58
< li >
59
59
< Link
60
60
to = "/nested/qux"
61
- pending = { < Pending isPending /> }
62
- notPending = { < Pending isPending = { false } /> }
61
+ unstable_pending = { < Pending isPending /> }
62
+ unstable_notPending = { < Pending isPending = { false } /> }
63
63
>
64
64
Nested / Qux
65
65
</ Link >
Original file line number Diff line number Diff line change @@ -22,17 +22,17 @@ const HomeLayout = ({ children }: { children: ReactNode }) => (
22
22
< li >
23
23
< Link
24
24
to = "/"
25
- pending = { < Pending isPending /> }
26
- notPending = { < Pending isPending = { false } /> }
25
+ unstable_pending = { < Pending isPending /> }
26
+ unstable_notPending = { < Pending isPending = { false } /> }
27
27
>
28
28
Home
29
29
</ Link >
30
30
</ li >
31
31
< li >
32
32
< Link
33
33
to = "/foo"
34
- pending = { < Pending isPending /> }
35
- notPending = { < Pending isPending = { false } /> }
34
+ unstable_pending = { < Pending isPending /> }
35
+ unstable_notPending = { < Pending isPending = { false } /> }
36
36
>
37
37
Foo
38
38
</ Link >
Original file line number Diff line number Diff line change @@ -22,17 +22,17 @@ const HomeLayout = ({ children }: { children: ReactNode }) => (
22
22
< li >
23
23
< Link
24
24
to = "/"
25
- pending = { < Pending isPending /> }
26
- notPending = { < Pending isPending = { false } /> }
25
+ unstable_pending = { < Pending isPending /> }
26
+ unstable_notPending = { < Pending isPending = { false } /> }
27
27
>
28
28
Home
29
29
</ Link >
30
30
</ li >
31
31
< li >
32
32
< Link
33
33
to = "/foo"
34
- pending = { < Pending isPending /> }
35
- notPending = { < Pending isPending = { false } /> }
34
+ unstable_pending = { < Pending isPending /> }
35
+ unstable_notPending = { < Pending isPending = { false } /> }
36
36
>
37
37
Foo
38
38
</ Link >
Original file line number Diff line number Diff line change @@ -24,26 +24,26 @@ const BarLayout = ({ children }: { children: ReactNode }) => {
24
24
< li >
25
25
< Link
26
26
to = "/"
27
- pending = { < Pending isPending /> }
28
- notPending = { < Pending isPending = { false } /> }
27
+ unstable_pending = { < Pending isPending /> }
28
+ unstable_notPending = { < Pending isPending = { false } /> }
29
29
>
30
30
Home
31
31
</ Link >
32
32
</ li >
33
33
< li >
34
34
< Link
35
35
to = "/foo"
36
- pending = { < Pending isPending /> }
37
- notPending = { < Pending isPending = { false } /> }
36
+ unstable_pending = { < Pending isPending /> }
37
+ unstable_notPending = { < Pending isPending = { false } /> }
38
38
>
39
39
Foo
40
40
</ Link >
41
41
</ li >
42
42
< li >
43
43
< Link
44
44
to = { '/nested/bar' as never }
45
- pending = { < Pending isPending /> }
46
- notPending = { < Pending isPending = { false } /> }
45
+ unstable_pending = { < Pending isPending /> }
46
+ unstable_notPending = { < Pending isPending = { false } /> }
47
47
>
48
48
Link to 404
49
49
</ Link >
Original file line number Diff line number Diff line change @@ -31,26 +31,26 @@ const HomeLayout = ({ children }: { children: ReactNode }) => {
31
31
< li >
32
32
< Link
33
33
to = "/"
34
- pending = { < Pending isPending /> }
35
- notPending = { < Pending isPending = { false } /> }
34
+ unstable_pending = { < Pending isPending /> }
35
+ unstable_notPending = { < Pending isPending = { false } /> }
36
36
>
37
37
Home
38
38
</ Link >
39
39
</ li >
40
40
< li >
41
41
< Link
42
42
to = "/foo"
43
- pending = { < Pending isPending /> }
44
- notPending = { < Pending isPending = { false } /> }
43
+ unstable_pending = { < Pending isPending /> }
44
+ unstable_notPending = { < Pending isPending = { false } /> }
45
45
>
46
46
Foo
47
47
</ Link >
48
48
</ li >
49
49
< li >
50
50
< Link
51
51
to = "/bar"
52
- pending = { < Pending isPending /> }
53
- notPending = { < Pending isPending = { false } /> }
52
+ unstable_pending = { < Pending isPending /> }
53
+ unstable_notPending = { < Pending isPending = { false } /> }
54
54
>
55
55
Bar
56
56
</ Link >
You can’t perform that action at this time.
0 commit comments