@@ -612,3 +612,54 @@ test("comment actions revealed while the drawer slides realign when it settles",
612612 await expect . poll ( anchoring ) . toEqual ( { ...settled , anchored : true } ) ;
613613 await shown ( ) ;
614614} ) ;
615+
616+ // Real pointer hit testing and preview transitions cannot be proved in jsdom.
617+ test ( "every repeated reaction toggles my reaction while its preview is open" , async ( {
618+ page,
619+ } ) => {
620+ await page . goto ( "/tests/fixtures/emoji.html?reactions&repeated" ) ;
621+ const row = page . locator ( "[data-message-id]" ) . first ( ) ;
622+ const buttons = row . locator ( 'button[data-reaction="😂"]' ) ;
623+ await expect ( buttons ) . toHaveCount ( 2 ) ;
624+ const authors = await buttons . evaluateAll ( ( nodes ) =>
625+ nodes . map ( ( node ) => node . dataset . reactionAuthor ) ,
626+ ) ;
627+ for ( const author of authors ) {
628+ const button = row . locator (
629+ `button[data-reaction="😂"][data-reaction-author="${ author } "]` ,
630+ ) ;
631+ await button . hover ( ) ;
632+ await expect ( page . locator ( ".buzz-preview-card[data-open]" ) ) . toBeVisible ( ) ;
633+ await button . click ( ) ;
634+ const mine = row . getByRole ( "button" , { name : "😂: You" , exact : true } ) ;
635+ await expect ( mine ) . toBeVisible ( ) ;
636+ await expect ( button ) . toHaveAttribute ( "aria-disabled" , "false" ) ;
637+ await button . click ( ) ;
638+ await expect ( mine ) . toHaveCount ( 0 ) ;
639+ await expect ( buttons ) . toHaveCount ( 2 ) ;
640+ await button . click ( ) ;
641+ await expect ( mine ) . toBeVisible ( ) ;
642+ await expect ( mine ) . toHaveAttribute ( "aria-disabled" , "false" ) ;
643+ await mine . hover ( ) ;
644+ await expect ( page . locator ( ".buzz-preview-card[data-open]" ) ) . toBeVisible ( ) ;
645+ await mine . click ( ) ;
646+ await expect ( mine ) . toHaveCount ( 0 ) ;
647+ }
648+ } ) ;
649+
650+ // A direct pointer click does not wait for preview handoff animations to settle.
651+ test ( "clicking the second reaction during preview handoff toggles it" , async ( {
652+ page,
653+ } ) => {
654+ await page . goto ( "/tests/fixtures/emoji.html?reactions&repeated&narrow" ) ;
655+ const row = page . locator ( "[data-message-id]" ) . first ( ) ;
656+ const buttons = row . locator ( 'button[data-reaction="😂"]' ) ;
657+ await expect ( buttons ) . toHaveCount ( 2 ) ;
658+ await buttons . first ( ) . hover ( ) ;
659+ await expect ( page . locator ( ".buzz-preview-card[data-open]" ) ) . toBeVisible ( ) ;
660+ const box = await buttons . nth ( 1 ) . boundingBox ( ) ;
661+ await page . mouse . click ( box . x + box . width / 2 , box . y + box . height / 2 ) ;
662+ await expect (
663+ row . getByRole ( "button" , { name : "😂: You" , exact : true } ) ,
664+ ) . toBeVisible ( ) ;
665+ } ) ;
0 commit comments