Skip to content

Commit

Permalink
Fix tests, and adjust auto auth behavior to only launch with the new …
Browse files Browse the repository at this point in the history
…flow.
  • Loading branch information
justinshreve committed Jul 3, 2019
1 parent cdaebcc commit 402e64f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 0 additions & 2 deletions client/blocks/login/login-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,6 @@ export class LoginForm extends Component {

return (
<form method="post">
{ this.renderPrivateSiteNotice() }

<Card className="login__form">
{ this.renderPrivateSiteNotice() }
<div className="login__form-userdata">
Expand Down
2 changes: 1 addition & 1 deletion client/blocks/signup-form/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ class SignupForm extends Component {

{ this.props.isSocialSignupEnabled && ! this.userCreationComplete() && (
<SocialSignupForm
handleResponse={ this.props.handleSocialResponse }
handleResponse={ this.handleWooCommerceSocialConnect }
socialService={ this.props.socialService }
socialServiceResponse={ this.props.socialServiceResponse }
/>
Expand Down
4 changes: 3 additions & 1 deletion client/jetpack-connect/authorize.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ export class JetpackAuthorize extends Component {
const { alreadyAuthorized, authApproved, from } = this.props.authQuery;
return (
this.isSso() ||
'woocommerce-services-auto-authorize' === from ||
( 'woocommerce-services-auto-authorize' === from ||
( ! config.isEnabled( 'jetpack/connect/woocommerce' ) &&
'woocommerce-setup-wizard' === ' from' ) ) ||
( ! this.props.isAlreadyOnSitesList &&
! alreadyAuthorized &&
( this.props.calypsoStartedConnection || authApproved ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ exports[`JetpackAuthorize renders as expected 1`] = `
</LoggedOutFormLinkItem>
<LoggedOutFormLinkItem
href="/log-in/jetpack?redirect_to=https%3A%2F%2Fexample.com%2F"
onClick={[Function]}
>
Sign in as a different user
</LoggedOutFormLinkItem>
Expand Down
17 changes: 11 additions & 6 deletions client/jetpack-connect/test/authorize.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ describe( 'JetpackAuthorize', () => {
describe( 'isWoo', () => {
const isWoo = new JetpackAuthorize().isWoo;

test( 'should return true for woo wizard', () => {
test( 'should return true for woo services', () => {
const props = { authQuery: { from: 'woocommerce-services-auto-authorize' } };
expect( isWoo( props ) ).toBe( true );
} );

test( 'should return true for woo services', () => {
test( 'should return true for woo wizard', () => {
const props = { authQuery: { from: 'woocommerce-setup-wizard' } };
expect( isWoo( props ) ).toBe( true );
} );
Expand All @@ -140,19 +140,24 @@ describe( 'JetpackAuthorize', () => {
} );

describe( 'shouldAutoAuthorize', () => {
const renderableComponent = <JetpackAuthorize { ...DEFAULT_PROPS } />;

test( 'should return true for sso', () => {
const renderableComponent = <JetpackAuthorize { ...DEFAULT_PROPS } />;
const component = shallow( renderableComponent );
component.instance().isSso = () => true;
const result = component.instance().shouldAutoAuthorize();

expect( result ).toBe( true );
} );

test( 'should return true for woo', () => {
test( 'should return true for woo services', () => {
const renderableComponent = <JetpackAuthorize { ...DEFAULT_PROPS } />;
const component = shallow( renderableComponent );
component.instance().isWoo = () => true;
component.setProps( {
authQuery: {
...DEFAULT_PROPS.authQuery,
from: 'woocommerce-services-auto-authorize',
},
} );
const result = component.instance().shouldAutoAuthorize();

expect( result ).toBe( true );
Expand Down

0 comments on commit 402e64f

Please sign in to comment.