@@ -670,5 +670,90 @@ describe("Timeline", () => {
670670 percyCSS,
671671 } ) ;
672672 } ) ;
673+
674+ it ( "should send, reply, and display long strings without overflowing" , ( ) => {
675+ // Max 256 characters for display name
676+ const LONG_STRING =
677+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut " +
678+ "et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " +
679+ "aliquip" ;
680+
681+ // Create a bot with a long display name
682+ let bot : MatrixClient ;
683+ cy . getBot ( homeserver , {
684+ displayName : LONG_STRING ,
685+ autoAcceptInvites : false ,
686+ } ) . then ( ( _bot ) => {
687+ bot = _bot ;
688+ } ) ;
689+
690+ // Create another room with a long name, invite the bot, and open the room
691+ cy . createRoom ( { name : LONG_STRING } )
692+ . as ( "testRoomId" )
693+ . then ( ( _roomId ) => {
694+ roomId = _roomId ;
695+ cy . inviteUser ( roomId , bot . getUserId ( ) ) ;
696+ bot . joinRoom ( roomId ) ;
697+ cy . visit ( "/#/room/" + roomId ) ;
698+ } ) ;
699+
700+ // Wait until configuration is finished
701+ cy . contains (
702+ ".mx_RoomView_body .mx_GenericEventListSummary .mx_GenericEventListSummary_summary" ,
703+ "created and configured the room." ,
704+ ) . should ( "exist" ) ;
705+
706+ // Set the display name to "LONG_STRING 2" in order to avoid a warning in Percy tests from being triggered
707+ // due to the generated random mxid being displayed inside the GELS summary.
708+ cy . setDisplayName ( `${ LONG_STRING } 2` ) ;
709+
710+ // Have the bot send a long message
711+ cy . get < string > ( "@testRoomId" ) . then ( ( roomId ) => {
712+ bot . sendMessage ( roomId , {
713+ body : LONG_STRING ,
714+ msgtype : "m.text" ,
715+ } ) ;
716+ } ) ;
717+
718+ // Wait until the message is rendered
719+ cy . get ( ".mx_EventTile_last .mx_MTextBody .mx_EventTile_body" ) . should ( "have.text" , LONG_STRING ) ;
720+
721+ // Reply to the message
722+ cy . get ( ".mx_EventTile_last" )
723+ . realHover ( )
724+ . within ( ( ) => {
725+ cy . get ( '[aria-label="Reply"]' ) . click ( { force : false } ) ;
726+ } ) ;
727+ cy . getComposer ( ) . type ( `${ reply } {enter}` ) ;
728+
729+ // Make sure the reply tile and the reply are displayed
730+ cy . get ( ".mx_EventTile_last" ) . within ( ( ) => {
731+ cy . get ( ".mx_ReplyTile .mx_MTextBody" ) . should ( "have.text" , LONG_STRING ) ;
732+ cy . get ( ".mx_EventTile_line > .mx_MTextBody" ) . should ( "have.text" , reply ) ;
733+ } ) ;
734+
735+ // Exclude timestamp and read marker from snapshots
736+ const percyCSS = ".mx_MessageTimestamp, .mx_RoomView_myReadMarker { visibility: hidden !important; }" ;
737+
738+ // Make sure the strings do not overflow on IRC layout
739+ cy . setSettingValue ( "layout" , null , SettingLevel . DEVICE , Layout . IRC ) ;
740+ cy . get ( ".mx_MainSplit" ) . percySnapshotElement ( "Long strings with a reply on IRC layout" , { percyCSS } ) ;
741+
742+ // Make sure the strings do not overflow on modern layout
743+ cy . setSettingValue ( "layout" , null , SettingLevel . DEVICE , Layout . Group ) ;
744+ cy . get ( ".mx_EventTile_last[data-layout='group'] .mx_EventTile_line > .mx_MTextBody" ) . should (
745+ "have.text" ,
746+ reply ,
747+ ) ;
748+ cy . get ( ".mx_MainSplit" ) . percySnapshotElement ( "Long strings with a reply on modern layout" , { percyCSS } ) ;
749+
750+ // Make sure the strings do not overflow on bubble layout
751+ cy . setSettingValue ( "layout" , null , SettingLevel . DEVICE , Layout . Bubble ) ;
752+ cy . get ( ".mx_EventTile_last[data-layout='bubble'] .mx_EventTile_line > .mx_MTextBody" ) . should (
753+ "have.text" ,
754+ reply ,
755+ ) ;
756+ cy . get ( ".mx_MainSplit" ) . percySnapshotElement ( "Long strings with a reply on bubble layout" , { percyCSS } ) ;
757+ } ) ;
673758 } ) ;
674759} ) ;
0 commit comments