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

Beta race fixes #4205

Merged
merged 5 commits into from
Jul 27, 2021
Merged

Beta race fixes #4205

merged 5 commits into from
Jul 27, 2021

Conversation

chiragsalian
Copy link
Contributor

@chiragsalian chiragsalian commented Jul 23, 2021

Details

Fixed Issues

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

Setup

  1. We'll want this to behave just like stag/prod so there are some setup steps.
  2. Remove isDevelopment from here. That line returns true really fast with isDevelopment so you can't test race conditions.
  3. Go to https://www.expensify.com.dev/_support/beta and add a test account to freePlan.
  4. Delete this block.
  5. If you really want to stretch the race condition update this line with,
setTimeout(() => Onyx.set(ONYXKEYS.BETAS, response.betas), 5000);

which is what I did while working on the code.

Tests

Testing workspace/new

  1. Go to Expensify App. While signed out visit http://localhost:8080/workspace/new.
  2. Enter your credentials.
  3. Once logged in confirm you see the workplace modal
    image

Testing pricing redirect.

  1. Logout of the Expensify App.
  2. Go to expensify.com.dev. Log into your test account then go to https://www.expensify.com.dev/pricing
  3. Select Free and confirm you see the workplace modal again
    image

QA Steps

Same steps as above except that you'll need to use an email that's on free plan beta.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Mobile Web

Desktop

iOS

Android

Sorry, something went wrong.

@chiragsalian chiragsalian self-assigned this Jul 23, 2021
@chiragsalian chiragsalian marked this pull request as ready for review July 23, 2021 23:40
@chiragsalian chiragsalian requested a review from a team as a code owner July 23, 2021 23:40
@MelvinBot MelvinBot requested review from alex-mechler and removed request for a team July 23, 2021 23:40
@Beamanator
Copy link
Contributor

Beamanator commented Jul 26, 2021

Testing steps for "Testing workspace/new" worked well 👍

While doing "Testing pricing redirect.", step 3 "Select Free and confirm you see the workplace modal again" I got this: [redacted image]

Rebuilt web-e w/ grunt and works well! 👍

Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

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

A few comments, nothing life-changing. Overall looks great 👍

