Skip to content
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

Use new UpdatePolicyRoomName api command #10237

Merged
merged 36 commits into from
Aug 15, 2022
Merged

Conversation

neil-marcellini
Copy link
Contributor

@neil-marcellini neil-marcellini commented Aug 3, 2022

cc @marcaaron

Details

Use the refactored UpdatePolicyRoomName api command, add offline feedback, and add RBR indicators. The RBR indicators probably won't be used because it is very unlikely that there will be errors from this command since there is front end validation.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/212892

Tests

A. Basic rename

  1. Sign in with any account
  2. Create a workspace from the green plus (if needed)
  3. Create a workspace room from the green plus (if needed)
  4. Click the header of the workspace room to open the room details page
  5. Click "Settings"
  6. Rename the room and hit save
  7. Verify that the room name updates correctly

B. Offline tests

  1. Go offline
  2. Update the room name again with a different name
  3. Verify that the input is grayed out
  4. Go back online
  5. Verify that the input is no longer grayed out

C. RBR tests

  1. Comment out these lines so that you can enter a duplicate room name
  2. if (ValidationUtils.isExistingRoomName(this.state.newRoomName, this.props.reports, this.props.report.policyID) && this.state.newRoomName !== this.props.report.reportName) {
    errors.newRoomName = this.props.translate('newRoomPage.roomAlreadyExistsError');
    }
  3. Create another room with a different name
  4. Click the header of the workspace room to open the room details page
  5. Click "Settings"
  6. Rename the room to a room name that already exists and hit save
  7. Verify that a red dot, error message, and X button appear under the room name
  8. Go back from settings and verify that a red dot shows on the settings menu item
  9. Close the room details
  10. Verify that there is a red dot on the room header and and in the LHN.
  11. Open the room settings again
  12. Dismiss the error by clicking the X
  13. Verify that the room name reverts to the previous name and that all the red dots no longer show
  • Verify that no errors appear in the JS console

PR Review Checklist

Contributor (PR Author) Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

PR Reviewer Checklist

The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

QA Steps

Tests A and B from above.

  • Verify that no errors appear in the JS console

Screenshots

Web

Offline

RBR


Mobile Web

Desktop

iOS

Android

@neil-marcellini neil-marcellini self-assigned this Aug 3, 2022
src/libs/actions/Report.js Outdated Show resolved Hide resolved
src/libs/actions/Report.js Outdated Show resolved Hide resolved
@neil-marcellini
Copy link
Contributor Author

I'm holding on #10317 so I can use the util function getBrickRoadIndicatorStatusForReport. I'll help review that and get it merged.

@marcaaron
Copy link
Contributor

Just a heads up that #10317 is merged now

@neil-marcellini
Copy link
Contributor Author

Yep, thanks for getting that merged in. I will try to finish this off soon.

@@ -132,11 +132,11 @@ const MenuItem = props => (
</Text>
</View>
)}
{props.brickRoadIndicator && (
{Boolean(props.brickRoadIndicator) && (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Treat this as a boolean in case it's an empty string.

brickRoadIndicator: PropTypes.oneOf(['error']),
/** If we need to show a brick road indicator or not. For now only value allowed is 'error' or '',
* but we will add 'success' later for manual requests */
brickRoadIndicator: PropTypes.oneOf([CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR, '']),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The empty string is the empty value so that functions that get the brick road indicator property can always return a string.

@neil-marcellini
Copy link
Contributor Author

Here's an alternative option for RBR / Offline feedback for the room name input. Although I like how the save button isn't grayed out while offline I think the error message looks bad. However, the error would be very rare.
image

@@ -91,6 +95,7 @@ class RoomNameInput extends Component {
render() {
return (
<TextInput
ref={this.props.forwardedRef}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a ref so the input value can be cleared from the parent.

@neil-marcellini
Copy link
Contributor Author

The errors were not looking good on iOS because the error text was taking up the full height due to flex1 and therefore it was not centered.

Before

After

Before

After

@neil-marcellini
Copy link
Contributor Author

Ok, ready for another review please! Also, cc @Expensify/design to make sure it looks good.

Copy link
Contributor

@marcochavezf marcochavezf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a few comments 👍🏽

src/pages/ReportDetailsPage.js Outdated Show resolved Hide resolved
src/libs/actions/Report.js Show resolved Hide resolved
@melvin-bot
Copy link

melvin-bot bot commented Aug 15, 2022

Looks like you modified deprecatedAPI.js! To be clear, you should not be adding any code to this file.

Instead, all new API commands should use API.js, and follow our guidelines for writing new API commands.

Unsure if your change is okay? Drop a note in #expensify-open-source!

@neil-marcellini
Copy link
Contributor Author

Ready for another round of reviews.

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Spotted a small improvement.

src/pages/ReportDetailsPage.js Outdated Show resolved Hide resolved
@marcochavezf marcochavezf merged commit a9c6f04 into main Aug 15, 2022
@marcochavezf marcochavezf deleted the neil-UpdatePolicyRoomName branch August 15, 2022 18:26
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@marcaaron
Copy link
Contributor

Oh hmm did this need to HOLD on the production web deploy? The command we are calling doesn't exist yet 🙃

@marcaaron
Copy link
Contributor

Looks like it is still on staging (we are probably OK as long as the production deploy goes out before the App deploy) but probably should have been on HOLD.

@neil-marcellini
Copy link
Contributor Author

Yeah true. I think it's fairly likely that the Web deploy will be done first. Is there anything I can do to make sure that happens?

@marcaaron
Copy link
Contributor

I think the easiest would be to put a deploy blocker label on this PR or the linked issue when it goes to staging. Not sure about the timing on that. In theory, QA should test this and it should fail QA if Web-Expensify is not deployed to production.

@neil-marcellini neil-marcellini added DeployBlockerCash This issue or pull request should block deployment and removed DeployBlockerCash This issue or pull request should block deployment labels Aug 15, 2022
@francoisl
Copy link
Contributor

https://github.com/Expensify/Web-Expensify/pull/34501 just hit production, going to remove the deploy blocker label.

@francoisl francoisl added DeployBlockerCash This issue or pull request should block deployment and removed DeployBlockerCash This issue or pull request should block deployment labels Aug 15, 2022
@neil-marcellini
Copy link
Contributor Author

Ha sorry I was just about to say that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants