-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3917b7
commit 9e1dcb3
Showing
2 changed files
with
30 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -665,7 +665,7 @@ describe('actions/IOU', () => { | |
let iouReportID: string | undefined; | ||
let createdAction: OnyxEntry<OnyxTypes.ReportAction>; | ||
let iouAction: OnyxEntry<OnyxTypes.ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.IOU>>; | ||
let transactionID: string; | ||
let transactionID: string | undefined; | ||
let transactionThreadReport: OnyxEntry<OnyxTypes.Report>; | ||
let transactionThreadAction: OnyxEntry<OnyxTypes.ReportAction>; | ||
mockFetch?.pause?.(); | ||
|
@@ -779,7 +779,7 @@ describe('actions/IOU', () => { | |
// There should be one transaction | ||
expect(Object.values(allTransactions ?? {}).length).toBe(1); | ||
const transaction = Object.values(allTransactions ?? {}).find((t) => !isEmptyObject(t)); | ||
transactionID = transaction?.transactionID ?? '-1'; | ||
transactionID = transaction?.transactionID; | ||
|
||
expect(transaction?.reportID).toBe(iouReportID); | ||
expect(transaction?.amount).toBe(amount); | ||
|
@@ -857,7 +857,9 @@ describe('actions/IOU', () => { | |
.then( | ||
() => | ||
new Promise<void>((resolve) => { | ||
ReportActions.clearAllRelatedReportActionErrors(iouReportID ?? '-1', iouAction ?? null); | ||
if (iouReportID) { | ||
ReportActions.clearAllRelatedReportActionErrors(iouReportID, iouAction ?? null); | ||
} | ||
resolve(); | ||
}), | ||
) | ||
|
@@ -938,8 +940,12 @@ describe('actions/IOU', () => { | |
.then( | ||
() => | ||
new Promise<void>((resolve) => { | ||
Report.deleteReport(chatReportID ?? '-1'); | ||
Report.deleteReport(transactionThreadReport?.reportID ?? '-1'); | ||
if (chatReportID) { | ||
Report.deleteReport(chatReportID); | ||
} | ||
if (transactionThreadReport?.reportID) { | ||
Report.deleteReport(transactionThreadReport?.reportID); | ||
} | ||
resolve(); | ||
}), | ||
) | ||
|
@@ -1108,7 +1114,7 @@ describe('actions/IOU', () => { | |
[carlosCreatedAction.reportActionID]: carlosCreatedAction, | ||
}, | ||
], | ||
(item) => item[carlosCreatedAction.reportActionID].reportID ?? '-1', | ||
(item) => item[carlosCreatedAction.reportActionID].reportID, | ||
); | ||
|
||
const julesActionsCollectionDataSet = toCollectionDataSet( | ||
|
@@ -1119,7 +1125,7 @@ describe('actions/IOU', () => { | |
[julesExistingIOUAction.reportActionID]: julesExistingIOUAction, | ||
}, | ||
], | ||
(item) => item[julesCreatedAction.reportActionID].reportID ?? '-1', | ||
(item) => item[julesCreatedAction.reportActionID].reportID, | ||
); | ||
|
||
const julesCreatedActionsCollectionDataSet = toCollectionDataSet( | ||
|
@@ -1129,7 +1135,7 @@ describe('actions/IOU', () => { | |
[julesChatCreatedAction.reportActionID]: julesChatCreatedAction, | ||
}, | ||
], | ||
(item) => item[julesChatCreatedAction.reportActionID].reportID ?? '-1', | ||
(item) => item[julesChatCreatedAction.reportActionID].reportID, | ||
); | ||
|
||
return Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, { | ||
|
@@ -2008,7 +2014,7 @@ describe('actions/IOU', () => { | |
let thread: OptimisticChatReport; | ||
const TEST_USER_ACCOUNT_ID = 1; | ||
const TEST_USER_LOGIN = '[email protected]'; | ||
let IOU_REPORT_ID: string; | ||
let IOU_REPORT_ID: string | undefined; | ||
let reportActionID; | ||
const REPORT_ACTION: OnyxEntry<OnyxTypes.ReportAction> = { | ||
actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT, | ||
|
@@ -2090,7 +2096,7 @@ describe('actions/IOU', () => { | |
expect(iouReport?.chatReportID).toBe(chatReport?.reportID); | ||
|
||
// Storing IOU Report ID for further reference | ||
IOU_REPORT_ID = chatReport?.iouReportID ?? '-1'; | ||
IOU_REPORT_ID = chatReport?.iouReportID; | ||
|
||
await waitForBatchedUpdates(); | ||
|
||
|
@@ -2270,7 +2276,9 @@ describe('actions/IOU', () => { | |
jest.advanceTimersByTime(10); | ||
|
||
// When a comment is added to the IOU report | ||
Report.addComment(IOU_REPORT_ID, 'Testing a comment'); | ||
if (IOU_REPORT_ID) { | ||
Report.addComment(IOU_REPORT_ID, 'Testing a comment'); | ||
} | ||
await waitForBatchedUpdates(); | ||
|
||
// Then verify that the comment is correctly added | ||
|
@@ -2710,7 +2718,9 @@ describe('actions/IOU', () => { | |
|
||
jest.advanceTimersByTime(10); | ||
|
||
Report.addComment(IOU_REPORT_ID, 'Testing a comment'); | ||
if (IOU_REPORT_ID) { | ||
Report.addComment(IOU_REPORT_ID, 'Testing a comment'); | ||
} | ||
await waitForBatchedUpdates(); | ||
|
||
resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT); | ||
|
@@ -2858,7 +2868,9 @@ describe('actions/IOU', () => { | |
|
||
jest.advanceTimersByTime(10); | ||
|
||
Report.addComment(IOU_REPORT_ID, 'Testing a comment'); | ||
if (IOU_REPORT_ID) { | ||
Report.addComment(IOU_REPORT_ID, 'Testing a comment'); | ||
} | ||
await waitForBatchedUpdates(); | ||
|
||
const resultAction = Object.values(reportActions ?? {}).find((reportAction) => reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT); | ||
|
@@ -2959,8 +2971,10 @@ describe('actions/IOU', () => { | |
expect(iouReport).toHaveProperty('chatReportID'); | ||
|
||
// Then we expect to navigate to the iou report | ||
|
||
expect(navigateToAfterDelete).toEqual(ROUTES.REPORT_WITH_ID.getRoute(IOU_REPORT_ID)); | ||
expect(IOU_REPORT_ID).not.toBeUndefined(); | ||
if (IOU_REPORT_ID) { | ||
expect(navigateToAfterDelete).toEqual(ROUTES.REPORT_WITH_ID.getRoute(IOU_REPORT_ID)); | ||
} | ||
}); | ||
|
||
it('navigate the user correctly to the chat Report when appropriate', () => { | ||
|