From 19f41807068c8efbd7908fa66da29cdf859333e8 Mon Sep 17 00:00:00 2001 From: thelullabyy Date: Thu, 19 Jun 2025 11:01:54 +0700 Subject: [PATCH 1/3] fix: markdown is rendered as html --- src/libs/actions/IOU.ts | 2 +- tests/actions/IOUTest.ts | 96 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 3fab5d90a5e3..82e9a9d71db0 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -11630,7 +11630,7 @@ function saveSplitTransactions(draftTransaction: OnyxEntry { expect(isMoneyRequestAction(updatedIOUReportActionOnSelfDMReport) ? getOriginalMessage(updatedIOUReportActionOnSelfDMReport)?.IOUTransactionID : undefined).toBe(undefined); expect(updatedTrackExpenseActionableWhisper).toBe(undefined); }); + + describe('saveSplitTransactions', () => { + it('should update split transaction\'s description correctly ', async () => { + const amount = 10000; + let expenseReport: OnyxEntry; + let chatReport: OnyxEntry; + let originalTransactionID; + + const policyID = generatePolicyID(); + createWorkspace(CARLOS_EMAIL, true, "Carlos's Workspace", policyID); + + // Change the approval mode for the policy since default is Submit and Close + setWorkspaceApprovalMode(policyID, CARLOS_EMAIL, CONST.POLICY.APPROVAL_MODE.BASIC); + await waitForBatchedUpdates(); + await getOnyxData({ + key: ONYXKEYS.COLLECTION.REPORT, + waitForCollectionCallback: true, + callback: (allReports) => { + chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); + }, + }), + requestMoney({ + report: chatReport, + participantParams: { + payeeEmail: RORY_EMAIL, + payeeAccountID: RORY_ACCOUNT_ID, + participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID, isPolicyExpenseChat: true, reportID: chatReport?.reportID}, + }, + transactionParams: { + amount, + attendees: [], + currency: CONST.CURRENCY.USD, + created: '', + merchant: 'NASDAQ', + comment: '*hey* `hey`', + }, + }); + await waitForBatchedUpdates(); + await getOnyxData({ + key: ONYXKEYS.COLLECTION.REPORT, + waitForCollectionCallback: true, + callback: (allReports) => { + expenseReport = Object.values(allReports ?? {}).find((report) => report?.type === CONST.REPORT.TYPE.EXPENSE); + }, + }); + await getOnyxData({ + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${expenseReport?.reportID}`, + waitForCollectionCallback: false, + callback: (allReportsAction) => { + const iouActions = Object.values(allReportsAction ?? {}).filter((reportAction): reportAction is ReportAction => + isMoneyRequestAction(reportAction), + ); + originalTransactionID = iouActions.at(0)?.originalMessage?.IOUTransactionID; + }, + }); + + const originalTransaction = await getOnyxValue(`${ONYXKEYS.COLLECTION.TRANSACTION}${originalTransactionID}`); + const draftTransaction: Transaction = { + reportID: originalTransaction?.reportID ?? '456', + transactionID: originalTransaction?.transactionID ?? '234', + amount, + created: originalTransaction?.created ?? DateUtils.getDBTime(), + currency: CONST.CURRENCY.USD, + merchant: originalTransaction?.merchant ?? '', + comment: { + originalTransactionID, + comment: originalTransaction?.comment?.comment ?? '', + splitExpenses: [ + { + transactionID: '235', + amount: amount / 2, + description: 'hey
hey', + created: DateUtils.getDBTime(), + }, + { + transactionID: '234', + amount: amount / 2, + description: '*hey1* `hey`', + created: DateUtils.getDBTime(), + }, + ], + attendees: [], + type: CONST.TRANSACTION.TYPE.CUSTOM_UNIT, + }, + }; + + saveSplitTransactions(draftTransaction, -2); + await waitForBatchedUpdates(); + + const split1 = await getOnyxValue(`${ONYXKEYS.COLLECTION.TRANSACTION}235`); + expect(split1?.comment?.comment).toBe('hey
hey'); + const split2 = await getOnyxValue(`${ONYXKEYS.COLLECTION.TRANSACTION}234`); + expect(split2?.comment?.comment).toBe('hey1 hey'); + }); + }); }); }); From 99e37a9728fca8561fcab2bab28dbbfe4e47fb31 Mon Sep 17 00:00:00 2001 From: thelullabyy Date: Thu, 19 Jun 2025 11:24:29 +0700 Subject: [PATCH 2/3] fix ESlint --- tests/actions/IOUTest.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index 40769b6c7253..17b858ae5357 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -6248,7 +6248,7 @@ describe('actions/IOU', () => { }); describe('saveSplitTransactions', () => { - it('should update split transaction\'s description correctly ', async () => { + it("should update split transaction's description correctly ", async () => { const amount = 10000; let expenseReport: OnyxEntry; let chatReport: OnyxEntry; @@ -6266,8 +6266,8 @@ describe('actions/IOU', () => { callback: (allReports) => { chatReport = Object.values(allReports ?? {}).find((report) => report?.chatType === CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); }, - }), - requestMoney({ + }); + requestMoney({ report: chatReport, participantParams: { payeeEmail: RORY_EMAIL, @@ -6298,7 +6298,8 @@ describe('actions/IOU', () => { const iouActions = Object.values(allReportsAction ?? {}).filter((reportAction): reportAction is ReportAction => isMoneyRequestAction(reportAction), ); - originalTransactionID = iouActions.at(0)?.originalMessage?.IOUTransactionID; + const originalMessage = isMoneyRequestAction(iouActions?.at(0)) ? getOriginalMessage(iouActions?.at(0)) : undefined; + originalTransactionID = originalMessage?.IOUTransactionID; }, }); From 627a41f4c2a0dda968e96f652b4ba9d6791fe6d9 Mon Sep 17 00:00:00 2001 From: thelullabyy Date: Thu, 19 Jun 2025 11:29:25 +0700 Subject: [PATCH 3/3] update test --- tests/actions/IOUTest.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index 17b858ae5357..a6258b8ae27d 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -6268,21 +6268,21 @@ describe('actions/IOU', () => { }, }); requestMoney({ - report: chatReport, - participantParams: { - payeeEmail: RORY_EMAIL, - payeeAccountID: RORY_ACCOUNT_ID, - participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID, isPolicyExpenseChat: true, reportID: chatReport?.reportID}, - }, - transactionParams: { - amount, - attendees: [], - currency: CONST.CURRENCY.USD, - created: '', - merchant: 'NASDAQ', - comment: '*hey* `hey`', - }, - }); + report: chatReport, + participantParams: { + payeeEmail: RORY_EMAIL, + payeeAccountID: RORY_ACCOUNT_ID, + participant: {login: CARLOS_EMAIL, accountID: CARLOS_ACCOUNT_ID, isPolicyExpenseChat: true, reportID: chatReport?.reportID}, + }, + transactionParams: { + amount, + attendees: [], + currency: CONST.CURRENCY.USD, + created: '', + merchant: 'NASDAQ', + comment: '*hey* `hey`', + }, + }); await waitForBatchedUpdates(); await getOnyxData({ key: ONYXKEYS.COLLECTION.REPORT,