@@ -50,17 +50,19 @@ describe('ssr-shadow-cmp', () => {
5050 // wait for Stencil to take over and reconcile
5151 await browser . waitUntil ( async ( ) => customElements . get ( 'ssr-shadow-cmp' ) ) ;
5252 expect ( typeof customElements . get ( 'ssr-shadow-cmp' ) ) . toBe ( 'function' ) ;
53+
5354 await expect ( getNodeNames ( document . querySelector ( 'ssr-shadow-cmp' ) . childNodes ) ) . toBe (
5455 `text comment div comment text` ,
5556 ) ;
5657
5758 document . querySelector ( '#stage' ) ?. remove ( ) ;
59+ await browser . waitUntil ( async ( ) => ! document . querySelector ( '#stage' ) ) ;
5860 } ) ;
5961
6062 it ( 'checks perf when loading lots of the same component' , async ( ) => {
6163 performance . mark ( 'start' ) ;
6264
63- const { html } = await renderToString (
65+ await renderToString (
6466 Array ( 50 )
6567 . fill ( 0 )
6668 . map ( ( _ , i ) => `<ssr-shadow-cmp>Value ${ i } </ssr-shadow-cmp>` )
@@ -71,15 +73,44 @@ describe('ssr-shadow-cmp', () => {
7173 constrainTimeouts : false ,
7274 } ,
7375 ) ;
74- const stage = document . createElement ( 'div' ) ;
75- stage . setAttribute ( 'id' , 'stage' ) ;
76- stage . setHTMLUnsafe ( html ) ;
77- document . body . appendChild ( stage ) ;
78-
7976 performance . mark ( 'end' ) ;
8077 const renderTime = performance . measure ( 'render' , 'start' , 'end' ) . duration ;
78+ await expect ( renderTime ) . toBeLessThan ( 50 ) ;
79+ } ) ;
80+
81+ it ( 'resolves slots correctly during client-side hydration' , async ( ) => {
82+ if ( ! document . querySelector ( '#stage' ) ) {
83+ const { html } = await renderToString (
84+ `
85+ <ssr-shadow-cmp>
86+ <p>Default slot content</p>
87+ <p slot="client-only">Client-only slot content</p>
88+ </ssr-shadow-cmp>
89+ ` ,
90+ {
91+ fullDocument : true ,
92+ serializeShadowRoot : true ,
93+ constrainTimeouts : false ,
94+ } ,
95+ ) ;
96+ const stage = document . createElement ( 'div' ) ;
97+ stage . setAttribute ( 'id' , 'stage' ) ;
98+ stage . setHTMLUnsafe ( html ) ;
99+ document . body . appendChild ( stage ) ;
100+ }
81101
82- await expect ( renderTime ) . toBeLessThan ( 100 ) ;
102+ // @ts -expect-error resolved through WDIO
103+ const { defineCustomElements } = await import ( '/dist/loader/index.js' ) ;
104+ defineCustomElements ( ) . catch ( console . error ) ;
105+
106+ // wait for Stencil to take over and reconcile
107+ await browser . waitUntil ( async ( ) => customElements . get ( 'ssr-shadow-cmp' ) ) ;
108+ expect ( typeof customElements . get ( 'ssr-shadow-cmp' ) ) . toBe ( 'function' ) ;
109+
110+ await browser . waitUntil ( async ( ) => document . querySelector ( 'ssr-shadow-cmp [slot="client-only"]' ) ) ;
111+ await expect ( document . querySelector ( 'ssr-shadow-cmp' ) . textContent ) . toBe (
112+ ' Default slot content Client-only slot content ' ,
113+ ) ;
83114
84115 document . querySelector ( '#stage' ) ?. remove ( ) ;
85116 } ) ;
0 commit comments