@@ -18,6 +18,8 @@ import * as SequentialQueue from '@src/libs/Network/SequentialQueue';
18
18
import * as ReportUtils from '@src/libs/ReportUtils' ;
19
19
import ONYXKEYS from '@src/ONYXKEYS' ;
20
20
import type * as OnyxTypes from '@src/types/onyx' ;
21
+ import createRandomReportAction from '../utils/collections/reportActions' ;
22
+ import createRandomReport from '../utils/collections/reports' ;
21
23
import getIsUsingFakeTimers from '../utils/getIsUsingFakeTimers' ;
22
24
import PusherHelper from '../utils/PusherHelper' ;
23
25
import * as TestHelper from '../utils/TestHelper' ;
@@ -1436,4 +1438,51 @@ describe('actions/Report', () => {
1436
1438
1437
1439
TestHelper . expectAPICommandToHaveBeenCalled ( WRITE_COMMANDS . UPDATE_COMMENT , 1 ) ;
1438
1440
} ) ;
1441
+
1442
+ it ( 'should clears lastMentionedTime when all mentions to the current user are deleted' , async ( ) => {
1443
+ const reportID = '1' ;
1444
+ const mentionActionID = '1' ;
1445
+ const mentionActionID2 = '2' ;
1446
+ const currentUserAccountID = 123 ;
1447
+
1448
+ const mentionAction = {
1449
+ ...createRandomReportAction ( Number ( mentionActionID ) ) ,
1450
+ actionName : CONST . REPORT . ACTIONS . TYPE . ADD_COMMENT ,
1451
+ originalMessage : {
1452
+ mentionedAccountIDs : [ currentUserAccountID ] ,
1453
+ } ,
1454
+ } as OnyxTypes . ReportAction < typeof CONST . REPORT . ACTIONS . TYPE . ADD_COMMENT > ;
1455
+
1456
+ const mentionAction2 = {
1457
+ ...createRandomReportAction ( Number ( mentionActionID2 ) ) ,
1458
+ actionName : CONST . REPORT . ACTIONS . TYPE . ADD_COMMENT ,
1459
+ originalMessage : {
1460
+ mentionedAccountIDs : [ currentUserAccountID ] ,
1461
+ } ,
1462
+ } as OnyxTypes . ReportAction < typeof CONST . REPORT . ACTIONS . TYPE . ADD_COMMENT > ;
1463
+
1464
+ await Onyx . merge ( ONYXKEYS . SESSION , { accountID : currentUserAccountID } ) ;
1465
+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ reportID } ` , {
1466
+ [ mentionActionID ] : mentionAction ,
1467
+ [ mentionActionID2 ] : mentionAction2 ,
1468
+ } ) ;
1469
+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ reportID } ` , {
1470
+ ...createRandomReport ( Number ( reportID ) ) ,
1471
+ lastMentionedTime : mentionAction2 . created ,
1472
+ } ) ;
1473
+
1474
+ Report . deleteReportComment ( reportID , mentionAction ) ;
1475
+ Report . deleteReportComment ( reportID , mentionAction2 ) ;
1476
+
1477
+ await waitForBatchedUpdates ( ) ;
1478
+
1479
+ const report = await new Promise < OnyxEntry < OnyxTypes . Report > > ( ( resolve ) => {
1480
+ Onyx . connect ( {
1481
+ key : `${ ONYXKEYS . COLLECTION . REPORT } ${ reportID } ` ,
1482
+ callback : resolve ,
1483
+ } ) ;
1484
+ } ) ;
1485
+
1486
+ expect ( report ?. lastMentionedTime ) . toBeUndefined ( ) ;
1487
+ } ) ;
1439
1488
} ) ;
0 commit comments