Skip to content

Commit 4af3a1f

Browse files
authored
feat: GooglePay live account test mode notice (#10429)
1 parent 1dfacfe commit 4af3a1f

File tree

26 files changed

+373
-185
lines changed

26 files changed

+373
-185
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: update
3+
4+
feat: add compatibility notice for Google Pay with live mode accounts.
Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import WizardTaskContext from '../../wizard/task/context';
1010
import SetupComplete from '../setup-complete-task';
1111
import WizardContext from '../../wizard/wrapper/context';
1212
import { useEnabledPaymentMethodIds } from '../../../data';
13+
import WCPaySettingsContext from 'wcpay/settings/wcpay-settings-context';
1314

1415
jest.mock( '@wordpress/data', () => ( {
1516
useDispatch: jest.fn().mockReturnValue( { updateOptions: jest.fn() } ),
@@ -18,16 +19,24 @@ jest.mock( '../../../data', () => ( {
1819
useEnabledPaymentMethodIds: jest.fn(),
1920
} ) );
2021

22+
const renderWithSettingsProvider = ( ui ) =>
23+
render(
24+
<WCPaySettingsContext.Provider value={ global.wcpaySettings }>
25+
{ ui }
26+
</WCPaySettingsContext.Provider>
27+
);
28+
2129
describe( 'SetupComplete', () => {
2230
beforeEach( () => {
2331
useEnabledPaymentMethodIds.mockReturnValue( [
2432
[ 'card', 'bancontact', 'eps', 'ideal', 'p24', 'sepa_debit' ],
2533
() => null,
2634
] );
35+
global.wcpaySettings = { featureFlags: { multiCurrency: true } };
2736
} );
2837

2938
it( 'renders setup complete messaging when context value is undefined', () => {
30-
render(
39+
renderWithSettingsProvider(
3140
<WizardContext.Provider value={ { completedTasks: {} } }>
3241
<WizardTaskContext.Provider value={ { isActive: true } }>
3342
<SetupComplete />
@@ -41,9 +50,11 @@ describe( 'SetupComplete', () => {
4150
} );
4251

4352
it( 'renders setup complete messaging when context value is `true`', () => {
44-
render(
53+
renderWithSettingsProvider(
4554
<WizardContext.Provider
46-
value={ { completedTasks: { 'add-payment-methods': true } } }
55+
value={ {
56+
completedTasks: { 'add-payment-methods': true },
57+
} }
4758
>
4859
<WizardTaskContext.Provider value={ { isActive: true } }>
4960
<SetupComplete />
@@ -57,7 +68,7 @@ describe( 'SetupComplete', () => {
5768
} );
5869

5970
it( 'renders setup complete messaging when context value says that methods have not changed', () => {
60-
render(
71+
renderWithSettingsProvider(
6172
<WizardContext.Provider
6273
value={ {
6374
completedTasks: {
@@ -90,7 +101,7 @@ describe( 'SetupComplete', () => {
90101
[ 'card', 'ideal' ],
91102
() => null,
92103
] );
93-
render(
104+
renderWithSettingsProvider(
94105
<WizardContext.Provider
95106
value={ {
96107
completedTasks: {
@@ -123,7 +134,7 @@ describe( 'SetupComplete', () => {
123134
[ 'card', 'ideal' ],
124135
() => null,
125136
] );
126-
render(
137+
renderWithSettingsProvider(
127138
<WizardContext.Provider
128139
value={ {
129140
completedTasks: {
@@ -156,7 +167,7 @@ describe( 'SetupComplete', () => {
156167
[ 'card', ...additionalMethods ],
157168
() => null,
158169
] );
159-
render(
170+
renderWithSettingsProvider(
160171
<WizardContext.Provider
161172
value={ {
162173
completedTasks: {

client/components/deposits-overview/deposit-notices.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export const DepositFailureNotice: React.FC< {
205205
/**
206206
* The link to update the account details.
207207
*/
208-
updateAccountLink: string;
208+
updateAccountLink?: string;
209209
} > = ( { updateAccountLink } ) => {
210210
const accountLinkWithSource = updateAccountLink
211211
? addQueryArgs( updateAccountLink, {

client/components/payment-methods-checkboxes/test/index.test.tsx renamed to client/components/payment-methods-checkboxes/__tests__/index.test.js

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,41 @@
22
/**
33
* External dependencies
44
*/
5-
import React, { ReactNode } from 'react';
5+
import React from 'react';
66
import { render, screen, within } from '@testing-library/react';
77
import userEvent from '@testing-library/user-event';
8+
import { act } from 'react-dom/test-utils';
89

910
/**
1011
* Internal dependencies
1112
*/
1213
import PaymentMethodsCheckboxes from '..';
1314
import PaymentMethodsCheckbox from '../payment-method-checkbox';
1415
import { upeCapabilityStatuses } from '../../../additional-methods-setup/constants';
15-
import { act } from 'react-dom/test-utils';
16+
import WCPaySettingsContext from 'wcpay/settings/wcpay-settings-context';
1617

1718
jest.mock( '@woocommerce/components', () => {
1819
return {
19-
Pill: ( {
20-
className,
21-
children,
22-
}: {
23-
className: string;
24-
children: ReactNode;
25-
} ): React.ReactElement => (
20+
Pill: ( { className, children } ) => (
2621
<span className={ className }>{ children }</span>
2722
),
2823
};
2924
} );
3025

26+
const renderWithSettingsProvider = ( ui ) =>
27+
render(
28+
<WCPaySettingsContext.Provider value={ global.wcpaySettings }>
29+
{ ui }
30+
</WCPaySettingsContext.Provider>
31+
);
32+
3133
describe( 'PaymentMethodsCheckboxes', () => {
34+
beforeEach( () => {
35+
global.wcpaySettings = {
36+
accountFees: {},
37+
};
38+
} );
39+
3240
it( 'triggers the onChange when clicking the checkbox', () => {
3341
const handleChange = jest.fn();
3442

@@ -40,14 +48,14 @@ describe( 'PaymentMethodsCheckboxes', () => {
4048
[ 'sepa_debit', false ],
4149
];
4250

43-
render(
51+
renderWithSettingsProvider(
4452
<PaymentMethodsCheckboxes>
45-
{ upeMethods.map( ( key ) => (
53+
{ upeMethods.map( ( [ name, checked ] ) => (
4654
<PaymentMethodsCheckbox
47-
key={ key[ 0 ] as React.Key }
55+
key={ name }
4856
onChange={ handleChange }
49-
checked={ key[ 1 ] as boolean }
50-
name={ key[ 0 ] as string }
57+
checked={ checked }
58+
name={ name }
5159
status={ upeCapabilityStatuses.ACTIVE }
5260
fees={ '' }
5361
required={ false }
@@ -95,7 +103,7 @@ describe( 'PaymentMethodsCheckboxes', () => {
95103

96104
it( 'can click the checkbox on payment methods with pending statuses', () => {
97105
const handleChange = jest.fn();
98-
render(
106+
renderWithSettingsProvider(
99107
<PaymentMethodsCheckboxes>
100108
<PaymentMethodsCheckbox
101109
key={ 'ideal' }
@@ -126,7 +134,7 @@ describe( 'PaymentMethodsCheckboxes', () => {
126134

127135
it( 'shows the required label on payment methods which are required', () => {
128136
const handleChange = jest.fn();
129-
const page = render(
137+
const page = renderWithSettingsProvider(
130138
<PaymentMethodsCheckboxes>
131139
<PaymentMethodsCheckbox
132140
key={ 'card' }
@@ -148,7 +156,7 @@ describe( 'PaymentMethodsCheckboxes', () => {
148156

149157
it( 'shows the disabled notice pill on payment methods with disabled statuses', () => {
150158
const handleChange = jest.fn();
151-
const page = render(
159+
const page = renderWithSettingsProvider(
152160
<PaymentMethodsCheckboxes>
153161
<PaymentMethodsCheckbox
154162
key={ 'ideal' }
@@ -170,7 +178,7 @@ describe( 'PaymentMethodsCheckboxes', () => {
170178

171179
it( 'can not click the payment methods checkbox that are locked', () => {
172180
const handleChange = jest.fn();
173-
render(
181+
renderWithSettingsProvider(
174182
<PaymentMethodsCheckboxes>
175183
<PaymentMethodsCheckbox
176184
key={ 'card' }
@@ -195,7 +203,7 @@ describe( 'PaymentMethodsCheckboxes', () => {
195203

196204
it( 'can not click the payment methods checkbox with disabled statuses', () => {
197205
const handleChange = jest.fn();
198-
render(
206+
renderWithSettingsProvider(
199207
<PaymentMethodsCheckboxes>
200208
<PaymentMethodsCheckbox
201209
key={ 'ideal' }
@@ -220,7 +228,7 @@ describe( 'PaymentMethodsCheckboxes', () => {
220228

221229
it( "doesn't show the disabled notice pill on payment methods with active and unrequested statuses", () => {
222230
const handleChange = jest.fn();
223-
render(
231+
renderWithSettingsProvider(
224232
<PaymentMethodsCheckboxes>
225233
<PaymentMethodsCheckbox
226234
key={ 'ideal' }

client/globals.d.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ declare global {
1313
isSubscriptionsActive: boolean;
1414
featureFlags: {
1515
customSearch: boolean;
16+
woopay: boolean;
17+
documents: boolean;
18+
woopayExpressCheckout: boolean;
1619
isAuthAndCaptureEnabled: boolean;
1720
paymentTimeline: boolean;
1821
isDisputeIssuerEvidenceEnabled: boolean;
1922
isPaymentOverviewWidgetEnabled?: boolean;
23+
multiCurrency?: boolean;
2024
};
25+
accountFees: Record< string, any >;
2126
fraudServices: unknown[];
2227
testMode: boolean;
2328
testModeOnboarding: boolean;
@@ -26,9 +31,10 @@ declare global {
2631
isJetpackIdcActive: boolean;
2732
isAccountConnected: boolean;
2833
isAccountValid: boolean;
29-
accountStatus: {
34+
accountStatus: Partial< {
3035
email?: string;
3136
created: string;
37+
isLive?: boolean;
3238
error?: boolean;
3339
status?: string;
3440
country?: string;
@@ -69,7 +75,7 @@ declare global {
6975
declineOnAVSFailure: boolean;
7076
declineOnCVCFailure: boolean;
7177
};
72-
};
78+
} >;
7379
accountLoans: {
7480
has_active_loan: boolean;
7581
has_past_loans: boolean;

client/overview/task-list/tasks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const getTasks = ( {
103103
getUpdateBusinessDetailsTask(
104104
errorMessages,
105105
status ?? '',
106-
accountLink,
106+
accountLink ?? '',
107107
Number( currentDeadline ) ?? null,
108108
pastDue ?? false,
109109
detailsSubmitted ?? true

client/overview/task-list/tasks/po-task.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export const getVerifyBankAccountTask = (): any => {
2121
progressiveOnboarding: {
2222
isEnabled: poEnabled,
2323
isComplete: poComplete,
24-
tpv,
24+
tpv = 0,
2525
firstTransactionDate: firstPaymentDate,
26-
},
26+
} = {},
2727
created: createdDate,
2828
} = wcpaySettings.accountStatus;
2929

0 commit comments

Comments
 (0)