From e2b35335c9e1352dad90be57c4ffe14cdb26de5e Mon Sep 17 00:00:00 2001 From: Tim Broddin Date: Tue, 14 Feb 2023 14:12:36 +0100 Subject: [PATCH 1/6] Don't show "Include social followers in count" when showSubscribersTotal is not toggled or isPublicizeEnabled is false --- .../blocks/subscriptions/controls.js | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/controls.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/controls.js index 78a431a2e6ee0..d8e41cf4a6fb8 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/controls.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/controls.js @@ -1,4 +1,5 @@ import { numberFormat } from '@automattic/jetpack-components'; +import { usePublicizeConfig } from '@automattic/jetpack-publicize-components'; import { isSimpleSite } from '@automattic/jetpack-shared-extension-utils'; import { ContrastChecker, @@ -54,6 +55,8 @@ export default function SubscriptionControls( { buttonWidth, successMessage, } ) { + const { isPublicizeEnabled } = usePublicizeConfig(); + return ( <> { isNewsletterFeatureEnabled() && } @@ -240,14 +243,17 @@ export default function SubscriptionControls( { } } } /> - { - setAttributes( { includeSocialFollowers: ! includeSocialFollowers } ); - } } - /> + { showSubscribersTotal && isPublicizeEnabled ? ( + { + setAttributes( { includeSocialFollowers: ! includeSocialFollowers } ); + } } + /> + ) : null } + Date: Tue, 14 Feb 2023 14:46:16 +0100 Subject: [PATCH 2/6] Don't show "Include social followers in count" when showSubscribersTotal is not toggled or isPublicizeEnabled is false --- .../jetpack/changelog/subscription-block-social-toggle | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/subscription-block-social-toggle diff --git a/projects/plugins/jetpack/changelog/subscription-block-social-toggle b/projects/plugins/jetpack/changelog/subscription-block-social-toggle new file mode 100644 index 0000000000000..00595e7fd265e --- /dev/null +++ b/projects/plugins/jetpack/changelog/subscription-block-social-toggle @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Don't show "Include social followers in count" when showSubscribersTotal is not toggled or isPublicizeEnabled is false From a1e270ac13597ce477d426a592f734e687a903b7 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Mon, 27 Feb 2023 14:09:23 +1300 Subject: [PATCH 3/6] Mock scss imports in jest --- projects/plugins/jetpack/tests/jest.config.extensions.js | 4 ++++ projects/plugins/jetpack/tests/styles-mock.js | 1 + 2 files changed, 5 insertions(+) create mode 100644 projects/plugins/jetpack/tests/styles-mock.js diff --git a/projects/plugins/jetpack/tests/jest.config.extensions.js b/projects/plugins/jetpack/tests/jest.config.extensions.js index b9a0b0f5a5509..1939d384aada3 100644 --- a/projects/plugins/jetpack/tests/jest.config.extensions.js +++ b/projects/plugins/jetpack/tests/jest.config.extensions.js @@ -8,4 +8,8 @@ module.exports = { ...baseConfig.testPathIgnorePatterns, 'extensions/shared/test/block-fixtures.js', ], + moduleNameMapper:{ + ...baseConfig.moduleNameMapper, + "\\.(css|less|sass|scss)$": "/tests/styles-mock.js", + } }; diff --git a/projects/plugins/jetpack/tests/styles-mock.js b/projects/plugins/jetpack/tests/styles-mock.js new file mode 100644 index 0000000000000..f053ebf7976e3 --- /dev/null +++ b/projects/plugins/jetpack/tests/styles-mock.js @@ -0,0 +1 @@ +module.exports = {}; From 9a461a301b3dd12abce40a644347f14350e3bdab Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Mon, 27 Feb 2023 14:21:52 +1300 Subject: [PATCH 4/6] Fix linting issues --- projects/plugins/jetpack/tests/jest.config.extensions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/plugins/jetpack/tests/jest.config.extensions.js b/projects/plugins/jetpack/tests/jest.config.extensions.js index 1939d384aada3..8fc400e7fe9bd 100644 --- a/projects/plugins/jetpack/tests/jest.config.extensions.js +++ b/projects/plugins/jetpack/tests/jest.config.extensions.js @@ -8,8 +8,8 @@ module.exports = { ...baseConfig.testPathIgnorePatterns, 'extensions/shared/test/block-fixtures.js', ], - moduleNameMapper:{ + moduleNameMapper: { ...baseConfig.moduleNameMapper, - "\\.(css|less|sass|scss)$": "/tests/styles-mock.js", - } + '\\.(css|less|sass|scss)$': '/tests/styles-mock.js', + }, }; From b83b62342730149f19a4678a40f737671455e27e Mon Sep 17 00:00:00 2001 From: Tim Broddin Date: Mon, 27 Feb 2023 09:02:49 +0100 Subject: [PATCH 5/6] Mock @wordpress/notices --- .../jetpack/extensions/blocks/subscriptions/test/controls.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/test/controls.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/test/controls.js index b494e2fad835b..2936085513ab6 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/test/controls.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/test/controls.js @@ -27,6 +27,8 @@ jest.mock( '@wordpress/block-editor/build/components/use-setting', () => { }; } ); +jest.mock( '@wordpress/notices', () => {}, { virtual: true } ); + const setButtonBackgroundColor = jest.fn(); const setGradient = jest.fn(); const setTextColor = jest.fn(); From abf6326af48565dba092c46859bd786aad788311 Mon Sep 17 00:00:00 2001 From: Tim Broddin Date: Mon, 6 Mar 2023 10:45:01 +0100 Subject: [PATCH 6/6] Mock @wordpress/notices in the tests --- .../jetpack/extensions/blocks/subscriptions/test/edit.js | 2 ++ .../jetpack/extensions/blocks/subscriptions/test/validate.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/test/edit.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/test/edit.js index 271ecd860d8d1..cf97ea9ce801a 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/test/edit.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/test/edit.js @@ -54,6 +54,8 @@ jest.mock( '@wordpress/block-editor', () => ( { } ), } ) ); +jest.mock( '@wordpress/notices', () => {}, { virtual: true } ); + describe( 'SubscriptionEdit', () => { test( 'adds correct classes to container', async () => { const { container } = render( ); diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/test/validate.js b/projects/plugins/jetpack/extensions/blocks/subscriptions/test/validate.js index 88e752617cd9b..7b6318f8c01cb 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/test/validate.js +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/test/validate.js @@ -5,4 +5,6 @@ import runBlockFixtureTests from '../../../shared/test/block-fixtures'; // The main block should be the first in the array. const blocks = [ { name: `jetpack/${ name }`, settings } ]; +jest.mock( '@wordpress/notices', () => {}, { virtual: true } ); + runBlockFixtureTests( `jetpack/${ name }`, blocks, __dirname );