@@ -69,18 +69,21 @@ export async function activateCommentDialog(
6969 await superdoc . waitForStable ( ) ;
7070 }
7171
72+ const activeDialog = superdoc . page . locator ( '.comment-placeholder .comments-dialog.is-active' ) . last ( ) ;
7273 const dialog = activeCommentDialog ( superdoc . page ) ;
73- const isActive = await dialog . isVisible ( { timeout : 2_000 } ) . catch ( ( ) => false ) ;
74+ const hasActiveDialog = ( await activeDialog . count ( ) ) > 0 ;
7475
75- if ( ! isActive ) {
76+ if ( ! hasActiveDialog ) {
7677 // Fallback: click the floating dialog directly to trigger setFocus → is-active
7778 const floatingDialog = superdoc . page . locator ( '.comment-placeholder .comments-dialog' ) . last ( ) ;
7879 await expect ( floatingDialog ) . toBeVisible ( { timeout : timeoutMs } ) ;
79- await floatingDialog . click ( ) ;
80+ // Click near the top-left to avoid accidentally hitting interactive controls
81+ // such as the "N more replies" collapse/expand pill in the middle of the card.
82+ await floatingDialog . click ( { position : { x : 12 , y : 12 } } ) ;
8083 await superdoc . waitForStable ( ) ;
8184
82- const isActiveNow = await dialog . isVisible ( { timeout : 2_000 } ) . catch ( ( ) => false ) ;
83- if ( ! isActiveNow ) {
85+ const hasActiveDialogNow = ( await activeDialog . count ( ) ) > 0 ;
86+ if ( ! hasActiveDialogNow ) {
8487 // Last resort: set activeComment directly on the Pinia store. This is
8588 // needed when click events don't propagate to activate the dialog
8689 // (Firefox/WebKit) or replyToComment calls set it to a child ID.
@@ -99,6 +102,11 @@ export async function activateCommentDialog(
99102 }
100103 }
101104
105+ if ( ( await activeDialog . count ( ) ) > 0 ) {
106+ await expect ( activeDialog ) . toBeVisible ( { timeout : timeoutMs } ) ;
107+ return activeDialog ;
108+ }
109+
102110 await expect ( dialog ) . toBeVisible ( { timeout : timeoutMs } ) ;
103111 return dialog ;
104112}
0 commit comments