diff --git a/packages/block-editor/src/store/index.js b/packages/block-editor/src/store/index.js index ed17b387ba5884..0bcc00cb5f6ae8 100644 --- a/packages/block-editor/src/store/index.js +++ b/packages/block-editor/src/store/index.js @@ -43,3 +43,13 @@ const registeredStore = registerStore( STORE_NAME, { } ); unlock( registeredStore ).registerPrivateActions( privateActions ); unlock( registeredStore ).registerPrivateSelectors( privateSelectors ); + +// TODO: Remove once we switch to the `register` function (see above). +// +// Until then, private functions also need to be attached to the original +// `store` descriptor in order to avoid unit tests failing, which could happen +// when tests create new registries in which they register stores. +// +// @see https://github.com/WordPress/gutenberg/pull/51145#discussion_r1239999590 +unlock( store ).registerPrivateActions( privateActions ); +unlock( store ).registerPrivateSelectors( privateSelectors ); diff --git a/packages/block-editor/src/store/private-actions.js b/packages/block-editor/src/store/private-actions.js index 8b5e066e5a83c0..d90aae340a92a7 100644 --- a/packages/block-editor/src/store/private-actions.js +++ b/packages/block-editor/src/store/private-actions.js @@ -161,19 +161,7 @@ export const privateRemoveBlocks = // register using `toggleRemovalPromptSupport()`. // // @see https://github.com/WordPress/gutenberg/pull/51145 - if ( - ! forceRemove && - // FIXME: Without this existence check, the unit tests for - // `__experimentalDeleteReusableBlock` in - // `packages/reusable-blocks/src/store/test/actions.js` fail due to - // the fact that the `registry` object passed to the thunk actions - // doesn't include this private action. This needs to be - // investigated to understand whether it's a real smell or if it's - // because not all store code has been updated to accommodate - // private selectors. - select.isRemovalPromptSupported && - select.isRemovalPromptSupported() - ) { + if ( ! forceRemove && select.isRemovalPromptSupported() ) { const blockNamesForPrompt = new Set(); // Given a list of client IDs of blocks that the user intended to diff --git a/packages/block-editor/src/store/test/actions.js b/packages/block-editor/src/store/test/actions.js index 27cd77b0769931..78df4a3e131d70 100644 --- a/packages/block-editor/src/store/test/actions.js +++ b/packages/block-editor/src/store/test/actions.js @@ -618,6 +618,7 @@ describe( 'actions', () => { const select = { getBlockRootClientId: () => undefined, canRemoveBlocks: () => true, + isRemovalPromptSupported: () => false, }; const dispatch = Object.assign( jest.fn(), { selectPreviousBlock: jest.fn(), @@ -728,6 +729,7 @@ describe( 'actions', () => { const select = { getBlockRootClientId: () => null, canRemoveBlocks: () => true, + isRemovalPromptSupported: () => false, }; const dispatch = Object.assign( jest.fn(), { selectPreviousBlock: jest.fn(), @@ -752,6 +754,7 @@ describe( 'actions', () => { const select = { getBlockRootClientId: () => null, canRemoveBlocks: () => true, + isRemovalPromptSupported: () => false, }; const dispatch = Object.assign( jest.fn(), { selectPreviousBlock: jest.fn(),