-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56171 from FitseTLT/fix-self-dm-not-on-top-of-sea…
…rch-result Fix - Search - Self DM is removed from top of search list when email is fully typed out in query
- Loading branch information
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -388,6 +388,32 @@ describe('OptionsListUtils', () => { | |
}, | ||
}; | ||
|
||
const REPORTS_WITH_SELFDM: OnyxCollection<Report> = { | ||
16: { | ||
lastReadTime: '2021-01-14 11:25:39.302', | ||
lastVisibleActionCreated: '2022-11-22 03:26:02.022', | ||
isPinned: false, | ||
reportID: '16', | ||
participants: { | ||
2: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}, | ||
}, | ||
reportName: 'Expense Report', | ||
type: CONST.REPORT.TYPE.EXPENSE, | ||
}, | ||
17: { | ||
lastReadTime: '2021-01-14 11:25:39.302', | ||
lastVisibleActionCreated: '2022-11-22 03:26:02.022', | ||
isPinned: false, | ||
reportID: '17', | ||
participants: { | ||
2: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}, | ||
}, | ||
reportName: '', | ||
type: CONST.REPORT.TYPE.CHAT, | ||
chatType: CONST.REPORT.CHAT_TYPE.SELF_DM, | ||
}, | ||
}; | ||
|
||
const PERSONAL_DETAILS_WITH_CONCIERGE: PersonalDetailsList = { | ||
...PERSONAL_DETAILS, | ||
'999': { | ||
|
@@ -1090,6 +1116,19 @@ describe('OptionsListUtils', () => { | |
expect(filteredOptions.personalDetails.length).toBe(2); | ||
expect(matchingEntries.length).toBe(1); | ||
}); | ||
|
||
it('should order self dm always on top if the search matches with the self dm login', () => { | ||
const searchTerm = '[email protected]'; | ||
|
||
const OPTIONS_WITH_SELFDM = OptionsListUtils.createOptionList(PERSONAL_DETAILS, REPORTS_WITH_SELFDM); | ||
|
||
// When search term matches with self dm login | ||
const options = OptionsListUtils.getSearchOptions(OPTIONS_WITH_SELFDM, [CONST.BETAS.ALL]); | ||
const filteredOptions = OptionsListUtils.filterAndOrderOptions(options, searchTerm); | ||
|
||
// Then the self dm should be on top. | ||
expect(filteredOptions.recentReports.at(0)?.isSelfDM).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('canCreateOptimisticPersonalDetailOption', () => { | ||
|