From 6f59377afd8fb5ebe175bc565e240d69475ea899 Mon Sep 17 00:00:00 2001 From: Taha Paksu <3295+tpaksu@users.noreply.github.com> Date: Wed, 20 Dec 2023 16:46:42 +0300 Subject: [PATCH 1/6] Fix currency negative sign position on JS rendered amounts (#7935) --- ...700-remove-currency-sign-modification-code | 4 +++ .../test/__snapshots__/index.test.tsx.snap | 26 +++++++-------- .../summary/test/index.test.tsx | 2 +- .../timeline/test/__snapshots__/index.js.snap | 2 +- .../test/__snapshots__/map-events.js.snap | 12 +++---- .../list/test/__snapshots__/index.tsx.snap | 32 +++++++++---------- client/utils/currency/index.js | 32 +++++++++++++++---- includes/class-wc-payments-utils.php | 10 +----- .../fixtures/captured-payments/discount.json | 2 +- .../captured-payments/foreign-card.json | 2 +- .../captured-payments/fx-decimal.json | 2 +- .../captured-payments/fx-foreign-card.json | 2 +- .../captured-payments/fx-with-capped-fee.json | 2 +- tests/fixtures/captured-payments/fx.json | 2 +- .../captured-payments/jpy-payment.json | 2 +- .../captured-payments/only-base-fee.json | 2 +- .../captured-payments/subscription.json | 2 +- tests/unit/test-class-wc-payments-utils.php | 2 +- 18 files changed, 78 insertions(+), 62 deletions(-) create mode 100644 changelog/fix-6700-remove-currency-sign-modification-code diff --git a/changelog/fix-6700-remove-currency-sign-modification-code b/changelog/fix-6700-remove-currency-sign-modification-code new file mode 100644 index 00000000000..74634338357 --- /dev/null +++ b/changelog/fix-6700-remove-currency-sign-modification-code @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Fix currency negative sign position on JS rendered amounts diff --git a/client/payment-details/summary/test/__snapshots__/index.test.tsx.snap b/client/payment-details/summary/test/__snapshots__/index.test.tsx.snap index 30c5c237e49..e9a596d35d5 100644 --- a/client/payment-details/summary/test/__snapshots__/index.test.tsx.snap +++ b/client/payment-details/summary/test/__snapshots__/index.test.tsx.snap @@ -42,7 +42,7 @@ exports[`PaymentDetailsSummary capture notification and fraud buttons renders ca

Fees: - $-0.70 + -$0.70

@@ -343,7 +343,7 @@ exports[`PaymentDetailsSummary capture notification and fraud buttons renders th

Fees: - $-0.70 + -$0.70

@@ -654,7 +654,7 @@ exports[`PaymentDetailsSummary correctly renders a charge 1`] = `

Fees: - $-0.70 + -$0.70

@@ -914,7 +914,7 @@ exports[`PaymentDetailsSummary order missing notice does not render notice if or

Fees: - $-0.70 + -$0.70

@@ -1174,7 +1174,7 @@ exports[`PaymentDetailsSummary order missing notice renders notice if order miss

Fees: - $-0.70 + -$0.70

@@ -1456,7 +1456,7 @@ exports[`PaymentDetailsSummary renders a charge with subscriptions 1`] = `

Fees: - $-0.70 + -$0.70

@@ -1742,16 +1742,16 @@ exports[`PaymentDetailsSummary renders fully refunded information for a charge 1 >

Refunded: - $-20.00 + -$20.00

Fees: - $-0.70 + -$0.70

Net: - $-0.70 + -$0.70

@@ -2238,11 +2238,11 @@ exports[`PaymentDetailsSummary renders partially refunded information for a char >

Refunded: - $-12.00 + -$12.00

Fees: - $-0.70 + -$0.70

@@ -2502,7 +2502,7 @@ exports[`PaymentDetailsSummary renders the Tap to Pay channel from metadata 1`]

Fees: - $-0.70 + -$0.70

@@ -2762,7 +2762,7 @@ exports[`PaymentDetailsSummary renders the information of a dispute-reversal cha

Fees: - $-0.70 + -$0.70

diff --git a/client/payment-details/summary/test/index.test.tsx b/client/payment-details/summary/test/index.test.tsx index 58de0645616..522c613d5ff 100755 --- a/client/payment-details/summary/test/index.test.tsx +++ b/client/payment-details/summary/test/index.test.tsx @@ -251,7 +251,7 @@ describe( 'PaymentDetailsSummary', () => { } ); const container = renderCharge( charge ); - screen.getByText( /Refunded: \$-20.00/i ); + screen.getByText( /Refunded: -\$20.00/i ); expect( container ).toMatchSnapshot(); } ); diff --git a/client/payment-details/timeline/test/__snapshots__/index.js.snap b/client/payment-details/timeline/test/__snapshots__/index.js.snap index df78052123c..e4753b57f06 100644 --- a/client/payment-details/timeline/test/__snapshots__/index.js.snap +++ b/client/payment-details/timeline/test/__snapshots__/index.js.snap @@ -1494,7 +1494,7 @@ exports[`PaymentDetailsTimeline renders subscription fee correctly 1`] = ` > - Fee (3.9% + $0.30): $-0.34 + Fee (3.9% + $0.30): -$0.34

@@ -455,7 +455,7 @@ Array [ Object { "body": Array [ undefined, - "Base fee (1.95% + $0.15): $-3.50", + "Base fee (1.95% + $0.15): -$3.50", undefined, "Net deposit: $59.50 USD", ], @@ -695,7 +695,7 @@ Array [ Object { "body": Array [ undefined, - "Fee (2.6% + $0.20): $-0.61", + "Fee (2.6% + $0.20): -$0.61", +