From d81d071bc598d530768170088acb2cf93b5002d4 Mon Sep 17 00:00:00 2001 From: Linh Vo Date: Fri, 7 Feb 2025 07:13:16 +0700 Subject: [PATCH] fix: update system message when move expense --- src/languages/en.ts | 6 +++--- src/languages/es.ts | 6 +++--- src/languages/params.ts | 4 ++-- src/libs/ModifiedExpenseMessage.ts | 4 ++-- tests/unit/ModifiedExpenseMessageTest.ts | 15 +++++++++------ 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index c56c191196be..8f3ffc57f6ef 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -103,7 +103,7 @@ import type { MarkedReimbursedParams, MarkReimbursedFromIntegrationParams, MissingPropertyParams, - MovedFromSelfDMParams, + MovedFromPersonalSpaceParams, NoLongerHaveAccessParams, NotAllowedExtensionParams, NotYouParams, @@ -995,8 +995,8 @@ const translations = { threadExpenseReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `${formattedAmount} ${comment ? `for ${comment}` : 'expense'}`, threadTrackReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Tracking ${formattedAmount} ${comment ? `for ${comment}` : ''}`, threadPaySomeoneReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} sent${comment ? ` for ${comment}` : ''}`, - movedFromSelfDM: ({workspaceName, reportName}: MovedFromSelfDMParams) => `moved expense from personal space to ${workspaceName ?? `chat with ${reportName}`}`, - movedToSelfDM: 'moved expense from expense report to your personal space', + movedFromPersonalSpace: ({workspaceName, reportName}: MovedFromPersonalSpaceParams) => `moved expense from personal space to ${workspaceName ?? `chat with ${reportName}`}`, + movedToPersonalSpace: 'moved expense to personal space', tagSelection: 'Select a tag to better organize your spend.', categorySelection: 'Select a category to better organize your spend.', error: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 1d27347864f3..18fe9771b8ae 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -102,7 +102,7 @@ import type { MarkedReimbursedParams, MarkReimbursedFromIntegrationParams, MissingPropertyParams, - MovedFromSelfDMParams, + MovedFromPersonalSpaceParams, NoLongerHaveAccessParams, NotAllowedExtensionParams, NotYouParams, @@ -993,8 +993,8 @@ const translations = { threadExpenseReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `${comment ? `${formattedAmount} para ${comment}` : `Gasto de ${formattedAmount}`}`, threadTrackReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Seguimiento ${formattedAmount} ${comment ? `para ${comment}` : ''}`, threadPaySomeoneReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`, - movedFromSelfDM: ({workspaceName, reportName}: MovedFromSelfDMParams) => `movió el gasto desde el espacio personal a ${workspaceName ?? `un chat con ${reportName}`}`, - movedToSelfDM: 'movió el gasto del informe de gastos a tu espacio personal', + movedFromPersonalSpace: ({workspaceName, reportName}: MovedFromPersonalSpaceParams) => `movió el gasto desde su espacio personal a ${workspaceName ?? `un chat con ${reportName}`}`, + movedToPersonalSpace: 'movió el gasto a su espacio personal', tagSelection: 'Selecciona una etiqueta para organizar mejor tus gastos.', categorySelection: 'Selecciona una categoría para organizar mejor tus gastos.', error: { diff --git a/src/languages/params.ts b/src/languages/params.ts index f3d48acc63b1..76675749416f 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -170,7 +170,7 @@ type ThreadRequestReportNameParams = {formattedAmount: string; comment: string}; type ThreadSentMoneyReportNameParams = {formattedAmount: string; comment: string}; -type MovedFromSelfDMParams = {workspaceName?: string; reportName?: string}; +type MovedFromPersonalSpaceParams = {workspaceName?: string; reportName?: string}; type SizeExceededParams = {maxUploadSizeInMB: number}; @@ -705,7 +705,7 @@ export type { LoggedInAsParams, ManagerApprovedAmountParams, ManagerApprovedParams, - MovedFromSelfDMParams, + MovedFromPersonalSpaceParams, SignUpNewFaceCodeParams, NoLongerHaveAccessParams, NotAllowedExtensionParams, diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 66fa0168ca4b..465067a045c4 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -141,7 +141,7 @@ function getForExpenseMovedFromSelfDM(destinationReportID: string) { const rootParentReport = getRootParentReport({report: destinationReport}); // In OldDot, expenses could be moved to a self-DM. Return the corresponding message for this case. if (isSelfDM(rootParentReport)) { - return translateLocal('iou.movedToSelfDM'); + return translateLocal('iou.movedToPersonalSpace'); } // In NewDot, the "Move report" flow only supports moving expenses from self-DM to: // - A policy expense chat @@ -152,7 +152,7 @@ function getForExpenseMovedFromSelfDM(destinationReportID: string) { if (isEmpty(policyName) && !reportName) { return translateLocal('iou.changedTheExpense'); } - return translateLocal('iou.movedFromSelfDM', { + return translateLocal('iou.movedFromPersonalSpace', { reportName, workspaceName: !isEmpty(policyName) ? policyName : undefined, }); diff --git a/tests/unit/ModifiedExpenseMessageTest.ts b/tests/unit/ModifiedExpenseMessageTest.ts index 12e2462b3738..b545e92280a5 100644 --- a/tests/unit/ModifiedExpenseMessageTest.ts +++ b/tests/unit/ModifiedExpenseMessageTest.ts @@ -403,7 +403,7 @@ describe('ModifiedExpenseMessage', () => { describe('when moving an expense', () => { beforeEach(() => Onyx.clear()); - it('return the message "moved expense from expense report to your personal space" when moving an expense from an expense chat or 1:1 DM to selfDM', async () => { + it('return the message "moved expense to personal space" when moving an expense from an expense chat or 1:1 DM to selfDM', async () => { // Given the selfDM report and report action const selfDMReport = { ...report, @@ -419,11 +419,11 @@ describe('ModifiedExpenseMessage', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReport.reportID}`]: selfDMReport}); await waitForBatchedUpdates(); - const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedToSelfDM'); + const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedToPersonalSpace'); // When the expense is moved from an expense chat or 1:1 DM to selfDM const result = ModifiedExpenseMessage.getForReportAction({reportOrID: selfDMReport.reportID, reportAction}); - // Then it should return the 'moved expense to self DM' message + // Then it should return the correct text message expect(result).toEqual(expectedResult); }); @@ -449,7 +449,7 @@ describe('ModifiedExpenseMessage', () => { // When the expense is moved to an expense chat with reportName empty const result = ModifiedExpenseMessage.getForReportAction({reportOrID: policyExpenseChat.reportID, reportAction}); - // Then it should return the 'changed the expense' message + // Then it should return the correct text message expect(result).toEqual(expectedResult); }); @@ -471,7 +471,10 @@ describe('ModifiedExpenseMessage', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`]: policyExpenseChat}); await waitForBatchedUpdates(); - const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromSelfDM', {reportName: policyExpenseChat.reportName, workspaceName: policyExpenseChat.policyName}); + const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromPersonalSpace', { + reportName: policyExpenseChat.reportName, + workspaceName: policyExpenseChat.policyName, + }); // When the expense is moved to an expense chat with both reportName and policyName are present const result = ModifiedExpenseMessage.getForReportAction({reportOrID: policyExpenseChat.reportID, reportAction}); @@ -496,7 +499,7 @@ describe('ModifiedExpenseMessage', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}`, {[`${ONYXKEYS.COLLECTION.REPORT}${policyExpenseChat.reportID}`]: policyExpenseChat}); await waitForBatchedUpdates(); - const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromSelfDM', {reportName: policyExpenseChat.reportName}); + const expectedResult = translate(CONST.LOCALES.EN as 'en', 'iou.movedFromPersonalSpace', {reportName: policyExpenseChat.reportName}); // When the expense is moved to an expense chat with only reportName is present const result = ModifiedExpenseMessage.getForReportAction({reportOrID: policyExpenseChat.reportID, reportAction});