@@ -424,7 +424,7 @@ describe('Sanity check SSR > Client hydration', () => {
424424 expect ( nestedCmp . childNodes [ 1 ] . textContent ) . toBe ( 'after' ) ;
425425 } ) ;
426426
427- it ( 'renders slots nodes appropriately in a `scoped: true` child with `serializeShadowRoot: "scoped"` parent' , async ( ) => {
427+ it ( 'renders slot nodes appropriately in a `scoped: true` child with `serializeShadowRoot: "scoped"` parent' , async ( ) => {
428428 if ( document . querySelector ( '#stage' ) ) {
429429 document . querySelector ( '#stage' ) ?. remove ( ) ;
430430 await browser . waitUntil ( async ( ) => ! document . querySelector ( '#stage' ) ) ;
@@ -501,4 +501,40 @@ describe('Sanity check SSR > Client hydration', () => {
501501 expect ( wrapCmp . childNodes . length ) . toBe ( 3 ) ;
502502 expect ( wrapCmp . textContent ) . toBe ( 'one23' ) ;
503503 } ) ;
504+
505+ it ( 'correctly renders a slow to hydrate component with a prop' , async ( ) => {
506+ if ( document . querySelector ( '#stage' ) ) {
507+ document . querySelector ( '#stage' ) ?. remove ( ) ;
508+ await browser . waitUntil ( async ( ) => ! document . querySelector ( '#stage' ) ) ;
509+ }
510+ const { html } = await renderToString ( `<slow-ssr-prop></slow-ssr-prop>` , {
511+ fullDocument : true ,
512+ serializeShadowRoot : 'declarative-shadow-dom' ,
513+ beforeHydrate : ( doc ) => {
514+ // simulate a slow prop update
515+ const slowCmp = doc . querySelector ( 'slow-ssr-prop' ) ;
516+ slowCmp . anArray = [ 'one' , 'two' , 'three' ] ;
517+ } ,
518+ } ) ;
519+ const stage = document . createElement ( 'div' ) ;
520+ stage . setAttribute ( 'id' , 'stage' ) ;
521+ stage . setHTMLUnsafe ( html ) ;
522+ document . body . appendChild ( stage ) ;
523+
524+ // @ts -expect-error resolved through WDIO
525+ const { defineCustomElements } = await import ( '/dist/loader/index.js' ) ;
526+ defineCustomElements ( ) . catch ( console . error ) ;
527+
528+ // wait for Stencil to take over and reconcile
529+ await browser . waitUntil ( async ( ) => customElements . get ( 'slow-ssr-prop' ) ) ;
530+ expect ( typeof customElements . get ( 'slow-ssr-prop' ) ) . toBe ( 'function' ) ;
531+
532+ const slowCmp : any = document . querySelector ( 'slow-ssr-prop' ) ;
533+ setTimeout ( ( ) => {
534+ slowCmp . anArray = [ 'one' , 'two' , 'three' , 'four' ] ;
535+ } , 400 ) ;
536+ await browser . pause ( 600 ) ;
537+
538+ expect ( slowCmp . shadowRoot . querySelector ( 'div' ) . textContent ) . toBe ( 'An array component:onetwothreefour' ) ;
539+ } ) ;
504540} ) ;
0 commit comments