From 72a40ed85e642b1e10cba6d7257d8a4234298a07 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Thu, 1 Feb 2024 11:00:52 -0300 Subject: [PATCH] Removing expandable menu for payment methods when UPE is disabled (#2869) * Removing expandable menu for payment methods when UPE is disabled * Including specific unit tests for the expandable menu (UPE) * Readme and changelog updates --------- Co-authored-by: Wesley Rosa Co-authored-by: James Allan --- changelog.txt | 1 + .../general-settings-section.test.js | 4 +- .../section-heading.js | 50 ++++++++++--------- readme.txt | 1 + 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/changelog.txt b/changelog.txt index dbb780f01f..0b9cee0de9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ *** Changelog *** = 8.0.0 - 2024-xx-xx = +* Fix - Hiding the expandable menu for UPE entirely when the feature is disabled. * Fix - Critical error when deactivating the extension after deactivating WooCommerce. * Fix - Add missing fee and payout information to the order details page in admin. * Fix - Hiding "Early Access" label and "Refresh payment methods" button when UPE is disabled. diff --git a/client/settings/general-settings-section/__tests__/general-settings-section.test.js b/client/settings/general-settings-section/__tests__/general-settings-section.test.js index d37769f754..5ebb9cfd17 100644 --- a/client/settings/general-settings-section/__tests__/general-settings-section.test.js +++ b/client/settings/general-settings-section/__tests__/general-settings-section.test.js @@ -606,7 +606,7 @@ describe( 'GeneralSettingsSection', () => { ).not.toBeInTheDocument(); } ); - it( 'menu should not contain "refresh payment method options" if UPE is disabled', () => { + it( 'should not render the expandable menu if UPE is disabled', () => { render( @@ -614,7 +614,7 @@ describe( 'GeneralSettingsSection', () => { ); expect( - screen.queryByText( /Refresh payment methods/ ) + screen.queryByTestId( 'upe-expandable-menu' ) ).not.toBeInTheDocument(); } ); } ); diff --git a/client/settings/general-settings-section/section-heading.js b/client/settings/general-settings-section/section-heading.js index e34883f7ac..ce91137192 100644 --- a/client/settings/general-settings-section/section-heading.js +++ b/client/settings/general-settings-section/section-heading.js @@ -79,22 +79,6 @@ const SectionHeading = ( { isChangingDisplayOrder, onChangeDisplayOrder } ) => { onChangeDisplayOrder( false, orderedPaymentMethodIds ); }; - const menuControls = [ - { - title: __( 'Disable', 'woocommerce-gateway-stripe' ), - onClick: toggleConfirmationModal, - }, - ]; - if ( isUpeEnabled ) { - menuControls.unshift( { - title: __( - 'Refresh payment methods', - 'woocommerce-gateway-stripe' - ), - onClick: refreshAccount, - } ); - } - return ( @@ -126,14 +110,32 @@ const SectionHeading = ( { isChangingDisplayOrder, onChangeDisplayOrder } ) => { ) } </Button> ) } - <DropdownMenu - icon={ moreVertical } - label={ __( - 'Payment methods menu', - 'woocommerce-gateway-stripe' - ) } - controls={ menuControls } - /> + { isUpeEnabled && ( + <DropdownMenu + data-testid="upe-expandable-menu" + icon={ moreVertical } + label={ __( + 'Payment methods menu', + 'woocommerce-gateway-stripe' + ) } + controls={ [ + { + title: __( + 'Disable', + 'woocommerce-gateway-stripe' + ), + onClick: toggleConfirmationModal, + }, + { + title: __( + 'Refresh payment methods', + 'woocommerce-gateway-stripe' + ), + onClick: refreshAccount, + }, + ] } + /> + ) } </> ) : ( <> diff --git a/readme.txt b/readme.txt index 556e01b5fe..c9358a8e22 100644 --- a/readme.txt +++ b/readme.txt @@ -129,6 +129,7 @@ If you get stuck, you can ask for help in the Plugin Forum. == Changelog == = 8.0.0 - 2024-xx-xx = +* Fix - Hiding the expandable menu for UPE entirely when the feature is disabled. * Fix - Critical error when deactivating the extension after deactivating WooCommerce. * Fix - Add missing fee and payout information to the order details page in admin. * Fix - Hiding "Early Access" label and "Refresh payment methods" button when UPE is disabled.