Skip to content

Commit

Permalink
Merge branch 'develop' into 8249/add-bnpl-icons-to-thank-you-page
Browse files Browse the repository at this point in the history
  • Loading branch information
brettshumaker authored Apr 30, 2024
2 parents 4a409b4 + 15e8a88 commit 9f92c52
Show file tree
Hide file tree
Showing 36 changed files with 254 additions and 123 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Update Payment Activity Card to use correct currency for rendering amounts.


5 changes: 5 additions & 0 deletions changelog/fix-8724-are-these-metrics
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: This is covered by emoji survey changelog from #8506


4 changes: 4 additions & 0 deletions changelog/fix-fatals-on-plugin-update
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Avoid warnings about fatal error during plugin update due to problems with plugin initialization.
12 changes: 6 additions & 6 deletions client/components/payment-activity/payment-activity-data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ const PaymentActivityData: React.FC = () => {
const fees = paymentActivityData?.fees ?? 0;
const disputes = paymentActivityData?.disputes ?? 0;
const refunds = paymentActivityData?.refunds ?? 0;
const { storeCurrency } = wcpaySettings;
const currency = paymentActivityData?.currency;

return (
<div className="wcpay-payment-activity-data">
<PaymentDataTile
id="wcpay-payment-activity-data__total-payment-volume"
label={ __( 'Total payment volume', 'woocommerce-payments' ) }
currencyCode={ storeCurrency }
currencyCode={ currency }
tooltip={
<ClickTooltip
className="wcpay-payment-activity-data__total-payment-volume__tooltip"
Expand Down Expand Up @@ -100,7 +100,7 @@ const PaymentActivityData: React.FC = () => {
<PaymentDataTile
id="wcpay-payment-data-highlights__charges"
label={ __( 'Charges', 'woocommerce-payments' ) }
currencyCode={ storeCurrency }
currencyCode={ currency }
tooltip={
<ClickTooltip
className="payment-data-highlights__charges__tooltip"
Expand Down Expand Up @@ -132,7 +132,7 @@ const PaymentActivityData: React.FC = () => {
<PaymentDataTile
id="wcpay-payment-data-highlights__refunds"
label={ __( 'Refunds', 'woocommerce-payments' ) }
currencyCode={ storeCurrency }
currencyCode={ currency }
amount={ refunds }
reportLink={ getAdminUrl( {
page: 'wc-admin',
Expand All @@ -151,7 +151,7 @@ const PaymentActivityData: React.FC = () => {
<PaymentDataTile
id="wcpay-payment-data-highlights__disputes"
label={ __( 'Disputes', 'woocommerce-payments' ) }
currencyCode={ storeCurrency }
currencyCode={ currency }
amount={ disputes }
reportLink={ getAdminUrl( {
page: 'wc-admin',
Expand All @@ -170,7 +170,7 @@ const PaymentActivityData: React.FC = () => {
<PaymentDataTile
id="wcpay-payment-data-highlights__fees"
label={ __( 'Fees', 'woocommerce-payments' ) }
currencyCode={ storeCurrency }
currencyCode={ currency }
tooltip={
<ClickTooltip
className="payment-data-highlights__fees__tooltip"
Expand Down
8 changes: 4 additions & 4 deletions client/components/payment-activity/payment-data-tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { Link } from '@woocommerce/components';
/**
* Internal dependencies
*/

import { formatCurrency } from 'wcpay/utils/currency';
import Loadable from '../loadable';
import './style.scss';

interface PaymentDataTileProps {
/**
* The id for the tile, can be used for CSS styling.
Expand All @@ -24,7 +24,7 @@ interface PaymentDataTileProps {
/**
* The currency code for the amount displayed.
*/
currencyCode: string;
currencyCode?: string;
/**
* For optionally passing a ClickTooltip component.
*/
Expand Down Expand Up @@ -53,9 +53,9 @@ const PaymentDataTile: React.FC< PaymentDataTileProps > = ( {
reportLink,
} ) => {
return (
<div id={ id } className="wcpay-payment-data-highlights__item">
<div className="wcpay-payment-data-highlights__item">
<p className="wcpay-payment-data-highlights__item__label">
<span>{ label }</span>
<span id={ id }>{ label }</span>
{ ! isLoading && tooltip }
</p>
<div className="wcpay-payment-data-highlights__item__wrapper">
Expand Down
2 changes: 1 addition & 1 deletion client/components/payment-activity/survey/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const Survey: React.FC = () => {
<div className="wcpay-payments-activity__survey">
<div className="survey_container">
{ __(
'Are those metrics helpful?',
'Are these metrics helpful?',
'woocommerce-payments'
) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`WcPayOverviewSurveyContextProvider test survey initial display 1`] = `
<div
class="survey_container"
>
Are those metrics helpful?
Are these metrics helpful?
<div
class="survey_container__emoticons"
>
Expand Down Expand Up @@ -92,7 +92,7 @@ exports[`WcPayOverviewSurveyContextProvider test survey with comments textbox 1`
<div
class="survey_container"
>
Are those metrics helpful?
Are these metrics helpful?
<div
class="survey_container__emoticons"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe( 'WcPayOverviewSurveyContextProvider', () => {
</WcPayOverviewSurveyContextProvider>
);

const surveyText = screen.getByText( 'Are those metrics helpful?' );
const surveyText = screen.getByText( 'Are these metrics helpful?' );
expect( surveyText ).toBeInTheDocument();

const buttons = screen.getAllByRole( 'button' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ exports[`PaymentActivity component should render 1`] = `
>
<div
class="wcpay-payment-data-highlights__item"
id="wcpay-payment-activity-data__total-payment-volume"
>
<p
class="wcpay-payment-data-highlights__item__label"
>
<span>
<span
id="wcpay-payment-activity-data__total-payment-volume"
>
Total payment volume
</span>
<button
Expand Down Expand Up @@ -71,7 +72,7 @@ exports[`PaymentActivity component should render 1`] = `
aria-labelledby="wcpay-payment-activity-data__total-payment-volume"
class="wcpay-payment-data-highlights__item__wrapper__amount"
>
$1,234.56
€1.234,56
</p>
<a
data-link-type="wc-admin"
Expand All @@ -86,12 +87,13 @@ exports[`PaymentActivity component should render 1`] = `
>
<div
class="wcpay-payment-data-highlights__item"
id="wcpay-payment-data-highlights__charges"
>
<p
class="wcpay-payment-data-highlights__item__label"
>
<span>
<span
id="wcpay-payment-data-highlights__charges"
>
Charges
</span>
<button
Expand Down Expand Up @@ -130,7 +132,7 @@ exports[`PaymentActivity component should render 1`] = `
aria-labelledby="wcpay-payment-data-highlights__charges"
class="wcpay-payment-data-highlights__item__wrapper__amount"
>
$98.76
€98,76
</p>
<a
data-link-type="wc-admin"
Expand All @@ -142,12 +144,13 @@ exports[`PaymentActivity component should render 1`] = `
</div>
<div
class="wcpay-payment-data-highlights__item"
id="wcpay-payment-data-highlights__refunds"
>
<p
class="wcpay-payment-data-highlights__item__label"
>
<span>
<span
id="wcpay-payment-data-highlights__refunds"
>
Refunds
</span>
</p>
Expand All @@ -158,7 +161,7 @@ exports[`PaymentActivity component should render 1`] = `
aria-labelledby="wcpay-payment-data-highlights__refunds"
class="wcpay-payment-data-highlights__item__wrapper__amount"
>
$44.44
€44,44
</p>
<a
data-link-type="wc-admin"
Expand All @@ -170,12 +173,13 @@ exports[`PaymentActivity component should render 1`] = `
</div>
<div
class="wcpay-payment-data-highlights__item"
id="wcpay-payment-data-highlights__disputes"
>
<p
class="wcpay-payment-data-highlights__item__label"
>
<span>
<span
id="wcpay-payment-data-highlights__disputes"
>
Disputes
</span>
</p>
Expand All @@ -186,7 +190,7 @@ exports[`PaymentActivity component should render 1`] = `
aria-labelledby="wcpay-payment-data-highlights__disputes"
class="wcpay-payment-data-highlights__item__wrapper__amount"
>
$55.55
€55,55
</p>
<a
data-link-type="wc-admin"
Expand All @@ -198,12 +202,13 @@ exports[`PaymentActivity component should render 1`] = `
</div>
<div
class="wcpay-payment-data-highlights__item"
id="wcpay-payment-data-highlights__fees"
>
<p
class="wcpay-payment-data-highlights__item__label"
>
<span>
<span
id="wcpay-payment-data-highlights__fees"
>
Fees
</span>
<button
Expand Down Expand Up @@ -242,7 +247,7 @@ exports[`PaymentActivity component should render 1`] = `
aria-labelledby="wcpay-payment-data-highlights__fees"
class="wcpay-payment-data-highlights__item__wrapper__amount"
>
$12.34
€12,34
</p>
</div>
</div>
Expand All @@ -260,7 +265,7 @@ exports[`PaymentActivity component should render 1`] = `
<div
class="survey_container"
>
Are those metrics helpful?
Are these metrics helpful?
<div
class="survey_container__emoticons"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ exports[`PaymentDataTile renders correctly 1`] = `
<div>
<div
class="wcpay-payment-data-highlights__item"
id="total-payment"
>
<p
class="wcpay-payment-data-highlights__item__label"
>
<span>
<span
id="total-payment"
>
Total payment volume
</span>
</p>
Expand Down
21 changes: 16 additions & 5 deletions client/components/payment-activity/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ const mockUsePaymentActivityData = usePaymentActivityData as jest.MockedFunction

mockUsePaymentActivityData.mockReturnValue( {
paymentActivityData: {
currency: 'eur',
total_payment_volume: 123456,
charges: 9876,
fees: 1234,
disputes: 5555,
refunds: 4444,
date_start: '2024-01-01',
date_end: '2024-01-31',
timezone: 'UTC',
interval: 'daily',
},
isLoading: false,
} );
Expand Down Expand Up @@ -83,10 +88,10 @@ describe( 'PaymentActivity component', () => {
},
},
},
accountDefaultCurrency: 'USD',
accountDefaultCurrency: 'eur',
zeroDecimalCurrencies: [],
connect: {
country: 'US',
country: 'DE',
},
currencyData: {
US: {
Expand Down Expand Up @@ -117,10 +122,16 @@ describe( 'PaymentActivity component', () => {
} );

it( 'should render', () => {
const { container, getByText } = render( <PaymentActivity /> );
const { container, getByText, getByLabelText } = render(
<PaymentActivity />
);

// Check survey is rendered.
getByText( 'Are those metrics helpful?' );
getByText( 'Are these metrics helpful?' );

// Check correct currency/value is displayed.
const tpvElement = getByLabelText( 'Total payment volume' );
expect( tpvElement ).toHaveTextContent( '€1.234,56' );

expect( container ).toMatchSnapshot();
} );
Expand All @@ -140,7 +151,7 @@ describe( 'PaymentActivity component', () => {
const { queryByText } = render( <PaymentActivity /> );

expect(
queryByText( 'Are those metrics helpful?' )
queryByText( 'Are these metrics helpful?' )
).not.toBeInTheDocument();
} );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ declare const global: {

describe( 'PaymentDataTile', () => {
global.wcpaySettings = {
accountDefaultCurrency: 'USD',
accountDefaultCurrency: 'usd',
zeroDecimalCurrencies: [],
connect: {
country: 'US',
Expand All @@ -43,7 +43,7 @@ describe( 'PaymentDataTile', () => {
const { container } = render(
<PaymentDataTile
id="total-payment"
currencyCode="USD"
currencyCode="usd"
label="Total payment volume"
/>
);
Expand All @@ -55,17 +55,18 @@ describe( 'PaymentDataTile', () => {
render(
<PaymentDataTile
id="total-payment"
currencyCode="USD"
currencyCode="usd"
label={ label }
amount={ 123 }
/>
);
const labelElement = screen.getByText( label );
expect( labelElement ).toBeInTheDocument();
expect( screen.getByText( label ) ).toBeInTheDocument();
expect( screen.getByLabelText( label ) ).toHaveTextContent( '$1.23' );
} );

test( 'renders amount correctly', () => {
const amount = 10000;
const currencyCode = 'USD';
const currencyCode = 'usd';
render(
<PaymentDataTile
id="charges-test-tile"
Expand All @@ -85,7 +86,7 @@ describe( 'PaymentDataTile', () => {
id="charges-test-tile"
label="Charges"
amount={ 10000 }
currencyCode="USD"
currencyCode="usd"
reportLink={ reportLink }
/>
);
Expand Down
Loading

0 comments on commit 9f92c52

Please sign in to comment.