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

Simplify and harden our onboarding [connect] links and Connect page state logic #9105

Merged
Merged
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
80eddde
Fix notice when account data is refreshed early
vladolaru Jul 16, 2024
6b31dc2
Document and clarify onboarding_service::get_source
vladolaru Jul 16, 2024
aa3cbe2
Extensively document and refactor for clarity the account onboarding …
vladolaru Jul 16, 2024
9a5c01e
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Jul 16, 2024
370b0f8
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Jul 16, 2024
ce18468
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Jul 17, 2024
c0836ec
Maintain source when redirecting to the Connect page
vladolaru Jul 17, 2024
1043047
Handle redirect from Connect to Overview when everything is OK
vladolaru Jul 17, 2024
3d0646c
Use the source GET param for maintaining source on Connect
vladolaru Jul 17, 2024
a05cdfc
No need to handle partially onboarded accounts separately
vladolaru Jul 17, 2024
465d790
Maintain onboarding source via the source GET param for Connect redir…
vladolaru Jul 17, 2024
81c49b1
URLDecode for simpler handling and consistency
vladolaru Jul 17, 2024
451af77
Add changelog
vladolaru Jul 17, 2024
c4bb552
test: Fix redirect to connect tests
vladolaru Jul 17, 2024
a8a93ba
test: Add tests for maybe_redirect_from_connect_page
vladolaru Jul 17, 2024
65942f5
Add unknown onboarding source
vladolaru Jul 17, 2024
98a0df1
Add method dedicated to redirecting to onboarding wizard
vladolaru Jul 17, 2024
4bfdca0
More refactoring and docs for the maybe_handle_onboarding method
vladolaru Jul 17, 2024
fd8e5f5
Simply maybe_init_jetpack_connection
vladolaru Jul 17, 2024
c2298cd
More resilient init_stripe_onboarding
vladolaru Jul 17, 2024
45d92c5
test: Add tests for maybe_handle_onboarding
vladolaru Jul 17, 2024
076a3a8
Minor docs
vladolaru Jul 17, 2024
a0cbae0
Refactor and document get_source for extra clarity and predictability
vladolaru Jul 18, 2024
c56f4db
test: Improve get_source unit tests
vladolaru Jul 18, 2024
ba077b6
test: Rename tests for clarity
vladolaru Jul 18, 2024
96214bc
Minor refactoring to redirect after plugin activation
vladolaru Jul 18, 2024
37a1ed9
Use string true for GET params when initiating onboarding from JS
vladolaru Jul 18, 2024
4ea4a07
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Jul 18, 2024
e68925d
Add from param for the connect page
vladolaru Jul 19, 2024
73f6552
Add from param for the onboarding wizard
vladolaru Jul 19, 2024
a4a01f0
Use constants for known from param values
vladolaru Jul 19, 2024
eb93fdf
Don't automatically carry over from param on Connect page redirects
vladolaru Jul 19, 2024
35b1fcf
Don't automatically carry over from param on Onboarding wizard redirects
vladolaru Jul 19, 2024
7957faa
Introduce filter to help with unit testing
vladolaru Jul 19, 2024
4e30964
Minor fix
vladolaru Jul 19, 2024
bff0895
Further refactoring and documenting the connect links handling
vladolaru Jul 19, 2024
5d4b5c8
test: Update and expand connect links handling tests
vladolaru Jul 19, 2024
6a3cfc6
Fixes for the get_from logic
vladolaru Jul 19, 2024
2dd2ceb
test: Add unit test for the get_from logic
vladolaru Jul 19, 2024
9312c31
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Jul 19, 2024
35c184e
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Jul 19, 2024
00eb238
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Jul 23, 2024
12e7650
docs: Document maybe_redirect_from_connect_page
vladolaru Jul 23, 2024
b5f0171
docs: Provide mention to keep the business logic comment updated
vladolaru Jul 23, 2024
4e00754
Remove new onboarding flow check and flag
vladolaru Jul 24, 2024
2c9b61a
Add source and from all over the FE code
vladolaru Jul 24, 2024
a146417
Show reset account notice
vladolaru Jul 24, 2024
fc20b4a
Fill in the tracking gaps around our onboarding flows
vladolaru Jul 24, 2024
fa67186
refact: Rename constant
vladolaru Jul 24, 2024
dbc1e96
refact: Rename constants
vladolaru Jul 24, 2024
adb4247
Do not switch gateway mode when setting onboarding mode DB option
vladolaru Jul 24, 2024
8964049
Default to doing live mode onboardings
vladolaru Jul 24, 2024
7381dc9
docs: Cleanup erroneous throws docs
vladolaru Jul 24, 2024
825b8f6
Pass explicit onboarding mode when calling our platform
vladolaru Jul 24, 2024
687d398
Add more from and source values
vladolaru Jul 24, 2024
eddddad
Add source when redirecting to overview page
vladolaru Jul 24, 2024
7d8c5cd
Fixes and improvements to the onboarding handling logic
vladolaru Jul 24, 2024
d5155c1
test:Fixes and improvements to account and onboarding unit tests
vladolaru Jul 24, 2024
91e52b6
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Jul 24, 2024
60c1108
test: Update JS snapshots
vladolaru Jul 24, 2024
3ca8a6e
Handle PO payouts requirements collection
vladolaru Jul 24, 2024
1bf5cdb
test: Fix JS tests
vladolaru Jul 24, 2024
b49c8c1
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
dmallory42 Jul 25, 2024
f24da5e
Allow some HTML in error notices
vladolaru Jul 25, 2024
20c612e
Redirect from overview page to connect if the Stripe account is not v…
vladolaru Jul 25, 2024
bb2228f
Better handling of finalize connection and onboarding sessions
vladolaru Jul 25, 2024
c734567
Render full menu only when the Stripe account is valid
vladolaru Jul 25, 2024
29ebb4d
test: Fix and improve unit tests
vladolaru Jul 25, 2024
3d452a5
Update includes/class-wc-payments-onboarding-service.php
vladolaru Jul 25, 2024
77eac10
Add more flags to the JS settings
vladolaru Jul 25, 2024
b05d065
Add connect page FE for partially onboarded accounts
vladolaru Jul 25, 2024
3ce9310
Redirect from settings to connect on invalid Stripe account
vladolaru Jul 25, 2024
03091cd
Redirect from onboarding wizard to connect on invalid onboarded accounts
vladolaru Jul 25, 2024
869e679
Move finalize connection handling earlier in connect links logic
vladolaru Jul 25, 2024
d7dcf8d
Make has_working_jetpack_connection public
vladolaru Jul 25, 2024
ab45312
Simplify our pages and menu registering: no working JP connection or …
vladolaru Jul 25, 2024
aa48730
test: Fix and improve unit tests
vladolaru Jul 25, 2024
c783d38
Add Tracks events to Event type
vladolaru Jul 25, 2024
e1bd467
refact: Change is_stripe_account_valid to get the account data only once
vladolaru Jul 25, 2024
c8367d8
Always update the should redirect to onboarding option
vladolaru Jul 25, 2024
ee6931d
test: Fix unit tests
vladolaru Jul 25, 2024
47344ac
Minor
vladolaru Jul 25, 2024
25c80a9
Add the reset account tool to the Connect page
vladolaru Jul 25, 2024
e2f4c1a
Redirect from settings page when everything not OK
vladolaru Jul 25, 2024
1d47ee3
Do a more sweeping cleanup when deleting accounts
vladolaru Jul 25, 2024
38a9a40
test: Fix unit tests
vladolaru Jul 25, 2024
c376d41
Change connect page errors to something bearable
vladolaru Jul 25, 2024
862d8a1
test: Add unit tests for connect and overview redirects looping detec…
vladolaru Jul 26, 2024
9428404
Remove Finish setup from overview account tools since we redirect to …
vladolaru Jul 26, 2024
90d5cf5
Carry over the from value when redirecting to the onboarding wizard
vladolaru Jul 26, 2024
18e2209
Fix unreliable testMode and devMode detection
vladolaru Jul 26, 2024
90df96d
Use named import
vladolaru Jul 26, 2024
135d91f
test: Update Account Status and Account Tools JS tests
vladolaru Jul 26, 2024
a273cfc
test: Improve and update Account status tests
vladolaru Jul 26, 2024
7419556
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Jul 26, 2024
d971096
Update reset account modal to be more in line with the Setup live pay…
vladolaru Jul 26, 2024
3848815
More sources and from splashing where they werent
vladolaru Jul 26, 2024
b4d511b
Improve JS Connect tracking source detection
vladolaru Jul 26, 2024
a62a3fb
test: Update snapshots
vladolaru Jul 26, 2024
d9f2764
Create separate component for sandbox mode switch to live notice
vladolaru Jul 26, 2024
95c3be7
The test mode notice should look at test mode not dev mode
vladolaru Jul 26, 2024
e5fc96d
Change error banner notice icon
vladolaru Jul 26, 2024
17955fb
Adjust error message copy to be more short
vladolaru Jul 26, 2024
a29ff35
Don't enable dev mode when onboarding test mode is enabled
vladolaru Jul 26, 2024
55bdbe5
Make isAccountConnected independent of the Jetpack connection
vladolaru Jul 26, 2024
3a59670
Handle backward compatibility case around onboarding test mode state …
vladolaru Jul 26, 2024
cf8d950
test: Fix unit tests
vladolaru Jul 26, 2024
66c422c
Show Connect broken setup error regardless of transient
vladolaru Jul 26, 2024
05bade5
Show main menu error badge if broken setup
vladolaru Jul 26, 2024
f84c5ca
Clarify docs and condition
vladolaru Jul 26, 2024
e4d5547
Copy adjustments
vladolaru Jul 26, 2024
c458c19
Fix requests mode to account for onboarding mode
vladolaru Jul 26, 2024
f1b6156
tests: Fix tests
vladolaru Jul 26, 2024
40e72a5
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Jul 26, 2024
dea7b4a
Adjust Connect CTA behavior when another account session error is shown
vladolaru Jul 26, 2024
af2db31
Remove params from overview to connect redirect
vladolaru Jul 26, 2024
0da5802
Fix Connect CTA logic
vladolaru Jul 26, 2024
42c20d6
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Jul 30, 2024
7f90f7b
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Aug 5, 2024
c1332e2
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Aug 5, 2024
dfc888b
docs: Minor improvements
vladolaru Aug 5, 2024
bb32cee
Impose a clear execution order for account onboarding and redirects h…
vladolaru Aug 5, 2024
8b2f2a2
Replace Stripe connected with Stripe account valid for resilience
vladolaru Aug 5, 2024
1dba812
Code styling
vladolaru Aug 5, 2024
051c627
tests: Fix unit tests
vladolaru Aug 5, 2024
ff670e4
Minor
vladolaru Aug 5, 2024
8ea89ce
test: Add unit tests for finalize connection
vladolaru Aug 5, 2024
82e1485
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
dmallory42 Aug 7, 2024
0ae379c
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Aug 8, 2024
66c3ec7
Merge branch 'develop' into fix/9103-payments-settings-originated-onb…
vladolaru Aug 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix onboarding redirect loop when starting from Woo Settings Payments.
oaratovskyi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '../utils';
import { getTracksIdentity } from 'tracks';
import { getAppearance } from 'wcpay/checkout/upe-styles';
import getAppearanceType from 'wcpay/checkout/utils';
import { getAppearanceType } from 'wcpay/checkout/utils';

export const expressCheckoutIframe = async ( api, context, emailSelector ) => {
const woopayEmailInput = await getTargetElement( emailSelector );
Expand Down
37 changes: 10 additions & 27 deletions client/components/account-status/account-tools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ import strings from './strings';
import './styles.scss';
import ResetAccountModal from 'wcpay/overview/modal/reset-account';
import { trackAccountReset } from 'wcpay/onboarding/tracking';
import { recordEvent } from 'wcpay/tracks';
import { isInDevMode } from 'wcpay/utils';

interface Props {
accountLink: string;
detailsSubmitted: boolean;
openModal: () => void;
}

const handleReset = () => {
trackAccountReset();

window.location.href = addQueryArgs( wcpaySettings.connectUrl, {
'wcpay-reset-account': true,
'wcpay-reset-account': 'true',
oaratovskyi marked this conversation as resolved.
Show resolved Hide resolved
source: 'wcpay-reset-account', // Overwrite any existing source because we are starting over.
} );
};

export const AccountTools: React.FC< Props > = ( props: Props ) => {
const accountLink = addQueryArgs( props.accountLink, {
source: 'account-tools__finish-setup-button',
vladolaru marked this conversation as resolved.
Show resolved Hide resolved
} );
const detailsSubmitted = props.detailsSubmitted;
export const AccountTools: React.FC< Props > = () => {
const [ modalVisible, setModalVisible ] = useState( false );

// Only render when in dev/sandbox mode.
if ( ! isInDevMode() ) {
return null;
}

return (
<>
<div className="account-tools">
Expand All @@ -43,25 +43,8 @@ export const AccountTools: React.FC< Props > = ( props: Props ) => {
<p>{ strings.description }</p>
{ /* Use wrapping div to keep buttons grouped together. */ }
<div className="account-tools__actions">
{ ! detailsSubmitted && (
<Button
variant={ 'secondary' }
onClick={ () =>
recordEvent(
'wcpay_account_details_link_clicked',
{
source:
'account-tools__finish-setup-button',
}
)
}
href={ accountLink }
>
{ strings.finish }
</Button>
) }
<Button
variant={ detailsSubmitted ? 'secondary' : 'tertiary' }
variant={ 'secondary' }
onClick={ () => setModalVisible( true ) }
>
{ strings.reset }
Expand Down
1 change: 0 additions & 1 deletion client/components/account-status/account-tools/strings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ export default {
'Payments and deposits are disabled until account setup is completed. If you are experiencing problems completing account setup, or need to change the email/country associated with your account, you can reset your account and start from the beginning.',
'woocommerce-payments'
),
finish: __( 'Finish setup', 'woocommerce-payments' ),
reset: __( 'Reset account', 'woocommerce-payments' ),
};
Original file line number Diff line number Diff line change
@@ -1,42 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AccountTools should render in live mode 1`] = `
<div>
<div
class="account-tools"
>
<hr
aria-orientation="horizontal"
class="components-divider components-card__divider components-card-divider css-yo8r29-DividerView-renderBorder-renderSize-renderMargin-Divider-borderColor e19on6iw0"
data-wp-c16t="true"
data-wp-component="CardDivider"
role="separator"
/>
<h4>
Account Tools
</h4>
<p>
Payments and deposits are disabled until account setup is completed. If you are experiencing problems completing account setup, or need to change the email/country associated with your account, you can reset your account and start from the beginning.
</p>
<div
class="account-tools__actions"
>
<a
class="components-button is-secondary"
href="/onboarding?source=account-tools__finish-setup-button"
>
Finish setup
</a>
<button
class="components-button is-tertiary"
type="button"
>
Reset account
</button>
</div>
</div>
</div>
`;
exports[`AccountTools should NOT render in live mode 1`] = `<div />`;

exports[`AccountTools should render in sandbox mode 1`] = `
<div>
Expand All @@ -59,14 +23,8 @@ exports[`AccountTools should render in sandbox mode 1`] = `
<div
class="account-tools__actions"
>
<a
class="components-button is-secondary"
href="/onboarding?source=account-tools__finish-setup-button"
>
Finish setup
</a>
<button
class="components-button is-tertiary"
class="components-button is-secondary"
type="button"
>
Reset account
Expand Down
34 changes: 5 additions & 29 deletions client/components/account-status/account-tools/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
* External dependencies
*/
import React from 'react';
import { render, screen } from '@testing-library/react';
import { render } from '@testing-library/react';

/**
* Internal dependencies
*/
import { AccountTools } from '..';

const accountLink = '/onboarding';
const openModal = jest.fn();

declare const global: {
Expand All @@ -20,18 +19,15 @@ declare const global: {
};

describe( 'AccountTools', () => {
it( 'should render in live mode', () => {
it( 'should NOT render in live mode', () => {
global.wcpaySettings = {
devMode: false,
};

const { container } = render(
<AccountTools
accountLink={ accountLink }
detailsSubmitted={ false }
openModal={ openModal }
/>
<AccountTools openModal={ openModal } />
);

expect( container ).toMatchSnapshot();
} );

Expand All @@ -41,29 +37,9 @@ describe( 'AccountTools', () => {
};

const { container } = render(
<AccountTools
accountLink={ accountLink }
detailsSubmitted={ false }
openModal={ openModal }
/>
<AccountTools openModal={ openModal } />
);

expect( container ).toMatchSnapshot();
} );

it( 'should render in sandbox mode for details submitted account without finish setup button', () => {
global.wcpaySettings = {
devMode: true,
};

render(
<AccountTools
accountLink={ accountLink }
detailsSubmitted={ true }
openModal={ openModal }
/>
);

expect( screen.queryByText( 'Finish setup' ) ).not.toBeInTheDocument();
} );
} );
14 changes: 5 additions & 9 deletions client/components/account-status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import StatusChip from './status-chip';
import './style.scss';
import './shared.scss';
import { AccountTools } from './account-tools';
import { isInDevMode } from 'wcpay/utils';
import { recordEvent } from 'wcpay/tracks';
import { addQueryArgs } from '@wordpress/url';

Expand Down Expand Up @@ -62,7 +61,8 @@ const AccountStatusError = () => {
const AccountStatusDetails = ( props ) => {
const { accountStatus, accountFees } = props;
const accountLink = addQueryArgs( accountStatus.accountLink, {
source: 'account-details',
from: 'WCPAY_ACCOUNT_DETAILS',
source: 'wcpay-account-details',
} );
const cardTitle = (
<>
Expand All @@ -83,7 +83,8 @@ const AccountStatusDetails = ( props ) => {
variant={ 'link' }
onClick={ () =>
recordEvent( 'wcpay_account_details_link_clicked', {
source: 'account-details',
from: 'WCPAY_ACCOUNT_DETAILS',
source: 'wcpay-account-details',
} )
}
href={ accountLink }
Expand Down Expand Up @@ -118,12 +119,7 @@ const AccountStatusDetails = ( props ) => {
}
/>
</AccountStatusItem>
{ ( ! accountStatus.detailsSubmitted || isInDevMode() ) && (
<AccountTools
accountLink={ wcpaySettings.connectUrl }
detailsSubmitted={ accountStatus.detailsSubmitted }
/>
) }
<AccountTools />
{ accountFees.length > 0 && (
<AccountFees accountFees={ accountFees } />
) }
Expand Down
Loading
Loading