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

Signup: Fix site path through domain-first flow #11601

Merged
merged 3 commits into from
Feb 28, 2017
Merged

Conversation

drewblaisdell
Copy link
Contributor

@drewblaisdell drewblaisdell commented Feb 25, 2017

aca2949 updated flow-controller such that the redux store can be accessed in a step's apiRequestFunction via this._reduxStore, as apiRequestFunction is bound to the context of SignupFlowController which has a _reduxStore property.

This is a little bit fragile, as:

  • It isn't clear which functions depend on the special context.
  • Any function in StepActions that calls another function will need to use Function.prototype.call to preserve the this value.

I didn't catch this behavior when reviewing #10936, which broke the domain-first flow (which isn't public yet) if you select to create a site, as it called a function in StepActions without using .call to preserve the SignupFlowController context.

As far as I can tell, there isn't any reason to access reduxStore from the context instead of through a parameter, and doing the latter doesn't have the issues listed above. This PR makes that change.

Testing

  • Visit /start/domain-first.

  • Select a domain.

  • Select to create a site in the second step.

  • Proceed through the flow and assert that you land in checkout with the domain/plan you selected.

  • Code

  • Product

@drewblaisdell drewblaisdell added [Feature] Signup & Account Creation All screens and flows for making a new WordPress.com account. [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 25, 2017
@drewblaisdell drewblaisdell self-assigned this Feb 25, 2017
@matticbot matticbot added the [Size] S Small sized issue label Feb 25, 2017
@matticbot
Copy link
Contributor

@@ -109,7 +109,7 @@ function createSiteWithCart( callback, dependencies, {
if ( ! user.get() && isFreeThemePreselected ) {
setThemeOnSite( addToCartAndProceed, { siteSlug, themeSlugWithRepo } );
} else if ( user.get() && isFreeThemePreselected ) {
fetchSitesAndUser( siteSlug, setThemeOnSite.bind( this, addToCartAndProceed, { siteSlug, themeSlugWithRepo } ) );
fetchSitesAndUser( siteSlug, setThemeOnSite.bind( null, addToCartAndProceed, { siteSlug, themeSlugWithRepo } ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of using an arrow function here?

fetchSitesAndUser( siteSlug, () => {
	setThemeOnSite( addToCartAndProceed, { siteSlug, themeSlugWithRepo } );
} );

This may be just me but I find it more readable :).

@stephanethomas
Copy link
Contributor

The code looks good - I only had a minor question.

However I've tested this pull request in an incognito tab several times but was sometimes redirected to the Plans page instead of the checkout (the shopping cart contained the right products though).

I have the feeling (maybe wrong) that there is a different behavior induced by some A/B tests : it worked fine every time I was presented with the option to upload a theme.

@stephanethomas stephanethomas added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 25, 2017
@matticbot matticbot added the [Size] S Small sized issue label Feb 27, 2017
@drewblaisdell
Copy link
Contributor Author

@stephanethomas Thanks for pointing that out. I was able to reproduce this by throttling to "Good 3G" in Chrome. Unfortunately, this affects master as well.

I added a commit to fix it, which was rather simple: ensure that we aren't setting the selected site in CartStore until the sites-list has fetched, as otherwise the cart is loaded for a siteless checkout and the user is redirected because that cart is empty.

@drewblaisdell drewblaisdell added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Author Reply labels Feb 27, 2017
@@ -43,7 +43,7 @@ function createCart( callback, dependencies, data ) {

SignupCart.addToCart( cartKey, [ domainItem ], error => callback( error, providedDependencies ) );
} else {
createSiteWithCart( callback, dependencies, data );
createSiteWithCart( callback, dependencies, data, reduxStore );
}
}

Copy link
Member

Choose a reason for hiding this comment

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

I noticed that we also have createSiteWithCartAndStartFreeTrial function that calls createSiteWithCart but reduxStore param is not passed. I have no idea if that is required, but we should double check if it doesn't break anything.

@gziolo gziolo added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 28, 2017
@gziolo
Copy link
Member

gziolo commented Feb 28, 2017

I had one comment about missing reduxStore param which probably needs some action. Otherwise code changes look good 👍

@matticbot matticbot added [Size] M Medium sized issue and removed [Size] S Small sized issue labels Feb 28, 2017
@Tug
Copy link
Contributor

Tug commented Feb 28, 2017

@gziolo Addressed that, thx for noticing!
Code 👍

@Tug Tug added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Author Reply labels Feb 28, 2017
@Tug Tug force-pushed the fix/domain-first-with-site branch from 53e3b95 to 5a69d5f Compare February 28, 2017 09:31
@matticbot matticbot added the [Size] M Medium sized issue label Feb 28, 2017
@Tug
Copy link
Contributor

Tug commented Feb 28, 2017

Product 👍

@Tug Tug removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 28, 2017
@Tug Tug merged commit 64725fb into master Feb 28, 2017
@Tug Tug deleted the fix/domain-first-with-site branch February 28, 2017 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Signup & Account Creation All screens and flows for making a new WordPress.com account. [Size] M Medium sized issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants