@@ -266,6 +266,77 @@ test("settings is a route: section survives reload, closing returns to the previ
266266 await expect ( threadPanel ) . toBeVisible ( ) ;
267267} ) ;
268268
269+ test ( "message links to visible root messages open the thread panel" , async ( {
270+ page,
271+ } ) => {
272+ await page . goto ( "/" ) ;
273+ await page . getByTestId ( "channel-general" ) . click ( ) ;
274+ await expect ( page . getByTestId ( "chat-title" ) ) . toHaveText ( "general" ) ;
275+ await expect ( page . getByTestId ( "message-timeline" ) ) . toContainText (
276+ "Welcome to #general" ,
277+ ) ;
278+
279+ const link =
280+ "buzz://message?channel=9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50&id=mock-general-welcome" ;
281+ await page . getByTestId ( "message-input" ) . fill ( `Root link repro ${ link } ` ) ;
282+ await page . getByTestId ( "send-message" ) . click ( ) ;
283+
284+ const linkMessage = page
285+ . getByTestId ( "message-row" )
286+ . filter ( { hasText : "Root link repro" } )
287+ . last ( ) ;
288+ await expect ( linkMessage ) . toBeVisible ( ) ;
289+ await linkMessage
290+ . getByRole ( "button" , { name : "Open message in general" } )
291+ . click ( ) ;
292+
293+ const threadPanel = page . getByTestId ( "message-thread-panel" ) ;
294+ await expect ( threadPanel ) . toBeVisible ( ) ;
295+ await expect ( page ) . toHaveURL ( / t h r e a d = m o c k - g e n e r a l - w e l c o m e / ) ;
296+ await expect ( threadPanel . getByTestId ( "message-thread-head" ) ) . toContainText (
297+ "Welcome to #general" ,
298+ ) ;
299+ } ) ;
300+
301+ test ( "message links reopen a closed thread when the same messageId is already in the URL" , async ( {
302+ page,
303+ } ) => {
304+ await page . goto (
305+ "/#/channels/9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50?messageId=mock-general-welcome" ,
306+ ) ;
307+ await expect ( page . getByTestId ( "chat-title" ) ) . toHaveText ( "general" ) ;
308+
309+ const threadPanel = page . getByTestId ( "message-thread-panel" ) ;
310+ await expect ( threadPanel ) . toBeVisible ( ) ;
311+ await expect ( threadPanel . getByTestId ( "message-thread-head" ) ) . toContainText (
312+ "Welcome to #general" ,
313+ ) ;
314+
315+ await threadPanel . getByRole ( "button" , { name : "Close thread" } ) . click ( ) ;
316+ await expect ( threadPanel ) . not . toBeVisible ( ) ;
317+
318+ const link =
319+ "buzz://message?channel=9a1657ac-f7aa-5db0-b632-d8bbeb6dfb50&id=mock-general-welcome" ;
320+ await page
321+ . getByTestId ( "message-input" )
322+ . fill ( `Reopen same root link repro ${ link } ` ) ;
323+ await page . getByTestId ( "send-message" ) . click ( ) ;
324+
325+ const linkMessage = page
326+ . getByTestId ( "message-row" )
327+ . filter ( { hasText : "Reopen same root link repro" } )
328+ . last ( ) ;
329+ await expect ( linkMessage ) . toBeVisible ( ) ;
330+ await linkMessage
331+ . getByRole ( "button" , { name : "Open message in general" } )
332+ . click ( ) ;
333+
334+ await expect ( threadPanel ) . toBeVisible ( ) ;
335+ await expect ( threadPanel . getByTestId ( "message-thread-head" ) ) . toContainText (
336+ "Welcome to #general" ,
337+ ) ;
338+ } ) ;
339+
269340test ( "message deep links survive reload" , async ( { page } ) => {
270341 await page . goto (
271342 `/#/channels/${ ENGINEERING_CHANNEL_ID } ?messageId=mock-engineering-shipped` ,
0 commit comments