Skip to content

Commit

Permalink
Signup: Remove invalid site_type parameter from verticals request (#3…
Browse files Browse the repository at this point in the history
…3918)

Remove invalid site_type parameter from verticals request

Some flows do not choose a site type before requesting verticals from
the API (e.g. 'desktop'). If the site type hasn't been choosen then
don't send the site_type parameter as part of the request. The server
can then choose what the default site type should be.
  • Loading branch information
p-jackson authored Jun 19, 2019
1 parent ad3d04a commit 5a68ca8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client/state/data-layer/wpcom/signup/verticals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { setVerticals } from 'state/signup/verticals/actions';
import { SIGNUP_VERTICALS_REQUEST } from 'state/action-types';
import { getSiteTypeId } from 'state/signup/steps/site-type/selectors';

// Some flows do not choose a site type before requesting verticals. In this
// case don't send a site_type param to the API.
export const requestVerticals = action =>
http(
{
Expand All @@ -26,7 +28,7 @@ export const requestVerticals = action =>
path: '/verticals',
query: {
search: action.search.trim(),
site_type: action.siteTypeId,
...( action.siteTypeId && { site_type: action.siteTypeId } ),
limit: action.limit,
include_preview: true,
},
Expand Down
9 changes: 9 additions & 0 deletions client/state/data-layer/wpcom/signup/verticals/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ describe( 'data-layer/wpcom/signup/verticals', () => {
);
} );

test( 'requestVerticals() with missing siteTypeId', () => {
const mockAction = {
search: 'Foo',
limit: 7,
};

expect( requestVerticals( mockAction ) ).not.toHaveProperty( 'query.site_type' );
} );

test( 'storeVerticals()', () => {
const search = 'Profit!';
const siteType = 'business';
Expand Down

0 comments on commit 5a68ca8

Please sign in to comment.