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

Update fetchCurrentTheme, with proper naming and tests. #9419

Merged
merged 6 commits into from
Nov 17, 2016

Conversation

budzanowski
Copy link
Contributor

@budzanowski budzanowski commented Nov 16, 2016

Intoduction

Aim of this PR is to update fetchCurrentTheme action with naming that matches rest of Calypso and also adding unit tests that will help with further themes Redux subtree refactor.

3 Redux state tests are added in this PR:

  • fetching current theme action dispatch
  • success action dispatch
  • failure action dispatch

To test:

  1. open /design in single site mode
  2. check if current theme name in properly displayed in current theme banner at the top of the page.

current-theme

@matticbot
Copy link
Contributor

@budzanowski budzanowski added the [Feature Group] Appearance & Themes Features related to the appearance of sites. label Nov 16, 2016
@budzanowski budzanowski added this to the Themes: JetPress Rally milestone Nov 16, 2016
@budzanowski budzanowski force-pushed the update/fetchCurrentTheme-refactore-and-testign branch from c350cbf to fd202cd Compare November 17, 2016 10:33
@budzanowski budzanowski added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 17, 2016
export const THEME_RECEIVE_CURRENT = 'THEMES_RECEIVE_CURRENT';
export const THEME_REQUEST_CURRENT = 'THEME_REQUEST_CURRENT';
export const THEME_REQUEST_CURRENT_FAILURE = 'THEME_REQUEST_CURRENT_FAILURE';
export const THEME_CURRENT_REQUEST_SUCCESS = 'THEME_CURRENT_REQUEST_SUCCESS';
Copy link
Contributor

Choose a reason for hiding this comment

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

Nomenclature is hard 😄. This sounds a bit like it's the current request for a theme, not a request for the current theme. Also, to align with the new action name, it should be active, not current.

Soo... maybe ACTIVE_THEME_REQUEST etc? (I think it's fine to not prefix with THEME_.)

@@ -75,26 +75,26 @@ export function incrementThemesPage( site ) {
};
}

export function fetchCurrentTheme( siteId ) {
export function requestActiveTheme( siteId ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a JSDoc block? 😄 Just once sentence should be enough (plus @param and @return).

.reply( 404, failureResponse );
} );

it( 'should dispatch current theme request action when triggered', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's stick to active theme for the nomenclature 😉 (same in the it statements below).

export const THEME_REQUEST_CURRENT = 'THEME_REQUEST_CURRENT';
export const THEME_REQUEST_CURRENT_FAILURE = 'THEME_REQUEST_CURRENT_FAILURE';
export const ACTIVE_THEME_REQUEST_SUCCESS = 'ACTIVE_THEME_REQUEST_SUCCESS';
export const ACTIVE_THEME_REQUEST = 'ACTIVE_THEME_REQUEST';
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick -- can we change the order here and define ACTIVE_THEME_REQUEST before ACTIVE_THEME_REQUEST_SUCCESS?

@@ -75,26 +75,34 @@ export function incrementThemesPage( site ) {
};
}

export function fetchCurrentTheme( siteId ) {
/**
* This action queries wpcom endpoint for active theme for site.
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation -- there should be a space, not a tab before the * so it aligns with the first * in /**.

export function fetchCurrentTheme( siteId ) {
/**
* This action queries wpcom endpoint for active theme for site.
* If request success formation about active theme is stored in Redux themes subtree.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: should be information 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, should also be If request succeeds, ...

THEME_REQUEST_CURRENT,
THEME_REQUEST_CURRENT_FAILURE,
ACTIVE_THEME_REQUEST_SUCCESS,
ACTIVE_THEME_REQUEST,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's import ACTIVE_THEME_REQUEST before ACTIVE_THEME_REQUEST_SUCCESS here, too.

@ockham
Copy link
Contributor

ockham commented Nov 17, 2016

Found couple more nits, but looking very good overall! Feel free to merge after you've addressed them 😄

@budzanowski budzanowski merged commit 289a9b6 into master Nov 17, 2016
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 17, 2016
@budzanowski budzanowski deleted the update/fetchCurrentTheme-refactore-and-testign branch November 17, 2016 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature Group] Appearance & Themes Features related to the appearance of sites.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants