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

Fix back redirection from Woo connect switch user flow #90836

Merged
merged 3 commits into from
May 28, 2024

Conversation

vishnugopal
Copy link
Contributor

Related to 20362-gh-Automattic/woocommerce.com

Proposed Changes

Fixes back button redirection from Woo connection switch user flow.

Why are these changes being made?

When redirecting from the Woo connection switch user flow, back button navigation calls history.back() which takes you back to the connection flow. At the connection flow however, because a user is not available, the page redirects back to the login flow. You can see this on production here (ensure you are logged into woocommerce.com):

CleanShot.2024-05-17.at.11.09.22.mp4

Testing Instructions

  1. Make sure you have a working Calypso installation.
  2. Switch to this branch.
  3. Make sure Calypso is started yarn start.
  4. Create a test WooCommerce installation (JN can help)
  5. Make sure you are logged in to woocommerce.com and wordpress.com.
  6. Connect the site to woocommerce.com by visiting /wp-admin/admin.php?page=wc-admin&tab=my-subscriptions&path=%2Fextensions and clicking Connect account.
  7. Now you should ideally see this connect screen:
    CleanShot 2024-05-17 at 11 13 06
  8. If you instead see this switch account, then it means you are not logged into woocommerce.com and you should login by clicking on the user account:
    CleanShot 2024-05-17 at 11 13 22
  9. Once you get back to the connection screen, click Use a different WooCommerce.com account
  10. Make sure you get to the WP switch account page.
  11. First reproduce the behaviour in production by clicking Back, you should see the behavior in the video.
  12. Now repeat steps 1-10, and substitute the beginning of the URL https://wordpress.com/log-in? with http://calypso.localhost:3000/log-in?
  13. Click Back
  14. Ensure that you are redirected back to the site:
CleanShot.2024-05-17.at.11.19.49.mp4
  1. Ensure that other login flows don't break with this change.
  2. Please test around this issue.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@vishnugopal vishnugopal requested a review from thilinah May 17, 2024 05:52
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 17, 2024
@matticbot
Copy link
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~138 bytes added 📈 [gzipped])

name           parsed_size           gzip_size
entry-stepper       +368 B  (+0.0%)     +138 B  (+0.0%)
entry-main          +368 B  (+0.0%)     +138 B  (+0.0%)
entry-login         +368 B  (+0.0%)     +138 B  (+0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@vishnugopal vishnugopal force-pushed the fix/20362-back-button-issues branch from 01d2dcf to e0e48c7 Compare May 21, 2024 09:33
@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug fix/20362-back-button-issues on your sandbox.

@vishnugopal vishnugopal self-assigned this May 22, 2024
@thilinah
Copy link

thilinah commented May 23, 2024

@vishnugopal when clicking the back button I'm getting redirected to the store but on logged out state. I think this is because I'm getting redirected to wp-login.php.

e.g: https://valiantly-immense.jurassic.ninja/wp-login.php?redirect_to=https%3A%2F%2Fvaliantly-immense.jurassic.ninja%2F%2Fwp-admin%2Fadmin.php%3Fpage%3Dwc-admin%26tab%3Dmy-subscriptions%26path%3D%252Fextensions&reauth=1

This is not ideal as it logout the user from the store.

wp-test.mov

@vishnugopal
Copy link
Contributor Author

@thilinah Could you re-review? This was an extra / that was introduced in my final commit. Should be fixed now, thanks much for the find!

Copy link

@thilinah thilinah left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the issue. Tested and works fine.

@vishnugopal vishnugopal merged commit 9170e76 into trunk May 28, 2024
11 checks passed
@vishnugopal vishnugopal deleted the fix/20362-back-button-issues branch May 28, 2024 03:05
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 28, 2024
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

3 participants