-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the Recents and Contacts headers to the single-user participants page used in the Request Money and New Chat flows #2818
Changes from 3 commits
8e6e216
d484819
ba7c1c5
e41360a
2d825e6
43b5932
49426e7
8c05935
443b2b0
179d0c8
e38ae64
fe39481
103ebfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ class NewChatPage extends Component { | |
this.createNewChat = this.createNewChat.bind(this); | ||
|
||
const { | ||
recentReports, | ||
personalDetails, | ||
userToInvite, | ||
} = getNewChatOptions( | ||
|
@@ -64,6 +65,7 @@ class NewChatPage extends Component { | |
|
||
this.state = { | ||
searchValue: '', | ||
recentReports, | ||
personalDetails, | ||
userToInvite, | ||
}; | ||
|
@@ -77,6 +79,13 @@ class NewChatPage extends Component { | |
getSections() { | ||
const sections = []; | ||
|
||
sections.push({ | ||
title: this.props.translate('iou.recents'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we're using this String for non-IOU pages, I think it should be refactored to a different group. Could you move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I moved |
||
data: this.state.recentReports, | ||
shouldShow: this.state.recentReports.length > 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just changed the code. And I noticed that OptionsSelector ignores shouldShow condition but it requires it as prop. |
||
indexOffset: sections.reduce((prev, {data}) => prev + data.length, 0), | ||
}); | ||
|
||
sections.push({ | ||
title: this.props.translate('iou.contacts'), | ||
data: this.state.personalDetails, | ||
|
@@ -128,6 +137,7 @@ class NewChatPage extends Component { | |
onSelectRow={this.createNewChat} | ||
onChangeText={(searchValue = '') => { | ||
const { | ||
recentReports, | ||
personalDetails, | ||
userToInvite, | ||
} = getNewChatOptions( | ||
|
@@ -137,12 +147,12 @@ class NewChatPage extends Component { | |
); | ||
this.setState({ | ||
searchValue, | ||
recentReports, | ||
userToInvite, | ||
personalDetails, | ||
}); | ||
}} | ||
headerMessage={headerMessage} | ||
hideSectionHeaders | ||
disableArrowKeysActions | ||
hideAdditionalOptionStates | ||
forceTextUnreadStyle | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import _ from 'underscore'; | ||
import _, {result} from 'underscore'; | ||
import Onyx from 'react-native-onyx'; | ||
import * as OptionsListUtils from '../../src/libs/OptionsListUtils'; | ||
import ONYXKEYS from '../../src/ONYXKEYS'; | ||
|
@@ -199,17 +199,17 @@ describe('OptionsListUtils', () => { | |
// When we call getNewChatOptions() with no search value | ||
let results = OptionsListUtils.getNewChatOptions(REPORTS, PERSONAL_DETAILS, ''); | ||
|
||
// Then no reports should be returned, only personalDetails and all the personalDetails should be returned | ||
// minus the currently logged in user | ||
expect(results.recentReports.length).toBe(0); | ||
expect(results.personalDetails.length).toBe(_.size(PERSONAL_DETAILS) - 1); | ||
// We should expect maxmimum of 5 recent reports to be returned | ||
// minus the currently logged in user and recent reports count | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure that this is correct.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is two different things, no?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got inspired by getNewGroupOptions() test and I think this is correct There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it was previously two different comments that have been merged into one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code is fine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I meant here is that there should be two separate comments, but I think you have combined them into one.
I think it should say this:
Does that make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I refactored the commenting |
||
expect(results.recentReports.length).toBe(5); | ||
expect(results.personalDetails.length).toBe(_.size(PERSONAL_DETAILS) - 1 - 5); | ||
|
||
// Then the result which has an existing report should also have the reportID attached | ||
const personalDetailWithExistingReport = _.find( | ||
results.personalDetails, | ||
personalDetail => personalDetail.login === 'reedrichards@expensify.com', | ||
personalDetail => personalDetail.login === 'peterparker@expensify.com', | ||
Julesssss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
expect(personalDetailWithExistingReport.reportID).toBe(3); | ||
expect(personalDetailWithExistingReport.reportID).toBe(2); | ||
|
||
// When we provide a search value that does not match any personal details | ||
results = OptionsListUtils.getNewChatOptions(REPORTS, PERSONAL_DETAILS, 'magneto'); | ||
|
@@ -221,26 +221,27 @@ describe('OptionsListUtils', () => { | |
results = OptionsListUtils.getNewChatOptions(REPORTS, PERSONAL_DETAILS, 'peterparker@expensify.com'); | ||
|
||
// Then one option will be returned and it will be the correct option | ||
expect(results.personalDetails.length).toBe(1); | ||
expect(results.personalDetails[0].text).toBe('Spider-Man'); | ||
expect(results.recentReports.length).toBe(1); | ||
expect(results.recentReports[0].text).toBe('Spider-Man'); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should test both instead of replacing the old There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now I expect personalDetails to be empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Could we add that as a test case then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, here it is. |
||
// When we provide a search value that matches a partial display name or email | ||
results = OptionsListUtils.getNewChatOptions(REPORTS, PERSONAL_DETAILS, 'man'); | ||
|
||
// Then several options will be returned and they will be each have the search string in their email or name | ||
// even though the currently logged in user matches they should not show. | ||
expect(results.personalDetails.length).toBe(3); | ||
expect(results.personalDetails[0].text).toBe('Spider-Man'); | ||
expect(results.personalDetails[1].text).toBe('Invisible Woman'); | ||
expect(results.personalDetails[2].login).toBe('natasharomanoff@expensify.com'); | ||
expect(results.personalDetails.length).toBe(1); | ||
expect(results.recentReports.length).toBe(2); | ||
expect(results.personalDetails[0].login).toBe('natasharomanoff@expensify.com'); | ||
expect(results.recentReports[0].text).toBe('Invisible Woman'); | ||
expect(results.recentReports[1].text).toBe('Spider-Man'); | ||
|
||
// Test for Concierge's existence in chat options | ||
results = OptionsListUtils.getNewChatOptions(REPORTS_WITH_CONCIERGE, PERSONAL_DETAILS_WITH_CONCIERGE); | ||
|
||
// Concierge is included in the results by default and all the personalDetails should be returned | ||
// minus the currently logged in user | ||
expect(results.personalDetails.length).toBe(_.size(PERSONAL_DETAILS_WITH_CONCIERGE) - 1); | ||
expect(results.personalDetails).toEqual( | ||
// Concierge is included in the results by default. We should expect all the personalDetails to show | ||
// (minus the 5 that are already showing and the currently logged in user) | ||
expect(results.personalDetails.length).toBe(_.size(PERSONAL_DETAILS_WITH_CONCIERGE) - 1 - 5); | ||
expect(results.recentReports).toEqual( | ||
Julesssss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
expect.arrayContaining([ | ||
expect.objectContaining({login: 'concierge@expensify.com'}), | ||
]), | ||
|
@@ -250,7 +251,7 @@ describe('OptionsListUtils', () => { | |
results = OptionsListUtils.getNewChatOptions(REPORTS_WITH_CONCIERGE, PERSONAL_DETAILS_WITH_CONCIERGE, '', true); | ||
|
||
// All the personalDetails should be returned minus the currently logged in user and Concierge | ||
expect(results.personalDetails.length).toBe(_.size(PERSONAL_DETAILS_WITH_CONCIERGE) - 2); | ||
expect(results.personalDetails.length).toBe(_.size(PERSONAL_DETAILS_WITH_CONCIERGE) - 2 - 5); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5 is used quite a lot, can we add a test that returns less than 5 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kakajann can you create a var for 5, something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In this line, we are testing
Of course, I did add a file-level constant variable for maxRecentReports in my last push |
||
expect(results.personalDetails).not.toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({login: 'concierge@expensify.com'}), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted