@@ -179,41 +179,57 @@ test.describe('hydration', async () => {
179179 await cleanup ( ) ;
180180 } ) ;
181181
182- test ( "55: hydrate onMedia('(min-width: 640px)') || onClick" , async ( { page } ) => {
182+ test ( "55: hydrate onMedia('(min-width: 640px)') || onClick - on desktop " , async ( { page } ) => {
183183 const { engine, cleanup } = await setupTestEngine (
184184 'fixtures/14-components/55-hydration-onMedia-or-onClick/docs' ,
185185 ) ;
186186 await engine . start ( ) ;
187187 const { port } = engine . devServer . config ;
188188
189+ // 1. start on small screen
189190 await page . setViewportSize ( {
190- width : 640 ,
191+ width : 320 ,
191192 height : 480 ,
192193 } ) ;
193194 await page . goto ( `localhost:${ port } ` ) ;
194195 const myEl = await page . locator ( 'my-el' ) ;
195196 const hydrated1 = await myEl . getAttribute ( 'hydrated' ) ;
196197 expect ( hydrated1 ) . toBe ( null ) ; // not hydrated
197198
199+ // 2. go bigger
200+ await page . setViewportSize ( {
201+ width : 640 ,
202+ height : 480 ,
203+ } ) ;
198204 await page . waitForLoadState ( 'networkidle0' ) ;
199205
200206 const hydrated2 = await myEl . getAttribute ( 'hydrated' ) ;
201207 expect ( hydrated2 ) . toBe ( '' ) ; // boolean attribute is there
202208
203- // revisit page on "mobile"
209+ await cleanup ( ) ;
210+ } ) ;
211+
212+ test ( "55b: hydrate onMedia('(min-width: 640px)') || onClick - on mobile" , async ( { page } ) => {
213+ const { engine, cleanup } = await setupTestEngine (
214+ 'fixtures/14-components/55-hydration-onMedia-or-onClick/docs' ,
215+ ) ;
216+ await engine . start ( ) ;
217+ const { port } = engine . devServer . config ;
218+
204219 await page . setViewportSize ( {
205220 width : 320 ,
206221 height : 480 ,
207222 } ) ;
208- await page . reload ( ) ;
209- const myEl2 = await page . locator ( 'my-el' ) ;
210- const hydrated3 = await myEl2 . getAttribute ( 'hydrated' ) ;
223+ await page . goto ( `localhost:${ port } ` ) ;
224+ const myEl = await page . locator ( 'my-el' ) ;
225+
226+ const hydrated3 = await myEl . getAttribute ( 'hydrated' ) ;
211227 expect ( hydrated3 ) . toBe ( null ) ; // not hydrated
212228
213229 await myEl . click ( ) ;
214230 await page . waitForLoadState ( 'networkidle0' ) ;
215231
216- const hydrated4 = await myEl2 . getAttribute ( 'hydrated' ) ;
232+ const hydrated4 = await myEl . getAttribute ( 'hydrated' ) ;
217233 expect ( hydrated4 ) . toBe ( '' ) ; // boolean attribute is there
218234
219235 await cleanup ( ) ;
@@ -243,7 +259,7 @@ test.describe('hydration', async () => {
243259 const focusInEv = await myEl . getAttribute ( 'focusin-ev' ) ;
244260 expect ( focusInEv ) . toBe ( '' ) ;
245261
246- // NOTE: focus event is NOT supported as it does not bubble
262+ // NOTE: we are using the focusin event as the focus event is NOT supported as it does not bubble
247263 await cleanup ( ) ;
248264 } ) ;
249265} ) ;
0 commit comments