From a0cae47edd3ad9e583355bd8dd9c91276d6ef796 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 29 Apr 2025 18:18:12 +0200 Subject: [PATCH 1/5] Update react-native-onyx to version 2.0.104 in package.json and package-lock.json --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index db9fe7c8b262..c37c5b60ef80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -107,7 +107,7 @@ "react-native-launch-arguments": "^4.0.2", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "2.0.100", + "react-native-onyx": "^2.0.104", "react-native-pager-view": "6.5.2", "react-native-pdf": "6.7.3", "react-native-performance": "^5.1.0", @@ -33036,9 +33036,9 @@ } }, "node_modules/react-native-onyx": { - "version": "2.0.100", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-2.0.100.tgz", - "integrity": "sha512-s/OaBmjzQ1oodChaEwsW0pHZ0LRD/L0e0TxCgNRF5kzBnh5tHSNZuoCDW5h7fMZrBQ+qmuFvkJya6Gb9ojcWVA==", + "version": "2.0.104", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-2.0.104.tgz", + "integrity": "sha512-ovMUxmIJVPt9mfQ9C1DL3xybIVQtGMaizsg76aEMaP+PMDL1vMC9bj75CfExclpPgwun+mTb9qIBiPVmTuwnPQ==", "license": "MIT", "dependencies": { "ascii-table": "0.0.9", diff --git a/package.json b/package.json index fb856940557e..6dd7769d2a2c 100644 --- a/package.json +++ b/package.json @@ -174,7 +174,7 @@ "react-native-launch-arguments": "^4.0.2", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "2.0.100", + "react-native-onyx": "^2.0.104", "react-native-pager-view": "6.5.2", "react-native-pdf": "6.7.3", "react-native-performance": "^5.1.0", From 100d5edeecc5fc97462e14e7990686de7046b676 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 29 Apr 2025 18:21:26 +0200 Subject: [PATCH 2/5] replace safeEvictionKeys with evictableKeys --- README.md | 4 ++-- src/setup/index.ts | 2 +- tests/perf-test/ModifiedExpenseMessage.perf-test.ts | 2 +- tests/perf-test/ReportActionCompose.perf-test.tsx | 2 +- tests/perf-test/ReportActionsList.perf-test.tsx | 2 +- tests/perf-test/ReportActionsUtils.perf-test.ts | 2 +- tests/perf-test/ReportUtils.perf-test.ts | 2 +- tests/perf-test/SearchRouter.perf-test.tsx | 2 +- tests/perf-test/SidebarLinks.perf-test.tsx | 2 +- tests/perf-test/SidebarUtils.perf-test.ts | 2 +- tests/ui/DebugReportActionsTest.tsx | 2 +- tests/ui/LHNItemsPresence.tsx | 2 +- tests/ui/ReportDetailsPageTest.tsx | 2 +- tests/unit/PersistedRequests.ts | 2 +- tests/unit/ReportActionItemSingleTest.ts | 2 +- tests/unit/ReportActionsUtilsTest.ts | 2 +- tests/unit/SidebarFilterTest.ts | 2 +- tests/unit/SidebarOrderTest.ts | 2 +- tests/unit/SidebarTest.ts | 2 +- tests/unit/SidebarUtilsTest.ts | 2 +- 20 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index c0cc272c58ce..2298e72a198b 100644 --- a/README.md +++ b/README.md @@ -414,14 +414,14 @@ Different platforms come with varying storage capacities and Onyx has a way to g By default, Onyx will not evict anything from storage and will presume all keys are "unsafe" to remove unless explicitly told otherwise. **To flag a key as safe for removal:** -- Add the key to the `safeEvictionKeys` option in `Onyx.init(options)` +- Add the key to the `evictableKeys` option in `Onyx.init(options)` - Implement `canEvict` in the Onyx config for each component subscribing to a key - The key will only be deleted when all subscribers return `true` for `canEvict` e.g. ```js Onyx.init({ - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }); ``` diff --git a/src/setup/index.ts b/src/setup/index.ts index 362a5511a228..65bd903aae01 100644 --- a/src/setup/index.ts +++ b/src/setup/index.ts @@ -28,7 +28,7 @@ export default function () { // Increase the cached key count so that the app works more consistently for accounts with large numbers of reports maxCachedKeysCount: 50000, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS, ONYXKEYS.COLLECTION.SNAPSHOT], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS, ONYXKEYS.COLLECTION.SNAPSHOT], initialKeyStates: { // Clear any loading and error messages so they do not appear on app startup [ONYXKEYS.SESSION]: {loading: false}, diff --git a/tests/perf-test/ModifiedExpenseMessage.perf-test.ts b/tests/perf-test/ModifiedExpenseMessage.perf-test.ts index 9b751d5b8982..c938320300ab 100644 --- a/tests/perf-test/ModifiedExpenseMessage.perf-test.ts +++ b/tests/perf-test/ModifiedExpenseMessage.perf-test.ts @@ -14,7 +14,7 @@ import waitForBatchedUpdates from '../utils/waitForBatchedUpdates'; beforeAll(() => Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }), ); diff --git a/tests/perf-test/ReportActionCompose.perf-test.tsx b/tests/perf-test/ReportActionCompose.perf-test.tsx index 6f6f05c45461..9bd9ac2e4a86 100644 --- a/tests/perf-test/ReportActionCompose.perf-test.tsx +++ b/tests/perf-test/ReportActionCompose.perf-test.tsx @@ -61,7 +61,7 @@ jest.mock('@components/ConfirmedRoute.tsx'); beforeAll(() => Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }), ); diff --git a/tests/perf-test/ReportActionsList.perf-test.tsx b/tests/perf-test/ReportActionsList.perf-test.tsx index 2dd7ed401fc2..42026e63f6a8 100644 --- a/tests/perf-test/ReportActionsList.perf-test.tsx +++ b/tests/perf-test/ReportActionsList.perf-test.tsx @@ -73,7 +73,7 @@ jest.mock('@src/components/ConfirmedRoute.tsx'); beforeAll(() => Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }), ); diff --git a/tests/perf-test/ReportActionsUtils.perf-test.ts b/tests/perf-test/ReportActionsUtils.perf-test.ts index 601a232abacb..494345c483ce 100644 --- a/tests/perf-test/ReportActionsUtils.perf-test.ts +++ b/tests/perf-test/ReportActionsUtils.perf-test.ts @@ -39,7 +39,7 @@ describe('ReportActionsUtils', () => { beforeAll(() => { Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }); Onyx.multiSet({ diff --git a/tests/perf-test/ReportUtils.perf-test.ts b/tests/perf-test/ReportUtils.perf-test.ts index 8cd531db8628..bec07b36118e 100644 --- a/tests/perf-test/ReportUtils.perf-test.ts +++ b/tests/perf-test/ReportUtils.perf-test.ts @@ -40,7 +40,7 @@ describe('ReportUtils', () => { beforeAll(() => { Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }); }); diff --git a/tests/perf-test/SearchRouter.perf-test.tsx b/tests/perf-test/SearchRouter.perf-test.tsx index da531a3a1230..0ddab58e3508 100644 --- a/tests/perf-test/SearchRouter.perf-test.tsx +++ b/tests/perf-test/SearchRouter.perf-test.tsx @@ -93,7 +93,7 @@ const mockedOptions = createOptionList(mockedPersonalDetails, mockedReports); beforeAll(() => Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT], }), ); diff --git a/tests/perf-test/SidebarLinks.perf-test.tsx b/tests/perf-test/SidebarLinks.perf-test.tsx index f50f1a217788..9bed2535bfe5 100644 --- a/tests/perf-test/SidebarLinks.perf-test.tsx +++ b/tests/perf-test/SidebarLinks.perf-test.tsx @@ -56,7 +56,7 @@ describe('SidebarLinks', () => { beforeAll(() => { Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }); }); diff --git a/tests/perf-test/SidebarUtils.perf-test.ts b/tests/perf-test/SidebarUtils.perf-test.ts index 456f1cd51f6a..5442ab6b4702 100644 --- a/tests/perf-test/SidebarUtils.perf-test.ts +++ b/tests/perf-test/SidebarUtils.perf-test.ts @@ -59,7 +59,7 @@ describe('SidebarUtils', () => { beforeAll(() => { Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }); Onyx.multiSet({ diff --git a/tests/ui/DebugReportActionsTest.tsx b/tests/ui/DebugReportActionsTest.tsx index dd1a7c23bed7..d17fbf5a24dc 100644 --- a/tests/ui/DebugReportActionsTest.tsx +++ b/tests/ui/DebugReportActionsTest.tsx @@ -31,7 +31,7 @@ describe('DebugReportActions', () => { beforeAll(() => { Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }); }); diff --git a/tests/ui/LHNItemsPresence.tsx b/tests/ui/LHNItemsPresence.tsx index a8bca540b5a0..9d668f787963 100644 --- a/tests/ui/LHNItemsPresence.tsx +++ b/tests/ui/LHNItemsPresence.tsx @@ -105,7 +105,7 @@ describe('SidebarLinksData', () => { beforeAll(() => { Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }); }); diff --git a/tests/ui/ReportDetailsPageTest.tsx b/tests/ui/ReportDetailsPageTest.tsx index 2e958b448b1e..5794cd3a297a 100644 --- a/tests/ui/ReportDetailsPageTest.tsx +++ b/tests/ui/ReportDetailsPageTest.tsx @@ -33,7 +33,7 @@ describe('ReportDetailsPage', () => { beforeAll(() => { Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }); }); diff --git a/tests/unit/PersistedRequests.ts b/tests/unit/PersistedRequests.ts index 321b0af3ad41..1c1b3c552c15 100644 --- a/tests/unit/PersistedRequests.ts +++ b/tests/unit/PersistedRequests.ts @@ -15,7 +15,7 @@ const request: Request = { beforeAll(() => Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }), ); diff --git a/tests/unit/ReportActionItemSingleTest.ts b/tests/unit/ReportActionItemSingleTest.ts index e987112ba5a3..ab914e9c0717 100644 --- a/tests/unit/ReportActionItemSingleTest.ts +++ b/tests/unit/ReportActionItemSingleTest.ts @@ -22,7 +22,7 @@ describe('ReportActionItemSingle', () => { beforeAll(() => Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }), ); diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index db7ef64589f9..ee5b2073b8aa 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -14,7 +14,7 @@ describe('ReportActionsUtils', () => { beforeAll(() => Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }), ); diff --git a/tests/unit/SidebarFilterTest.ts b/tests/unit/SidebarFilterTest.ts index 754375db9287..8d71b6d9602c 100644 --- a/tests/unit/SidebarFilterTest.ts +++ b/tests/unit/SidebarFilterTest.ts @@ -35,7 +35,7 @@ xdescribe('Sidebar', () => { beforeAll(() => Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }), ); diff --git a/tests/unit/SidebarOrderTest.ts b/tests/unit/SidebarOrderTest.ts index 64e108be9e7c..d661c13ddbb2 100644 --- a/tests/unit/SidebarOrderTest.ts +++ b/tests/unit/SidebarOrderTest.ts @@ -32,7 +32,7 @@ describe('Sidebar', () => { beforeAll(() => Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }), ); diff --git a/tests/unit/SidebarTest.ts b/tests/unit/SidebarTest.ts index 4a48085d0a96..0b9611e9a900 100644 --- a/tests/unit/SidebarTest.ts +++ b/tests/unit/SidebarTest.ts @@ -25,7 +25,7 @@ describe('Sidebar', () => { beforeAll(() => Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }), ); diff --git a/tests/unit/SidebarUtilsTest.ts b/tests/unit/SidebarUtilsTest.ts index e3a8595cbd93..43300dfabfb9 100644 --- a/tests/unit/SidebarUtilsTest.ts +++ b/tests/unit/SidebarUtilsTest.ts @@ -21,7 +21,7 @@ describe('SidebarUtils', () => { beforeAll(() => Onyx.init({ keys: ONYXKEYS, - safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], }), ); From e29404c4ca7181acce277cf295d460e8d4805b0c Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 29 Apr 2025 18:22:06 +0200 Subject: [PATCH 3/5] Enhance evictableKeys in setup to include additional report-related collections for improved caching management --- src/setup/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/setup/index.ts b/src/setup/index.ts index 65bd903aae01..5cc21e47373c 100644 --- a/src/setup/index.ts +++ b/src/setup/index.ts @@ -28,7 +28,13 @@ export default function () { // Increase the cached key count so that the app works more consistently for accounts with large numbers of reports maxCachedKeysCount: 50000, - evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS, ONYXKEYS.COLLECTION.SNAPSHOT], + evictableKeys: [ + ONYXKEYS.COLLECTION.REPORT_ACTIONS, + ONYXKEYS.COLLECTION.SNAPSHOT, + ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS, + ONYXKEYS.COLLECTION.REPORT_ACTIONS_PAGES, + ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS, + ], initialKeyStates: { // Clear any loading and error messages so they do not appear on app startup [ONYXKEYS.SESSION]: {loading: false}, From a1da1f11d99f7565eb0a23e7cc1a333913e3654f Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 29 Apr 2025 18:25:16 +0200 Subject: [PATCH 4/5] Refactor ReportUtils import statements and update test cases to use named imports for improved readability and maintainability --- tests/perf-test/ReportUtils.perf-test.ts | 50 +++++++++++++++--------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/tests/perf-test/ReportUtils.perf-test.ts b/tests/perf-test/ReportUtils.perf-test.ts index bec07b36118e..f53465bbaf4e 100644 --- a/tests/perf-test/ReportUtils.perf-test.ts +++ b/tests/perf-test/ReportUtils.perf-test.ts @@ -1,6 +1,22 @@ import Onyx from 'react-native-onyx'; import {measureFunction} from 'reassure'; -import * as ReportUtils from '@libs/ReportUtils'; +import { + canDeleteReportAction, + canShowReportRecipientLocalTime, + findLastAccessedReport, + getDisplayNamesWithTooltips, + getIcons, + getIconsForParticipants, + getIOUReportActionDisplayMessage, + getReportName, + getReportPreviewMessage, + getReportRecipientAccountIDs, + getTransactionDetails, + getWorkspaceChats, + getWorkspaceIcon, + shouldReportBeInOptionList, + temporary_getMoneyRequestOptions, +} from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PersonalDetails, Policy, Report, ReportAction} from '@src/types/onyx'; @@ -67,7 +83,7 @@ describe('ReportUtils', () => { }); await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.findLastAccessedReport(ignoreDomainRooms, openOnAdminRoom)); + await measureFunction(() => findLastAccessedReport(ignoreDomainRooms, openOnAdminRoom)); }); test('[ReportUtils] canDeleteReportAction on 1k reports and policies', async () => { @@ -75,7 +91,7 @@ describe('ReportUtils', () => { const reportAction = {...createRandomReportAction(1), actionName: CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT} as unknown as ReportAction; await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.canDeleteReportAction(reportAction, reportID)); + await measureFunction(() => canDeleteReportAction(reportAction, reportID)); }); test('[ReportUtils] getReportRecipientAccountID on 1k participants', async () => { @@ -83,14 +99,14 @@ describe('ReportUtils', () => { const currentLoginAccountID = 1; await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.getReportRecipientAccountIDs(report, currentLoginAccountID)); + await measureFunction(() => getReportRecipientAccountIDs(report, currentLoginAccountID)); }); test('[ReportUtils] getIconsForParticipants on 1k participants', async () => { const participants = Array.from({length: 1000}, (v, i) => i + 1); await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.getIconsForParticipants(participants, personalDetails)); + await measureFunction(() => getIconsForParticipants(participants, personalDetails)); }); test('[ReportUtils] getIcons on 1k participants', async () => { @@ -101,7 +117,7 @@ describe('ReportUtils', () => { const defaultIconId = -1; await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.getIcons(report, personalDetails, defaultIcon, defaultName, defaultIconId, policy)); + await measureFunction(() => getIcons(report, personalDetails, defaultIcon, defaultName, defaultIconId, policy)); }); test('[ReportUtils] getDisplayNamesWithTooltips 1k participants', async () => { @@ -109,7 +125,7 @@ describe('ReportUtils', () => { const shouldFallbackToHidden = true; await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.getDisplayNamesWithTooltips(personalDetails, isMultipleParticipantReport, shouldFallbackToHidden)); + await measureFunction(() => getDisplayNamesWithTooltips(personalDetails, isMultipleParticipantReport, shouldFallbackToHidden)); }); test('[ReportUtils] getReportPreviewMessage on 1k policies', async () => { @@ -120,7 +136,7 @@ describe('ReportUtils', () => { const isPreviewMessageForParentChatReport = true; await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.getReportPreviewMessage(report, reportAction, shouldConsiderReceiptBeingScanned, isPreviewMessageForParentChatReport, policy)); + await measureFunction(() => getReportPreviewMessage(report, reportAction, shouldConsiderReceiptBeingScanned, isPreviewMessageForParentChatReport, policy)); }); test('[ReportUtils] getReportName on 1k participants', async () => { @@ -128,7 +144,7 @@ describe('ReportUtils', () => { const policy = createRandomPolicy(1); await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.getReportName(report, policy)); + await measureFunction(() => getReportName(report, policy)); }); test('[ReportUtils] canShowReportRecipientLocalTime on 1k participants', async () => { @@ -136,7 +152,7 @@ describe('ReportUtils', () => { const accountID = 1; await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.canShowReportRecipientLocalTime(personalDetails, report, accountID)); + await measureFunction(() => canShowReportRecipientLocalTime(personalDetails, report, accountID)); }); test('[ReportUtils] shouldReportBeInOptionList on 1k participant', async () => { @@ -147,9 +163,7 @@ describe('ReportUtils', () => { const policies = getMockedPolicies(); await waitForBatchedUpdates(); - await measureFunction(() => - ReportUtils.shouldReportBeInOptionList({report, currentReportId, isInFocusMode, betas, policies, doesReportHaveViolations: false, excludeEmptyChats: false}), - ); + await measureFunction(() => shouldReportBeInOptionList({report, currentReportId, isInFocusMode, betas, policies, doesReportHaveViolations: false, excludeEmptyChats: false})); }); test('[ReportUtils] getWorkspaceIcon on 1k policies', async () => { @@ -157,7 +171,7 @@ describe('ReportUtils', () => { const policy = createRandomPolicy(1); await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.getWorkspaceIcon(report, policy)); + await measureFunction(() => getWorkspaceIcon(report, policy)); }); test('[ReportUtils] getMoneyRequestOptions on 1k participants', async () => { @@ -166,7 +180,7 @@ describe('ReportUtils', () => { const reportParticipants = Array.from({length: 1000}, (v, i) => i + 1); await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.temporary_getMoneyRequestOptions(report, policy, reportParticipants)); + await measureFunction(() => temporary_getMoneyRequestOptions(report, policy, reportParticipants)); }); test('[ReportUtils] getWorkspaceChat on 1k policies', async () => { @@ -174,14 +188,14 @@ describe('ReportUtils', () => { const accountsID = Array.from({length: 20}, (v, i) => i + 1); await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.getWorkspaceChats(policyID, accountsID)); + await measureFunction(() => getWorkspaceChats(policyID, accountsID)); }); test('[ReportUtils] getTransactionDetails on 1k reports', async () => { const transaction = createRandomTransaction(1); await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.getTransactionDetails(transaction, 'yyyy-MM-dd')); + await measureFunction(() => getTransactionDetails(transaction, 'yyyy-MM-dd')); }); test('[ReportUtils] getIOUReportActionDisplayMessage on 1k policies', async () => { @@ -200,6 +214,6 @@ describe('ReportUtils', () => { }; await waitForBatchedUpdates(); - await measureFunction(() => ReportUtils.getIOUReportActionDisplayMessage(reportAction)); + await measureFunction(() => getIOUReportActionDisplayMessage(reportAction)); }); }); From ae33edc709bea9f90bf2d6c42cbe43788815a6c7 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Tue, 29 Apr 2025 18:25:51 +0200 Subject: [PATCH 5/5] Update ReportActionItemSingleTest to use CONST.DEFAULT_NUMBER_ID for faceAccountId assignment --- tests/unit/ReportActionItemSingleTest.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/ReportActionItemSingleTest.ts b/tests/unit/ReportActionItemSingleTest.ts index ab914e9c0717..f04d31db798d 100644 --- a/tests/unit/ReportActionItemSingleTest.ts +++ b/tests/unit/ReportActionItemSingleTest.ts @@ -1,5 +1,6 @@ import {screen, waitFor} from '@testing-library/react-native'; import Onyx from 'react-native-onyx'; +import CONST from '@src/CONST'; import type {PersonalDetailsList} from '@src/types/onyx'; import {toCollectionDataSet} from '@src/types/utils/CollectionDataSet'; import * as LHNTestUtils from '../utils/LHNTestUtils'; @@ -44,7 +45,7 @@ describe('ReportActionItemSingle', () => { const fakeReport = LHNTestUtils.getFakeReportWithPolicy([1, 2]); const fakeReportAction = LHNTestUtils.getFakeAdvancedReportAction(); const fakePolicy = LHNTestUtils.getFakePolicy(fakeReport.policyID); - const faceAccountId = fakeReportAction.actorAccountID ?? -1; + const faceAccountId = fakeReportAction.actorAccountID ?? CONST.DEFAULT_NUMBER_ID; const fakePersonalDetails: PersonalDetailsList = { [faceAccountId]: { accountID: faceAccountId,