[No QA]Method to generate default workspace name#10563
Conversation
thienlnam
left a comment
There was a problem hiding this comment.
Looking solid - we are missing a check for multiples though
For example, if you already have a policy name
My Group Workspace, creating another default one should be My Group Workspace 1
|
Updated and awaiting another review |
| @@ -1,104 +1,65 @@ | |||
| import * as Policy from '../../src/libs/actions/Policy'; | |||
|
|
|||
There was a problem hiding this comment.
can you not just create a variable here called allPolicies that would have the policy details that it would grab from? Haven't tried this yet so not sure though
There was a problem hiding this comment.
This wouldn't work. I went ahead and added a second parameter to the method, which is passed down from the tests
There was a problem hiding this comment.
There should be a way to mock local variables in jest from this brief google search - maybe setting this.allPolicies or window.allPolicies?
We don't want to adjust the code just so that we can pass testing parameters through it
thienlnam
left a comment
There was a problem hiding this comment.
If it's too difficult to add tests right now, we can create a separate PR later that adds them back
| * @param {Array} polices | ||
| * @returns {String} | ||
| */ | ||
| function generateDefaultWorkspaceName(email, polices = null) { |
There was a problem hiding this comment.
Actually, the preference is that we don't need to pass any parameters at all. This makes it so that wherever we call this method we need to connect to onyx to get all policies and the session email
| let userPolicies = null; | ||
| if (!polices) { | ||
| userPolicies = allPolicies; | ||
| } else { | ||
| userPolicies = polices; | ||
| } |
There was a problem hiding this comment.
Hmm, we don't want this code since it is just specific to tests
| @@ -1,104 +1,65 @@ | |||
| import * as Policy from '../../src/libs/actions/Policy'; | |||
|
|
|||
There was a problem hiding this comment.
There should be a way to mock local variables in jest from this brief google search - maybe setting this.allPolicies or window.allPolicies?
We don't want to adjust the code just so that we can pass testing parameters through it
thienlnam
left a comment
There was a problem hiding this comment.
Everything else looks good, did you merge main?
| /** | ||
| * Checks if we have any errors stored within the POLICY_MEMBER_LIST. Determines whether we should show a red brick road error or not | ||
| * Data structure: {email: {role:'bla', errors: []}, email2: {role:'bla', errors: [{1231312313: 'Unable to do X'}]}, ...} | ||
| * @param {Object} policyMemberList | ||
| * @returns {Boolean} | ||
| */ | ||
| function hasPolicyMemberError(policyMemberList) { | ||
| return _.some(policyMemberList, member => !_.isEmpty(member.errors)); | ||
| } |
There was a problem hiding this comment.
How are these showing as your new changes? 😮
There was a problem hiding this comment.
Because there was a merge conflict
thienlnam
left a comment
There was a problem hiding this comment.
You should actually be removing those changes since it does not exist in that file on main anymore
|
cc @MonilBhavsar could we please get a review here? |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
| * @param {String} value | ||
| * @returns {String} | ||
| */ | ||
| function capitalizeFirstLetter(value) { |
There was a problem hiding this comment.
It does not really feel like this function belongs here.. more importantly, this function already exists: https://github.com/Expensify/expensify-common/blob/main/lib/str.js#L327 -- please change the code to use that instead 🙇
There was a problem hiding this comment.
This PR was created to remove the out of place method
|
🚀 Deployed to staging by @MonilBhavsar in version: 1.1.95-0 🚀
|
Details
Fixed Issues
$https://github.com/Expensify/Expensify/issues/224684
Tests
PR Review Checklist
PR Reviewer Checklist
The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick).src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarhave been tested & I retested again)/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)QA Steps
Screenshots
N/A
Web
N/A
Mobile Web
N/A
Desktop
N/A
iOS
N/A
Android
N/A