@@ -4049,6 +4049,24 @@ describe("right-click Reply", () => {
40494049 expect ( target . senderLabel ) . toBe ( "User" ) ;
40504050 } ) ;
40514051
4052+ it ( "backs off before an emoji that crosses the reply target limit" , ( ) => {
4053+ const onSetReply = vi . fn ( ) ;
4054+ const container = renderChatView ( { onSetReply } ) ;
4055+ const section = container . querySelector < HTMLElement > ( ".card.chat" ) ;
4056+ const group = document . createElement ( "div" ) ;
4057+ group . className = "chat-group" ;
4058+ const bubble = document . createElement ( "div" ) ;
4059+ bubble . className = "chat-bubble" ;
4060+ bubble . dataset . messageText = "x" . repeat ( 499 ) + "🧠tail" ;
4061+ group . appendChild ( bubble ) ;
4062+ section ! . querySelector ( ".chat-thread-inner" ) ! . appendChild ( group ) ;
4063+
4064+ bubble . dispatchEvent ( new MouseEvent ( "contextmenu" , { bubbles : true , cancelable : true } ) ) ;
4065+ document . querySelector < HTMLButtonElement > ( ".chat-reply-context-menu button" ) ! . click ( ) ;
4066+
4067+ expect ( onSetReply . mock . calls [ 0 ] [ 0 ] . text ) . toBe ( "x" . repeat ( 499 ) ) ;
4068+ } ) ;
4069+
40524070 it ( "keeps the native context menu when Reply is unavailable" , ( ) => {
40534071 const container = renderChatView ( ) ;
40544072 const section = container . querySelector < HTMLElement > ( ".card.chat" ) ;
@@ -4129,6 +4147,20 @@ describe("right-click Reply", () => {
41294147 expect ( dismiss ) . not . toBeNull ( ) ;
41304148 } ) ;
41314149
4150+ it ( "backs off before an emoji that crosses the reply preview limit" , ( ) => {
4151+ const container = renderChatView ( {
4152+ replyTarget : {
4153+ messageId : "msg-emoji" ,
4154+ text : "x" . repeat ( 119 ) + "🧠tail" ,
4155+ senderLabel : "User" ,
4156+ } ,
4157+ } ) ;
4158+
4159+ expect ( container . querySelector ( ".chat-reply-preview__text" ) ?. textContent ) . toBe (
4160+ `${ "x" . repeat ( 119 ) } ...` ,
4161+ ) ;
4162+ } ) ;
4163+
41324164 it ( "calls onClearReply when dismiss button is clicked" , ( ) => {
41334165 const onClearReply = vi . fn ( ) ;
41344166 const container = renderChatView ( {
0 commit comments