@@ -39,7 +43,11 @@ class ValidateLoginNewWorkspacePage extends Component {
// by calling dismissModal(), the /v/... route is removed from history so the user will get taken to `/`
// if they cancel out of the new workspace modal.
Navigation.dismissModal();
Navigation.navigate(ROUTES.WORKSPACE_NEW);
if (this.props.betas) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to comment in other file - how do you feel about using lodashGet here (like below)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason to use lodashGet here imo since the proptype and default are provided. The other example of lodashGet makes sense because accountID and validateCode are not defined in the defaultParams.

Copy link
Contributor

Choose a reason for hiding this comment

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

True, but I did mention how session.authToken and session.accountID are in defaultProps and defaulted via lodashGet in the other component. But still I don't mind not using lodashGet here since this.props.betas is not nested in another onyx key 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah i'm not going to add it atm since I don't see its value.

Copy link
Contributor

@alex-mechler alex-mechler left a comment

Choose a reason for hiding this comment

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

Code LGTM, but I see a comment about potentially changing this up in the issue, so holding off on an approve

Copy link
Contributor

@TomatoToaster TomatoToaster left a comment

Choose a reason for hiding this comment

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

I think this PR is necessary and I left a comment in the original issue here why I think so.

Also had some suggestions for this PR lmk what you think.

@@ -62,7 +66,12 @@ class ValidateLogin2FANewWorkspacePage extends Component {
// by calling dismissModal(), the /v/... route is removed from history so the user will get taken to `/`
// if they cancel out of the new workspace modal.
Navigation.dismissModal();
Navigation.navigate(ROUTES.WORKSPACE_NEW);

if (this.props.betas) {
Copy link
Contributor

@TomatoToaster TomatoToaster Jul 26, 2021

Choose a reason for hiding this comment

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

If we are saving this behavior for the beta, why wouldn't we use

Suggested change
if (this.props.betas) {
if (Permissions.canUseFreePlan(this.props.betas)) {

And similarily for other parts referencing this.props.betas

Otherwise, aren't we saying this can be used by anyone? When betas load they'll be [] for those who aren't in any beta so the else part below here wouldn't run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well ROUTES.WORKSPACE_NEW already does the check for Permissions.canUseFreePlan so to keep the code DRY i think its best that the check for canUseFreePlan happens only in NewWorkSpace.js

Otherwise, aren't we saying this can be used by anyone? When betas load they'll be [] for those who aren't in any beta so the else part below here wouldn't run.

I didn't follow your question. Maybe this helps. The if condition determines if newWorkSpace component should render now or later. This take care of race conditions. If we have loaded betas, even if its empty, then we call Navigation.navigate(ROUTES.WORKSPACE_NEW); to render NewWorkSpace since there is no reason to wait. If betas is null, that means we're still waiting and hence we call setRedirectToWorkspaceNewAfterSignIn(true) so that once the betas are loaded (even if its empty) we call Navigation.navigate(ROUTES.WORKSPACE_NEW); at a later time over here. Does that make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh yes that totally makes sense. Thanks for exposing that!

@TomatoToaster
Copy link
Contributor

TomatoToaster commented Jul 26, 2021

There's one line that's too long but this LGTM, don't block on me 👍 (aaaand you just got it lol)

@chiragsalian
Copy link
Contributor Author

Updated code to address comments 👍 Ready for review.

Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

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

LGTM!

@Beamanator Beamanator merged commit 30242db into main Jul 27, 2021
@Beamanator Beamanator deleted the chirag-beta-race-fixes branch July 27, 2021 09:42
@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.

@chiragsalian chiragsalian mentioned this pull request Jul 27, 2021
5 tasks
@@ -39,7 +45,11 @@ class ValidateLoginNewWorkspacePage extends Component {
// by calling dismissModal(), the /v/... route is removed from history so the user will get taken to `/`
// if they cancel out of the new workspace modal.
Navigation.dismissModal();
Navigation.navigate(ROUTES.WORKSPACE_NEW);
if (_.isEmpty(this.props.betas)) {
setRedirectToWorkspaceNewAfterSignIn(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

@chiragsalian I'm not quite understanding this, so can you explain it to me? If this logic runs, there is already an authToken, so why is the user being redirected to the new workspace page after sign in, when they are already signed in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe the method name is not the best. Atm i just copied pasted the param i.e., redirectToWorkspaceNewAfterSignIn. The functionality of this is more like redirectAfterSignInAndHaveNecessaryParams. So yeah even though we have the authToken we don't have the betas loaded yet.
So if we go to Navigation.navigate(ROUTES.WORKSPACE_NEW) without the betas it will fail and not show the component, which is the issue.

The betas take a little longer to load after being signed in which is why we save the redirect in onyx and then check if we have everything here before we can navigate to the component. Does that make sense?

As for the method name. Atm i just renamed it exactly to the variable. I thought once I continue with the QR code redirect project of mine I'll discuss the method name closely with you to make it more generic.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I understand about needing to wait for betas to load, but I'm still confused why setRedirectToWorkspaceNewAfterSignIn is necessary. It wasn't in the original code, so it's being added for some reason, but I can't tell what that reason is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't in the original code, so it's being added for some reason, but I can't tell what that reason is.

Do you mean you can't tell easily tell what the reason is in the code and hence want me to add comments or you can't see the reason in general. Cause the reason its added is to fix the GH issue. Since its possible to sign in faster than getting betas, if we redirect to Navigation.navigate(ROUTES.WORKSPACE_NEW) too early then the new workspace screen won't show up. You can easily reproduce the same on dev too with my test steps (Test step - Testing pricing redirect while being signed out hits this flow). Let me know if that makes sense.

Copy link
Contributor Author

@chiragsalian chiragsalian Jul 28, 2021

Choose a reason for hiding this comment

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

Discussed 1:1 and landing on a resolution to be made in my follow up QR scanning project work.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging in version: 1.0.80-3🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production in version: 1.0.81-4🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@kevinksullivan
Copy link
Contributor

@chiragsalian if this deployed to production, why hasn't it closed?

@chiragsalian
Copy link
Contributor Author

oh good question, looks like some bug that didn't close the parent issue. I'll manually close the parent issue.

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.

None yet

7 participants