File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
apps/qwikrouter-test/src/routes/loaders-serialization Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ export default component$(() => {
18
18
return (
19
19
< >
20
20
{ testSignal . value . test }
21
- < button onClick$ = { ( ) => ( toggle . value = ! toggle . value ) } >
21
+ < button id = "toggle-child" onClick$ = { ( ) => ( toggle . value = ! toggle . value ) } >
22
22
toggle child
23
23
</ button >
24
24
{ toggle . value && < Child /> }
25
- < ChildEager />
25
+ { toggle . value && < ChildEager /> }
26
26
</ >
27
27
) ;
28
28
} ) ;
@@ -41,8 +41,8 @@ export const ChildEager = component$(() => {
41
41
const testSignal = useTestLoaderEager ( ) ;
42
42
return (
43
43
< >
44
- < div id = "prop1 " > { testSignal . value . foo } </ div >
45
- < div id = "prop2 " > { testSignal . value . bar } </ div >
44
+ < div id = "prop3 " > { testSignal . value . foo } </ div >
45
+ < div id = "prop4 " > { testSignal . value . bar } </ div >
46
46
</ >
47
47
) ;
48
48
} ) ;
Original file line number Diff line number Diff line change @@ -151,5 +151,34 @@ test.describe("loaders", () => {
151
151
const body = page . locator ( "body" ) ;
152
152
await expect ( body ) . toContainText ( "server-error-data" ) ;
153
153
} ) ;
154
+
155
+ test ( "should not serialize loaders by default and serialize with serializationStrategy: always" , async ( {
156
+ page,
157
+ javaScriptEnabled,
158
+ } ) => {
159
+ await page . goto ( "/qwikrouter-test/loaders-serialization/" ) ;
160
+ const stateData = page . locator ( 'script[type="qwik/state"]' ) ;
161
+
162
+ expect ( await stateData . textContent ( ) ) . not . toContain ( "some test value" ) ;
163
+ expect ( await stateData . textContent ( ) ) . not . toContain (
164
+ "should not serialize this" ,
165
+ ) ;
166
+ expect ( await stateData . textContent ( ) ) . toContain ( "some eager test value" ) ;
167
+ expect ( await stateData . textContent ( ) ) . toContain ( "should serialize this" ) ;
168
+
169
+ if ( javaScriptEnabled ) {
170
+ await page . locator ( "#toggle-child" ) . click ( ) ;
171
+ await expect ( page . locator ( "#prop1" ) ) . toHaveText ( "some test value" ) ;
172
+ await expect ( page . locator ( "#prop2" ) ) . toHaveText (
173
+ "should not serialize this" ,
174
+ ) ;
175
+ await expect ( page . locator ( "#prop3" ) ) . toHaveText (
176
+ "some eager test value" ,
177
+ ) ;
178
+ await expect ( page . locator ( "#prop4" ) ) . toHaveText (
179
+ "should serialize this" ,
180
+ ) ;
181
+ }
182
+ } ) ;
154
183
}
155
184
} ) ;
You can’t perform that action at this time.
0 commit comments