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

Plans: Reduxify Plan Remove component #2952

Merged
merged 23 commits into from
Feb 8, 2016

Conversation

stephanethomas
Copy link
Contributor

This pull request addresses #2626 by extracting the part that handles the API call from the <PlanRemove /> component and connecting this component to the Redux state tree. It also fixes a few things and refactors some code in the process:

Fixing
  • Fixed redirection failing when clicking success notice
  • Removed duplicate action types constants
  • Fixed error property not reset when fetching site plans
  • Added error handling when fetching site plans
Refactoring
  • Renamed action type constants to follow naming convention
  • Updated action for clearing site plans to return an action object
  • Standardized descriptions of unit tests and updated them to be easier to reason about
  • Added a bunch of new unit tests
Reduxification
  • Added new actions (and unit tests) for canceling a plan free trial
  • Reduxified the <PlanRemove /> component

As a reminder the <PlanRemove /> component is responsible for displaying a new section with a link at the bottom of the Plans Overview page during the grace period:

screenshot

This link displays a modal that allows users to cancel a free trial:

screenshot

Users are redirected on the Plans page with a message if the cancelation is successful:

screenshot

Testing instructions

  1. Run git checkout update/reduxify-plan-remove and start your server
  2. Open the Plan Overview page with a free trial in grace period
  3. Click the Remove now link and then click the Remove Now button in the modal
  4. Check that the free trial was canceled successfully
  5. Check that you are redirected to the Plans page
  6. Check that you can dismiss the success notice and that no error is thrown

Reviews

  • Code
  • Product

@stephanethomas stephanethomas added [Feature] Plans & Upgrades All of the plans on WordPress.com and flow for upgrading plans. [Status] In Progress Free Trials labels Feb 1, 2016
@stephanethomas stephanethomas self-assigned this Feb 1, 2016
@scruffian
Copy link
Member

These changes look great. There are a lot though. I think it would have been better to do the Redux stuff in a different PR to the refactoring.

@stephanethomas
Copy link
Contributor Author

Thanks for your feedback Ben! I agree this pull request ended up being too long.

@stephanethomas stephanethomas added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Feb 2, 2016
type: FETCH_SITE_PLANS,
siteId: siteId
it( 'should return an empty state when original state and action are empty', () => {
const original = Object.freeze( {} ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea to wrap the initial state in Object.freeze in all of these tests. 👍

@drewblaisdell drewblaisdell 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 3, 2016
@stephanethomas stephanethomas force-pushed the update/reduxify-plan-remove branch 2 times, most recently from eec8ebf to 1ecada0 Compare February 5, 2016 15:23
@stephanethomas
Copy link
Contributor Author

I've rebased (this was lots of fun this time sic) and implemented the changes requested. This is ready for another review.

@stephanethomas stephanethomas 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 5, 2016
@scruffian
Copy link
Member

Changes look good.

@fabianapsimoes
Copy link
Contributor

Product 👌

@fabianapsimoes fabianapsimoes added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 8, 2016
… about

This moves from using initial site state constants to using plain objects to describe assertions. The goal is to make these unit tests easier to understand (since the expected results are obvious and don't require any interpretation of Object.assign()) and more flexible (by specifying different original states).
This also fixes the case where isFetching would not be reset in case of failure.
This makes obvious that this action expects a list of plans returned by the API - which will then be converted to a different data structure by the assembler.
This also adds the corresponding unit tests.
This is the first step to merging this flag with the one for fetching since we don't really need to manage both states after all.
This is the last step to merging this flag with the one used previously for updating - so we only have to manage a single state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Plans & Upgrades All of the plans on WordPress.com and flow for upgrading plans.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants