@@ -18,7 +18,7 @@ const run = async (viewport, label, dir = "ltr", lang = "en") => {
1818 const page = await context . newPage ( )
1919 page . setDefaultTimeout ( 15_000 )
2020 page . on ( "pageerror" , ( error ) => errors . push ( `${ label } : ${ error . message } ` ) )
21- await page . goto ( preview . laneUrl , { waitUntil : "domcontentloaded" } )
21+ await page . goto ( preview . laneUrl , { waitUntil : "domcontentloaded" , timeout : 60_000 } )
2222 const header = page . locator ( ".topbar" )
2323 const editor = page . getByRole ( "textbox" , { name : "Message" , exact : true } )
2424 await expect ( page . locator ( '[data-find-message="msg_1011"]' ) ) . toBeVisible ( { timeout : 30_000 } )
@@ -89,6 +89,30 @@ const run = async (viewport, label, dir = "ltr", lang = "en") => {
8989 await expect ( content ) . toHaveCount ( 0 )
9090 await expect ( menu ) . toHaveAttribute ( "aria-expanded" , "false" )
9191 await expect ( menu ) . toBeFocused ( )
92+ // Tab and Shift+Tab continue from the trigger and close the menu.
93+ const neighbour = async ( shift ) => page . evaluate ( ( shift ) => {
94+ const trigger = document . querySelector ( '[aria-label="Session mail"]' )
95+ const focusable = [ ...document . querySelectorAll ( "button, [href], input, textarea, select, [tabindex]:not([tabindex='-1'])" ) ]
96+ . filter ( ( element ) => ! element . disabled && element . offsetParent !== null && element . tabIndex >= 0 )
97+ return focusable [ focusable . indexOf ( trigger ) + ( shift ? - 1 : 1 ) ] ?. outerHTML . slice ( 0 , 120 )
98+ } , shift )
99+ for ( const shift of [ false , true ] ) {
100+ await menu . press ( "Enter" )
101+ await expect ( content . getByRole ( "menuitem" ) . first ( ) ) . toBeFocused ( )
102+ const expected = await neighbour ( shift )
103+ await page . keyboard . press ( shift ? "Shift+Tab" : "Tab" )
104+ await expect ( content ) . toHaveCount ( 0 )
105+ await expect ( menu ) . toHaveAttribute ( "aria-expanded" , "false" )
106+ expect ( await page . evaluate ( ( ) => document . activeElement ?. outerHTML . slice ( 0 , 120 ) ) ) . toBe ( expected )
107+ }
108+ // The Find shortcut moves focus out of the open menu, which closes it.
109+ await menu . press ( "Enter" )
110+ await expect ( content ) . toBeVisible ( )
111+ await page . keyboard . press ( "Control+f" )
112+ await expect ( page . getByRole ( "searchbox" , { name : "Find in transcript" } ) ) . toBeFocused ( )
113+ await expect ( content ) . toHaveCount ( 0 )
114+ await page . keyboard . press ( "Escape" )
115+ await expect ( page . getByRole ( "searchbox" , { name : "Find in transcript" } ) ) . toHaveCount ( 0 )
92116 await menu . click ( )
93117 await expect ( content ) . toBeVisible ( )
94118 // The menu sits in the viewport and above the transcript, not behind the header.
0 commit comments