@@ -1322,3 +1322,73 @@ it("never mounts an audio player for a native lookalike", () => {
13221322 expect ( html ) . not . toContain ( "<audio" ) ;
13231323 expect ( html ) . toContain ( "File unavailable" ) ;
13241324} ) ;
1325+
1326+ it ( "renders built-in own bubbles and keeps only the last grouped avatar" , ( ) => {
1327+ const props = {
1328+ row : { ...row , authorId : "ab" . repeat ( 32 ) } ,
1329+ viewer : "ab" . repeat ( 32 ) ,
1330+ profile : { name : "author" } ,
1331+ media : ( ) => undefined ,
1332+ onOpenLink : ( ) => true ,
1333+ canOpenLink : ( ) => true ,
1334+ day : false ,
1335+ retry : undefined ,
1336+ } ;
1337+ try {
1338+ const { container, rerender } = renderDom (
1339+ < MessageRow { ...props } stackNext /> ,
1340+ ) ;
1341+ expect ( container . querySelector ( "[data-own]" ) ) . toHaveTextContent ( "Root" ) ;
1342+ expect (
1343+ screen . queryByRole ( "button" , { name : "View author profile" } ) ,
1344+ ) . toBeNull ( ) ;
1345+ rerender ( < MessageRow { ...props } stackPrevious /> ) ;
1346+ expect (
1347+ screen . getByRole ( "button" , { name : "View author profile" } ) ,
1348+ ) . toBeInTheDocument ( ) ;
1349+ rerender ( < MessageRow { ...props } viewer = "someone-else" /> ) ;
1350+ expect ( container . querySelector ( "[data-own]" ) ) . toBeNull ( ) ;
1351+ } finally {
1352+ cleanup ( ) ;
1353+ }
1354+ } ) ;
1355+
1356+ it . each ( [ "image" , "video" , "file" , "audio" ] as const ) (
1357+ "places %s attachments outside the text bubble and omits empty bubbles" ,
1358+ ( kind ) => {
1359+ const props = {
1360+ row : {
1361+ ...row ,
1362+ content : "" ,
1363+ attachments : [ { kind, url : "https://example.com/photo.png" } ] ,
1364+ } ,
1365+ profile : undefined ,
1366+ media : ( ) => undefined ,
1367+ onOpenLink : ( ) => true ,
1368+ day : false ,
1369+ retry : undefined ,
1370+ } ;
1371+ try {
1372+ const { container, rerender } = renderDom ( < MessageRow { ...props } /> ) ;
1373+ expect ( container . querySelector ( "[data-own]" ) ) . toBeNull ( ) ;
1374+ expect ( container . querySelector ( "[class*=messageBubble]" ) ) . toBeNull ( ) ;
1375+ rerender (
1376+ < MessageRow
1377+ { ...props }
1378+ row = { { ...props . row , content : "Photo caption" } }
1379+ /> ,
1380+ ) ;
1381+ const bubble = container . querySelector ( "[class*=messageBubble]" ) ;
1382+ const attachments = container . querySelector (
1383+ "[class*=messageAttachments]" ,
1384+ ) ;
1385+ expect ( bubble ) . toHaveTextContent ( "Photo caption" ) ;
1386+ expect ( attachments ) . not . toBeNull ( ) ;
1387+ expect ( bubble ?. contains ( attachments ) ) . toBe ( false ) ;
1388+ expect ( bubble ?. nextElementSibling ) . toBe ( attachments ) ;
1389+ expect ( screen . getByText ( "Photo caption" ) ) . toBeInTheDocument ( ) ;
1390+ } finally {
1391+ cleanup ( ) ;
1392+ }
1393+ } ,
1394+ ) ;
0 commit comments