@@ -304,6 +304,92 @@ describe('AccountPostsView', () => {
304304 }
305305 } ) ;
306306
307+ describe ( 'inReplyTo' , ( ) => {
308+ async function getOutbox ( subject : Account ) {
309+ const result = await viewer . getPostsFromOutbox (
310+ subject ,
311+ contextAccount . id ,
312+ 10 ,
313+ null ,
314+ true ,
315+ ) ;
316+ expect ( isError ( result ) ) . toBe ( false ) ;
317+ return getValue ( result as [ null , AccountPosts ] ) . results ;
318+ }
319+
320+ it ( 'names the parent author when replying to another account' , async ( ) => {
321+ const [ parentAuthor ] =
322+ await fixtureManager . createInternalAccount ( ) ;
323+ const parent = await fixtureManager . createPost ( parentAuthor ) ;
324+ const reply = await fixtureManager . createReply ( account , parent ) ;
325+
326+ const [ parentAsListed ] = await getOutbox ( parentAuthor ) ;
327+ const results = await getOutbox ( account ) ;
328+
329+ expect ( results ) . toHaveLength ( 1 ) ;
330+ expect ( results [ 0 ] . id ) . toBe ( reply . apId . href ) ;
331+ expect ( results [ 0 ] . inReplyTo ) . toEqual ( {
332+ id : parent . apId . href ,
333+ author : {
334+ name : parentAuthor . name ,
335+ handle : parentAsListed . author . handle ,
336+ url : parentAuthor . url . href ,
337+ } ,
338+ } ) ;
339+ expect ( results [ 0 ] . inReplyTo ?. author ?. handle ) . not . toBe (
340+ results [ 0 ] . author . handle ,
341+ ) ;
342+ } ) ;
343+
344+ it ( 'gives the same handle for author and parent when replying to self' , async ( ) => {
345+ const parent = await fixtureManager . createPost ( account ) ;
346+ await fixtureManager . createReply ( account , parent ) ;
347+
348+ const results = await getOutbox ( account ) ;
349+
350+ expect ( results ) . toHaveLength ( 2 ) ;
351+ const [ reply , original ] = results ;
352+ expect ( reply . inReplyTo ) . toMatchObject ( {
353+ id : parent . apId . href ,
354+ author : { handle : reply . author . handle } ,
355+ } ) ;
356+ expect ( reply . inReplyTo ?. author ?. handle ) . toBe (
357+ original . author . handle ,
358+ ) ;
359+ } ) ;
360+
361+ it ( 'returns null for posts that are not replies' , async ( ) => {
362+ await fixtureManager . createPost ( account ) ;
363+
364+ const results = await getOutbox ( account ) ;
365+
366+ expect ( results ) . toHaveLength ( 1 ) ;
367+ expect ( results [ 0 ] . inReplyTo ) . toBeNull ( ) ;
368+ } ) ;
369+
370+ it ( 'still names the parent author when the parent is soft-deleted' , async ( ) => {
371+ const [ parentAuthor ] =
372+ await fixtureManager . createInternalAccount ( ) ;
373+ const parent = await fixtureManager . createPost ( parentAuthor ) ;
374+ await fixtureManager . createReply ( account , parent ) ;
375+
376+ await db ( 'posts' )
377+ . where ( { id : parent . id } )
378+ . update ( { deleted_at : db . fn . now ( ) } ) ;
379+
380+ const results = await getOutbox ( account ) ;
381+
382+ expect ( results ) . toHaveLength ( 1 ) ;
383+ expect ( results [ 0 ] . inReplyTo ) . toMatchObject ( {
384+ id : parent . apId . href ,
385+ author : {
386+ name : parentAuthor . name ,
387+ url : parentAuthor . url . href ,
388+ } ,
389+ } ) ;
390+ } ) ;
391+ } ) ;
392+
307393 it ( 'sets likedByMe and repostedByMe correctly' , async ( ) => {
308394 const post = await fixtureManager . createPost ( account ) ;
309395 await postRepository . save ( post ) ;
0 commit comments