@@ -137,11 +137,41 @@ async function check(name: string, run: () => Promise<void>, page?: Page) {
137137 logger . info ( 'Check passed' , { name } )
138138 } catch ( error ) {
139139 if ( page ) await page . screenshot ( { path : resolve ( artifactDir , `failure-${ checks . length } .png` ) } )
140+ const browserState = await page
141+ ?. evaluate ( ( ) => {
142+ const selection = getSelection ( )
143+ const editable = document . querySelector ( '.rich-markdown-prose[contenteditable="true"]' )
144+ return {
145+ documentFocused : document . hasFocus ( ) ,
146+ editorFocused : document . activeElement === editable ,
147+ activeTag : document . activeElement ?. tagName ,
148+ selection : selection ?. toString ( ) . slice ( 0 , 160 ) ,
149+ selectionInEditor : Boolean (
150+ editable && selection ?. anchorNode && editable . contains ( selection . anchorNode )
151+ ) ,
152+ textMenus : [ ...document . querySelectorAll ( '[aria-label="Text formatting"]' ) ] . map (
153+ ( element ) => {
154+ const popup = element . parentElement
155+ const bounds = popup ?. getBoundingClientRect ( )
156+ const style = popup && getComputedStyle ( popup )
157+ return {
158+ connected : element . isConnected ,
159+ display : style ?. display ,
160+ visibility : style ?. visibility ,
161+ x : bounds ?. x ,
162+ y : bounds ?. y ,
163+ width : bounds ?. width ,
164+ }
165+ }
166+ ) ,
167+ }
168+ } )
169+ . catch ( ( ) => null )
140170 checks . push ( {
141171 name,
142172 passed : false ,
143173 durationMs : performance . now ( ) - start ,
144- error : getErrorMessage ( error ) ,
174+ error : ` ${ getErrorMessage ( error ) } ${ browserState ? `\nBrowser state: ${ JSON . stringify ( browserState ) } ` : '' } ` ,
145175 } )
146176 logger . error ( 'Check failed' , { name, error : getErrorMessage ( error ) } )
147177 }
@@ -225,10 +255,22 @@ async function proveFeatures(page: Page) {
225255 . locator ( 'td' )
226256 . first ( )
227257 assert (
228- await longCell . evaluate ( ( element ) => element . getBoundingClientRect ( ) . width <= 321 ) ,
258+ await longCell . evaluate (
259+ ( element ) =>
260+ element . getBoundingClientRect ( ) . width <=
261+ Math . max ( 321 , element . closest ( '.tableWrapper' ) ?. clientWidth ?? 0 )
262+ ) ,
229263 'A long token expands its column without a bound'
230264 )
231265 const aligned = page . locator ( '.rich-markdown-prose table' ) . filter ( { hasText : 'Escaped | pipe' } )
266+ assert (
267+ await aligned . evaluate (
268+ ( element ) =>
269+ element . getBoundingClientRect ( ) . width >=
270+ ( element . closest ( '.tableWrapper' ) ?. clientWidth ?? Number . POSITIVE_INFINITY ) - 1
271+ ) ,
272+ 'A short table no longer fills the reading column'
273+ )
232274 const alignment = await aligned
233275 . locator ( 'tr' )
234276 . nth ( 1 )
@@ -332,10 +374,12 @@ async function editLastCell(page: Page, marker: string) {
332374 await expect ( page . locator ( '.rich-markdown-prose[contenteditable="true"]' ) ) . toBeVisible ( {
333375 timeout : 120_000 ,
334376 } )
377+ await page . bringToFront ( )
335378 await page
336379 . locator ( '.rich-markdown-prose strong' )
337380 . filter ( { hasText : / ^ b o l d $ / } )
338381 . click ( )
382+ await expect ( page . locator ( '.rich-markdown-prose[contenteditable="true"]' ) ) . toBeFocused ( )
339383 await page . keyboard . press ( 'ArrowLeft' )
340384 await page . keyboard . press ( 'Shift+ArrowRight' )
341385 assert (
@@ -379,6 +423,7 @@ async function proveCollaborationCursor(page: Page) {
379423 await page . screenshot ( { path : resolve ( artifactDir , `collaborator-${ checks . length } .png` ) } )
380424 } finally {
381425 await peer . close ( )
426+ await page . bringToFront ( )
382427 }
383428}
384429
@@ -517,6 +562,7 @@ async function proveCollaborationScroll(page: Page) {
517562 } )
518563 } finally {
519564 await peer . close ( )
565+ await page . bringToFront ( )
520566 }
521567}
522568
0 commit comments