From 87f6644cb83af0dbe23851d7b3aaa9c053fdca72 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 29 Oct 2024 17:46:03 +0700 Subject: [PATCH 01/16] =?UTF-8?q?fix:=20Inbox=20showing=20GBR=20when=20the?= =?UTF-8?q?re=E2=80=99s=20a=20report=20with=20RBR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/WorkspacesSettingsUtils.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/WorkspacesSettingsUtils.ts b/src/libs/WorkspacesSettingsUtils.ts index a27d518fe727..b16d0e2b17c8 100644 --- a/src/libs/WorkspacesSettingsUtils.ts +++ b/src/libs/WorkspacesSettingsUtils.ts @@ -62,6 +62,14 @@ const getBrickRoadForPolicy = (report: Report, altReportActions?: OnyxCollection const reportErrors = ReportUtils.getAllReportErrors(report, reportActions); const oneTransactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, reportActions); let doesReportContainErrors = Object.keys(reportErrors ?? {}).length !== 0 ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined; + const parentReportActions = (altReportActions ?? allReportActions)?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`]; + const parentReportAction = parentReportActions?.[report?.parentReportActionID ?? '-1']; + const shouldDisplayViolations = ReportUtils.shouldDisplayTransactionThreadViolations(report, allTransactionViolations, parentReportAction); + const shouldDisplayReportViolations = ReportUtils.isReportOwner(report) && ReportUtils.hasReportViolations(report.reportID); + const hasViolations = shouldDisplayViolations || shouldDisplayReportViolations; + if (hasViolations) { + doesReportContainErrors = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; + } if (oneTransactionThreadReportID) { const oneTransactionThreadReport = ReportUtils.getReport(oneTransactionThreadReportID); From 6d00a658f563dd4e7d8e6774abc7ba064f3184d0 Mon Sep 17 00:00:00 2001 From: truph01 Date: Thu, 31 Oct 2024 09:20:38 +0700 Subject: [PATCH 02/16] fix: optimize code --- src/libs/WorkspacesSettingsUtils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/WorkspacesSettingsUtils.ts b/src/libs/WorkspacesSettingsUtils.ts index b16d0e2b17c8..0b88c80ea9e7 100644 --- a/src/libs/WorkspacesSettingsUtils.ts +++ b/src/libs/WorkspacesSettingsUtils.ts @@ -62,16 +62,17 @@ const getBrickRoadForPolicy = (report: Report, altReportActions?: OnyxCollection const reportErrors = ReportUtils.getAllReportErrors(report, reportActions); const oneTransactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, reportActions); let doesReportContainErrors = Object.keys(reportErrors ?? {}).length !== 0 ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined; + const parentReportActions = (altReportActions ?? allReportActions)?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`]; const parentReportAction = parentReportActions?.[report?.parentReportActionID ?? '-1']; const shouldDisplayViolations = ReportUtils.shouldDisplayTransactionThreadViolations(report, allTransactionViolations, parentReportAction); const shouldDisplayReportViolations = ReportUtils.isReportOwner(report) && ReportUtils.hasReportViolations(report.reportID); const hasViolations = shouldDisplayViolations || shouldDisplayReportViolations; - if (hasViolations) { + if (hasViolations && !doesReportContainErrors) { doesReportContainErrors = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; } - if (oneTransactionThreadReportID) { + if (oneTransactionThreadReportID && !doesReportContainErrors) { const oneTransactionThreadReport = ReportUtils.getReport(oneTransactionThreadReportID); if ( From bbbe5aa1441005bc8b99ee59ce02a359e998dd79 Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 4 Nov 2024 13:44:27 +0700 Subject: [PATCH 03/16] fix: refactor code --- src/libs/WorkspacesSettingsUtils.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libs/WorkspacesSettingsUtils.ts b/src/libs/WorkspacesSettingsUtils.ts index 0b88c80ea9e7..e8b9b363e768 100644 --- a/src/libs/WorkspacesSettingsUtils.ts +++ b/src/libs/WorkspacesSettingsUtils.ts @@ -63,14 +63,15 @@ const getBrickRoadForPolicy = (report: Report, altReportActions?: OnyxCollection const oneTransactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, reportActions); let doesReportContainErrors = Object.keys(reportErrors ?? {}).length !== 0 ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined; - const parentReportActions = (altReportActions ?? allReportActions)?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`]; - const parentReportAction = parentReportActions?.[report?.parentReportActionID ?? '-1']; - const shouldDisplayViolations = ReportUtils.shouldDisplayTransactionThreadViolations(report, allTransactionViolations, parentReportAction); - const shouldDisplayReportViolations = ReportUtils.isReportOwner(report) && ReportUtils.hasReportViolations(report.reportID); - const hasViolations = shouldDisplayViolations || shouldDisplayReportViolations; - if (hasViolations && !doesReportContainErrors) { - doesReportContainErrors = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; - } + if (!doesReportContainErrors) { + const parentReportActions = (altReportActions ?? allReportActions)?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`]; + const parentReportAction = parentReportActions?.[report?.parentReportActionID ?? '-1']; + const shouldDisplayViolations = ReportUtils.shouldDisplayTransactionThreadViolations(report, allTransactionViolations, parentReportAction); + const shouldDisplayReportViolations = ReportUtils.isReportOwner(report) && ReportUtils.hasReportViolations(report.reportID); + const hasViolations = shouldDisplayViolations || shouldDisplayReportViolations; + if (hasViolations) { + doesReportContainErrors = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; + } if (oneTransactionThreadReportID && !doesReportContainErrors) { const oneTransactionThreadReport = ReportUtils.getReport(oneTransactionThreadReportID); From 462c52f852513c8b1a3854f88cb29bc41fb6c1c0 Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 4 Nov 2024 13:47:10 +0700 Subject: [PATCH 04/16] fix: lint --- src/libs/WorkspacesSettingsUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/WorkspacesSettingsUtils.ts b/src/libs/WorkspacesSettingsUtils.ts index e8b9b363e768..46927e430f67 100644 --- a/src/libs/WorkspacesSettingsUtils.ts +++ b/src/libs/WorkspacesSettingsUtils.ts @@ -72,6 +72,7 @@ const getBrickRoadForPolicy = (report: Report, altReportActions?: OnyxCollection if (hasViolations) { doesReportContainErrors = CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; } + } if (oneTransactionThreadReportID && !doesReportContainErrors) { const oneTransactionThreadReport = ReportUtils.getReport(oneTransactionThreadReportID); From f20b84fa0aa022fd85f63c4eb311b702bdf53274 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 5 Nov 2024 18:42:42 +0700 Subject: [PATCH 05/16] fix: add test --- tests/unit/WorkspaceSettingsUtilsTest.ts | 563 +++++++++++++++++++++++ 1 file changed, 563 insertions(+) create mode 100644 tests/unit/WorkspaceSettingsUtilsTest.ts diff --git a/tests/unit/WorkspaceSettingsUtilsTest.ts b/tests/unit/WorkspaceSettingsUtilsTest.ts new file mode 100644 index 000000000000..2c7cf153c68a --- /dev/null +++ b/tests/unit/WorkspaceSettingsUtilsTest.ts @@ -0,0 +1,563 @@ +import {OnyxCollection} from 'react-native-onyx'; +import Onyx from 'react-native-onyx'; +import waitForBatchedUpdates from 'tests/utils/waitForBatchedUpdates'; +import {getBrickRoadForPolicy} from '@libs/WorkspacesSettingsUtils'; +import ONYXKEYS from '@src/ONYXKEYS'; +import {Report, ReportActions} from '@src/types/onyx'; +import * as TestHelper from '../utils/TestHelper'; + +describe('WorkspacesSettingsUtils', () => { + beforeAll(() => { + Onyx.init({ + keys: ONYXKEYS, + }); + }); + + beforeEach(() => { + global.fetch = TestHelper.getGlobalFetchMock(); + return Onyx.clear().then(waitForBatchedUpdates); + }); + describe('getBrickRoadForPolicy', () => { + it('Should return "error"', async () => { + const report: Report = { + isOptimisticReport: false, + type: 'chat', + isOwnPolicyExpenseChat: false, + isPinned: false, + lastActorAccountID: 0, + lastMessageTranslationKey: '', + lastMessageHtml: '', + lastReadTime: '2024-11-05 11:19:18.288', + lastVisibleActionCreated: '2024-11-05 11:19:18.288', + oldPolicyName: '', + ownerAccountID: 0, + parentReportActionID: '8722650843049927838', + parentReportID: '6955627196303088', + participants: { + '18634488': { + notificationPreference: 'hidden', + role: 'admin', + }, + }, + policyID: '57D0F454E0BCE54B', + reportID: '4286515777714555', + reportName: 'Expense', + stateNum: 0, + statusNum: 0, + description: '', + avatarUrl: '', + avatarFileName: '', + }; + + const actions: OnyxCollection = { + reportActions_1699789757771388: { + '4007735288062946397': { + reportActionID: '4007735288062946397', + actionName: 'CREATED', + actorAccountID: 18634488, + message: [ + { + type: 'TEXT', + style: 'strong', + text: 'You', + }, + { + type: 'TEXT', + style: 'normal', + text: ' created this report', + }, + ], + person: [ + { + type: 'TEXT', + style: 'strong', + text: 'adasdasd', + }, + ], + automatic: false, + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', + created: '2024-11-05 11:10:47.852', + shouldShow: true, + reportActionTimestamp: 1730805047852, + sequenceNumber: 0, + lastModified: '2024-11-05 11:10:47.852', + }, + '7978085421707288417': { + reportActionID: '7978085421707288417', + reportID: '1699789757771388', + actionName: 'REPORTPREVIEW', + originalMessage: {}, + message: [ + { + deleted: '', + html: "Adasdasd's Workspace owes β‚«579", + isDeletedParentAction: false, + isEdited: false, + text: "Adasdasd's Workspace owes β‚«579", + type: 'COMMENT', + whisperedTo: [], + }, + ], + created: '2024-11-05 11:19:18.710', + accountID: 18634488, + actorAccountID: 18634488, + childReportID: '6955627196303088', + childMoneyRequestCount: 2, + childLastMoneyRequestComment: '', + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', + childCommenterCount: 0, + childLastActorAccountID: 18634488, + + childLastVisibleActionCreated: '', + childOldestFourAccountIDs: '', + childReportNotificationPreference: 'hidden', + childType: 'expense', + childVisibleActionCount: 0, + lastModified: '2024-11-05 11:19:18.710', + person: [ + { + style: 'strong', + text: 'adasdasd', + type: 'TEXT', + }, + ], + shouldShow: true, + automatic: false, + childManagerAccountID: 18634488, + childOwnerAccountID: 18634488, + childReportName: 'Expense Report #6955627196303088', + childStateNum: 1, + childStatusNum: 1, + + reportActionTimestamp: 1730805558710, + timestamp: 1730805558, + whisperedToAccountIDs: [], + }, + }, + reportActions_4148694821839494: { + '2964625714811661556': { + reportActionID: '2964625714811661556', + actionName: 'CREATED', + actorAccountID: 18634488, + message: [ + { + type: 'TEXT', + style: 'strong', + text: '_FAKE_', + }, + { + type: 'TEXT', + style: 'normal', + text: ' created this report', + }, + ], + person: [ + { + type: 'TEXT', + style: 'strong', + text: 'adasdasd', + }, + ], + automatic: false, + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', + created: '2024-11-05 11:10:47.077', + shouldShow: true, + }, + '5971844472086652538': { + actionName: 'ADDCOMMENT', + actorAccountID: 10288574, + avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/26271df52c9c9db57fa0221feaef04d18a045f2b_128.jpeg', + created: '2024-11-05 11:11:47.410', + lastModified: '2024-11-05 11:11:47.410', + message: [ + { + html: '

Let\'s get you set up on Expensify

Hi there πŸ‘‹ , I\'m your dedicated setup specialist. I look forward to helping you explore and configure Expensify. A few important things to mention:
  • Your workspace has a ton of custom settings, just select your workspace settings to set it up.
  • You\'ve got more functionality to enable, like custom categories, tags, etc. Just ask me how.
Chat with me here in your #admins room or just reply to this message. You can also schedule a call if you have more in-depth questions. Talk soon!

Setup Guide GIF', + text: "Let's get you set up on Expensify\nHi there πŸ‘‹ , I'm your dedicated setup specialist. I look forward to helping you explore and configure Expensify. A few important things to mention: \nYour workspace has a ton of custom settings, just select your workspace settings to set it up.You've got more functionality to enable, like custom categories, tags, etc. Just ask me how. Chat with me here in your #admins room or just reply to this message. You can also schedule a call if you have more in-depth questions. Talk soon!\n\n[Attachment]", + type: 'COMMENT', + whisperedTo: [], + }, + ], + originalMessage: {}, + person: [ + { + style: 'strong', + text: 'Setup Specialist - BreAnna Sumpter Mon-Friday GMT & EST', + type: 'TEXT', + }, + ], + reportActionID: '5971844472086652538', + shouldShow: true, + }, + }, + reportActions_4625283659773773: { + '7132923952865070123': { + actionName: 'ADDCOMMENT', + actorAccountID: 8392101, + avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png', + created: '2024-11-05 11:10:38.956', + lastModified: '2024-11-05 11:10:38.956', + message: [ + { + type: 'COMMENT', + html: "

Welcome to Expensify

πŸ‘‹ Hey there, I'm Concierge! If you have any questions about Expensify, you can always chat with me here 24-7 for fast and reliable support. I'm happy to help!", + text: "Welcome to Expensify\nπŸ‘‹ Hey there, I'm Concierge! If you have any questions about Expensify, you can always chat with me here 24-7 for fast and reliable support. I'm happy to help!", + isEdited: false, + whisperedTo: [], + isDeletedParentAction: false, + deleted: '', + }, + ], + originalMessage: {}, + person: [ + { + type: 'TEXT', + style: 'strong', + text: 'Expensify Concierge', + }, + ], + reportActionID: '7132923952865070123', + shouldShow: true, + timestamp: 1730805038, + reportActionTimestamp: 1730805038956, + automatic: false, + whisperedToAccountIDs: [], + }, + '5686837203726341682': { + reportActionID: '5686837203726341682', + actionName: 'CREATED', + created: '2024-11-05 11:10:38.688', + reportActionTimestamp: 1730805038688, + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', + message: [ + { + type: 'TEXT', + style: 'strong', + text: '__fake__', + }, + { + type: 'TEXT', + style: 'normal', + text: ' created this report', + }, + ], + person: [ + { + type: 'TEXT', + style: 'strong', + text: '__fake__', + }, + ], + automatic: false, + sequenceNumber: 0, + shouldShow: true, + lastModified: '2024-11-05 11:10:38.688', + }, + '536505040772198026': { + reportActionID: '536505040772198026', + actionName: 'ADDCOMMENT', + actorAccountID: 8392101, + person: [ + { + style: 'strong', + text: 'Expensify Concierge', + type: 'TEXT', + }, + ], + automatic: false, + avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png', + created: '2024-11-05 11:10:43.943', + message: [ + { + html: 'Let’s get you set up πŸ”§', + text: 'Let’s get you set up πŸ”§', + type: 'COMMENT', + whisperedTo: [], + }, + ], + originalMessage: {}, + isFirstItem: false, + isAttachmentWithText: false, + shouldShow: true, + isOptimisticAction: true, + lastModified: '2024-11-05 11:10:43.943', + }, + '5286007009323266706': { + reportActionID: '5286007009323266706', + actionName: 'ADDCOMMENT', + actorAccountID: 8392101, + person: [ + { + style: 'strong', + text: 'Expensify Concierge', + type: 'TEXT', + }, + ], + automatic: false, + avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png', + created: '2024-11-05 11:10:43.944', + message: [ + { + html: "Expensify is best known for expense and corporate card management, but we do a lot more than that. Let me know what you're interested in and I'll help get you started.", + text: "Expensify is best known for expense and corporate card management, but we do a lot more than that. Let me know what you're interested in and I'll help get you started.", + type: 'COMMENT', + whisperedTo: [], + }, + ], + originalMessage: {}, + isFirstItem: false, + isAttachmentWithText: false, + shouldShow: true, + isOptimisticAction: true, + lastModified: '2024-11-05 11:10:43.944', + }, + '4422060638727390382': { + actionName: 'ADDCOMMENT', + actorAccountID: 8392101, + avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png', + created: '2024-11-05 11:11:47.086', + lastModified: '2024-11-05 11:11:47.086', + message: [ + { + html: 'Let\'s get your company set up! Setup Specialist - BreAnna, your dedicated specialist, is online now and can answer your initial questions or provide a demo.

πŸ’¬ CHAT WITH YOUR SETUP SPECIALIST', + text: "Let's get your company set up! Setup Specialist - BreAnna, your dedicated specialist, is online now and can answer your initial questions or provide a demo.\n\nπŸ’¬ CHAT WITH YOUR SETUP SPECIALIST", + type: 'COMMENT', + whisperedTo: [], + }, + ], + originalMessage: {}, + person: [ + { + style: 'strong', + text: 'Expensify Concierge', + type: 'TEXT', + }, + ], + reportActionID: '4422060638727390382', + shouldShow: true, + }, + '2824688328360312239': { + actionName: 'ADDCOMMENT', + actorAccountID: 8392101, + avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png', + created: '2024-11-05 11:19:18.703', + lastModified: '2024-11-05 11:19:18.703', + message: [ + { + html: '

You’ve started a free trial!


Welcome to your free 7-day trial of Expensify πŸŽ‰ Use it to continue exploring your workspace\'s benefits, including tracking expenses, reimbursing employees, managing company spend, and more.

If you have any questions, chat with your dedicated Setup Specialist in #admins. Enjoy!', + text: "You’ve started a free trial!\n\nWelcome to your free 7-day trial of Expensify πŸŽ‰ Use it to continue exploring your workspace's benefits, including tracking expenses, reimbursing employees, managing company spend, and more.\n\nIf you have any questions, chat with your dedicated Setup Specialist in #admins. Enjoy!", + type: 'COMMENT', + whisperedTo: [], + }, + ], + originalMessage: {}, + person: [ + { + style: 'strong', + text: 'Expensify Concierge', + type: 'TEXT', + }, + ], + reportActionID: '2824688328360312239', + shouldShow: true, + }, + }, + reportActions_6955627196303088: { + '1493209744740418100': { + reportActionID: '1493209744740418100', + actionName: 'CREATED', + actorAccountID: 18634488, + message: [ + { + type: 'TEXT', + style: 'strong', + text: 'ajsdjajdjadjajsjajdsj123@gmail.com', + }, + { + type: 'TEXT', + style: 'normal', + text: ' created this report', + }, + ], + person: [ + { + type: 'TEXT', + style: 'strong', + text: 'adasdasd', + }, + ], + automatic: false, + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', + created: '2024-11-05 11:19:18.285', + shouldShow: true, + }, + '8722650843049927838': { + actionName: 'IOU', + actorAccountID: 18634488, + automatic: false, + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', + isAttachmentOnly: false, + originalMessage: { + amount: 12300, + comment: '', + currency: 'VND', + IOUTransactionID: '3106135972713435169', + IOUReportID: '6955627196303088', + }, + message: [ + { + deleted: '', + html: 'β‚«123 expense', + isDeletedParentAction: false, + isEdited: false, + text: 'β‚«123 expense', + type: 'COMMENT', + whisperedTo: [], + }, + ], + person: [ + { + style: 'strong', + text: 'adasdasd', + type: 'TEXT', + }, + ], + reportActionID: '8722650843049927838', + shouldShow: true, + created: '2024-11-05 11:19:18.706', + childReportID: '4286515777714555', + lastModified: '2024-11-05 11:19:18.706', + childReportNotificationPreference: 'hidden', + childType: 'chat', + reportActionTimestamp: 1730805558706, + sequenceNumber: 1, + timestamp: 1730805558, + whisperedToAccountIDs: [], + }, + '1783566081350093529': { + actionName: 'IOU', + actorAccountID: 18634488, + automatic: false, + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', + isAttachmentOnly: false, + originalMessage: { + amount: 45600, + comment: '', + currency: 'VND', + IOUTransactionID: '3690687111940510713', + IOUReportID: '6955627196303088', + }, + message: [ + { + deleted: '', + html: 'β‚«456 expense', + isDeletedParentAction: false, + isEdited: false, + text: 'β‚«456 expense', + type: 'COMMENT', + whisperedTo: [], + }, + ], + person: [ + { + style: 'strong', + text: 'adasdasd', + type: 'TEXT', + }, + ], + reportActionID: '1783566081350093529', + shouldShow: true, + created: '2024-11-05 11:20:22.065', + childReportID: '7900715127836904', + lastModified: '2024-11-05 11:20:22.065', + childReportNotificationPreference: 'hidden', + childType: 'chat', + reportActionTimestamp: 1730805622065, + sequenceNumber: 2, + timestamp: 1730805622, + whisperedToAccountIDs: [], + }, + }, + reportActions_4286515777714555: { + '1995312838979534584': { + reportActionID: '1995312838979534584', + actionName: 'CREATED', + actorAccountID: 18634488, + message: [ + { + type: 'TEXT', + style: 'strong', + text: 'ajsdjajdjadjajsjajdsj123@gmail.com', + }, + { + type: 'TEXT', + style: 'normal', + text: ' created this report', + }, + ], + person: [ + { + type: 'TEXT', + style: 'strong', + text: 'adasdasd', + }, + ], + automatic: false, + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', + created: '2024-11-05 11:19:18.288', + shouldShow: true, + }, + }, + reportActions_7900715127836904: { + '3536855248086336861': { + reportActionID: '3536855248086336861', + actionName: 'CREATED', + actorAccountID: 18634488, + message: [ + { + type: 'TEXT', + style: 'strong', + text: 'ajsdjajdjadjajsjajdsj123@gmail.com', + }, + { + type: 'TEXT', + style: 'normal', + text: ' created this report', + }, + ], + person: [ + { + type: 'TEXT', + style: 'strong', + text: 'adasdasd', + }, + ], + automatic: false, + avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', + created: '2024-11-05 11:20:21.589', + shouldShow: true, + }, + }, + }; + + await Onyx.multiSet({ + ...report, + ...actions, + transactionViolations_3106135972713435169: [ + { + name: 'missingCategory', + type: 'violation', + }, + ], + transactionViolations_3690687111940510713: [ + { + name: 'missingCategory', + type: 'violation', + }, + ], + }); + + const result = getBrickRoadForPolicy(report, actions); + expect(result).toBe('error'); + }); + }); +}); From a708691fd04cd605b50a520d2dc9eb2bcd49714a Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 5 Nov 2024 18:51:53 +0700 Subject: [PATCH 06/16] fix: lint --- tests/unit/WorkspaceSettingsUtilsTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/WorkspaceSettingsUtilsTest.ts b/tests/unit/WorkspaceSettingsUtilsTest.ts index 2c7cf153c68a..3fcfd6549131 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.ts +++ b/tests/unit/WorkspaceSettingsUtilsTest.ts @@ -1,10 +1,10 @@ import {OnyxCollection} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; -import waitForBatchedUpdates from 'tests/utils/waitForBatchedUpdates'; import {getBrickRoadForPolicy} from '@libs/WorkspacesSettingsUtils'; import ONYXKEYS from '@src/ONYXKEYS'; import {Report, ReportActions} from '@src/types/onyx'; import * as TestHelper from '../utils/TestHelper'; +import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; describe('WorkspacesSettingsUtils', () => { beforeAll(() => { From 85d684ff6a0e1dfad2f1818e9438548f96f7f0d1 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 5 Nov 2024 19:58:35 +0700 Subject: [PATCH 07/16] fix: unit test --- tests/unit/WorkspaceSettingsUtilsTest.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/unit/WorkspaceSettingsUtilsTest.ts b/tests/unit/WorkspaceSettingsUtilsTest.ts index 3fcfd6549131..a25cec98c0f4 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.ts +++ b/tests/unit/WorkspaceSettingsUtilsTest.ts @@ -3,6 +3,7 @@ import Onyx from 'react-native-onyx'; import {getBrickRoadForPolicy} from '@libs/WorkspacesSettingsUtils'; import ONYXKEYS from '@src/ONYXKEYS'; import {Report, ReportActions} from '@src/types/onyx'; +import {ReportCollectionDataSet} from '@src/types/onyx/Report'; import * as TestHelper from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; @@ -49,6 +50,21 @@ describe('WorkspacesSettingsUtils', () => { avatarFileName: '', }; + const MOCK_REPORTS: ReportCollectionDataSet = { + [`${ONYXKEYS.COLLECTION.REPORT}4286515777714555` as const]: report, + [`${ONYXKEYS.COLLECTION.REPORT}6955627196303088` as const]: { + reportID: '6955627196303088', + chatReportID: '1699789757771388', + policyID: '57D0F454E0BCE54B', + type: 'expense', + ownerAccountID: 18634488, + stateNum: 1, + statusNum: 1, + parentReportID: '1699789757771388', + parentReportActionID: '7978085421707288417', + }, + }; + const actions: OnyxCollection = { reportActions_1699789757771388: { '4007735288062946397': { @@ -540,8 +556,11 @@ describe('WorkspacesSettingsUtils', () => { }; await Onyx.multiSet({ - ...report, + ...MOCK_REPORTS, ...actions, + [ONYXKEYS.SESSION]: { + accountID: 18634488, + }, transactionViolations_3106135972713435169: [ { name: 'missingCategory', @@ -556,6 +575,8 @@ describe('WorkspacesSettingsUtils', () => { ], }); + await waitForBatchedUpdates(); + const result = getBrickRoadForPolicy(report, actions); expect(result).toBe('error'); }); From 0f9e3dfd6c372c5c2fe7e9cd1a549ef3fe2db41a Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 5 Nov 2024 20:20:15 +0700 Subject: [PATCH 08/16] fix: lint --- tests/unit/WorkspaceSettingsUtilsTest.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/unit/WorkspaceSettingsUtilsTest.ts b/tests/unit/WorkspaceSettingsUtilsTest.ts index a25cec98c0f4..427356c0ccc4 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.ts +++ b/tests/unit/WorkspaceSettingsUtilsTest.ts @@ -34,12 +34,6 @@ describe('WorkspacesSettingsUtils', () => { ownerAccountID: 0, parentReportActionID: '8722650843049927838', parentReportID: '6955627196303088', - participants: { - '18634488': { - notificationPreference: 'hidden', - role: 'admin', - }, - }, policyID: '57D0F454E0BCE54B', reportID: '4286515777714555', reportName: 'Expense', @@ -67,6 +61,7 @@ describe('WorkspacesSettingsUtils', () => { const actions: OnyxCollection = { reportActions_1699789757771388: { + // eslint-disable-next-line @typescript-eslint/naming-convention '4007735288062946397': { reportActionID: '4007735288062946397', actionName: 'CREATED', @@ -98,6 +93,7 @@ describe('WorkspacesSettingsUtils', () => { sequenceNumber: 0, lastModified: '2024-11-05 11:10:47.852', }, + // eslint-disable-next-line @typescript-eslint/naming-convention '7978085421707288417': { reportActionID: '7978085421707288417', reportID: '1699789757771388', @@ -151,6 +147,7 @@ describe('WorkspacesSettingsUtils', () => { }, }, reportActions_4148694821839494: { + // eslint-disable-next-line @typescript-eslint/naming-convention '2964625714811661556': { reportActionID: '2964625714811661556', actionName: 'CREATED', @@ -179,6 +176,7 @@ describe('WorkspacesSettingsUtils', () => { created: '2024-11-05 11:10:47.077', shouldShow: true, }, + // eslint-disable-next-line @typescript-eslint/naming-convention '5971844472086652538': { actionName: 'ADDCOMMENT', actorAccountID: 10288574, @@ -206,6 +204,7 @@ describe('WorkspacesSettingsUtils', () => { }, }, reportActions_4625283659773773: { + // eslint-disable-next-line @typescript-eslint/naming-convention '7132923952865070123': { actionName: 'ADDCOMMENT', actorAccountID: 8392101, @@ -238,6 +237,7 @@ describe('WorkspacesSettingsUtils', () => { automatic: false, whisperedToAccountIDs: [], }, + // eslint-disable-next-line @typescript-eslint/naming-convention '5686837203726341682': { reportActionID: '5686837203726341682', actionName: 'CREATED', @@ -268,6 +268,7 @@ describe('WorkspacesSettingsUtils', () => { shouldShow: true, lastModified: '2024-11-05 11:10:38.688', }, + // eslint-disable-next-line @typescript-eslint/naming-convention '536505040772198026': { reportActionID: '536505040772198026', actionName: 'ADDCOMMENT', @@ -297,6 +298,7 @@ describe('WorkspacesSettingsUtils', () => { isOptimisticAction: true, lastModified: '2024-11-05 11:10:43.943', }, + // eslint-disable-next-line @typescript-eslint/naming-convention '5286007009323266706': { reportActionID: '5286007009323266706', actionName: 'ADDCOMMENT', @@ -326,6 +328,7 @@ describe('WorkspacesSettingsUtils', () => { isOptimisticAction: true, lastModified: '2024-11-05 11:10:43.944', }, + // eslint-disable-next-line @typescript-eslint/naming-convention '4422060638727390382': { actionName: 'ADDCOMMENT', actorAccountID: 8392101, @@ -351,6 +354,7 @@ describe('WorkspacesSettingsUtils', () => { reportActionID: '4422060638727390382', shouldShow: true, }, + // eslint-disable-next-line @typescript-eslint/naming-convention '2824688328360312239': { actionName: 'ADDCOMMENT', actorAccountID: 8392101, @@ -378,6 +382,7 @@ describe('WorkspacesSettingsUtils', () => { }, }, reportActions_6955627196303088: { + // eslint-disable-next-line @typescript-eslint/naming-convention '1493209744740418100': { reportActionID: '1493209744740418100', actionName: 'CREATED', @@ -406,6 +411,7 @@ describe('WorkspacesSettingsUtils', () => { created: '2024-11-05 11:19:18.285', shouldShow: true, }, + // eslint-disable-next-line @typescript-eslint/naming-convention '8722650843049927838': { actionName: 'IOU', actorAccountID: 18634488, @@ -449,6 +455,7 @@ describe('WorkspacesSettingsUtils', () => { timestamp: 1730805558, whisperedToAccountIDs: [], }, + // eslint-disable-next-line @typescript-eslint/naming-convention '1783566081350093529': { actionName: 'IOU', actorAccountID: 18634488, @@ -494,6 +501,7 @@ describe('WorkspacesSettingsUtils', () => { }, }, reportActions_4286515777714555: { + // eslint-disable-next-line @typescript-eslint/naming-convention '1995312838979534584': { reportActionID: '1995312838979534584', actionName: 'CREATED', @@ -524,6 +532,7 @@ describe('WorkspacesSettingsUtils', () => { }, }, reportActions_7900715127836904: { + // eslint-disable-next-line @typescript-eslint/naming-convention '3536855248086336861': { reportActionID: '3536855248086336861', actionName: 'CREATED', From 976c78f0427a4fd355523dc8a648600ace9c5703 Mon Sep 17 00:00:00 2001 From: truph01 Date: Wed, 6 Nov 2024 00:44:01 +0700 Subject: [PATCH 09/16] fix: lint --- tests/unit/WorkspaceSettingsUtilsTest.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/unit/WorkspaceSettingsUtilsTest.ts b/tests/unit/WorkspaceSettingsUtilsTest.ts index 427356c0ccc4..bd765dad8cab 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.ts +++ b/tests/unit/WorkspaceSettingsUtilsTest.ts @@ -1,9 +1,9 @@ -import {OnyxCollection} from 'react-native-onyx'; +import type {OnyxCollection} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import {getBrickRoadForPolicy} from '@libs/WorkspacesSettingsUtils'; import ONYXKEYS from '@src/ONYXKEYS'; -import {Report, ReportActions} from '@src/types/onyx'; -import {ReportCollectionDataSet} from '@src/types/onyx/Report'; +import type {Report, ReportActions} from '@src/types/onyx'; +import type {ReportCollectionDataSet} from '@src/types/onyx/Report'; import * as TestHelper from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; @@ -60,6 +60,7 @@ describe('WorkspacesSettingsUtils', () => { }; const actions: OnyxCollection = { + // eslint-disable-next-line @typescript-eslint/naming-convention reportActions_1699789757771388: { // eslint-disable-next-line @typescript-eslint/naming-convention '4007735288062946397': { @@ -146,6 +147,7 @@ describe('WorkspacesSettingsUtils', () => { whisperedToAccountIDs: [], }, }, + // eslint-disable-next-line @typescript-eslint/naming-convention reportActions_4148694821839494: { // eslint-disable-next-line @typescript-eslint/naming-convention '2964625714811661556': { @@ -203,6 +205,7 @@ describe('WorkspacesSettingsUtils', () => { shouldShow: true, }, }, + // eslint-disable-next-line @typescript-eslint/naming-convention reportActions_4625283659773773: { // eslint-disable-next-line @typescript-eslint/naming-convention '7132923952865070123': { @@ -381,6 +384,7 @@ describe('WorkspacesSettingsUtils', () => { shouldShow: true, }, }, + // eslint-disable-next-line @typescript-eslint/naming-convention reportActions_6955627196303088: { // eslint-disable-next-line @typescript-eslint/naming-convention '1493209744740418100': { @@ -500,6 +504,7 @@ describe('WorkspacesSettingsUtils', () => { whisperedToAccountIDs: [], }, }, + // eslint-disable-next-line @typescript-eslint/naming-convention reportActions_4286515777714555: { // eslint-disable-next-line @typescript-eslint/naming-convention '1995312838979534584': { @@ -531,6 +536,7 @@ describe('WorkspacesSettingsUtils', () => { shouldShow: true, }, }, + // eslint-disable-next-line @typescript-eslint/naming-convention reportActions_7900715127836904: { // eslint-disable-next-line @typescript-eslint/naming-convention '3536855248086336861': { @@ -570,12 +576,14 @@ describe('WorkspacesSettingsUtils', () => { [ONYXKEYS.SESSION]: { accountID: 18634488, }, + // eslint-disable-next-line @typescript-eslint/naming-convention transactionViolations_3106135972713435169: [ { name: 'missingCategory', type: 'violation', }, ], + // eslint-disable-next-line @typescript-eslint/naming-convention transactionViolations_3690687111940510713: [ { name: 'missingCategory', From e156dca948e0cd0392146e31736afde3e6782a38 Mon Sep 17 00:00:00 2001 From: truph01 Date: Thu, 7 Nov 2024 09:46:18 +0700 Subject: [PATCH 10/16] fix: add comment to test and create json file --- tests/unit/WorkspaceSettingsUtilsTest.json | 542 +++++++++++++++++++ tests/unit/WorkspaceSettingsUtilsTest.ts | 586 +-------------------- 2 files changed, 558 insertions(+), 570 deletions(-) create mode 100644 tests/unit/WorkspaceSettingsUtilsTest.json diff --git a/tests/unit/WorkspaceSettingsUtilsTest.json b/tests/unit/WorkspaceSettingsUtilsTest.json new file mode 100644 index 000000000000..7408429a5c1f --- /dev/null +++ b/tests/unit/WorkspaceSettingsUtilsTest.json @@ -0,0 +1,542 @@ +{ + "session": { + "accountID": 18634488 + }, + "reports": { + "report_4286515777714555": { + "isOptimisticReport": false, + "type": "chat", + "isOwnPolicyExpenseChat": false, + "isPinned": false, + "lastActorAccountID": 0, + "lastMessageTranslationKey": "", + "lastMessageHtml": "", + "lastReadTime": "2024-11-05 11:19:18.288", + "lastVisibleActionCreated": "2024-11-05 11:19:18.288", + "oldPolicyName": "", + "ownerAccountID": 0, + "parentReportActionID": "8722650843049927838", + "parentReportID": "6955627196303088", + "policyID": "57D0F454E0BCE54B", + "reportID": "4286515777714555", + "reportName": "Expense", + "stateNum": 0, + "statusNum": 0, + "description": "", + "avatarUrl": "", + "avatarFileName": "" + }, + "report_6955627196303088": { + "reportID": "6955627196303088", + "chatReportID": "1699789757771388", + "policyID": "57D0F454E0BCE54B", + "type": "expense", + "ownerAccountID": 18634488, + "stateNum": 1, + "statusNum": 1, + "parentReportID": "1699789757771388", + "parentReportActionID": "7978085421707288417" + } + }, + "transactionViolations": { + "transactionViolations_3106135972713435169": [ + { + "name": "missingCategory", + "type": "violation" + } + ], + "transactionViolations_3690687111940510713": [ + { + "name": "missingCategory", + "type": "violation" + } + ] + }, + "reportActions": { + "reportActions_1699789757771388": { + "4007735288062946397": { + "reportActionID": "4007735288062946397", + "actionName": "CREATED", + "actorAccountID": 18634488, + "message": [ + { + "type": "TEXT", + "style": "strong", + "text": "You" + }, + { + "type": "TEXT", + "style": "normal", + "text": " created this report" + } + ], + "person": [ + { + "type": "TEXT", + "style": "strong", + "text": "adasdasd" + } + ], + "automatic": false, + "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", + "created": "2024-11-05 11: 10: 47.852", + "shouldShow": true, + "reportActionTimestamp": 1730805047852, + "sequenceNumber": 0, + "lastModified": "2024-11-05 11: 10: 47.852" + }, + "7978085421707288417": { + "reportActionID": "7978085421707288417", + "reportID": "1699789757771388", + "actionName": "REPORTPREVIEW", + "originalMessage": {}, + "message": [ + { + "deleted": "", + "html": "Adasdasd's Workspace owes β‚«579", + "isDeletedParentAction": false, + "isEdited": false, + "text": "Adasdasd's Workspace owes β‚«579", + "type": "COMMENT", + "whisperedTo": [] + } + ], + "created": "2024-11-05 11: 19: 18.710", + "accountID": 18634488, + "actorAccountID": 18634488, + "childReportID": "6955627196303088", + "childMoneyRequestCount": 2, + "childLastMoneyRequestComment": "", + "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", + "childCommenterCount": 0, + "childLastActorAccountID": 18634488, + "childLastVisibleActionCreated": "", + "childOldestFourAccountIDs": "", + "childReportNotificationPreference": "hidden", + "childType": "expense", + "childVisibleActionCount": 0, + "lastModified": "2024-11-05 11: 19: 18.710", + "person": [ + { + "style": "strong", + "text": "adasdasd", + "type": "TEXT" + } + ], + "shouldShow": true, + "automatic": false, + "childManagerAccountID": 18634488, + "childOwnerAccountID": 18634488, + "childReportName": "Expense Report #6955627196303088", + "childStateNum": 1, + "childStatusNum": 1, + "reportActionTimestamp": 1730805558710, + "timestamp": 1730805558, + "whisperedToAccountIDs": [] + } + }, + "reportActions_4148694821839494": { + "2964625714811661556": { + "reportActionID": "2964625714811661556", + "actionName": "CREATED", + "actorAccountID": 18634488, + "message": [ + { + "type": "TEXT", + "style": "strong", + "text": "_FAKE_" + }, + { + "type": "TEXT", + "style": "normal", + "text": " created this report" + } + ], + "person": [ + { + "type": "TEXT", + "style": "strong", + "text": "adasdasd" + } + ], + "automatic": false, + "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", + "created": "2024-11-05 11: 10: 47.077", + "shouldShow": true + }, + "5971844472086652538": { + "actionName": "ADDCOMMENT", + "actorAccountID": 10288574, + "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/26271df52c9c9db57fa0221feaef04d18a045f2b_128.jpeg", + "created": "2024-11-05 11: 11: 47.410", + "lastModified": "2024-11-05 11: 11: 47.410", + "message": [ + { + "html": "

Let's get you set up on Expensify

Hi there πŸ‘‹ , I'm your dedicated setup specialist. I look forward to helping you explore and configure Expensify. A few important things to mention:
  • Your workspace has a ton of custom settings, just select your workspace settings to set it up.
  • You've got more functionality to enable, like custom categories, tags, etc. Just ask me how.
Chat with me here in your #admins room or just reply to this message. You can also schedule a call if you have more in-depth questions. Talk soon!

\"Setup", + "text": "Let's get you set up on Expensify\nHi there πŸ‘‹ , I'm your dedicated setup specialist. I look forward to helping you explore and configure Expensify. A few important things to mention: \nYour workspace has a ton of custom settings, just select your workspace settings to set it up.You've got more functionality to enable, like custom categories, tags, etc. Just ask me how. Chat with me here in your #admins room or just reply to this message. You can also schedule a call if you have more in-depth questions. Talk soon!\n\n[Attachment]", + "type": "COMMENT", + "whisperedTo": [] + } + ], + "originalMessage": {}, + "person": [ + { + "style": "strong", + "text": "Setup Specialist - BreAnna Sumpter Mon-Friday GMT & EST", + "type": "TEXT" + } + ], + "reportActionID": "5971844472086652538", + "shouldShow": true + } + }, + "reportActions_4625283659773773": { + "7132923952865070123": { + "actionName": "ADDCOMMENT", + "actorAccountID": 8392101, + "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png", + "created": "2024-11-05 11: 10: 38.956", + "lastModified": "2024-11-05 11: 10: 38.956", + "message": [ + { + "type": "COMMENT", + "html": "

Welcome to Expensify

πŸ‘‹ Hey there, I'm Concierge! If you have any questions about Expensify, you can always chat with me here 24-7 for fast and reliable support. I'm happy to help!", + "text": "Welcome to Expensify\nπŸ‘‹ Hey there, I'm Concierge! If you have any questions about Expensify, you can always chat with me here 24-7 for fast and reliable support. I'm happy to help!", + "isEdited": false, + "whisperedTo": [], + "isDeletedParentAction": false, + "deleted": "" + } + ], + "originalMessage": {}, + "person": [ + { + "type": "TEXT", + "style": "strong", + "text": "Expensify Concierge" + } + ], + "reportActionID": "7132923952865070123", + "shouldShow": true, + "timestamp": 1730805038, + "reportActionTimestamp": 1730805038956, + "automatic": false, + "whisperedToAccountIDs": [] + }, + "5686837203726341682": { + "reportActionID": "5686837203726341682", + "actionName": "CREATED", + "created": "2024-11-05 11: 10: 38.688", + "reportActionTimestamp": 1730805038688, + "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", + "message": [ + { + "type": "TEXT", + "style": "strong", + "text": "__fake__" + }, + { + "type": "TEXT", + "style": "normal", + "text": " created this report" + } + ], + "person": [ + { + "type": "TEXT", + "style": "strong", + "text": "__fake__" + } + ], + "automatic": false, + "sequenceNumber": 0, + "shouldShow": true, + "lastModified": "2024-11-05 11: 10: 38.688" + }, + "536505040772198026": { + "reportActionID": "536505040772198026", + "actionName": "ADDCOMMENT", + "actorAccountID": 8392101, + "person": [ + { + "style": "strong", + "text": "Expensify Concierge", + "type": "TEXT" + } + ], + "automatic": false, + "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png", + "created": "2024-11-05 11: 10: 43.943", + "message": [ + { + "html": "Let’s get you set up πŸ”§", + "text": "Let’s get you set up πŸ”§", + "type": "COMMENT", + "whisperedTo": [] + } + ], + "originalMessage": {}, + "isFirstItem": false, + "isAttachmentWithText": false, + "shouldShow": true, + "isOptimisticAction": true, + "lastModified": "2024-11-05 11: 10: 43.943" + }, + "5286007009323266706": { + "reportActionID": "5286007009323266706", + "actionName": "ADDCOMMENT", + "actorAccountID": 8392101, + "person": [ + { + "style": "strong", + "text": "Expensify Concierge", + "type": "TEXT" + } + ], + "automatic": false, + "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png", + "created": "2024-11-05 11: 10: 43.944", + "message": [ + { + "html": "Expensify is best known for expense and corporate card management, but we do a lot more than that. Let me know what you're interested in and I'll help get you started.", + "text": "Expensify is best known for expense and corporate card management, but we do a lot more than that. Let me know what you're interested in and I'll help get you started.", + "type": "COMMENT", + "whisperedTo": [] + } + ], + "originalMessage": {}, + "isFirstItem": false, + "isAttachmentWithText": false, + "shouldShow": true, + "isOptimisticAction": true, + "lastModified": "2024-11-05 11: 10: 43.944" + }, + "4422060638727390382": { + "actionName": "ADDCOMMENT", + "actorAccountID": 8392101, + "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png", + "created": "2024-11-05 11: 11: 47.086", + "lastModified": "2024-11-05 11: 11: 47.086", + "message": [ + { + "html": "Let's get your company set up! Setup Specialist - BreAnna, your dedicated specialist, is online now and can answer your initial questions or provide a demo.

πŸ’¬ CHAT WITH YOUR SETUP SPECIALIST", + "text": "Let's get your company set up! Setup Specialist - BreAnna, your dedicated specialist, is online now and can answer your initial questions or provide a demo.\n\nπŸ’¬ CHAT WITH YOUR SETUP SPECIALIST", + "type": "COMMENT", + "whisperedTo": [] + } + ], + "originalMessage": {}, + "person": [ + { + "style": "strong", + "text": "Expensify Concierge", + "type": "TEXT" + } + ], + "reportActionID": "4422060638727390382", + "shouldShow": true + }, + "2824688328360312239": { + "actionName": "ADDCOMMENT", + "actorAccountID": 8392101, + "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png", + "created": "2024-11-05 11: 19: 18.703", + "lastModified": "2024-11-05 11: 19: 18.703", + "message": [ + { + "html": "

You’ve started a free trial!


Welcome to your free 7-day trial of Expensify πŸŽ‰ Use it to continue exploring your workspace's benefits, including tracking expenses, reimbursing employees, managing company spend, and more.

If you have any questions, chat with your dedicated Setup Specialist in #admins. Enjoy!", + "text": "You’ve started a free trial!\n\nWelcome to your free 7-day trial of Expensify πŸŽ‰ Use it to continue exploring your workspace's benefits, including tracking expenses, reimbursing employees, managing company spend, and more.\n\nIf you have any questions, chat with your dedicated Setup Specialist in #admins. Enjoy!", + "type": "COMMENT", + "whisperedTo": [] + } + ], + "originalMessage": {}, + "person": [ + { + "style": "strong", + "text": "Expensify Concierge", + "type": "TEXT" + } + ], + "reportActionID": "2824688328360312239", + "shouldShow": true + } + }, + "reportActions_6955627196303088": { + "1493209744740418100": { + "reportActionID": "1493209744740418100", + "actionName": "CREATED", + "actorAccountID": 18634488, + "message": [ + { + "type": "TEXT", + "style": "strong", + "text": "ajsdjajdjadjajsjajdsj123@gmail.com" + }, + { + "type": "TEXT", + "style": "normal", + "text": " created this report" + } + ], + "person": [ + { + "type": "TEXT", + "style": "strong", + "text": "adasdasd" + } + ], + "automatic": false, + "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", + "created": "2024-11-05 11: 19: 18.285", + "shouldShow": true + }, + "8722650843049927838": { + "actionName": "IOU", + "actorAccountID": 18634488, + "automatic": false, + "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", + "isAttachmentOnly": false, + "originalMessage": { + "amount": 12300, + "comment": "", + "currency": "VND", + "IOUTransactionID": "3106135972713435169", + "IOUReportID": "6955627196303088" + }, + "message": [ + { + "deleted": "", + "html": "β‚«123 expense", + "isDeletedParentAction": false, + "isEdited": false, + "text": "β‚«123 expense", + "type": "COMMENT", + "whisperedTo": [] + } + ], + "person": [ + { + "style": "strong", + "text": "adasdasd", + "type": "TEXT" + } + ], + "reportActionID": "8722650843049927838", + "shouldShow": true, + "created": "2024-11-05 11: 19: 18.706", + "childReportID": "4286515777714555", + "lastModified": "2024-11-05 11: 19: 18.706", + "childReportNotificationPreference": "hidden", + "childType": "chat", + "reportActionTimestamp": 1730805558706, + "sequenceNumber": 1, + "timestamp": 1730805558, + "whisperedToAccountIDs": [] + }, + "1783566081350093529": { + "actionName": "IOU", + "actorAccountID": 18634488, + "automatic": false, + "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", + "isAttachmentOnly": false, + "originalMessage": { + "amount": 45600, + "comment": "", + "currency": "VND", + "IOUTransactionID": "3690687111940510713", + "IOUReportID": "6955627196303088" + }, + "message": [ + { + "deleted": "", + "html": "β‚«456 expense", + "isDeletedParentAction": false, + "isEdited": false, + "text": "β‚«456 expense", + "type": "COMMENT", + "whisperedTo": [] + } + ], + "person": [ + { + "style": "strong", + "text": "adasdasd", + "type": "TEXT" + } + ], + "reportActionID": "1783566081350093529", + "shouldShow": true, + "created": "2024-11-05 11: 20: 22.065", + "childReportID": "7900715127836904", + "lastModified": "2024-11-05 11: 20: 22.065", + "childReportNotificationPreference": "hidden", + "childType": "chat", + "reportActionTimestamp": 1730805622065, + "sequenceNumber": 2, + "timestamp": 1730805622, + "whisperedToAccountIDs": [] + } + }, + "reportActions_4286515777714555": { + "1995312838979534584": { + "reportActionID": "1995312838979534584", + "actionName": "CREATED", + "actorAccountID": 18634488, + "message": [ + { + "type": "TEXT", + "style": "strong", + "text": "ajsdjajdjadjajsjajdsj123@gmail.com" + }, + { + "type": "TEXT", + "style": "normal", + "text": " created this report" + } + ], + "person": [ + { + "type": "TEXT", + "style": "strong", + "text": "adasdasd" + } + ], + "automatic": false, + "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", + "created": "2024-11-05 11: 19: 18.288", + "shouldShow": true + } + }, + "reportActions_7900715127836904": { + "3536855248086336861": { + "reportActionID": "3536855248086336861", + "actionName": "CREATED", + "actorAccountID": 18634488, + "message": [ + { + "type": "TEXT", + "style": "strong", + "text": "ajsdjajdjadjajsjajdsj123@gmail.com" + }, + { + "type": "TEXT", + "style": "normal", + "text": " created this report" + } + ], + "person": [ + { + "type": "TEXT", + "style": "strong", + "text": "adasdasd" + } + ], + "automatic": false, + "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", + "created": "2024-11-05 11: 20: 21.589", + "shouldShow": true + } + } + } +} \ No newline at end of file diff --git a/tests/unit/WorkspaceSettingsUtilsTest.ts b/tests/unit/WorkspaceSettingsUtilsTest.ts index bd765dad8cab..2e7d82263e41 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.ts +++ b/tests/unit/WorkspaceSettingsUtilsTest.ts @@ -2,10 +2,11 @@ import type {OnyxCollection} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import {getBrickRoadForPolicy} from '@libs/WorkspacesSettingsUtils'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Report, ReportActions} from '@src/types/onyx'; +import type {Report, ReportActions, TransactionViolations} from '@src/types/onyx'; import type {ReportCollectionDataSet} from '@src/types/onyx/Report'; import * as TestHelper from '../utils/TestHelper'; import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; +import mockData from './WorkspaceSettingsUtilsTest.json'; describe('WorkspacesSettingsUtils', () => { beforeAll(() => { @@ -20,581 +21,26 @@ describe('WorkspacesSettingsUtils', () => { }); describe('getBrickRoadForPolicy', () => { it('Should return "error"', async () => { - const report: Report = { - isOptimisticReport: false, - type: 'chat', - isOwnPolicyExpenseChat: false, - isPinned: false, - lastActorAccountID: 0, - lastMessageTranslationKey: '', - lastMessageHtml: '', - lastReadTime: '2024-11-05 11:19:18.288', - lastVisibleActionCreated: '2024-11-05 11:19:18.288', - oldPolicyName: '', - ownerAccountID: 0, - parentReportActionID: '8722650843049927838', - parentReportID: '6955627196303088', - policyID: '57D0F454E0BCE54B', - reportID: '4286515777714555', - reportName: 'Expense', - stateNum: 0, - statusNum: 0, - description: '', - avatarUrl: '', - avatarFileName: '', - }; - - const MOCK_REPORTS: ReportCollectionDataSet = { - [`${ONYXKEYS.COLLECTION.REPORT}4286515777714555` as const]: report, - [`${ONYXKEYS.COLLECTION.REPORT}6955627196303088` as const]: { - reportID: '6955627196303088', - chatReportID: '1699789757771388', - policyID: '57D0F454E0BCE54B', - type: 'expense', - ownerAccountID: 18634488, - stateNum: 1, - statusNum: 1, - parentReportID: '1699789757771388', - parentReportActionID: '7978085421707288417', - }, - }; - - const actions: OnyxCollection = { - // eslint-disable-next-line @typescript-eslint/naming-convention - reportActions_1699789757771388: { - // eslint-disable-next-line @typescript-eslint/naming-convention - '4007735288062946397': { - reportActionID: '4007735288062946397', - actionName: 'CREATED', - actorAccountID: 18634488, - message: [ - { - type: 'TEXT', - style: 'strong', - text: 'You', - }, - { - type: 'TEXT', - style: 'normal', - text: ' created this report', - }, - ], - person: [ - { - type: 'TEXT', - style: 'strong', - text: 'adasdasd', - }, - ], - automatic: false, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', - created: '2024-11-05 11:10:47.852', - shouldShow: true, - reportActionTimestamp: 1730805047852, - sequenceNumber: 0, - lastModified: '2024-11-05 11:10:47.852', - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - '7978085421707288417': { - reportActionID: '7978085421707288417', - reportID: '1699789757771388', - actionName: 'REPORTPREVIEW', - originalMessage: {}, - message: [ - { - deleted: '', - html: "Adasdasd's Workspace owes β‚«579", - isDeletedParentAction: false, - isEdited: false, - text: "Adasdasd's Workspace owes β‚«579", - type: 'COMMENT', - whisperedTo: [], - }, - ], - created: '2024-11-05 11:19:18.710', - accountID: 18634488, - actorAccountID: 18634488, - childReportID: '6955627196303088', - childMoneyRequestCount: 2, - childLastMoneyRequestComment: '', - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', - childCommenterCount: 0, - childLastActorAccountID: 18634488, - - childLastVisibleActionCreated: '', - childOldestFourAccountIDs: '', - childReportNotificationPreference: 'hidden', - childType: 'expense', - childVisibleActionCount: 0, - lastModified: '2024-11-05 11:19:18.710', - person: [ - { - style: 'strong', - text: 'adasdasd', - type: 'TEXT', - }, - ], - shouldShow: true, - automatic: false, - childManagerAccountID: 18634488, - childOwnerAccountID: 18634488, - childReportName: 'Expense Report #6955627196303088', - childStateNum: 1, - childStatusNum: 1, - - reportActionTimestamp: 1730805558710, - timestamp: 1730805558, - whisperedToAccountIDs: [], - }, - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - reportActions_4148694821839494: { - // eslint-disable-next-line @typescript-eslint/naming-convention - '2964625714811661556': { - reportActionID: '2964625714811661556', - actionName: 'CREATED', - actorAccountID: 18634488, - message: [ - { - type: 'TEXT', - style: 'strong', - text: '_FAKE_', - }, - { - type: 'TEXT', - style: 'normal', - text: ' created this report', - }, - ], - person: [ - { - type: 'TEXT', - style: 'strong', - text: 'adasdasd', - }, - ], - automatic: false, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', - created: '2024-11-05 11:10:47.077', - shouldShow: true, - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - '5971844472086652538': { - actionName: 'ADDCOMMENT', - actorAccountID: 10288574, - avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/26271df52c9c9db57fa0221feaef04d18a045f2b_128.jpeg', - created: '2024-11-05 11:11:47.410', - lastModified: '2024-11-05 11:11:47.410', - message: [ - { - html: '

Let\'s get you set up on Expensify

Hi there πŸ‘‹ , I\'m your dedicated setup specialist. I look forward to helping you explore and configure Expensify. A few important things to mention:
  • Your workspace has a ton of custom settings, just select your workspace settings to set it up.
  • You\'ve got more functionality to enable, like custom categories, tags, etc. Just ask me how.
Chat with me here in your #admins room or just reply to this message. You can also schedule a call if you have more in-depth questions. Talk soon!

Setup Guide GIF', - text: "Let's get you set up on Expensify\nHi there πŸ‘‹ , I'm your dedicated setup specialist. I look forward to helping you explore and configure Expensify. A few important things to mention: \nYour workspace has a ton of custom settings, just select your workspace settings to set it up.You've got more functionality to enable, like custom categories, tags, etc. Just ask me how. Chat with me here in your #admins room or just reply to this message. You can also schedule a call if you have more in-depth questions. Talk soon!\n\n[Attachment]", - type: 'COMMENT', - whisperedTo: [], - }, - ], - originalMessage: {}, - person: [ - { - style: 'strong', - text: 'Setup Specialist - BreAnna Sumpter Mon-Friday GMT & EST', - type: 'TEXT', - }, - ], - reportActionID: '5971844472086652538', - shouldShow: true, - }, - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - reportActions_4625283659773773: { - // eslint-disable-next-line @typescript-eslint/naming-convention - '7132923952865070123': { - actionName: 'ADDCOMMENT', - actorAccountID: 8392101, - avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png', - created: '2024-11-05 11:10:38.956', - lastModified: '2024-11-05 11:10:38.956', - message: [ - { - type: 'COMMENT', - html: "

Welcome to Expensify

πŸ‘‹ Hey there, I'm Concierge! If you have any questions about Expensify, you can always chat with me here 24-7 for fast and reliable support. I'm happy to help!", - text: "Welcome to Expensify\nπŸ‘‹ Hey there, I'm Concierge! If you have any questions about Expensify, you can always chat with me here 24-7 for fast and reliable support. I'm happy to help!", - isEdited: false, - whisperedTo: [], - isDeletedParentAction: false, - deleted: '', - }, - ], - originalMessage: {}, - person: [ - { - type: 'TEXT', - style: 'strong', - text: 'Expensify Concierge', - }, - ], - reportActionID: '7132923952865070123', - shouldShow: true, - timestamp: 1730805038, - reportActionTimestamp: 1730805038956, - automatic: false, - whisperedToAccountIDs: [], - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - '5686837203726341682': { - reportActionID: '5686837203726341682', - actionName: 'CREATED', - created: '2024-11-05 11:10:38.688', - reportActionTimestamp: 1730805038688, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', - message: [ - { - type: 'TEXT', - style: 'strong', - text: '__fake__', - }, - { - type: 'TEXT', - style: 'normal', - text: ' created this report', - }, - ], - person: [ - { - type: 'TEXT', - style: 'strong', - text: '__fake__', - }, - ], - automatic: false, - sequenceNumber: 0, - shouldShow: true, - lastModified: '2024-11-05 11:10:38.688', - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - '536505040772198026': { - reportActionID: '536505040772198026', - actionName: 'ADDCOMMENT', - actorAccountID: 8392101, - person: [ - { - style: 'strong', - text: 'Expensify Concierge', - type: 'TEXT', - }, - ], - automatic: false, - avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png', - created: '2024-11-05 11:10:43.943', - message: [ - { - html: 'Let’s get you set up πŸ”§', - text: 'Let’s get you set up πŸ”§', - type: 'COMMENT', - whisperedTo: [], - }, - ], - originalMessage: {}, - isFirstItem: false, - isAttachmentWithText: false, - shouldShow: true, - isOptimisticAction: true, - lastModified: '2024-11-05 11:10:43.943', - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - '5286007009323266706': { - reportActionID: '5286007009323266706', - actionName: 'ADDCOMMENT', - actorAccountID: 8392101, - person: [ - { - style: 'strong', - text: 'Expensify Concierge', - type: 'TEXT', - }, - ], - automatic: false, - avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png', - created: '2024-11-05 11:10:43.944', - message: [ - { - html: "Expensify is best known for expense and corporate card management, but we do a lot more than that. Let me know what you're interested in and I'll help get you started.", - text: "Expensify is best known for expense and corporate card management, but we do a lot more than that. Let me know what you're interested in and I'll help get you started.", - type: 'COMMENT', - whisperedTo: [], - }, - ], - originalMessage: {}, - isFirstItem: false, - isAttachmentWithText: false, - shouldShow: true, - isOptimisticAction: true, - lastModified: '2024-11-05 11:10:43.944', - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - '4422060638727390382': { - actionName: 'ADDCOMMENT', - actorAccountID: 8392101, - avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png', - created: '2024-11-05 11:11:47.086', - lastModified: '2024-11-05 11:11:47.086', - message: [ - { - html: 'Let\'s get your company set up! Setup Specialist - BreAnna, your dedicated specialist, is online now and can answer your initial questions or provide a demo.

πŸ’¬ CHAT WITH YOUR SETUP SPECIALIST', - text: "Let's get your company set up! Setup Specialist - BreAnna, your dedicated specialist, is online now and can answer your initial questions or provide a demo.\n\nπŸ’¬ CHAT WITH YOUR SETUP SPECIALIST", - type: 'COMMENT', - whisperedTo: [], - }, - ], - originalMessage: {}, - person: [ - { - style: 'strong', - text: 'Expensify Concierge', - type: 'TEXT', - }, - ], - reportActionID: '4422060638727390382', - shouldShow: true, - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - '2824688328360312239': { - actionName: 'ADDCOMMENT', - actorAccountID: 8392101, - avatar: 'https://d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png', - created: '2024-11-05 11:19:18.703', - lastModified: '2024-11-05 11:19:18.703', - message: [ - { - html: '

You’ve started a free trial!


Welcome to your free 7-day trial of Expensify πŸŽ‰ Use it to continue exploring your workspace\'s benefits, including tracking expenses, reimbursing employees, managing company spend, and more.

If you have any questions, chat with your dedicated Setup Specialist in #admins. Enjoy!', - text: "You’ve started a free trial!\n\nWelcome to your free 7-day trial of Expensify πŸŽ‰ Use it to continue exploring your workspace's benefits, including tracking expenses, reimbursing employees, managing company spend, and more.\n\nIf you have any questions, chat with your dedicated Setup Specialist in #admins. Enjoy!", - type: 'COMMENT', - whisperedTo: [], - }, - ], - originalMessage: {}, - person: [ - { - style: 'strong', - text: 'Expensify Concierge', - type: 'TEXT', - }, - ], - reportActionID: '2824688328360312239', - shouldShow: true, - }, - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - reportActions_6955627196303088: { - // eslint-disable-next-line @typescript-eslint/naming-convention - '1493209744740418100': { - reportActionID: '1493209744740418100', - actionName: 'CREATED', - actorAccountID: 18634488, - message: [ - { - type: 'TEXT', - style: 'strong', - text: 'ajsdjajdjadjajsjajdsj123@gmail.com', - }, - { - type: 'TEXT', - style: 'normal', - text: ' created this report', - }, - ], - person: [ - { - type: 'TEXT', - style: 'strong', - text: 'adasdasd', - }, - ], - automatic: false, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', - created: '2024-11-05 11:19:18.285', - shouldShow: true, - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - '8722650843049927838': { - actionName: 'IOU', - actorAccountID: 18634488, - automatic: false, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', - isAttachmentOnly: false, - originalMessage: { - amount: 12300, - comment: '', - currency: 'VND', - IOUTransactionID: '3106135972713435169', - IOUReportID: '6955627196303088', - }, - message: [ - { - deleted: '', - html: 'β‚«123 expense', - isDeletedParentAction: false, - isEdited: false, - text: 'β‚«123 expense', - type: 'COMMENT', - whisperedTo: [], - }, - ], - person: [ - { - style: 'strong', - text: 'adasdasd', - type: 'TEXT', - }, - ], - reportActionID: '8722650843049927838', - shouldShow: true, - created: '2024-11-05 11:19:18.706', - childReportID: '4286515777714555', - lastModified: '2024-11-05 11:19:18.706', - childReportNotificationPreference: 'hidden', - childType: 'chat', - reportActionTimestamp: 1730805558706, - sequenceNumber: 1, - timestamp: 1730805558, - whisperedToAccountIDs: [], - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - '1783566081350093529': { - actionName: 'IOU', - actorAccountID: 18634488, - automatic: false, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', - isAttachmentOnly: false, - originalMessage: { - amount: 45600, - comment: '', - currency: 'VND', - IOUTransactionID: '3690687111940510713', - IOUReportID: '6955627196303088', - }, - message: [ - { - deleted: '', - html: 'β‚«456 expense', - isDeletedParentAction: false, - isEdited: false, - text: 'β‚«456 expense', - type: 'COMMENT', - whisperedTo: [], - }, - ], - person: [ - { - style: 'strong', - text: 'adasdasd', - type: 'TEXT', - }, - ], - reportActionID: '1783566081350093529', - shouldShow: true, - created: '2024-11-05 11:20:22.065', - childReportID: '7900715127836904', - lastModified: '2024-11-05 11:20:22.065', - childReportNotificationPreference: 'hidden', - childType: 'chat', - reportActionTimestamp: 1730805622065, - sequenceNumber: 2, - timestamp: 1730805622, - whisperedToAccountIDs: [], - }, - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - reportActions_4286515777714555: { - // eslint-disable-next-line @typescript-eslint/naming-convention - '1995312838979534584': { - reportActionID: '1995312838979534584', - actionName: 'CREATED', - actorAccountID: 18634488, - message: [ - { - type: 'TEXT', - style: 'strong', - text: 'ajsdjajdjadjajsjajdsj123@gmail.com', - }, - { - type: 'TEXT', - style: 'normal', - text: ' created this report', - }, - ], - person: [ - { - type: 'TEXT', - style: 'strong', - text: 'adasdasd', - }, - ], - automatic: false, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', - created: '2024-11-05 11:19:18.288', - shouldShow: true, - }, - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - reportActions_7900715127836904: { - // eslint-disable-next-line @typescript-eslint/naming-convention - '3536855248086336861': { - reportActionID: '3536855248086336861', - actionName: 'CREATED', - actorAccountID: 18634488, - message: [ - { - type: 'TEXT', - style: 'strong', - text: 'ajsdjajdjadjajsjajdsj123@gmail.com', - }, - { - type: 'TEXT', - style: 'normal', - text: ' created this report', - }, - ], - person: [ - { - type: 'TEXT', - style: 'strong', - text: 'adasdasd', - }, - ], - automatic: false, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png', - created: '2024-11-05 11:20:21.589', - shouldShow: true, - }, - }, - }; + // Given mock data for reports, transaction violations, sessions, and report actions + const report = Object.values(mockData.reports)?.at(0); + const transactionViolations = mockData.transactionViolations; + const reports = mockData.reports; + const session = mockData.session; + const reportActions = mockData.reportActions; await Onyx.multiSet({ - ...MOCK_REPORTS, - ...actions, - [ONYXKEYS.SESSION]: { - accountID: 18634488, - }, - // eslint-disable-next-line @typescript-eslint/naming-convention - transactionViolations_3106135972713435169: [ - { - name: 'missingCategory', - type: 'violation', - }, - ], - // eslint-disable-next-line @typescript-eslint/naming-convention - transactionViolations_3690687111940510713: [ - { - name: 'missingCategory', - type: 'violation', - }, - ], + ...(reports as ReportCollectionDataSet), + ...(reportActions as OnyxCollection), + ...(transactionViolations as OnyxCollection), + session, }); await waitForBatchedUpdates(); - const result = getBrickRoadForPolicy(report, actions); + // When calling getBrickRoadForPolicy with a report and report actions + const result = getBrickRoadForPolicy(report as Report, reportActions as OnyxCollection); + + // Then the result should be 'error' expect(result).toBe('error'); }); }); From e82e777b8cc38057477239852328ce7015b52b8f Mon Sep 17 00:00:00 2001 From: truph01 Date: Thu, 7 Nov 2024 09:50:14 +0700 Subject: [PATCH 11/16] fix: prettier --- tests/unit/WorkspaceSettingsUtilsTest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/WorkspaceSettingsUtilsTest.json b/tests/unit/WorkspaceSettingsUtilsTest.json index 7408429a5c1f..08b40bfacbdc 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.json +++ b/tests/unit/WorkspaceSettingsUtilsTest.json @@ -539,4 +539,4 @@ } } } -} \ No newline at end of file +} From 8d0da0016de99bf79d2e181e8f17930b0b198984 Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 8 Nov 2024 16:28:41 +0700 Subject: [PATCH 12/16] fix: remove unused data in json --- tests/unit/WorkspaceSettingsUtilsTest.json | 460 +-------------------- 1 file changed, 2 insertions(+), 458 deletions(-) diff --git a/tests/unit/WorkspaceSettingsUtilsTest.json b/tests/unit/WorkspaceSettingsUtilsTest.json index 08b40bfacbdc..ff83fe078adf 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.json +++ b/tests/unit/WorkspaceSettingsUtilsTest.json @@ -4,27 +4,15 @@ }, "reports": { "report_4286515777714555": { - "isOptimisticReport": false, "type": "chat", "isOwnPolicyExpenseChat": false, - "isPinned": false, - "lastActorAccountID": 0, - "lastMessageTranslationKey": "", - "lastMessageHtml": "", - "lastReadTime": "2024-11-05 11:19:18.288", - "lastVisibleActionCreated": "2024-11-05 11:19:18.288", - "oldPolicyName": "", "ownerAccountID": 0, "parentReportActionID": "8722650843049927838", "parentReportID": "6955627196303088", "policyID": "57D0F454E0BCE54B", "reportID": "4286515777714555", - "reportName": "Expense", "stateNum": 0, - "statusNum": 0, - "description": "", - "avatarUrl": "", - "avatarFileName": "" + "statusNum": 0 }, "report_6955627196303088": { "reportID": "6955627196303088", @@ -53,344 +41,7 @@ ] }, "reportActions": { - "reportActions_1699789757771388": { - "4007735288062946397": { - "reportActionID": "4007735288062946397", - "actionName": "CREATED", - "actorAccountID": 18634488, - "message": [ - { - "type": "TEXT", - "style": "strong", - "text": "You" - }, - { - "type": "TEXT", - "style": "normal", - "text": " created this report" - } - ], - "person": [ - { - "type": "TEXT", - "style": "strong", - "text": "adasdasd" - } - ], - "automatic": false, - "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", - "created": "2024-11-05 11: 10: 47.852", - "shouldShow": true, - "reportActionTimestamp": 1730805047852, - "sequenceNumber": 0, - "lastModified": "2024-11-05 11: 10: 47.852" - }, - "7978085421707288417": { - "reportActionID": "7978085421707288417", - "reportID": "1699789757771388", - "actionName": "REPORTPREVIEW", - "originalMessage": {}, - "message": [ - { - "deleted": "", - "html": "Adasdasd's Workspace owes β‚«579", - "isDeletedParentAction": false, - "isEdited": false, - "text": "Adasdasd's Workspace owes β‚«579", - "type": "COMMENT", - "whisperedTo": [] - } - ], - "created": "2024-11-05 11: 19: 18.710", - "accountID": 18634488, - "actorAccountID": 18634488, - "childReportID": "6955627196303088", - "childMoneyRequestCount": 2, - "childLastMoneyRequestComment": "", - "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", - "childCommenterCount": 0, - "childLastActorAccountID": 18634488, - "childLastVisibleActionCreated": "", - "childOldestFourAccountIDs": "", - "childReportNotificationPreference": "hidden", - "childType": "expense", - "childVisibleActionCount": 0, - "lastModified": "2024-11-05 11: 19: 18.710", - "person": [ - { - "style": "strong", - "text": "adasdasd", - "type": "TEXT" - } - ], - "shouldShow": true, - "automatic": false, - "childManagerAccountID": 18634488, - "childOwnerAccountID": 18634488, - "childReportName": "Expense Report #6955627196303088", - "childStateNum": 1, - "childStatusNum": 1, - "reportActionTimestamp": 1730805558710, - "timestamp": 1730805558, - "whisperedToAccountIDs": [] - } - }, - "reportActions_4148694821839494": { - "2964625714811661556": { - "reportActionID": "2964625714811661556", - "actionName": "CREATED", - "actorAccountID": 18634488, - "message": [ - { - "type": "TEXT", - "style": "strong", - "text": "_FAKE_" - }, - { - "type": "TEXT", - "style": "normal", - "text": " created this report" - } - ], - "person": [ - { - "type": "TEXT", - "style": "strong", - "text": "adasdasd" - } - ], - "automatic": false, - "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", - "created": "2024-11-05 11: 10: 47.077", - "shouldShow": true - }, - "5971844472086652538": { - "actionName": "ADDCOMMENT", - "actorAccountID": 10288574, - "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/26271df52c9c9db57fa0221feaef04d18a045f2b_128.jpeg", - "created": "2024-11-05 11: 11: 47.410", - "lastModified": "2024-11-05 11: 11: 47.410", - "message": [ - { - "html": "

Let's get you set up on Expensify

Hi there πŸ‘‹ , I'm your dedicated setup specialist. I look forward to helping you explore and configure Expensify. A few important things to mention:
  • Your workspace has a ton of custom settings, just select your workspace settings to set it up.
  • You've got more functionality to enable, like custom categories, tags, etc. Just ask me how.
Chat with me here in your #admins room or just reply to this message. You can also schedule a call if you have more in-depth questions. Talk soon!

\"Setup", - "text": "Let's get you set up on Expensify\nHi there πŸ‘‹ , I'm your dedicated setup specialist. I look forward to helping you explore and configure Expensify. A few important things to mention: \nYour workspace has a ton of custom settings, just select your workspace settings to set it up.You've got more functionality to enable, like custom categories, tags, etc. Just ask me how. Chat with me here in your #admins room or just reply to this message. You can also schedule a call if you have more in-depth questions. Talk soon!\n\n[Attachment]", - "type": "COMMENT", - "whisperedTo": [] - } - ], - "originalMessage": {}, - "person": [ - { - "style": "strong", - "text": "Setup Specialist - BreAnna Sumpter Mon-Friday GMT & EST", - "type": "TEXT" - } - ], - "reportActionID": "5971844472086652538", - "shouldShow": true - } - }, - "reportActions_4625283659773773": { - "7132923952865070123": { - "actionName": "ADDCOMMENT", - "actorAccountID": 8392101, - "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png", - "created": "2024-11-05 11: 10: 38.956", - "lastModified": "2024-11-05 11: 10: 38.956", - "message": [ - { - "type": "COMMENT", - "html": "

Welcome to Expensify

πŸ‘‹ Hey there, I'm Concierge! If you have any questions about Expensify, you can always chat with me here 24-7 for fast and reliable support. I'm happy to help!", - "text": "Welcome to Expensify\nπŸ‘‹ Hey there, I'm Concierge! If you have any questions about Expensify, you can always chat with me here 24-7 for fast and reliable support. I'm happy to help!", - "isEdited": false, - "whisperedTo": [], - "isDeletedParentAction": false, - "deleted": "" - } - ], - "originalMessage": {}, - "person": [ - { - "type": "TEXT", - "style": "strong", - "text": "Expensify Concierge" - } - ], - "reportActionID": "7132923952865070123", - "shouldShow": true, - "timestamp": 1730805038, - "reportActionTimestamp": 1730805038956, - "automatic": false, - "whisperedToAccountIDs": [] - }, - "5686837203726341682": { - "reportActionID": "5686837203726341682", - "actionName": "CREATED", - "created": "2024-11-05 11: 10: 38.688", - "reportActionTimestamp": 1730805038688, - "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", - "message": [ - { - "type": "TEXT", - "style": "strong", - "text": "__fake__" - }, - { - "type": "TEXT", - "style": "normal", - "text": " created this report" - } - ], - "person": [ - { - "type": "TEXT", - "style": "strong", - "text": "__fake__" - } - ], - "automatic": false, - "sequenceNumber": 0, - "shouldShow": true, - "lastModified": "2024-11-05 11: 10: 38.688" - }, - "536505040772198026": { - "reportActionID": "536505040772198026", - "actionName": "ADDCOMMENT", - "actorAccountID": 8392101, - "person": [ - { - "style": "strong", - "text": "Expensify Concierge", - "type": "TEXT" - } - ], - "automatic": false, - "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png", - "created": "2024-11-05 11: 10: 43.943", - "message": [ - { - "html": "Let’s get you set up πŸ”§", - "text": "Let’s get you set up πŸ”§", - "type": "COMMENT", - "whisperedTo": [] - } - ], - "originalMessage": {}, - "isFirstItem": false, - "isAttachmentWithText": false, - "shouldShow": true, - "isOptimisticAction": true, - "lastModified": "2024-11-05 11: 10: 43.943" - }, - "5286007009323266706": { - "reportActionID": "5286007009323266706", - "actionName": "ADDCOMMENT", - "actorAccountID": 8392101, - "person": [ - { - "style": "strong", - "text": "Expensify Concierge", - "type": "TEXT" - } - ], - "automatic": false, - "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png", - "created": "2024-11-05 11: 10: 43.944", - "message": [ - { - "html": "Expensify is best known for expense and corporate card management, but we do a lot more than that. Let me know what you're interested in and I'll help get you started.", - "text": "Expensify is best known for expense and corporate card management, but we do a lot more than that. Let me know what you're interested in and I'll help get you started.", - "type": "COMMENT", - "whisperedTo": [] - } - ], - "originalMessage": {}, - "isFirstItem": false, - "isAttachmentWithText": false, - "shouldShow": true, - "isOptimisticAction": true, - "lastModified": "2024-11-05 11: 10: 43.944" - }, - "4422060638727390382": { - "actionName": "ADDCOMMENT", - "actorAccountID": 8392101, - "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png", - "created": "2024-11-05 11: 11: 47.086", - "lastModified": "2024-11-05 11: 11: 47.086", - "message": [ - { - "html": "Let's get your company set up! Setup Specialist - BreAnna, your dedicated specialist, is online now and can answer your initial questions or provide a demo.

πŸ’¬ CHAT WITH YOUR SETUP SPECIALIST", - "text": "Let's get your company set up! Setup Specialist - BreAnna, your dedicated specialist, is online now and can answer your initial questions or provide a demo.\n\nπŸ’¬ CHAT WITH YOUR SETUP SPECIALIST", - "type": "COMMENT", - "whisperedTo": [] - } - ], - "originalMessage": {}, - "person": [ - { - "style": "strong", - "text": "Expensify Concierge", - "type": "TEXT" - } - ], - "reportActionID": "4422060638727390382", - "shouldShow": true - }, - "2824688328360312239": { - "actionName": "ADDCOMMENT", - "actorAccountID": 8392101, - "avatar": "https: //d1wpcgnaa73g0y.cloudfront.net/894b50e60056c966d12216005fbcacec8ce5a2c0.png", - "created": "2024-11-05 11: 19: 18.703", - "lastModified": "2024-11-05 11: 19: 18.703", - "message": [ - { - "html": "

You’ve started a free trial!


Welcome to your free 7-day trial of Expensify πŸŽ‰ Use it to continue exploring your workspace's benefits, including tracking expenses, reimbursing employees, managing company spend, and more.

If you have any questions, chat with your dedicated Setup Specialist in #admins. Enjoy!", - "text": "You’ve started a free trial!\n\nWelcome to your free 7-day trial of Expensify πŸŽ‰ Use it to continue exploring your workspace's benefits, including tracking expenses, reimbursing employees, managing company spend, and more.\n\nIf you have any questions, chat with your dedicated Setup Specialist in #admins. Enjoy!", - "type": "COMMENT", - "whisperedTo": [] - } - ], - "originalMessage": {}, - "person": [ - { - "style": "strong", - "text": "Expensify Concierge", - "type": "TEXT" - } - ], - "reportActionID": "2824688328360312239", - "shouldShow": true - } - }, "reportActions_6955627196303088": { - "1493209744740418100": { - "reportActionID": "1493209744740418100", - "actionName": "CREATED", - "actorAccountID": 18634488, - "message": [ - { - "type": "TEXT", - "style": "strong", - "text": "ajsdjajdjadjajsjajdsj123@gmail.com" - }, - { - "type": "TEXT", - "style": "normal", - "text": " created this report" - } - ], - "person": [ - { - "type": "TEXT", - "style": "strong", - "text": "adasdasd" - } - ], - "automatic": false, - "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", - "created": "2024-11-05 11: 19: 18.285", - "shouldShow": true - }, "8722650843049927838": { "actionName": "IOU", "actorAccountID": 18634488, @@ -428,114 +79,7 @@ "childReportID": "4286515777714555", "lastModified": "2024-11-05 11: 19: 18.706", "childReportNotificationPreference": "hidden", - "childType": "chat", - "reportActionTimestamp": 1730805558706, - "sequenceNumber": 1, - "timestamp": 1730805558, - "whisperedToAccountIDs": [] - }, - "1783566081350093529": { - "actionName": "IOU", - "actorAccountID": 18634488, - "automatic": false, - "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", - "isAttachmentOnly": false, - "originalMessage": { - "amount": 45600, - "comment": "", - "currency": "VND", - "IOUTransactionID": "3690687111940510713", - "IOUReportID": "6955627196303088" - }, - "message": [ - { - "deleted": "", - "html": "β‚«456 expense", - "isDeletedParentAction": false, - "isEdited": false, - "text": "β‚«456 expense", - "type": "COMMENT", - "whisperedTo": [] - } - ], - "person": [ - { - "style": "strong", - "text": "adasdasd", - "type": "TEXT" - } - ], - "reportActionID": "1783566081350093529", - "shouldShow": true, - "created": "2024-11-05 11: 20: 22.065", - "childReportID": "7900715127836904", - "lastModified": "2024-11-05 11: 20: 22.065", - "childReportNotificationPreference": "hidden", - "childType": "chat", - "reportActionTimestamp": 1730805622065, - "sequenceNumber": 2, - "timestamp": 1730805622, - "whisperedToAccountIDs": [] - } - }, - "reportActions_4286515777714555": { - "1995312838979534584": { - "reportActionID": "1995312838979534584", - "actionName": "CREATED", - "actorAccountID": 18634488, - "message": [ - { - "type": "TEXT", - "style": "strong", - "text": "ajsdjajdjadjajsjajdsj123@gmail.com" - }, - { - "type": "TEXT", - "style": "normal", - "text": " created this report" - } - ], - "person": [ - { - "type": "TEXT", - "style": "strong", - "text": "adasdasd" - } - ], - "automatic": false, - "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", - "created": "2024-11-05 11: 19: 18.288", - "shouldShow": true - } - }, - "reportActions_7900715127836904": { - "3536855248086336861": { - "reportActionID": "3536855248086336861", - "actionName": "CREATED", - "actorAccountID": 18634488, - "message": [ - { - "type": "TEXT", - "style": "strong", - "text": "ajsdjajdjadjajsjajdsj123@gmail.com" - }, - { - "type": "TEXT", - "style": "normal", - "text": " created this report" - } - ], - "person": [ - { - "type": "TEXT", - "style": "strong", - "text": "adasdasd" - } - ], - "automatic": false, - "avatar": "https: //d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_1.png", - "created": "2024-11-05 11: 20: 21.589", - "shouldShow": true + "childType": "chat" } } } From d42e264564a476786262ac6e29957d50912d5821 Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 8 Nov 2024 16:32:21 +0700 Subject: [PATCH 13/16] fix: add 2nd test case --- tests/unit/WorkspaceSettingsUtilsTest.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/unit/WorkspaceSettingsUtilsTest.ts b/tests/unit/WorkspaceSettingsUtilsTest.ts index 2e7d82263e41..239fd8e6ddfa 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.ts +++ b/tests/unit/WorkspaceSettingsUtilsTest.ts @@ -43,5 +43,28 @@ describe('WorkspacesSettingsUtils', () => { // Then the result should be 'error' expect(result).toBe('error'); }); + + it('Should return "undefined"', async () => { + // Given mock data for reports, transaction violations, sessions, and report actions + const report = Object.values(mockData.reports)?.at(0); + const transactionViolations = mockData.transactionViolations; + const reports = mockData.reports; + const session = mockData.session; + const reportActions = mockData.reportActions; + + await Onyx.multiSet({ + ...(reports as ReportCollectionDataSet), + ...(reportActions as OnyxCollection), + session, + }); + + await waitForBatchedUpdates(); + + // When calling getBrickRoadForPolicy with a report and report actions + const result = getBrickRoadForPolicy(report as Report, reportActions as OnyxCollection); + + // Then the result should be 'error' + expect(result).toBe(undefined); + }); }); }); From ef77bb997ca8f232423d0627c98f361a988d94e9 Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 8 Nov 2024 16:37:32 +0700 Subject: [PATCH 14/16] fix: lint --- tests/unit/WorkspaceSettingsUtilsTest.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/WorkspaceSettingsUtilsTest.ts b/tests/unit/WorkspaceSettingsUtilsTest.ts index 239fd8e6ddfa..934c003ccda6 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.ts +++ b/tests/unit/WorkspaceSettingsUtilsTest.ts @@ -47,7 +47,6 @@ describe('WorkspacesSettingsUtils', () => { it('Should return "undefined"', async () => { // Given mock data for reports, transaction violations, sessions, and report actions const report = Object.values(mockData.reports)?.at(0); - const transactionViolations = mockData.transactionViolations; const reports = mockData.reports; const session = mockData.session; const reportActions = mockData.reportActions; From bd9c7acd3d217373c98ee085e6a54177872e7a91 Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 8 Nov 2024 23:07:23 +0700 Subject: [PATCH 15/16] fix: update comment --- tests/unit/WorkspaceSettingsUtilsTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/WorkspaceSettingsUtilsTest.ts b/tests/unit/WorkspaceSettingsUtilsTest.ts index 934c003ccda6..f804356d3706 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.ts +++ b/tests/unit/WorkspaceSettingsUtilsTest.ts @@ -62,7 +62,7 @@ describe('WorkspacesSettingsUtils', () => { // When calling getBrickRoadForPolicy with a report and report actions const result = getBrickRoadForPolicy(report as Report, reportActions as OnyxCollection); - // Then the result should be 'error' + // Then the result should be 'undefined' expect(result).toBe(undefined); }); }); From 16b9d4e25f7ccd5adc78c8deadb4f0bae66ac919 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 12 Nov 2024 16:39:51 +0700 Subject: [PATCH 16/16] fix: add detailed comments in test --- tests/unit/WorkspaceSettingsUtilsTest.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/WorkspaceSettingsUtilsTest.ts b/tests/unit/WorkspaceSettingsUtilsTest.ts index f804356d3706..9ee2b511379f 100644 --- a/tests/unit/WorkspaceSettingsUtilsTest.ts +++ b/tests/unit/WorkspaceSettingsUtilsTest.ts @@ -21,7 +21,7 @@ describe('WorkspacesSettingsUtils', () => { }); describe('getBrickRoadForPolicy', () => { it('Should return "error"', async () => { - // Given mock data for reports, transaction violations, sessions, and report actions + // Given mock data for reports, transaction violations, sessions, and report actions. const report = Object.values(mockData.reports)?.at(0); const transactionViolations = mockData.transactionViolations; const reports = mockData.reports; @@ -40,12 +40,12 @@ describe('WorkspacesSettingsUtils', () => { // When calling getBrickRoadForPolicy with a report and report actions const result = getBrickRoadForPolicy(report as Report, reportActions as OnyxCollection); - // Then the result should be 'error' + // The result should be 'error' because there is at least one IOU action associated with a transaction that has a violation. expect(result).toBe('error'); }); it('Should return "undefined"', async () => { - // Given mock data for reports, transaction violations, sessions, and report actions + // Given mock data for reports, sessions, and report actions. Note: Transaction data is intentionally excluded. const report = Object.values(mockData.reports)?.at(0); const reports = mockData.reports; const session = mockData.session; @@ -62,7 +62,7 @@ describe('WorkspacesSettingsUtils', () => { // When calling getBrickRoadForPolicy with a report and report actions const result = getBrickRoadForPolicy(report as Report, reportActions as OnyxCollection); - // Then the result should be 'undefined' + // Then the result should be 'undefined' since no IOU action is linked to a transaction with a violation. expect(result).toBe(undefined); }); });