@@ -1693,6 +1693,67 @@ describe('actions/Report', () => {
16931693 callback : ( val ) => ( updateReport = val ) ,
16941694 } ) ;
16951695 expect ( updateReport ?. description ) . toBe ( '<h1>test</h1>' ) ;
1696+ mockFetch . mockReset ( ) ;
1697+ } ) ;
1698+ } ) ;
1699+
1700+ describe ( 'deleteAppReport' , ( ) => {
1701+ it ( 'should only moves CREATE or TRACK type of IOU action to self DM' , async ( ) => {
1702+ // Given an expense report with CREATE, TRACK, and PAY of IOU actions
1703+ const reportID = '1' ;
1704+ const firstIOUAction : OnyxTypes . ReportAction < typeof CONST . REPORT . ACTIONS . TYPE . IOU > = {
1705+ reportActionID : '1' ,
1706+ actionName : CONST . REPORT . ACTIONS . TYPE . IOU ,
1707+ created : DateUtils . getDBTime ( ) ,
1708+ originalMessage : {
1709+ amount : 100 ,
1710+ currency : CONST . CURRENCY . USD ,
1711+ type : CONST . IOU . REPORT_ACTION_TYPE . CREATE ,
1712+ } ,
1713+ } ;
1714+ const secondIOUAction : OnyxTypes . ReportAction < typeof CONST . REPORT . ACTIONS . TYPE . IOU > = {
1715+ reportActionID : '2' ,
1716+ actionName : CONST . REPORT . ACTIONS . TYPE . IOU ,
1717+ created : DateUtils . getDBTime ( ) ,
1718+ originalMessage : {
1719+ amount : 100 ,
1720+ currency : CONST . CURRENCY . USD ,
1721+ type : CONST . IOU . REPORT_ACTION_TYPE . TRACK ,
1722+ } ,
1723+ } ;
1724+ const payAction : OnyxTypes . ReportAction < typeof CONST . REPORT . ACTIONS . TYPE . IOU > = {
1725+ reportActionID : '3' ,
1726+ actionName : CONST . REPORT . ACTIONS . TYPE . IOU ,
1727+ created : DateUtils . getDBTime ( ) ,
1728+ originalMessage : {
1729+ amount : 100 ,
1730+ currency : CONST . CURRENCY . USD ,
1731+ type : CONST . IOU . REPORT_ACTION_TYPE . PAY ,
1732+ } ,
1733+ } ;
1734+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ reportID } ` , {
1735+ [ firstIOUAction . reportActionID ] : firstIOUAction ,
1736+ [ secondIOUAction . reportActionID ] : secondIOUAction ,
1737+ [ payAction . reportActionID ] : payAction ,
1738+ } ) ;
1739+
1740+ // When deleting the expense report
1741+ Report . deleteAppReport ( reportID ) ;
1742+ await waitForBatchedUpdates ( ) ;
1743+
1744+ // Then only the IOU action with type of CREATE and TRACK is moved to the self DM
1745+ const selfDMReportID = ReportUtils . findSelfDMReportID ( ) ;
1746+ const selfDMReportActions = await new Promise < OnyxEntry < OnyxTypes . ReportActions > > ( ( resolve ) => {
1747+ const connection = Onyx . connect ( {
1748+ key : `${ ONYXKEYS . COLLECTION . REPORT_ACTIONS } ${ selfDMReportID } ` ,
1749+ callback : ( val ) => {
1750+ Onyx . disconnect ( connection ) ;
1751+ resolve ( val ) ;
1752+ } ,
1753+ } ) ;
1754+ } ) ;
1755+ // The length is 3 to include the CREATED action
1756+ expect ( Object . keys ( selfDMReportActions ?? { } ) . length ) . toBe ( 3 ) ;
16961757 } ) ;
16971758 } ) ;
16981759} ) ;
0 commit comments