Skip to content

Commit

Permalink
Fix incorrect usage of publicize config in subscribe block (#40355)
Browse files Browse the repository at this point in the history
* Fix incorrect usage of publicize config in subscribe block

* Fix unit tests
  • Loading branch information
manzoorwanijk authored Nov 27, 2024
1 parent f9382e2 commit f9a3dc7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

Fixed block error when editing Subscribe block
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { numberFormat } from '@automattic/jetpack-components';
import { usePublicizeConfig } from '@automattic/jetpack-publicize-components';
import { isSimpleSite } from '@automattic/jetpack-shared-extension-utils';
import { isSimpleSite, useModuleStatus } from '@automattic/jetpack-shared-extension-utils';
import {
ContrastChecker,
PanelColorSettings,
Expand Down Expand Up @@ -56,7 +55,7 @@ export default function SubscriptionControls( {
subscribePlaceholder = DEFAULT_SUBSCRIBE_PLACEHOLDER,
successMessage = DEFAULT_SUCCESS_MESSAGE,
} ) {
const { isPublicizeEnabled } = usePublicizeConfig();
const { isModuleActive: isPublicizeEnabled } = useModuleStatus( 'publicize' );

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ afterAll( () => {

jest.mock( '@wordpress/notices', () => {}, { virtual: true } );

jest.mock( '@automattic/jetpack-shared-extension-utils', () => ( {
__esModule: true,
...jest.requireActual( '@automattic/jetpack-shared-extension-utils' ),
useModuleStatus: jest.fn().mockReturnValue( {
isModuleActive: true,
isLoadingModules: false,
isChangingStatus: false,
changeStatus: jest.fn(),
} ),
} ) );

const setButtonBackgroundColor = jest.fn();
const setGradient = jest.fn();
const setTextColor = jest.fn();
Expand Down Expand Up @@ -74,13 +85,6 @@ beforeEach( () => {
} );

describe( 'Inspector controls', () => {
beforeEach( () => {
window.JetpackScriptData = {
social: {
urls: {},
},
};
} );
describe( 'Gradient settings panel', () => {
test( 'displays gradient settings control panel', () => {
render( <SubscriptionsInspectorControls { ...defaultProps } /> );
Expand Down

0 comments on commit f9a3dc7

Please sign in to comment.