From 10d5bcf47c9d2192ba01b634df38fbb0b7db6e5c Mon Sep 17 00:00:00 2001 From: K4tsuki <1313124+K4tsuki@users.noreply.github.com> Date: Tue, 21 Dec 2021 14:05:53 +0700 Subject: [PATCH 01/10] Update gsd focus mode test unit --- tests/unit/OptionsListUtilsTest.js | 59 +++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index df981f3631d5..5bc0a848a006 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -188,6 +188,28 @@ describe('OptionsListUtils', () => { unreadActionCount: 1, }, }; + + const REPORTS_WITH_MORE_PINS = { + ...REPORTS, + 10: { + lastVisitedTimestamp: 1610666739302, + lastMessageTimestamp: 1, + isPinned: true, + reportID: 10, + participants: ['d_email@email.com'], + reportName: 'D report name', + unreadActionCount: 0, + }, + 11: { + lastVisitedTimestamp: 1610666732302, + lastMessageTimestamp: 1, + isPinned: true, + reportID: 11, + participants: ['z_email@email.com'], + reportName: 'Z Report Name', + unreadActionCount: 0, + }, + }; const PERSONAL_DETAILS_WITH_CONCIERGE = { ...PERSONAL_DETAILS, @@ -597,23 +619,42 @@ describe('OptionsListUtils', () => { () => Report.setReportWithDraft(1, true) .then(() => { // When we call getSidebarOptions() with no search value - const results = OptionsListUtils.getSidebarOptions(REPORTS, PERSONAL_DETAILS, 0, CONST.PRIORITY_MODE.GSD); + const results = OptionsListUtils.getSidebarOptions(REPORTS_WITH_MORE_PINS, PERSONAL_DETAILS_WITH_MORE_PINS, 0, CONST.PRIORITY_MODE.GSD); + //const results = OptionsListUtils.getSidebarOptions(REPORTS_WITH_MORE_PINNED, PERSONAL_DETAILS, 0, CONST.PRIORITY_MODE.GSD); // Then expect all of the reports to be shown both multiple and single participant except the // report that has no lastMessageTimestamp and the chat with Thor who's message is read - expect(results.recentReports.length).toBe(_.size(REPORTS) - 2); + expect(results.recentReports.length).toBe(_.size(REPORTS_WITH_MORE_PINS) - 2); // That no personalDetails are shown expect(results.personalDetails.length).toBe(0); - // And Mister Fantastic is alphabetically the fourth report and has an unread message - // despite being pinned - expect(results.recentReports[4].login).toBe('reedrichards@expensify.com'); - // And Black Panther is alphabetically the first report and has an unread message - expect(results.recentReports[0].login).toBe('tchalla@expensify.com'); + //------------------- Pinned report--------- + // Pinned reports always on top regardless of having unread message or not + // and regardless having IOU debt or not + // ordered by alphabetical order. + // D report name (Alphabetically first among pinned tabs) + expect(results.recentReports[0].login).toBe('d_email@email'); + + // Mister Fantastic report name (Alphabetically second among pinned tabs) + expect(results.recentReports[1].login).toBe('reedrichards@expensify.com'); + + // Z report name (Alphabetically third among pinned tabs) + expect(results.recentReports[2].login).toBe('z_email@email'); + + //------------ Unpinned reports ------------ + // Unpinned report name ordered alphabetically after pinned report + //Black Panther report name + expect(results.recentReports[3].login).toBe('tchalla@expensify.com'); + + //Captain America report name + expect(results.recentReports[4].login).toBe('steverogers@expensify.com'); + + //Invisible woman report name. Has an IOU debt. + expect(results.recentReports[5].login).toBe('suestorm@expensify.com'); - // And Mister Sinister is alphabetically the fifth report and has an IOU debt despite not being pinned - expect(results.recentReports[5].login).toBe('mistersinister@marauders.com'); + //Spider-Man report name is last report + expect(results.recentReports[8].login).toBe('peterparker@expensify.com'); })); }); From 4bbbdd7a2e543896ad2c76257f6837f9896d7065 Mon Sep 17 00:00:00 2001 From: K4tsuki <1313124+K4tsuki@users.noreply.github.com> Date: Tue, 21 Dec 2021 14:09:31 +0700 Subject: [PATCH 02/10] Prioritize pinned rooms on gsd mode --- src/libs/OptionsListUtils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index e8c17a932ef9..1c20a27a9c5e 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -686,6 +686,7 @@ function getSidebarOptions( }; if (priorityMode === CONST.PRIORITY_MODE.GSD) { sideBarOptions = { + prioritizePinnedReports: true, hideReadReports: true, sortByAlphaAsc: true, }; From 8b108f66aa4e546971ef7e74e164adc0da87dc1b Mon Sep 17 00:00:00 2001 From: K4tsuki <1313124+K4tsuki@users.noreply.github.com> Date: Tue, 21 Dec 2021 14:14:36 +0700 Subject: [PATCH 03/10] cleaning on unit OptionUtils unit test --- tests/unit/OptionsListUtilsTest.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index 5bc0a848a006..8545c7dc2905 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -619,8 +619,7 @@ describe('OptionsListUtils', () => { () => Report.setReportWithDraft(1, true) .then(() => { // When we call getSidebarOptions() with no search value - const results = OptionsListUtils.getSidebarOptions(REPORTS_WITH_MORE_PINS, PERSONAL_DETAILS_WITH_MORE_PINS, 0, CONST.PRIORITY_MODE.GSD); - //const results = OptionsListUtils.getSidebarOptions(REPORTS_WITH_MORE_PINNED, PERSONAL_DETAILS, 0, CONST.PRIORITY_MODE.GSD); + const results = OptionsListUtils.getSidebarOptions(REPORTS_WITH_MORE_PINS, PERSONAL_DETAILS, 0, CONST.PRIORITY_MODE.GSD); // Then expect all of the reports to be shown both multiple and single participant except the // report that has no lastMessageTimestamp and the chat with Thor who's message is read From b01046b98053e4906dfc95aba6342bd67cfa2045 Mon Sep 17 00:00:00 2001 From: K4tsuki <1313124+K4tsuki@users.noreply.github.com> Date: Wed, 22 Dec 2021 07:07:55 +0700 Subject: [PATCH 04/10] Fix email --- tests/unit/OptionsListUtilsTest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index 8545c7dc2905..3944e1dadcb2 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -634,13 +634,13 @@ describe('OptionsListUtils', () => { // and regardless having IOU debt or not // ordered by alphabetical order. // D report name (Alphabetically first among pinned tabs) - expect(results.recentReports[0].login).toBe('d_email@email'); + expect(results.recentReports[0].login).toBe('d_email@email.com'); // Mister Fantastic report name (Alphabetically second among pinned tabs) expect(results.recentReports[1].login).toBe('reedrichards@expensify.com'); // Z report name (Alphabetically third among pinned tabs) - expect(results.recentReports[2].login).toBe('z_email@email'); + expect(results.recentReports[2].login).toBe('z_email@email.com'); //------------ Unpinned reports ------------ // Unpinned report name ordered alphabetically after pinned report From 89b132700da608b2daf521886426efc942507afd Mon Sep 17 00:00:00 2001 From: K4tsuki <1313124+K4tsuki@users.noreply.github.com> Date: Wed, 22 Dec 2021 22:49:07 +0700 Subject: [PATCH 05/10] Add pprioritize pinned reports on getSidebarOption --- src/libs/OptionsListUtils.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 1c20a27a9c5e..cf0367762f5d 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -680,13 +680,11 @@ function getSidebarOptions( betas, ) { let sideBarOptions = { - prioritizePinnedReports: true, prioritizeIOUDebts: true, prioritizeReportsWithDraftComments: true, }; if (priorityMode === CONST.PRIORITY_MODE.GSD) { sideBarOptions = { - prioritizePinnedReports: true, hideReadReports: true, sortByAlphaAsc: true, }; @@ -699,6 +697,7 @@ function getSidebarOptions( maxRecentReportsToShow: 0, // Unlimited sortByLastMessageTimestamp: true, showChatPreviewLine: true, + prioritizePinnedReports: true, ...sideBarOptions, }); } From 40a5d1915c0ea3d811de92473a6a8d3703232333 Mon Sep 17 00:00:00 2001 From: K4tsuki <1313124+K4tsuki@users.noreply.github.com> Date: Wed, 22 Dec 2021 23:17:47 +0700 Subject: [PATCH 06/10] Add IOU debt report test on gsd mode --- tests/unit/OptionsListUtilsTest.js | 31 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index 3944e1dadcb2..ae4626a8060f 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -191,20 +191,20 @@ describe('OptionsListUtils', () => { const REPORTS_WITH_MORE_PINS = { ...REPORTS, - 10: { + 13: { lastVisitedTimestamp: 1610666739302, lastMessageTimestamp: 1, isPinned: true, - reportID: 10, + reportID: 13, participants: ['d_email@email.com'], reportName: 'D report name', unreadActionCount: 0, }, - 11: { + 14: { lastVisitedTimestamp: 1610666732302, lastMessageTimestamp: 1, isPinned: true, - reportID: 11, + reportID: 14, participants: ['z_email@email.com'], reportName: 'Z Report Name', unreadActionCount: 0, @@ -630,30 +630,31 @@ describe('OptionsListUtils', () => { //------------------- Pinned report--------- - // Pinned reports always on top regardless of having unread message or not - // and regardless having IOU debt or not - // ordered by alphabetical order. - // D report name (Alphabetically first among pinned tabs) + // Pinned reports are always on the top in alphabetical order regardless of whether they are unread or have IOU debt. + // D report name (Alphabetically first among pinned reports) expect(results.recentReports[0].login).toBe('d_email@email.com'); - // Mister Fantastic report name (Alphabetically second among pinned tabs) + // Mister Fantastic report name (Alphabetically second among pinned reports) expect(results.recentReports[1].login).toBe('reedrichards@expensify.com'); - // Z report name (Alphabetically third among pinned tabs) + // Z report name (Alphabetically third among pinned reports) expect(results.recentReports[2].login).toBe('z_email@email.com'); //------------ Unpinned reports ------------ - // Unpinned report name ordered alphabetically after pinned report - //Black Panther report name + // Unpinned report name ordered alphabetically after pinned reports + //Black Panther report name has unread message expect(results.recentReports[3].login).toBe('tchalla@expensify.com'); - //Captain America report name + //Captain America report name has unread message expect(results.recentReports[4].login).toBe('steverogers@expensify.com'); - //Invisible woman report name. Has an IOU debt. + //Invisible woman report name has unread message expect(results.recentReports[5].login).toBe('suestorm@expensify.com'); + + //Mister Sinister report name has IOU debt + expect(results.recentReports[7].login).toBe('mistersinister@marauders.com'); - //Spider-Man report name is last report + //Spider-Man report name is last report and has unread message expect(results.recentReports[8].login).toBe('peterparker@expensify.com'); })); }); From 52e78d0d16763b57375825b91acdff139bfdbdd9 Mon Sep 17 00:00:00 2001 From: K4tsuki <1313124+K4tsuki@users.noreply.github.com> Date: Wed, 22 Dec 2021 23:20:29 +0700 Subject: [PATCH 07/10] Update tests/unit/OptionsListUtilsTest.js Co-authored-by: Rajat Parashar --- tests/unit/OptionsListUtilsTest.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index ae4626a8060f..b29710c21f6d 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -640,7 +640,6 @@ describe('OptionsListUtils', () => { // Z report name (Alphabetically third among pinned reports) expect(results.recentReports[2].login).toBe('z_email@email.com'); - //------------ Unpinned reports ------------ // Unpinned report name ordered alphabetically after pinned reports //Black Panther report name has unread message expect(results.recentReports[3].login).toBe('tchalla@expensify.com'); From 59c82d964f99ab9829cdf6c30a583617c6d5782f Mon Sep 17 00:00:00 2001 From: K4tsuki <1313124+K4tsuki@users.noreply.github.com> Date: Wed, 22 Dec 2021 23:23:05 +0700 Subject: [PATCH 08/10] Remove comments --- tests/unit/OptionsListUtilsTest.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index b29710c21f6d..801362230022 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -628,8 +628,6 @@ describe('OptionsListUtils', () => { // That no personalDetails are shown expect(results.personalDetails.length).toBe(0); - - //------------------- Pinned report--------- // Pinned reports are always on the top in alphabetical order regardless of whether they are unread or have IOU debt. // D report name (Alphabetically first among pinned reports) expect(results.recentReports[0].login).toBe('d_email@email.com'); From b991b46f0125f95f7c7213220ee68ab2a10a56c8 Mon Sep 17 00:00:00 2001 From: Katsuki <1313124+K4tsuki@users.noreply.github.com> Date: Tue, 4 Jan 2022 10:28:11 +0700 Subject: [PATCH 09/10] fixing lint errors --- tests/unit/OptionsListUtilsTest.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.js b/tests/unit/OptionsListUtilsTest.js index 801362230022..a592199c179a 100644 --- a/tests/unit/OptionsListUtilsTest.js +++ b/tests/unit/OptionsListUtilsTest.js @@ -188,7 +188,7 @@ describe('OptionsListUtils', () => { unreadActionCount: 1, }, }; - + const REPORTS_WITH_MORE_PINS = { ...REPORTS, 13: { @@ -516,7 +516,6 @@ describe('OptionsListUtils', () => { ]), ); - // Test by excluding Chronos from the results results = OptionsListUtils.getNewChatOptions( REPORTS_WITH_CHRONOS, @@ -629,29 +628,29 @@ describe('OptionsListUtils', () => { expect(results.personalDetails.length).toBe(0); // Pinned reports are always on the top in alphabetical order regardless of whether they are unread or have IOU debt. - // D report name (Alphabetically first among pinned reports) + // D report name (Alphabetically first among pinned reports) expect(results.recentReports[0].login).toBe('d_email@email.com'); - - // Mister Fantastic report name (Alphabetically second among pinned reports) + + // Mister Fantastic report name (Alphabetically second among pinned reports) expect(results.recentReports[1].login).toBe('reedrichards@expensify.com'); - // Z report name (Alphabetically third among pinned reports) + // Z report name (Alphabetically third among pinned reports) expect(results.recentReports[2].login).toBe('z_email@email.com'); // Unpinned report name ordered alphabetically after pinned reports - //Black Panther report name has unread message + // Black Panther report name has unread message expect(results.recentReports[3].login).toBe('tchalla@expensify.com'); - //Captain America report name has unread message + // Captain America report name has unread message expect(results.recentReports[4].login).toBe('steverogers@expensify.com'); - //Invisible woman report name has unread message + // Invisible woman report name has unread message expect(results.recentReports[5].login).toBe('suestorm@expensify.com'); - - //Mister Sinister report name has IOU debt + + // Mister Sinister report name has IOU debt expect(results.recentReports[7].login).toBe('mistersinister@marauders.com'); - //Spider-Man report name is last report and has unread message + // Spider-Man report name is last report and has unread message expect(results.recentReports[8].login).toBe('peterparker@expensify.com'); })); }); From 0a78f61031255e1edd5df8eee63f6e09353af581 Mon Sep 17 00:00:00 2001 From: Katsuki <1313124+K4tsuki@users.noreply.github.com> Date: Thu, 6 Jan 2022 14:11:46 +0700 Subject: [PATCH 10/10] retrigger checks