-
diff --git a/client/components/platform-checkout/save-user/style.scss b/client/components/woopay/save-user/style.scss
similarity index 97%
rename from client/components/platform-checkout/save-user/style.scss
rename to client/components/woopay/save-user/style.scss
index b86c7ea6814..c95090c127c 100644
--- a/client/components/platform-checkout/save-user/style.scss
+++ b/client/components/woopay/save-user/style.scss
@@ -1,7 +1,7 @@
@import '../../../stylesheets/abstracts/colors';
@import '../../../stylesheets/abstracts/variables';
-.platform-checkout-save-new-user-container {
+.woopay-save-new-user-container {
.save-details {
padding: $gap-small;
border: 1px solid rgba( 109, 109, 109, 0.3 );
diff --git a/client/components/platform-checkout/save-user/test/checkout-page-save-user.test.js b/client/components/woopay/save-user/test/checkout-page-save-user.test.js
similarity index 82%
rename from client/components/platform-checkout/save-user/test/checkout-page-save-user.test.js
rename to client/components/woopay/save-user/test/checkout-page-save-user.test.js
index d548fab3fb8..8fdf2fc96aa 100644
--- a/client/components/platform-checkout/save-user/test/checkout-page-save-user.test.js
+++ b/client/components/woopay/save-user/test/checkout-page-save-user.test.js
@@ -11,11 +11,11 @@ import { extensionCartUpdate } from '@woocommerce/blocks-checkout';
* Internal dependencies
*/
import CheckoutPageSaveUser from '../checkout-page-save-user';
-import usePlatformCheckoutUser from '../../hooks/use-platform-checkout-user';
+import useWooPayUser from '../../hooks/use-woopay-user';
import useSelectedPaymentMethod from '../../hooks/use-selected-payment-method';
import { getConfig } from 'utils/checkout';
-jest.mock( '../../hooks/use-platform-checkout-user', () => jest.fn() );
+jest.mock( '../../hooks/use-woopay-user', () => jest.fn() );
jest.mock( '../../hooks/use-selected-payment-method', () => jest.fn() );
jest.mock( 'utils/checkout', () => ( {
getConfig: jest.fn(),
@@ -36,7 +36,7 @@ jest.mock( '@wordpress/data', () => ( {
describe( 'CheckoutPageSaveUser', () => {
beforeEach( () => {
- usePlatformCheckoutUser.mockImplementation( () => false );
+ useWooPayUser.mockImplementation( () => false );
useSelectedPaymentMethod.mockImplementation( () => ( {
isWCPayChosen: true,
@@ -52,7 +52,7 @@ describe( 'CheckoutPageSaveUser', () => {
jest.restoreAllMocks();
} );
- it( 'should render checkbox for saving Platform Checkout user when user is not registered and selected payment method is card', () => {
+ it( 'should render checkbox for saving WooPay user when user is not registered and selected payment method is card', () => {
render(
);
expect(
screen.queryByLabelText(
@@ -66,8 +66,8 @@ describe( 'CheckoutPageSaveUser', () => {
).not.toBeChecked();
} );
- it( 'should not render checkbox for saving Platform Checkout user when user is already registered', () => {
- usePlatformCheckoutUser.mockImplementation( () => true );
+ it( 'should not render checkbox for saving WooPay user when user is already registered', () => {
+ useWooPayUser.mockImplementation( () => true );
render(
);
expect(
@@ -77,7 +77,7 @@ describe( 'CheckoutPageSaveUser', () => {
).not.toBeInTheDocument();
} );
- it( 'should not render checkbox for saving Platform Checkout user when forceNetworkSavedCards is false', () => {
+ it( 'should not render checkbox for saving WooPay user when forceNetworkSavedCards is false', () => {
getConfig.mockImplementation( () => false );
render(
);
@@ -88,7 +88,7 @@ describe( 'CheckoutPageSaveUser', () => {
).not.toBeInTheDocument();
} );
- it( 'should render checkbox for saving Platform Checkout user when selected payment method is not card', () => {
+ it( 'should render checkbox for saving WooPay user when selected payment method is not card', () => {
useSelectedPaymentMethod.mockImplementation( () => ( {
isWCPayChosen: false,
} ) );
@@ -183,13 +183,13 @@ describe( 'CheckoutPageSaveUser', () => {
expect( label ).toBeChecked();
await waitFor( () =>
expect( extensionCartUpdate ).toHaveBeenCalledWith( {
- namespace: 'platform-checkout',
+ namespace: 'woopay',
data: {
- save_user_in_platform_checkout: true,
- platform_checkout_source_url: 'http://localhost/',
- platform_checkout_is_blocks: true,
- platform_checkout_viewport: '0x0',
- platform_checkout_user_phone_field: {
+ save_user_in_woopay: true,
+ woopay_source_url: 'http://localhost/',
+ woopay_is_blocks: true,
+ woopay_viewport: '0x0',
+ woopay_user_phone_field: {
full: '+12015555555',
},
},
@@ -202,7 +202,7 @@ describe( 'CheckoutPageSaveUser', () => {
expect( label ).not.toBeChecked();
await waitFor( () =>
expect( extensionCartUpdate ).toHaveBeenCalledWith( {
- namespace: 'platform-checkout',
+ namespace: 'woopay',
data: {},
} )
);
@@ -242,13 +242,13 @@ describe( 'CheckoutPageSaveUser', () => {
expect( label ).toBeChecked();
await waitFor( () =>
expect( extensionCartUpdate ).toHaveBeenCalledWith( {
- namespace: 'platform-checkout',
+ namespace: 'woopay',
data: {
- save_user_in_platform_checkout: true,
- platform_checkout_source_url: 'http://localhost/',
- platform_checkout_is_blocks: true,
- platform_checkout_viewport: '0x0',
- platform_checkout_user_phone_field: {
+ save_user_in_woopay: true,
+ woopay_source_url: 'http://localhost/',
+ woopay_is_blocks: true,
+ woopay_viewport: '0x0',
+ woopay_user_phone_field: {
full: '+12015555555',
},
},
@@ -261,7 +261,7 @@ describe( 'CheckoutPageSaveUser', () => {
expect( label ).not.toBeChecked();
await waitFor( () =>
expect( extensionCartUpdate ).toHaveBeenCalledWith( {
- namespace: 'platform-checkout',
+ namespace: 'woopay',
data: {},
} )
);
diff --git a/client/components/platform-checkout/test/index.test.js b/client/components/woopay/test/index.test.js
similarity index 67%
rename from client/components/platform-checkout/test/index.test.js
rename to client/components/woopay/test/index.test.js
index ea7e5942de2..77ad76d8381 100644
--- a/client/components/platform-checkout/test/index.test.js
+++ b/client/components/woopay/test/index.test.js
@@ -8,17 +8,17 @@ import userEvent from '@testing-library/user-event';
/**
* Internal dependencies
*/
-import { platformCheckoutPaymentMethod } from '..';
+import { woopayPaymentMethod } from '..';
jest.mock( 'utils/checkout', () => ( {
getConfig: jest.fn(),
} ) );
-describe( 'platformCheckoutPaymentMethod', () => {
+describe( 'woopayPaymentMethod', () => {
let nativeWindowLocation;
const apiMock = {
- initPlatformCheckout: jest.fn(),
+ initWooPay: jest.fn(),
};
beforeEach( () => {
@@ -29,7 +29,7 @@ describe( 'platformCheckoutPaymentMethod', () => {
Object.defineProperty( window, 'location', {
writable: true,
} );
- apiMock.initPlatformCheckout = jest.fn();
+ apiMock.initWooPay = jest.fn();
} );
afterEach( () => {
@@ -37,61 +37,61 @@ describe( 'platformCheckoutPaymentMethod', () => {
} );
test( 'creates expected payment method object', () => {
- const method = platformCheckoutPaymentMethod( apiMock );
+ const method = woopayPaymentMethod( apiMock );
expect( method ).toEqual(
expect.objectContaining( {
- name: 'platform_checkout',
+ name: 'woopay',
paymentMethodId: 'woocommerce_payments',
} )
);
} );
test( 'method front-end matches expectation', () => {
- const method = platformCheckoutPaymentMethod( apiMock );
+ const method = woopayPaymentMethod( apiMock );
render( method.content );
expect(
screen.queryByRole( 'button', {
- name: /Buy now with.*platform checkout/,
+ name: /Buy now with.*woopay/,
} )
).toBeInTheDocument();
} );
test( 'method edit mode matches expectation', () => {
- const method = platformCheckoutPaymentMethod( apiMock );
+ const method = woopayPaymentMethod( apiMock );
render( method.edit );
// No button this time but the text should still be there.
expect(
screen.queryByRole( 'button', {
- name: /Buy now with.*platform checkout/,
+ name: /Buy now with.*woopay/,
} )
).not.toBeInTheDocument();
expect(
- screen.queryByText( /Buy now with.*platform checkout/ )
+ screen.queryByText( /Buy now with.*woopay/ )
).toBeInTheDocument();
} );
- test( 'clicking checkout button calls initPlatformCheckout()', async () => {
+ test( 'clicking checkout button calls initWooPay()', async () => {
let resolvePromise;
const initCheckoutPromise = new Promise( ( resolve ) => {
resolvePromise = resolve;
} );
- apiMock.initPlatformCheckout.mockReturnValue( initCheckoutPromise );
+ apiMock.initWooPay.mockReturnValue( initCheckoutPromise );
- const method = platformCheckoutPaymentMethod( apiMock );
+ const method = woopayPaymentMethod( apiMock );
render( method.content );
// Button should not be disabled initially.
const buyNowButton = screen.getByRole( 'button', {
- name: /Buy now with.*platform checkout/,
+ name: /Buy now with.*woopay/,
} );
expect( buyNowButton ).not.toBeDisabled();
- // Let's click it. It should be disabled and initPlatformCheckout should be called.
+ // Let's click it. It should be disabled and initWooPay should be called.
userEvent.click( buyNowButton );
expect( buyNowButton ).toBeDisabled();
- expect( apiMock.initPlatformCheckout ).toHaveBeenCalledTimes( 1 );
+ expect( apiMock.initWooPay ).toHaveBeenCalledTimes( 1 );
/*
* The button should be enabled again once the promise is resolved and
diff --git a/client/connect-account-page/info-modal/test/__snapshots__/index.tsx.snap b/client/connect-account-page/info-modal/test/__snapshots__/index.tsx.snap
index 2af3edac78a..13522edbd4b 100644
--- a/client/connect-account-page/info-modal/test/__snapshots__/index.tsx.snap
+++ b/client/connect-account-page/info-modal/test/__snapshots__/index.tsx.snap
@@ -32,9 +32,10 @@ exports[`Onboarding: more info modal renders correctly when opened 1`] = `
@@ -426,7 +426,7 @@ exports[`Deposits list renders correctly a single deposit 1`] = `
>
@@ -639,7 +639,7 @@ exports[`Deposits list renders correctly with multiple currencies 1`] = `
>
@@ -875,7 +875,7 @@ exports[`Deposits list renders correctly with multiple currencies 1`] = `
>
@@ -962,7 +962,7 @@ exports[`Deposits list renders correctly with multiple currencies 1`] = `
>
diff --git a/client/deposits/utils/index.js b/client/deposits/utils/index.js
deleted file mode 100644
index 06b0aa89d2e..00000000000
--- a/client/deposits/utils/index.js
+++ /dev/null
@@ -1,208 +0,0 @@
-/**
- * External dependencies
- */
-import { __, sprintf, _n } from '@wordpress/i18n';
-import { dateI18n } from '@wordpress/date';
-import moment from 'moment';
-import { createInterpolateElement } from '@wordpress/element';
-
-/**
- * Internal dependencies.
- */
-import { getAdminUrl } from 'wcpay/utils';
-
-const formatDate = ( format, date ) =>
- dateI18n(
- format,
- moment.utc( date ).toISOString(),
- true // TODO Change call to gmdateI18n and remove this deprecated param once WP 5.4 support ends.
- );
-
-export const getDepositDate = ( deposit ) =>
- deposit ? formatDate( 'F j, Y', deposit.date ) : '—';
-
-export const getBalanceDepositCount = ( balance ) =>
- sprintf(
- _n(
- '%d deposit',
- '%d deposits',
- balance.deposits_count,
- 'woocommerce-payments'
- ),
- balance.deposits_count
- );
-
-export const getNextDepositLabelFormatted = ( deposit ) => {
- const baseLabel = deposit
- ? `${ __( 'Est.', 'woocommerce-payments' ) } ${ formatDate(
- 'M j, Y',
- deposit.date
- ) }`
- : '—';
- if ( deposit && 'in_transit' === deposit.status ) {
- return `${ baseLabel } - ${ __(
- 'In transit',
- 'woocommerce-payments'
- ) }`;
- }
- return baseLabel;
-};
-
-export const getDepositMonthlyAnchorLabel = ( {
- monthlyAnchor,
- capitalize = true,
-} ) => {
- // If locale is set up as en_US or en_GB the ordinal will not show up
- // More details can be found in https://github.com/WordPress/gutenberg/issues/15221/
- // Using 'en' as the locale should be enough to workaround it
- // TODO: Remove workaround when issue is resolved
- const fixedLocale = moment.locale().startsWith( 'en' )
- ? 'en'
- : moment.locale();
-
- let label = moment()
- .locale( fixedLocale )
- .date( monthlyAnchor )
- .format( 'Do' );
-
- if ( 31 === monthlyAnchor ) {
- label = __( 'Last day of the month', 'woocommerce-payments' );
- }
- if ( ! capitalize ) {
- label = label.toLowerCase();
- }
- return label;
-};
-
-const formatDepositSchedule = ( schedule ) => {
- switch ( schedule.interval ) {
- case 'manual':
- return __( 'Deposits set to manual.', 'woocommerce-payments' );
- case 'daily':
- return __( 'Deposits set to daily.', 'woocommerce-payments' );
- case 'weekly':
- return sprintf(
- /** translators: %s day of the week e.g. Monday */
- __( 'Deposits set to every %s.', 'woocommerce-payments' ),
- // moment().day() is locale based when using strings. Since Stripe's response is in English,
- // we need to temporarily set the locale to add the day before formatting
- moment()
- .locale( 'en' )
- .day( schedule.weekly_anchor )
- .locale( moment.locale() )
- .format( 'dddd' )
- );
- case 'monthly':
- return sprintf(
- /** translators: %s day of the month */
- __(
- 'Deposits set to monthly on the %s.',
- 'woocommerce-payments'
- ),
- getDepositMonthlyAnchorLabel( {
- monthlyAnchor: schedule.monthly_anchor,
- capitalize: false,
- } )
- );
- }
-};
-
-export const getDepositScheduleDescriptor = ( {
- account: {
- deposits_schedule: schedule,
- deposits_disabled: disabled,
- deposits_blocked: blocked,
- },
- last_deposit: last,
-} ) => {
- const hasCompletedWaitingPeriod =
- window.wcpaySettings?.accountStatus?.deposits
- ?.completed_waiting_period ?? false;
-
- const learnMoreHref =
- 'https://woocommerce.com/document/payments/faq/deposit-schedule/';
-
- if ( disabled || blocked ) {
- return createInterpolateElement(
- /* translators:
- suspended accounts FAQ URL */
- __(
- 'Deposits temporarily suspended (learn more).',
- 'woocommerce-payments'
- ),
- {
- a: (
- // eslint-disable-next-line jsx-a11y/anchor-has-content
-
- ),
- }
- );
- }
-
- if ( ! last ) {
- return createInterpolateElement(
- sprintf(
- /** translators: %s - deposit schedule,
- waiting period doc URL */
- __(
- '%s Your first deposit is held for seven days (learn more).',
- 'woocommerce-payments'
- ),
- formatDepositSchedule( schedule )
- ),
- {
- a: (
- // eslint-disable-next-line jsx-a11y/anchor-has-content
-
- ),
- }
- );
- }
-
- if ( hasCompletedWaitingPeriod && ! blocked && ! disabled ) {
- return createInterpolateElement(
- sprintf(
- /** translators: %s - deposit schedule,
- Settings page URL */
- __(
- '%s Change this or
.',
- 'woocommerce-payments'
- ),
- formatDepositSchedule( schedule )
- ),
- {
- a: (
- // eslint-disable-next-line jsx-a11y/anchor-has-content
-
- ),
- learn_more_href: (
- // eslint-disable-next-line jsx-a11y/anchor-has-content
-
- { __( 'learn more', 'woocommerce-payments' ) }
-
- ),
- }
- );
- }
-
- return formatDepositSchedule( schedule );
-};
diff --git a/client/deposits/utils/index.ts b/client/deposits/utils/index.ts
new file mode 100644
index 00000000000..a8c0470b51c
--- /dev/null
+++ b/client/deposits/utils/index.ts
@@ -0,0 +1,49 @@
+/**
+ * External dependencies
+ */
+import { __ } from '@wordpress/i18n';
+import { dateI18n } from '@wordpress/date';
+import moment from 'moment';
+
+const formatDate = ( format: string, date: number | string ) =>
+ dateI18n(
+ format,
+ moment.utc( date ).toISOString(),
+ true // TODO Change call to gmdateI18n and remove this deprecated param once WP 5.4 support ends.
+ );
+
+interface DepositObject {
+ date: number | string;
+}
+export const getDepositDate = ( deposit?: DepositObject | null ): string =>
+ deposit ? formatDate( 'F j, Y', deposit?.date ) : '—';
+
+interface GetDepositMonthlyAnchorLabelProps {
+ monthlyAnchor: number;
+ capitalize?: boolean;
+}
+export const getDepositMonthlyAnchorLabel = ( {
+ monthlyAnchor,
+ capitalize = true,
+}: GetDepositMonthlyAnchorLabelProps ): string => {
+ // If locale is set up as en_US or en_GB the ordinal will not show up
+ // More details can be found in https://github.com/WordPress/gutenberg/issues/15221/
+ // Using 'en' as the locale should be enough to workaround it
+ // TODO: Remove workaround when issue is resolved
+ const fixedLocale = moment.locale().startsWith( 'en' )
+ ? 'en'
+ : moment.locale();
+
+ let label = moment()
+ .locale( fixedLocale )
+ .date( monthlyAnchor )
+ .format( 'Do' );
+
+ if ( 31 === monthlyAnchor ) {
+ label = __( 'Last day of the month', 'woocommerce-payments' );
+ }
+ if ( ! capitalize ) {
+ label = label.toLowerCase();
+ }
+ return label;
+};
diff --git a/client/deposits/utils/test/index.js b/client/deposits/utils/test/index.js
deleted file mode 100644
index d90d30cebfd..00000000000
--- a/client/deposits/utils/test/index.js
+++ /dev/null
@@ -1,241 +0,0 @@
-/**
- * External dependencies
- */
-import { render } from '@testing-library/react';
-import momentLib from 'moment';
-
-/**
- * Internal dependencies
- */
-import {
- getDepositDate,
- getBalanceDepositCount,
- getNextDepositLabelFormatted,
- getDepositScheduleDescriptor,
- getDepositMonthlyAnchorLabel,
-} from './..';
-
-function getDepositSchedule(
- schedule,
- includeLastDeposit = true,
- disabled = false,
- blocked = false
-) {
- const lastDeposit = {
- id: 'last_deposit',
- amount: 6574,
- date: new Date( '2019-04-18' ).getTime(),
- };
-
- const descriptor = getDepositScheduleDescriptor( {
- account: {
- deposits_schedule: schedule,
- deposits_disabled: disabled,
- deposits_blocked: blocked,
- },
- last_deposit: includeLastDeposit ? lastDeposit : null,
- } );
-
- if ( 'string' === typeof descriptor ) {
- return descriptor;
- }
-
- const { container } = render( descriptor );
- return container.textContent;
-}
-
-describe( 'Deposits Overview Utils / getDepositScheduleDescriptor', () => {
- test( 'renders temporarily suspended notice for accounts with disabled deposits', () => {
- const depositSchedule = getDepositSchedule(
- { interval: 'daily' },
- true,
- true
- );
- expect( depositSchedule ).toEqual(
- 'Deposits temporarily suspended (learn more).'
- );
- } );
-
- test( 'renders temporarily suspended notice for accounts with deposits blocked', () => {
- const depositSchedule = getDepositSchedule(
- { interval: 'daily' },
- true,
- false,
- true // blocked
- );
- expect( depositSchedule ).toEqual(
- 'Deposits temporarily suspended (learn more).'
- );
- } );
-
- test( 'renders deposit schedule for manual interval', () => {
- const depositSchedule = getDepositSchedule( { interval: 'manual' } );
- expect( depositSchedule ).toEqual( 'Deposits set to manual.' );
- } );
-
- test( 'renders deposit schedule for daily interval', () => {
- const depositSchedule = getDepositSchedule( { interval: 'daily' } );
- expect( depositSchedule ).toEqual( 'Deposits set to daily.' );
- } );
-
- test( 'renders deposit schedule for weekly interval', () => {
- const depositSchedule = getDepositSchedule( {
- interval: 'weekly',
- weekly_anchor: 'monday',
- } );
- expect( depositSchedule ).toEqual( 'Deposits set to every Monday.' );
- } );
-
- test( 'renders deposit schedule for monthly interval', () => {
- const depositSchedule = getDepositSchedule( {
- interval: 'monthly',
- monthly_anchor: 26,
- } );
- expect( depositSchedule ).toEqual(
- 'Deposits set to monthly on the 26th.'
- );
- } );
-
- test( 'renders deposit schedule for monthly interval', () => {
- const depositSchedule = getDepositSchedule( {
- interval: 'monthly',
- monthly_anchor: 31,
- } );
- expect( depositSchedule ).toEqual(
- 'Deposits set to monthly on the last day of the month.'
- );
- } );
-
- test( 'renders weekly anchor for non en locales', () => {
- momentLib.locale( 'de' );
- const depositSchedule = getDepositSchedule( {
- interval: 'weekly',
- weekly_anchor: 'tuesday',
- } );
- // without resetting the locale to en the anchor monday would become Sonntag, instead of Dienstag
- expect( depositSchedule ).toEqual( 'Deposits set to every Dienstag.' );
- // the default locale should not have changed
- expect( momentLib.locale() ).toEqual( 'de' );
- } );
-
- test( 'renders deposit delay notice prior to first deposit', () => {
- const depositSchedule = getDepositSchedule(
- { interval: 'daily' },
- false
- );
- expect( depositSchedule ).toEqual(
- 'Deposits set to daily. Your first deposit is held for seven days (learn more).'
- );
- } );
-} );
-
-describe( 'Deposits Overview Utils / getDepositDate', () => {
- test( 'returns a display value without a deposit', () => {
- expect( getDepositDate() ).toEqual( '—' );
- } );
-
- test( 'Returns a well-formated date', () => {
- const deposit = {
- date: new Date( '2019-04-18' ).getTime(),
- };
-
- expect( getDepositDate( deposit ) ).toEqual( 'April 18, 2019' );
- } );
-} );
-
-describe( 'Deposits Overview Utils / getBalanceDepositCount', () => {
- test( 'formats the count with a single deposit', () => {
- const balance = { deposits_count: 1 };
- expect( getBalanceDepositCount( balance ) ).toEqual( '1 deposit' );
- } );
-
- test( 'formats the count with multiple deposits', () => {
- const balance = { deposits_count: 3 };
- expect( getBalanceDepositCount( balance ) ).toEqual( '3 deposits' );
- } );
-} );
-
-describe( 'Deposits Overview Utils / getNextDepositLabelFormatted', () => {
- test( 'returns a display value without a deposit', () => {
- expect( getNextDepositLabelFormatted() ).toEqual( '—' );
- } );
-
- test( 'returns a well-formated estimation string', () => {
- const deposit = {
- date: new Date( '2019-04-18' ).getTime(),
- };
-
- expect( getNextDepositLabelFormatted( deposit ) ).toEqual(
- 'Est. Apr 18, 2019'
- );
- } );
-
- test( 'includes the in-transit status', () => {
- const deposit = {
- date: new Date( '2019-04-18' ).getTime(),
- status: 'in_transit',
- };
-
- expect( getNextDepositLabelFormatted( deposit ) ).toEqual(
- 'Est. Apr 18, 2019 - In transit'
- );
- } );
-} );
-
-describe( 'Deposits Overview Utils / getDepositMonthlyAnchorLabel', () => {
- const expectedLabels = [
- { label: '1st', value: 1 },
- { label: '2nd', value: 2 },
- { label: '3rd', value: 3 },
- { label: '4th', value: 4 },
- { label: '5th', value: 5 },
- { label: '6th', value: 6 },
- { label: '7th', value: 7 },
- { label: '8th', value: 8 },
- { label: '9th', value: 9 },
- { label: '10th', value: 10 },
- { label: '11th', value: 11 },
- { label: '12th', value: 12 },
- { label: '13th', value: 13 },
- { label: '14th', value: 14 },
- { label: '15th', value: 15 },
- { label: '16th', value: 16 },
- { label: '17th', value: 17 },
- { label: '18th', value: 18 },
- { label: '19th', value: 19 },
- { label: '20th', value: 20 },
- { label: '21st', value: 21 },
- { label: '22nd', value: 22 },
- { label: '23rd', value: 23 },
- { label: '24th', value: 24 },
- { label: '25th', value: 25 },
- { label: '26th', value: 26 },
- { label: '27th', value: 27 },
- { label: '28th', value: 28 },
- {
- label: 'Last day of the month',
- value: 31,
- },
- ];
-
- test( 'returns the expected label', () => {
- momentLib.locale( 'en' );
- expectedLabels.forEach( ( expectedLabel ) => {
- expect(
- getDepositMonthlyAnchorLabel( {
- monthlyAnchor: expectedLabel.value,
- } )
- ).toEqual( expectedLabel.label );
- } );
- } );
-
- test( 'returns a lowercase value with false capitalize argument', () => {
- momentLib.locale( 'en' );
- expect(
- getDepositMonthlyAnchorLabel( {
- monthlyAnchor: 31,
- capitalize: false,
- } )
- ).toEqual( 'last day of the month' );
- } );
-} );
diff --git a/client/deposits/utils/test/index.ts b/client/deposits/utils/test/index.ts
new file mode 100644
index 00000000000..d0361137104
--- /dev/null
+++ b/client/deposits/utils/test/index.ts
@@ -0,0 +1,81 @@
+/**
+ * External dependencies
+ */
+import momentLib from 'moment';
+
+/**
+ * Internal dependencies
+ */
+import { getDepositDate, getDepositMonthlyAnchorLabel } from '../';
+
+describe( 'Deposits Overview Utils / getDepositDate', () => {
+ test( 'returns a display value without a deposit', () => {
+ expect( getDepositDate() ).toEqual( '—' );
+ } );
+
+ test( 'Returns a well-formated date', () => {
+ const deposit = {
+ date: new Date( '2019-04-18' ).getTime(),
+ };
+
+ expect( getDepositDate( deposit ) ).toEqual( 'April 18, 2019' );
+ } );
+} );
+
+describe( 'Deposits Overview Utils / getDepositMonthlyAnchorLabel', () => {
+ const expectedLabels = [
+ { label: '1st', value: 1 },
+ { label: '2nd', value: 2 },
+ { label: '3rd', value: 3 },
+ { label: '4th', value: 4 },
+ { label: '5th', value: 5 },
+ { label: '6th', value: 6 },
+ { label: '7th', value: 7 },
+ { label: '8th', value: 8 },
+ { label: '9th', value: 9 },
+ { label: '10th', value: 10 },
+ { label: '11th', value: 11 },
+ { label: '12th', value: 12 },
+ { label: '13th', value: 13 },
+ { label: '14th', value: 14 },
+ { label: '15th', value: 15 },
+ { label: '16th', value: 16 },
+ { label: '17th', value: 17 },
+ { label: '18th', value: 18 },
+ { label: '19th', value: 19 },
+ { label: '20th', value: 20 },
+ { label: '21st', value: 21 },
+ { label: '22nd', value: 22 },
+ { label: '23rd', value: 23 },
+ { label: '24th', value: 24 },
+ { label: '25th', value: 25 },
+ { label: '26th', value: 26 },
+ { label: '27th', value: 27 },
+ { label: '28th', value: 28 },
+ {
+ label: 'Last day of the month',
+ value: 31,
+ },
+ ];
+
+ test( 'returns the expected label', () => {
+ momentLib.locale( 'en' );
+ expectedLabels.forEach( ( expectedLabel ) => {
+ expect(
+ getDepositMonthlyAnchorLabel( {
+ monthlyAnchor: expectedLabel.value,
+ } )
+ ).toEqual( expectedLabel.label );
+ } );
+ } );
+
+ test( 'returns a lowercase value with false capitalize argument', () => {
+ momentLib.locale( 'en' );
+ expect(
+ getDepositMonthlyAnchorLabel( {
+ monthlyAnchor: 31,
+ capitalize: false,
+ } )
+ ).toEqual( 'last day of the month' );
+ } );
+} );
diff --git a/client/disputes/evidence/test/__snapshots__/index.js.snap b/client/disputes/evidence/test/__snapshots__/index.js.snap
index 5369e26a190..38efd7b70eb 100644
--- a/client/disputes/evidence/test/__snapshots__/index.js.snap
+++ b/client/disputes/evidence/test/__snapshots__/index.js.snap
@@ -91,7 +91,7 @@ exports[`Dispute evidence form needing response, renders correctly 1`] = `
>
diff --git a/client/disputes/test/__snapshots__/index.tsx.snap b/client/disputes/test/__snapshots__/index.tsx.snap
index bb0006c4b79..5f4c8b6cec9 100644
--- a/client/disputes/test/__snapshots__/index.tsx.snap
+++ b/client/disputes/test/__snapshots__/index.tsx.snap
@@ -76,7 +76,7 @@ exports[`Disputes list renders correctly 1`] = `
>
@@ -386,7 +386,7 @@ exports[`Disputes list renders correctly 1`] = `
>
@@ -509,7 +509,7 @@ exports[`Disputes list renders correctly 1`] = `
>
@@ -629,7 +629,7 @@ exports[`Disputes list renders correctly 1`] = `
>
diff --git a/client/external-declarations.d.ts b/client/external-declarations.d.ts
new file mode 100644
index 00000000000..8a60ed02226
--- /dev/null
+++ b/client/external-declarations.d.ts
@@ -0,0 +1,12 @@
+/**
+ * External dependencies
+ */
+import '@wordpress/date';
+
+declare module '@wordpress/date' {
+ export function dateI18n(
+ dateFormat: string,
+ dateValue: import('moment').Moment | Date | string | undefined,
+ timezone?: string | boolean
+ ): string;
+}
diff --git a/client/globals.d.ts b/client/globals.d.ts
index c8201024ae5..e998ced76be 100644
--- a/client/globals.d.ts
+++ b/client/globals.d.ts
@@ -1,74 +1,90 @@
-declare interface RequirementError {
- code: string;
- reason: string;
- requirement: string;
-}
+/**
+ * Internal dependencies
+ */
+import { MccsDisplayTreeItem, Country } from 'onboarding-prototype/types';
-declare const wcpaySettings: {
- connectUrl: string;
- isSubscriptionsActive: boolean;
- featureFlags: {
- customSearch: boolean;
- isAuthAndCaptureEnabled: boolean;
- simplifyDepositsUi?: boolean;
- paymentTimeline: boolean;
- };
- fraudServices: unknown[];
- isJetpackConnected: boolean;
- isJetpackIdcActive: boolean;
- accountStatus: {
- email?: string;
- created: string;
- error?: boolean;
- status?: string;
- country?: string;
- paymentsEnabled?: boolean;
- deposits?: {
- status: string;
- interval: string;
- weekly_anchor: string;
- monthly_anchor: null | number;
- delay_days: null | number;
- completed_waiting_period: boolean;
- minimum_deposit_amounts: Record< string, number >;
+declare global {
+ const wcpaySettings: {
+ connectUrl: string;
+ isSubscriptionsActive: boolean;
+ featureFlags: {
+ customSearch: boolean;
+ isAuthAndCaptureEnabled: boolean;
+ paymentTimeline: boolean;
};
- depositsStatus?: string;
- currentDeadline?: bigint;
- pastDue?: boolean;
- accountLink: string;
- hasSubmittedVatData?: boolean;
- requirements?: {
- errors?: Array< RequirementError >;
+ fraudServices: unknown[];
+ isJetpackConnected: boolean;
+ isJetpackIdcActive: boolean;
+ accountStatus: {
+ email?: string;
+ created: string;
+ error?: boolean;
+ status?: string;
+ country?: string;
+ paymentsEnabled?: boolean;
+ deposits?: {
+ status: string;
+ interval: string;
+ weekly_anchor: string;
+ monthly_anchor: null | number;
+ delay_days: null | number;
+ completed_waiting_period: boolean;
+ minimum_deposit_amounts: Record< string, number >;
+ };
+ depositsStatus?: string;
+ currentDeadline?: bigint;
+ pastDue?: boolean;
+ accountLink: string;
+ hasSubmittedVatData?: boolean;
+ requirements?: {
+ errors?: {
+ code: string;
+ reason: string;
+ requirement: string;
+ }[];
+ };
+ progressiveOnboarding: {
+ isEnabled: boolean;
+ isComplete: boolean;
+ tpv: number;
+ firstTransactionDate?: string;
+ };
+ fraudProtection: {
+ declineOnAVSFailure: boolean;
+ declineOnCVCFailure: boolean;
+ };
};
- progressiveOnboarding: {
- isEnabled: boolean;
- isComplete: boolean;
- tpv: number;
- firstTransactionDate?: string;
+ accountLoans: {
+ has_active_loan: boolean;
+ has_past_loans: boolean;
+ loans: Array< string >;
};
+ connect: {
+ country: string;
+ availableStates: Array< Record< string, string > >;
+ };
+ accountEmail: string;
+ currentUserEmail: string;
+ zeroDecimalCurrencies: string[];
+ restUrl: string;
+ shouldUseExplicitPrice: boolean;
+ numDisputesNeedingResponse: string;
+ fraudProtection: {
+ isWelcomeTourDismissed?: boolean;
+ };
+ accountDefaultCurrency: string;
+ isFRTReviewFeatureActive: boolean;
+ frtDiscoverBannerSettings: string;
+ onboardingTestMode: boolean;
+ onboardingFieldsData?: {
+ business_types: Country[];
+ mccs_display_tree: MccsDisplayTreeItem[];
+ };
+ storeCurrency: string;
+ isMultiCurrencyEnabled: string;
};
- accountLoans: {
- has_active_loan: boolean;
- has_past_loans: boolean;
- loans: Array< string >;
- };
- connect: {
- country: string;
- availableStates: Array< Record< string, string > >;
- };
- accountEmail: string;
- currentUserEmail: string;
- zeroDecimalCurrencies: string[];
- restUrl: string;
- shouldUseExplicitPrice: boolean;
- numDisputesNeedingResponse: string;
- fraudProtection: {
- isWelcomeTourDismissed?: boolean;
- };
- accountDefaultCurrency: string;
- isFraudProtectionSettingsEnabled: boolean;
- frtDiscoverBannerSettings: string;
- onboardingTestMode: boolean;
-};
-declare const wcTracks: any;
+ const wcTracks: any;
+
+ const wcSettings: Record< string, any >;
+}
diff --git a/client/index.js b/client/index.js
index f2f0669cd7b..09911d6800e 100644
--- a/client/index.js
+++ b/client/index.js
@@ -255,7 +255,7 @@ addFilter(
capability: 'manage_woocommerce',
} );
}
- if ( wcpaySettings && wcpaySettings.isFraudProtectionSettingsEnabled ) {
+ if ( wcpaySettings ) {
pages.push( {
container: FraudProtectionAdvancedSettingsPage,
path: '/payments/fraud-protection',
diff --git a/client/multi-currency-setup/tasks/add-currencies-task/test/__snapshots__/index.test.js.snap b/client/multi-currency-setup/tasks/add-currencies-task/test/__snapshots__/index.test.js.snap
index e685d1da98a..97c16d5a264 100644
--- a/client/multi-currency-setup/tasks/add-currencies-task/test/__snapshots__/index.test.js.snap
+++ b/client/multi-currency-setup/tasks/add-currencies-task/test/__snapshots__/index.test.js.snap
@@ -25,13 +25,12 @@ exports[`Multi-Currency enabled currencies list add currencies task renders corr
class="wcpay-wizard-task__icon-checkmark"
focusable="false"
height="24"
- role="img"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
@@ -73,7 +72,6 @@ exports[`Multi-Currency enabled currencies list add currencies task renders corr
class="search__icon"
focusable="false"
height="24"
- role="img"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
@@ -749,13 +747,12 @@ exports[`Multi-Currency enabled currencies list currency search works with curre
class="wcpay-wizard-task__icon-checkmark"
focusable="false"
height="24"
- role="img"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>