@@ -22,6 +22,7 @@ import {
2222 canAddTransaction ,
2323 canDeleteReportAction ,
2424 canDeleteTransaction ,
25+ canEditFieldOfMoneyRequest ,
2526 canEditReportDescription ,
2627 canEditRoomVisibility ,
2728 canEditWriteCapability ,
@@ -295,6 +296,88 @@ describe('ReportUtils', () => {
295296 } ) ;
296297 beforeEach ( ( ) => IntlStore . load ( CONST . LOCALES . DEFAULT ) . then ( waitForBatchedUpdates ) ) ;
297298
299+ describe ( 'canEditFieldOfMoneyRequest' , ( ) => {
300+ const reportActionID = 2 ;
301+ const IOUReportID = '1234' ;
302+ const IOUTransactionID = '123' ;
303+ const randomReportAction = createRandomReportAction ( reportActionID ) ;
304+ const policyID = '2424' ;
305+ const reportAction = {
306+ ...randomReportAction ,
307+ actionName : CONST . REPORT . ACTIONS . TYPE . IOU ,
308+ actorAccountID : currentUserAccountID ,
309+ childStateNum : 0 ,
310+ childStatusNum : 0 ,
311+ originalMessage : {
312+ ...randomReportAction . originalMessage ,
313+ IOUReportID,
314+ IOUTransactionID,
315+ type : 'create' ,
316+ } ,
317+ } ;
318+
319+ /* CREATE money request transaction
320+ transaction = allTransaction[reportAction.originalMessage.IOUTransactionID]
321+ moneyRequestReport.reportID = moneyRequestReport.reportID = originalMessage.IOUReportID
322+ moneyRequestTransaction.transactionID = originalMessage.IOUTransactionID
323+
324+ */
325+
326+ const moneyRequestTransaction = { ...createRandomTransaction ( Number ( IOUTransactionID ) ) , reportID : IOUReportID , transactionID : IOUTransactionID } ;
327+
328+ /* CREATE money request report (invoice report)
329+ invoiceReport = allReports[reportAction.originalMessage.IOUReportID]
330+ invoiceReport.reportID = originalMessage.IOUReportID
331+ invoiceReport.ownerAccountID = currentUserAccountID
332+ invoioiceReport.policyID = policy.id
333+ */
334+
335+ const invoiceReport = {
336+ ...createInvoiceReport ( Number ( IOUReportID ) ) ,
337+ policyID,
338+ ownerAccountID : currentUserAccountID ,
339+ state : CONST . REPORT . ACTIONS . TYPE . SUBMITTED ,
340+ stateNum : 1 ,
341+ statusNum : 1 ,
342+ managerID : 8723 ,
343+ } ;
344+
345+ /* CREATE policy
346+ moneyRequestReport?.policyID = policy.id
347+ */
348+ const policyC = { ...createRandomPolicy ( Number ( policyID ) , CONST . POLICY . TYPE . TEAM ) , areInvoicesEnabled : true , role : 'admin' } ;
349+
350+ /* CREATE an outstanding EXPENSE REPORT
351+ type = expense
352+ TODO: stateNum and statusNum can be less than or equal to CONST.REPORT.STATE_NUM.SUBMITTED
353+
354+ */
355+
356+ const outstandingExpenseReport = { ...createExpenseReport ( 483 ) , policyID, stateNum : 0 , statusNum : 0 , ownerAccountID : currentUserAccountID } ;
357+
358+ /* might not need to add this
359+ add the report action with
360+ hasForwardedAction
361+ */
362+
363+ /* no need for this
364+ Add reportNameValuePairs in onyx for the oustandingExpenseReport
365+ */
366+
367+ beforeAll ( ( ) => {
368+ Onyx . merge ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ IOUTransactionID } ` , moneyRequestTransaction ) ;
369+ Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ IOUReportID } ` , invoiceReport ) ;
370+ Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ 483 } ` , outstandingExpenseReport ) ;
371+ Onyx . merge ( `${ ONYXKEYS . COLLECTION . POLICY } ${ policyID } ` , policyC ) ;
372+ return waitForBatchedUpdates ( ) ;
373+ } ) ;
374+
375+ it ( 'test' , ( ) => {
376+ const canEditReportField = canEditFieldOfMoneyRequest ( reportAction , CONST . EDIT_REQUEST_FIELD . REPORT ) ;
377+ expect ( canEditReportField ) . toBe ( true ) ;
378+ } ) ;
379+ } ) ;
380+
298381 describe ( 'prepareOnboardingOnyxData' , ( ) => {
299382 it ( 'provides test drive url to task title' , ( ) => {
300383 const title = jest . fn ( ) ;
0 commit comments