@@ -95,30 +95,60 @@ describe('getReportPreviewAction', () => {
9595 expect ( getReportPreviewAction ( VIOLATIONS , report , policy , [ transaction ] , isReportArchived . current ) ) . toBe ( CONST . REPORT . REPORT_PREVIEW_ACTIONS . SUBMIT ) ;
9696 } ) ;
9797
98- it ( 'canApprove should return true for report being processed' , async ( ) => {
99- const report = {
100- ...createRandomReport ( REPORT_ID ) ,
101- type : CONST . REPORT . TYPE . EXPENSE ,
102- ownerAccountID : CURRENT_USER_ACCOUNT_ID ,
103- stateNum : CONST . REPORT . STATE_NUM . SUBMITTED ,
104- statusNum : CONST . REPORT . STATUS_NUM . SUBMITTED ,
105- managerID : CURRENT_USER_ACCOUNT_ID ,
106- isWaitingOnBankAccount : false ,
107- } ;
108-
109- const policy = createRandomPolicy ( 0 ) ;
110- policy . type = CONST . POLICY . TYPE . CORPORATE ;
111- policy . approver = CURRENT_USER_EMAIL ;
112- policy . approvalMode = CONST . POLICY . APPROVAL_MODE . BASIC ;
113- policy . preventSelfApproval = false ;
98+ describe ( 'canApprove' , ( ) => {
99+ it ( 'should return true for report being processed' , async ( ) => {
100+ const report = {
101+ ...createRandomReport ( REPORT_ID ) ,
102+ type : CONST . REPORT . TYPE . EXPENSE ,
103+ ownerAccountID : CURRENT_USER_ACCOUNT_ID ,
104+ stateNum : CONST . REPORT . STATE_NUM . SUBMITTED ,
105+ statusNum : CONST . REPORT . STATUS_NUM . SUBMITTED ,
106+ managerID : CURRENT_USER_ACCOUNT_ID ,
107+ isWaitingOnBankAccount : false ,
108+ } ;
109+
110+ const policy = createRandomPolicy ( 0 ) ;
111+ policy . type = CONST . POLICY . TYPE . CORPORATE ;
112+ policy . approver = CURRENT_USER_EMAIL ;
113+ policy . approvalMode = CONST . POLICY . APPROVAL_MODE . BASIC ;
114+ policy . preventSelfApproval = false ;
115+
116+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ REPORT_ID } ` , report ) ;
117+ const transaction = {
118+ reportID : `${ REPORT_ID } ` ,
119+ } as unknown as Transaction ;
120+
121+ const { result : isReportArchived } = renderHook ( ( ) => useReportIsArchived ( report ?. parentReportID ) ) ;
122+ expect ( getReportPreviewAction ( VIOLATIONS , report , policy , [ transaction ] , isReportArchived . current ) ) . toBe ( CONST . REPORT . REPORT_PREVIEW_ACTIONS . APPROVE ) ;
123+ } ) ;
114124
115- await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ REPORT_ID } ` , report ) ;
116- const transaction = {
117- reportID : `${ REPORT_ID } ` ,
118- } as unknown as Transaction ;
125+ it ( 'should return false for report with scanning expenses' , async ( ) => {
126+ const report = {
127+ ...createRandomReport ( REPORT_ID ) ,
128+ type : CONST . REPORT . TYPE . EXPENSE ,
129+ ownerAccountID : CURRENT_USER_ACCOUNT_ID ,
130+ stateNum : CONST . REPORT . STATE_NUM . SUBMITTED ,
131+ statusNum : CONST . REPORT . STATUS_NUM . SUBMITTED ,
132+ managerID : CURRENT_USER_ACCOUNT_ID ,
133+ isWaitingOnBankAccount : false ,
134+ } ;
135+
136+ const policy = createRandomPolicy ( 0 ) ;
137+ policy . type = CONST . POLICY . TYPE . CORPORATE ;
138+ policy . approver = CURRENT_USER_EMAIL ;
139+ policy . approvalMode = CONST . POLICY . APPROVAL_MODE . BASIC ;
140+ policy . preventSelfApproval = false ;
141+
142+ await Onyx . merge ( `${ ONYXKEYS . COLLECTION . REPORT } ${ REPORT_ID } ` , report ) ;
143+ const transaction = {
144+ reportID : `${ REPORT_ID } ` ,
145+ receipt : {
146+ state : CONST . IOU . RECEIPT_STATE . SCANNING ,
147+ } ,
148+ } as unknown as Transaction ;
119149
120- const { result : isReportArchived } = renderHook ( ( ) => useReportIsArchived ( report ?. parentReportID ) ) ;
121- expect ( getReportPreviewAction ( VIOLATIONS , report , policy , [ transaction ] , isReportArchived . current ) ) . toBe ( CONST . REPORT . REPORT_PREVIEW_ACTIONS . APPROVE ) ;
150+ expect ( getReportPreviewAction ( VIOLATIONS , report , policy , [ transaction ] , false ) ) . toBe ( CONST . REPORT . REPORT_PREVIEW_ACTIONS . VIEW ) ;
151+ } ) ;
122152 } ) ;
123153
124154 it ( 'canPay should return true for expense report with payments enabled' , async ( ) => {
0 commit comments