Skip to content

Commit 9f29e75

Browse files
author
nabi-ebrahimi
committed
test: align received payment visibility tests with latest behavior
1 parent 3287f30 commit 9f29e75

3 files changed

Lines changed: 22 additions & 34 deletions

File tree

src/components/MoneyReportHeaderActions/MoneyReportHeaderSelectionDropdown.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,17 @@ function MoneyReportHeaderSelectionDropdown({reportID, primaryAction, isReportIn
157157
const {confirmApproval, handleSubmitReport, shouldBlockSubmit, isBlockSubmitDueToPreventSelfApproval} = useLifecycleActions({
158158
reportID,
159159
startApprovedAnimation,
160+
startAnimation,
160161
startSubmittingAnimation,
161-
onHoldMenuOpen: (requestType) => openHoldMenu({requestType, onConfirm: () => clearSelectedTransactions(true)}),
162+
onHoldMenuOpen: (requestType, onConfirm, paymentType) =>
163+
openHoldMenu({
164+
requestType,
165+
onConfirm: () => {
166+
onConfirm?.();
167+
clearSelectedTransactions(true);
168+
},
169+
paymentType,
170+
}),
162171
});
163172

164173
const {

src/libs/ReportSecondaryActionUtils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import {
5252
canRejectReportAction,
5353
canUserPerformWriteAction as canUserPerformWriteActionReportUtils,
5454
doesReportContainRequestsFromMultipleUsers,
55-
getMoneyRequestSpendBreakdown,
5655
getTransactionDetails,
5756
hasExportError as hasExportErrorUtils,
5857
hasOnlyHeldExpenses,

tests/unit/ReportSecondaryActionUtilsTest.ts

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,17 +1363,13 @@ describe('getSecondaryAction', () => {
13631363
ownerAccountID: EMPLOYEE_ACCOUNT_ID,
13641364
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
13651365
statusNum: CONST.REPORT.STATUS_NUM.APPROVED,
1366+
total: -100,
1367+
nonReimbursableTotal: 0,
13661368
} as unknown as Report;
13671369
const policy = {
13681370
role: CONST.POLICY.ROLE.USER,
13691371
} as unknown as Policy;
13701372

1371-
jest.spyOn(ReportUtils, 'getMoneyRequestSpendBreakdown').mockReturnValue({
1372-
totalDisplaySpend: 100,
1373-
reimbursableSpend: 100,
1374-
nonReimbursableSpend: 0,
1375-
});
1376-
13771373
const result = getSecondaryReportActions({
13781374
currentUserLogin: EMPLOYEE_EMAIL,
13791375
currentUserAccountID: EMPLOYEE_ACCOUNT_ID,
@@ -1389,24 +1385,20 @@ describe('getSecondaryAction', () => {
13891385
expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.RECEIVED_PAYMENT)).toBe(true);
13901386
});
13911387

1392-
it('does not include RECEIVED_PAYMENT option for fully non-reimbursable expense report', () => {
1388+
it('includes RECEIVED_PAYMENT option for negative expense report even when non-reimbursable total matches total', () => {
13931389
const report = {
13941390
reportID: REPORT_ID,
13951391
type: CONST.REPORT.TYPE.EXPENSE,
13961392
ownerAccountID: EMPLOYEE_ACCOUNT_ID,
13971393
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
13981394
statusNum: CONST.REPORT.STATUS_NUM.APPROVED,
1395+
total: -100,
1396+
nonReimbursableTotal: -100,
13991397
} as unknown as Report;
14001398
const policy = {
14011399
role: CONST.POLICY.ROLE.USER,
14021400
} as unknown as Policy;
14031401

1404-
jest.spyOn(ReportUtils, 'getMoneyRequestSpendBreakdown').mockReturnValue({
1405-
totalDisplaySpend: 100,
1406-
reimbursableSpend: 0,
1407-
nonReimbursableSpend: 100,
1408-
});
1409-
14101402
const result = getSecondaryReportActions({
14111403
currentUserLogin: EMPLOYEE_EMAIL,
14121404
currentUserAccountID: EMPLOYEE_ACCOUNT_ID,
@@ -1419,7 +1411,7 @@ describe('getSecondaryAction', () => {
14191411
policy,
14201412
reportActions: [],
14211413
});
1422-
expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.RECEIVED_PAYMENT)).toBe(false);
1414+
expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.RECEIVED_PAYMENT)).toBe(true);
14231415
});
14241416

14251417
it('does not include RECEIVED_PAYMENT option for admin', () => {
@@ -1429,17 +1421,13 @@ describe('getSecondaryAction', () => {
14291421
ownerAccountID: EMPLOYEE_ACCOUNT_ID,
14301422
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
14311423
statusNum: CONST.REPORT.STATUS_NUM.APPROVED,
1424+
total: -100,
1425+
nonReimbursableTotal: 0,
14321426
} as unknown as Report;
14331427
const policy = {
14341428
role: CONST.POLICY.ROLE.ADMIN,
14351429
} as unknown as Policy;
14361430

1437-
jest.spyOn(ReportUtils, 'getMoneyRequestSpendBreakdown').mockReturnValue({
1438-
totalDisplaySpend: 100,
1439-
reimbursableSpend: 100,
1440-
nonReimbursableSpend: 0,
1441-
});
1442-
14431431
const result = getSecondaryReportActions({
14441432
currentUserLogin: EMPLOYEE_EMAIL,
14451433
currentUserAccountID: EMPLOYEE_ACCOUNT_ID,
@@ -1462,6 +1450,8 @@ describe('getSecondaryAction', () => {
14621450
ownerAccountID: EMPLOYEE_ACCOUNT_ID,
14631451
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
14641452
statusNum: CONST.REPORT.STATUS_NUM.APPROVED,
1453+
total: -100,
1454+
nonReimbursableTotal: 0,
14651455
} as unknown as Report;
14661456
const policy = {
14671457
role: CONST.POLICY.ROLE.USER,
@@ -1474,12 +1464,6 @@ describe('getSecondaryAction', () => {
14741464
},
14751465
} as unknown as ReportAction;
14761466

1477-
jest.spyOn(ReportUtils, 'getMoneyRequestSpendBreakdown').mockReturnValue({
1478-
totalDisplaySpend: 100,
1479-
reimbursableSpend: 100,
1480-
nonReimbursableSpend: 0,
1481-
});
1482-
14831467
const result = getSecondaryReportActions({
14841468
currentUserLogin: EMPLOYEE_EMAIL,
14851469
currentUserAccountID: EMPLOYEE_ACCOUNT_ID,
@@ -1502,6 +1486,8 @@ describe('getSecondaryAction', () => {
15021486
ownerAccountID: EMPLOYEE_ACCOUNT_ID,
15031487
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
15041488
statusNum: CONST.REPORT.STATUS_NUM.REIMBURSED,
1489+
total: -100,
1490+
nonReimbursableTotal: 0,
15051491
} as unknown as Report;
15061492
const policy = {
15071493
role: CONST.POLICY.ROLE.USER,
@@ -1514,12 +1500,6 @@ describe('getSecondaryAction', () => {
15141500
},
15151501
} as unknown as ReportAction;
15161502

1517-
jest.spyOn(ReportUtils, 'getMoneyRequestSpendBreakdown').mockReturnValue({
1518-
totalDisplaySpend: 100,
1519-
reimbursableSpend: 100,
1520-
nonReimbursableSpend: 0,
1521-
});
1522-
15231503
const result = getSecondaryReportActions({
15241504
currentUserLogin: EMPLOYEE_EMAIL,
15251505
currentUserAccountID: EMPLOYEE_ACCOUNT_ID,

0 commit comments

Comments
 (0)