From e5bc39bd6970a6313e41acbd194134333682fcbb Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 7 Jun 2023 12:47:30 +0200 Subject: [PATCH 1/3] SidebarFilterTest fixed --- src/pages/home/sidebar/SidebarLinks.js | 4 ++-- tests/unit/SidebarFilterTest.js | 2 +- tests/unit/SidebarTest.js | 2 +- tests/utils/LHNTestUtils.js | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/home/sidebar/SidebarLinks.js b/src/pages/home/sidebar/SidebarLinks.js index bb790aad74fe..eb5f9efb85a2 100644 --- a/src/pages/home/sidebar/SidebarLinks.js +++ b/src/pages/home/sidebar/SidebarLinks.js @@ -262,10 +262,10 @@ const chatReportSelector = (report) => const personalDetailsSelector = (personalDetails) => _.reduce( personalDetails, - (finalPersonalDetails, personalData, login) => { + (finalPersonalDetails, personalData, accountID) => { // It's OK to do param-reassignment in _.reduce() because we absolutely know the starting state of finalPersonalDetails // eslint-disable-next-line no-param-reassign - finalPersonalDetails[login] = { + finalPersonalDetails[accountID] = { login: personalData.login, displayName: personalData.displayName, firstName: personalData.firstName, diff --git a/tests/unit/SidebarFilterTest.js b/tests/unit/SidebarFilterTest.js index 1cdaf9881c6e..f79b5e2f2ddd 100644 --- a/tests/unit/SidebarFilterTest.js +++ b/tests/unit/SidebarFilterTest.js @@ -11,7 +11,7 @@ import * as Localize from '../../src/libs/Localize'; jest.mock('../../src/libs/Permissions'); const ONYXKEYS = { - PERSONAL_DETAILS: 'personalDetails', + PERSONAL_DETAILS_LIST: 'personalDetailsList', NVP_PRIORITY_MODE: 'nvp_priorityMode', SESSION: 'session', BETAS: 'betas', diff --git a/tests/unit/SidebarTest.js b/tests/unit/SidebarTest.js index 566ba8ba2734..9b5b021341ac 100644 --- a/tests/unit/SidebarTest.js +++ b/tests/unit/SidebarTest.js @@ -11,7 +11,7 @@ jest.mock('../../src/libs/Permissions'); jest.mock('../../src/components/Icon/Expensicons'); const ONYXKEYS = { - PERSONAL_DETAILS: 'personalDetails', + PERSONAL_DETAILS_LIST: 'personalDetailsList', NVP_PRIORITY_MODE: 'nvp_priorityMode', SESSION: 'session', BETAS: 'betas', diff --git a/tests/utils/LHNTestUtils.js b/tests/utils/LHNTestUtils.js index fbb273d76c5e..601b14487b4c 100644 --- a/tests/utils/LHNTestUtils.js +++ b/tests/utils/LHNTestUtils.js @@ -95,12 +95,12 @@ let lastFakeReportID = 0; let lastFakeReportActionID = 0; /** - * @param {String[]} participants + * @param {Number[]} participants * @param {Number} millisecondsInThePast the number of milliseconds in the past for the last message timestamp (to order reports by most recent messages) * @param {boolean} isUnread * @returns {Object} */ -function getFakeReport(participants = ['email1@test.com', 'email2@test.com'], millisecondsInThePast = 0, isUnread = false) { +function getFakeReport(participants = [1, 2], millisecondsInThePast = 0, isUnread = false) { const lastVisibleActionCreated = DateUtils.getDBTime(Date.now() - millisecondsInThePast); return { type: CONST.REPORT.TYPE.CHAT, From d547dab2f763890197ee37ba031ca26de401189b Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 7 Jun 2023 13:02:55 +0200 Subject: [PATCH 2/3] SidebarOrderTest fixed --- tests/unit/SidebarOrderTest.js | 92 +++++++++++++++++----------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/tests/unit/SidebarOrderTest.js b/tests/unit/SidebarOrderTest.js index 544a04e2a793..b2072f66ed03 100644 --- a/tests/unit/SidebarOrderTest.js +++ b/tests/unit/SidebarOrderTest.js @@ -75,7 +75,7 @@ describe('Sidebar', () => { it('contains one report when a report is in Onyx', () => { // Given a single report - const report = LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com']); + const report = LHNTestUtils.getFakeReport([1, 2]); LHNTestUtils.getDefaultRenderedSidebarLinks(report.reportID); return ( @@ -101,13 +101,13 @@ describe('Sidebar', () => { // Given three unread reports in the recently updated order of 3, 2, 1 const report1 = { - ...LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com'], 3), + ...LHNTestUtils.getFakeReport([1, 2], 3), }; const report2 = { - ...LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com'], 2), + ...LHNTestUtils.getFakeReport([3, 4], 2), }; const report3 = { - ...LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com'], 1), + ...LHNTestUtils.getFakeReport([5, 6], 1), }; return ( @@ -140,11 +140,11 @@ describe('Sidebar', () => { // And the first report has a draft // And the currently viewed report is the first report const report1 = { - ...LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com'], 3), + ...LHNTestUtils.getFakeReport([1, 2], 3), hasDraft: true, }; - const report2 = LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com'], 2); - const report3 = LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com'], 1); + const report2 = LHNTestUtils.getFakeReport([3, 4], 2); + const report3 = LHNTestUtils.getFakeReport([5, 6], 1); const reportIDFromRoute = report1.reportID; LHNTestUtils.getDefaultRenderedSidebarLinks(reportIDFromRoute); return ( @@ -180,9 +180,9 @@ describe('Sidebar', () => { LHNTestUtils.getDefaultRenderedSidebarLinks(); // Given three reports in the recently updated order of 3, 2, 1 - const report1 = LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com'], 3); - const report2 = LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com'], 2); - const report3 = LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com'], 1); + const report1 = LHNTestUtils.getFakeReport([1, 2], 3); + const report2 = LHNTestUtils.getFakeReport([3, 4], 2); + const report3 = LHNTestUtils.getFakeReport([5, 6], 1); return ( waitForPromisesToResolve() @@ -221,12 +221,12 @@ describe('Sidebar', () => { // Given three reports in the recently updated order of 3, 2, 1 // And the second report has a draft // And the currently viewed report is the second report - const report1 = LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com'], 3); + const report1 = LHNTestUtils.getFakeReport([1, 2], 3); const report2 = { - ...LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com'], 2), + ...LHNTestUtils.getFakeReport([3, 4], 2), hasDraft: true, }; - const report3 = LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com'], 1); + const report3 = LHNTestUtils.getFakeReport([5, 6], 1); const reportIDFromRoute = report2.reportID; LHNTestUtils.getDefaultRenderedSidebarLinks(reportIDFromRoute); @@ -270,7 +270,7 @@ describe('Sidebar', () => { // Given a single report // And the report has a draft const report = { - ...LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com']), + ...LHNTestUtils.getFakeReport([1, 2]), hasDraft: true, }; @@ -306,7 +306,7 @@ describe('Sidebar', () => { // Given a single report // And the report is pinned const report = { - ...LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com']), + ...LHNTestUtils.getFakeReport([1, 2]), isPinned: true, }; @@ -342,22 +342,22 @@ describe('Sidebar', () => { // with a report that has a draft, a report that is pinned, and // an outstanding IOU report that doesn't belong to the current user const report1 = { - ...LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com'], 3), + ...LHNTestUtils.getFakeReport([1, 2], 3), isPinned: true, }; const report2 = { - ...LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com'], 2), + ...LHNTestUtils.getFakeReport([3, 4], 2), hasDraft: true, }; const report3 = { - ...LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com'], 1), + ...LHNTestUtils.getFakeReport([5, 6], 1), hasOutstandingIOU: true, // This has to be added after the IOU report is generated iouReportID: null, }; const iouReport = { - ...LHNTestUtils.getFakeReport(['email7@test.com', 'email8@test.com']), + ...LHNTestUtils.getFakeReport([7, 8]), type: CONST.REPORT.TYPE.IOU, ownerEmail: 'email2@test.com', managerEmail: 'email2@test.com', @@ -407,19 +407,19 @@ describe('Sidebar', () => { // Given three reports in the recently updated order of 3, 2, 1 // and they are all pinned const report1 = { - ...LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com'], 3), + ...LHNTestUtils.getFakeReport([1, 2], 3), isPinned: true, }; const report2 = { - ...LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com'], 2), + ...LHNTestUtils.getFakeReport([3, 4], 2), isPinned: true, }; const report3 = { - ...LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com'], 1), + ...LHNTestUtils.getFakeReport([5, 6], 1), isPinned: true, }; const report4 = { - ...LHNTestUtils.getFakeReport(['email7@test.com', 'email8@test.com'], 0), + ...LHNTestUtils.getFakeReport([7, 8], 0), isPinned: true, }; LHNTestUtils.getDefaultRenderedSidebarLinks('0'); @@ -466,19 +466,19 @@ describe('Sidebar', () => { // Given three reports in the recently updated order of 3, 2, 1 // and they all have drafts const report1 = { - ...LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com'], 3), + ...LHNTestUtils.getFakeReport([1, 2], 3), hasDraft: true, }; const report2 = { - ...LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com'], 2), + ...LHNTestUtils.getFakeReport([3, 4], 2), hasDraft: true, }; const report3 = { - ...LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com'], 1), + ...LHNTestUtils.getFakeReport([5, 6], 1), hasDraft: true, }; const report4 = { - ...LHNTestUtils.getFakeReport(['email7@test.com', 'email8@test.com'], 0), + ...LHNTestUtils.getFakeReport([7, 8], 0), hasDraft: true, }; LHNTestUtils.getDefaultRenderedSidebarLinks('0'); @@ -524,13 +524,13 @@ describe('Sidebar', () => { it('puts archived chats last', () => { // Given three reports, with the first report being archived const report1 = { - ...LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com']), + ...LHNTestUtils.getFakeReport([1, 2]), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, statusNum: CONST.REPORT.STATUS.CLOSED, stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, }; - const report2 = LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com']); - const report3 = LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com']); + const report2 = LHNTestUtils.getFakeReport([3, 4]); + const report3 = LHNTestUtils.getFakeReport([5, 6]); // Given the user is in all betas const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT]; @@ -566,10 +566,10 @@ describe('Sidebar', () => { it('alphabetizes chats', () => { LHNTestUtils.getDefaultRenderedSidebarLinks(); - const report1 = LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com'], 3, true); - const report2 = LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com'], 2, true); - const report3 = LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com'], 1, true); - const report4 = LHNTestUtils.getFakeReport(['email7@test.com', 'email8@test.com'], 0, true); + const report1 = LHNTestUtils.getFakeReport([1, 2], 3, true); + const report2 = LHNTestUtils.getFakeReport([3, 4], 2, true); + const report3 = LHNTestUtils.getFakeReport([5, 6], 1, true); + const report4 = LHNTestUtils.getFakeReport([7, 8], 0, true); return ( waitForPromisesToResolve() @@ -614,13 +614,13 @@ describe('Sidebar', () => { it('puts archived chats last', () => { // Given three unread reports, with the first report being archived const report1 = { - ...LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com'], 3, true), + ...LHNTestUtils.getFakeReport([1, 2], 3, true), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, statusNum: CONST.REPORT.STATUS.CLOSED, stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, }; - const report2 = LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com'], 2, true); - const report3 = LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com'], 1, true); + const report2 = LHNTestUtils.getFakeReport([3, 4], 2, true); + const report3 = LHNTestUtils.getFakeReport([5, 6], 1, true); // Given the user is in all betas const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT]; @@ -654,28 +654,28 @@ describe('Sidebar', () => { it('orders IOU reports by displayName if amounts are the same', () => { // Given three IOU reports containing the same IOU amounts const report1 = { - ...LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com']), + ...LHNTestUtils.getFakeReport([1, 2]), hasOutstandingIOU: true, // This has to be added after the IOU report is generated iouReportID: null, }; const report2 = { - ...LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com']), + ...LHNTestUtils.getFakeReport([3, 4]), hasOutstandingIOU: true, // This has to be added after the IOU report is generated iouReportID: null, }; const report3 = { - ...LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com']), + ...LHNTestUtils.getFakeReport([5, 6]), hasOutstandingIOU: true, // This has to be added after the IOU report is generated iouReportID: null, }; const iouReport1 = { - ...LHNTestUtils.getFakeReport(['email7@test.com', 'email8@test.com']), + ...LHNTestUtils.getFakeReport([7, 8]), type: CONST.REPORT.TYPE.IOU, ownerEmail: 'email2@test.com', managerEmail: 'email2@test.com', @@ -685,7 +685,7 @@ describe('Sidebar', () => { chatReportID: report3.reportID, }; const iouReport2 = { - ...LHNTestUtils.getFakeReport(['email9@test.com', 'email10@test.com']), + ...LHNTestUtils.getFakeReport([9, 10]), type: CONST.REPORT.TYPE.IOU, ownerEmail: 'email2@test.com', managerEmail: 'email2@test.com', @@ -695,7 +695,7 @@ describe('Sidebar', () => { chatReportID: report3.reportID, }; const iouReport3 = { - ...LHNTestUtils.getFakeReport(['email11@test.com', 'email12@test.com']), + ...LHNTestUtils.getFakeReport([11, 12]), type: CONST.REPORT.TYPE.IOU, ownerEmail: 'email2@test.com', managerEmail: 'email2@test.com', @@ -746,15 +746,15 @@ describe('Sidebar', () => { // Given three nonArchived reports created at the same time const lastVisibleActionCreated = DateUtils.getDBTime(); const report1 = { - ...LHNTestUtils.getFakeReport(['email1@test.com', 'email2@test.com']), + ...LHNTestUtils.getFakeReport([1, 2]), lastVisibleActionCreated, }; const report2 = { - ...LHNTestUtils.getFakeReport(['email3@test.com', 'email4@test.com']), + ...LHNTestUtils.getFakeReport([3, 4]), lastVisibleActionCreated, }; const report3 = { - ...LHNTestUtils.getFakeReport(['email5@test.com', 'email6@test.com']), + ...LHNTestUtils.getFakeReport([5, 6]), lastVisibleActionCreated, }; From 588cb20b4ea3d0d8d645dbed5f515da9527bca03 Mon Sep 17 00:00:00 2001 From: burczu Date: Wed, 7 Jun 2023 14:44:55 +0200 Subject: [PATCH 3/3] JSDoc fixed --- src/libs/UserUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/UserUtils.js b/src/libs/UserUtils.js index 776ff45318ec..2a4cac33ebf1 100644 --- a/src/libs/UserUtils.js +++ b/src/libs/UserUtils.js @@ -97,7 +97,7 @@ function getDefaultAvatar(accountID = -1) { /** * Helper method to return default avatar URL associated with login * - * @param {String} [login] + * @param {String} [accountID] * @param {Boolean} [isNewDot] * @returns {String} */