Skip to content

Commit

Permalink
feat: GooglePlay live account test node notice
Browse files Browse the repository at this point in the history
  • Loading branch information
frosso committed Feb 24, 2025
1 parent 7199fbb commit e272cd0
Show file tree
Hide file tree
Showing 22 changed files with 366 additions and 225 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: update

feat: add compatibility notice for GooglePlay with live mode accounts.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import WizardTaskContext from '../../wizard/task/context';
import SetupComplete from '../setup-complete-task';
import WizardContext from '../../wizard/wrapper/context';
import { useEnabledPaymentMethodIds } from '../../../data';
import WCPaySettingsContext from 'wcpay/settings/wcpay-settings-context';

jest.mock( '@wordpress/data', () => ( {
useDispatch: jest.fn().mockReturnValue( { updateOptions: jest.fn() } ),
Expand All @@ -18,6 +19,14 @@ jest.mock( '../../../data', () => ( {
useEnabledPaymentMethodIds: jest.fn(),
} ) );

const SettingsContextProvider = ( { children } ) => (
<WCPaySettingsContext.Provider
value={ { featureFlags: { multiCurrency: true } } }
>
{ children }
</WCPaySettingsContext.Provider>
);

describe( 'SetupComplete', () => {
beforeEach( () => {
useEnabledPaymentMethodIds.mockReturnValue( [
Expand All @@ -28,11 +37,13 @@ describe( 'SetupComplete', () => {

it( 'renders setup complete messaging when context value is undefined', () => {
render(
<WizardContext.Provider value={ { completedTasks: {} } }>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
<SettingsContextProvider>
<WizardContext.Provider value={ { completedTasks: {} } }>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
</SettingsContextProvider>
);

expect(
Expand All @@ -42,13 +53,17 @@ describe( 'SetupComplete', () => {

it( 'renders setup complete messaging when context value is `true`', () => {
render(
<WizardContext.Provider
value={ { completedTasks: { 'add-payment-methods': true } } }
>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
<SettingsContextProvider>
<WizardContext.Provider
value={ {
completedTasks: { 'add-payment-methods': true },
} }
>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
</SettingsContextProvider>
);

expect( screen.getByText( /Setup complete/ ) ).toHaveTextContent(
Expand All @@ -58,26 +73,28 @@ describe( 'SetupComplete', () => {

it( 'renders setup complete messaging when context value says that methods have not changed', () => {
render(
<WizardContext.Provider
value={ {
completedTasks: {
'add-payment-methods': {
initialMethods: [
'card',
'bancontact',
'eps',
'ideal',
'p24',
'sepa_debit',
],
<SettingsContextProvider>
<WizardContext.Provider
value={ {
completedTasks: {
'add-payment-methods': {
initialMethods: [
'card',
'bancontact',
'eps',
'ideal',
'p24',
'sepa_debit',
],
},
},
},
} }
>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
} }
>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
</SettingsContextProvider>
);

expect( screen.getByText( /Setup complete/ ) ).toHaveTextContent(
Expand All @@ -91,26 +108,28 @@ describe( 'SetupComplete', () => {
() => null,
] );
render(
<WizardContext.Provider
value={ {
completedTasks: {
'add-payment-methods': {
initialMethods: [
'card',
'bancontact',
'eps',
'ideal',
'p24',
'sepa_debit',
],
<SettingsContextProvider>
<WizardContext.Provider
value={ {
completedTasks: {
'add-payment-methods': {
initialMethods: [
'card',
'bancontact',
'eps',
'ideal',
'p24',
'sepa_debit',
],
},
},
},
} }
>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
} }
>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
</SettingsContextProvider>
);

expect( screen.getByText( /Setup complete/ ) ).toHaveTextContent(
Expand All @@ -124,19 +143,21 @@ describe( 'SetupComplete', () => {
() => null,
] );
render(
<WizardContext.Provider
value={ {
completedTasks: {
'add-payment-methods': {
initialMethods: [ 'card' ],
<SettingsContextProvider>
<WizardContext.Provider
value={ {
completedTasks: {
'add-payment-methods': {
initialMethods: [ 'card' ],
},
},
},
} }
>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
} }
>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
</SettingsContextProvider>
);

expect( screen.getByText( /Setup complete/ ) ).toHaveTextContent(
Expand All @@ -157,19 +178,21 @@ describe( 'SetupComplete', () => {
() => null,
] );
render(
<WizardContext.Provider
value={ {
completedTasks: {
'add-payment-methods': {
initialMethods: [ 'card' ],
<SettingsContextProvider>
<WizardContext.Provider
value={ {
completedTasks: {
'add-payment-methods': {
initialMethods: [ 'card' ],
},
},
},
} }
>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
} }
>
<WizardTaskContext.Provider value={ { isActive: true } }>
<SetupComplete />
</WizardTaskContext.Provider>
</WizardContext.Provider>
</SettingsContextProvider>
);

expect( screen.getByText( /Setup complete/ ) ).toHaveTextContent(
Expand Down
2 changes: 1 addition & 1 deletion client/components/deposits-overview/deposit-notices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export const DepositFailureNotice: React.FC< {
/**
* The link to update the account details.
*/
updateAccountLink: string;
updateAccountLink?: string;
} > = ( { updateAccountLink } ) => {
const accountLinkWithSource = updateAccountLink
? addQueryArgs( updateAccountLink, {
Expand Down
2 changes: 1 addition & 1 deletion client/components/deposits-overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const DepositsOverview: React.FC = () => {
{ hasErroredExternalAccount && (
<DepositFailureNotice
updateAccountLink={
wcpaySettings.accountStatus.accountLink
wcpaySettings.accountStatus?.accountLink
}
/>
) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const PaymentMethodCheckbox: React.FC< PaymentMethodCheckboxProps > = ( {
} ) => {
const {
accountFees,
}: { accountFees: Record< string, FeeStructure > } = useContext(
}: { accountFees?: Record< string, FeeStructure > } = useContext(
WCPaySettingsContext
);

Expand Down Expand Up @@ -192,10 +192,10 @@ const PaymentMethodCheckbox: React.FC< PaymentMethodCheckboxProps > = ( {
</PaymentMethodDisabledTooltip>
) }
</div>
<div className={ 'payment-method-checkbox__pills-right' }>
<div className="payment-method-checkbox__pills-right">
<HoverTooltip
content={ formatMethodFeesTooltip(
accountFees[ name ]
accountFees?.[ name ]
) }
maxWidth={ '300px' }
>
Expand All @@ -210,7 +210,7 @@ const PaymentMethodCheckbox: React.FC< PaymentMethodCheckboxProps > = ( {
>
<span>
{ formatMethodFeesDescription(
accountFees[ name ]
accountFees?.[ name ]
) }
</span>
</Pill>
Expand Down
13 changes: 9 additions & 4 deletions client/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ declare global {
connectUrl: string;
overviewUrl: string;
isSubscriptionsActive: boolean;
featureFlags: {
featureFlags: Partial< {
customSearch: boolean;
woopay: boolean;
woopayExpressCheckout: boolean;
isAuthAndCaptureEnabled: boolean;
paymentTimeline: boolean;
isDisputeIssuerEvidenceEnabled: boolean;
isPaymentOverviewWidgetEnabled?: boolean;
};
multiCurrency?: boolean;
} >;
accountFees: Record< string, any >;
fraudServices: unknown[];
testMode: boolean;
testModeOnboarding: boolean;
Expand All @@ -26,9 +30,10 @@ declare global {
isJetpackIdcActive: boolean;
isAccountConnected: boolean;
isAccountValid: boolean;
accountStatus: {
accountStatus: Partial< {
email?: string;
created: string;
isLive?: boolean;
error?: boolean;
status?: string;
country?: string;
Expand Down Expand Up @@ -69,7 +74,7 @@ declare global {
declineOnAVSFailure: boolean;
declineOnCVCFailure: boolean;
};
};
} >;
accountLoans: {
has_active_loan: boolean;
has_past_loans: boolean;
Expand Down
2 changes: 1 addition & 1 deletion client/overview/task-list/tasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const getTasks = ( {
getUpdateBusinessDetailsTask(
errorMessages,
status ?? '',
accountLink,
accountLink ?? '',
Number( currentDeadline ) ?? null,
pastDue ?? false,
detailsSubmitted ?? true
Expand Down
4 changes: 2 additions & 2 deletions client/overview/task-list/tasks/po-task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export const getVerifyBankAccountTask = (): any => {
progressiveOnboarding: {
isEnabled: poEnabled,
isComplete: poComplete,
tpv,
tpv = 0,
firstTransactionDate: firstPaymentDate,
},
} = {},
created: createdDate,
} = wcpaySettings.accountStatus;

Expand Down
Loading

0 comments on commit e272cd0

Please sign in to comment.