Commit 035ed41fa93 for woocommerce

commit 035ed41fa93678b818d8200f0bb42b87d5755628
Author: Vlad Olaru <vlad.olaru@automattic.com>
Date:   Wed Sep 16 00:31:46 2026 +0300

    [tests] Reduce product block registration E2E tests from 9 to 3 (#68604)

    * test(blocks): Reduce product block registration E2E tests from 9 to 3

    The Related Products, Product Details, and product block registration
    specs ran nine browser titles. Most of them inserted a block into a
    post or a template to check where the editor allows it. The shared
    registration manager decides that before the editor renders anything.

    Add a Jest suite for the registration manager: a block that allows
    the post editor registers with the Single Product ancestor, a block
    that doesn't is skipped, and switching templates re-registers a block
    with the ancestor each template needs. It also checks the Product
    Price and Product Image Gallery declarations. A Product Details Jest
    test checks that a freshly inserted block gets the description
    placeholder. Delete the Product Details spec, keep two registration
    titles and one Related Products title, and make the command palette
    title check the Product Price option before clicking it.

    Consolidates the mega-branch slices:
    - Slice 018: test(blocks): Move registration transitions below E2E
    - Slice 115: test(blocks): Consolidate Related Products availability
      coverage
    - test(e2e): Verify Related Products variation type
    - test(e2e): Expose Product Price registration failures

    Refs TESTOPS-234
    Refs #68046

    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

    * test(blocks): Cover the deprecated Related Products registration

    The PR's coverage table mapped the removed Related Products "can't be
    added in the Post Editor" and "can't be added in the Product Catalog
    Template" E2E titles to no replacement. Review asked for a call-site
    case like the Product Price and Image Gallery one.

    The new case loads the real related-products module with
    registerProductBlockType mocked and asserts the registration declares
    isAvailableOnPostEditor: false and carries supports.inserter: false
    from block.json. It mocks the block's edit and save modules: they load
    the block editor a second time and the Product Query variations, which
    log to the console and fail the suite under @wordpress/jest-console.

    Refs TESTOPS-234

    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

    * test(blocks): Cover the Product Details post-editor registration

    The call-site tests in register-product-block-type.test.ts pin the
    post-editor flag for Product Price, Product Image Gallery and Related
    Products, but not for Product Details, which registers with
    isAvailableOnPostEditor: true. The retained placeholder test inserts
    the block directly, so nothing would notice Product Details dropping
    out of the post editor. CodeRabbit raised this in its review of this
    PR.

    Load the Product Details block and assert its registration flag, with
    its editor components mocked the way the Related Products test does:
    they pull in the block editor, which logs a duplicate Yjs import
    inside isolateModules.

    Refs TESTOPS-234

    Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

    ---------

    Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

diff --git a/plugins/woocommerce/changelog/testops-234-single-product-page-blocks b/plugins/woocommerce/changelog/testops-234-single-product-page-blocks
new file mode 100644
index 00000000000..eab8a59626f
--- /dev/null
+++ b/plugins/woocommerce/changelog/testops-234-single-product-page-blocks
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Reduce product block registration E2E tests from 9 to 3; Jest owns the registration manager, the Product Price and Image Gallery declarations, and the Product Details placeholder.
+
diff --git a/plugins/woocommerce/client/blocks/assets/js/atomic/utils/test/register-product-block-type.test.ts b/plugins/woocommerce/client/blocks/assets/js/atomic/utils/test/register-product-block-type.test.ts
new file mode 100644
index 00000000000..fb8042b1238
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/assets/js/atomic/utils/test/register-product-block-type.test.ts
@@ -0,0 +1,333 @@
+/**
+ * External dependencies
+ */
+import type { BlockConfiguration } from '@wordpress/blocks';
+
+const mockRegisterBlockType = jest.fn();
+const mockUnregisterBlockType = jest.fn();
+const mockRegisterBlockVariation = jest.fn();
+const mockUnregisterBlockVariation = jest.fn();
+const mockUnsubscribe = jest.fn();
+const mockRegisterProductBlockTypeCallSite = jest.fn();
+
+let mockContextSubscription: () => void;
+let mockTemplateSubscription: () => void;
+let mockPostType: string;
+let mockTemplateSlug: string;
+let mockIsSiteEditor: boolean;
+
+const getBlocksMock = () => ( {
+	registerBlockType: mockRegisterBlockType,
+	unregisterBlockType: mockUnregisterBlockType,
+	registerBlockVariation: mockRegisterBlockVariation,
+	unregisterBlockVariation: mockUnregisterBlockVariation,
+} );
+
+const getDataMock = () => ( {
+	select: jest.fn( ( storeName: string ) => {
+		if ( storeName === 'core/editor' ) {
+			return {
+				getCurrentPostType: () => mockPostType,
+				getEditedPostSlug: () => mockTemplateSlug,
+			};
+		}
+
+		if ( storeName === 'core/edit-site' ) {
+			return mockIsSiteEditor ? {} : undefined;
+		}
+
+		return undefined;
+	} ),
+	subscribe: jest.fn( ( callback: () => void, storeName?: string ) => {
+		if ( storeName === 'core/editor' ) {
+			mockTemplateSubscription = callback;
+		} else {
+			mockContextSubscription = callback;
+		}
+
+		return mockUnsubscribe;
+	} ),
+} );
+
+type RegisterProductBlockType =
+	typeof import('../register-product-block-type').registerProductBlockType;
+
+const blockSettings = {
+	title: 'Test product block',
+	category: 'woocommerce',
+} as Partial< BlockConfiguration >;
+
+const loadRegistrationFunction = (): RegisterProductBlockType => {
+	let registerProductBlockType: RegisterProductBlockType | undefined;
+
+	jest.isolateModules( () => {
+		( { registerProductBlockType } = jest.requireActual(
+			'../register-product-block-type'
+		) );
+	} );
+
+	if ( ! registerProductBlockType ) {
+		throw new Error( 'Expected registerProductBlockType to be loaded.' );
+	}
+
+	return registerProductBlockType;
+};
+
+describe( 'registerProductBlockType', () => {
+	beforeEach( () => {
+		jest.resetModules();
+		jest.clearAllMocks();
+		mockPostType = 'post';
+		mockTemplateSlug = '';
+		mockIsSiteEditor = false;
+		mockContextSubscription = () => {
+			throw new Error( 'Expected a context subscription.' );
+		};
+		mockTemplateSubscription = () => {
+			throw new Error( 'Expected a template subscription.' );
+		};
+		jest.doMock( '@wordpress/blocks', getBlocksMock );
+		jest.doMock( '@wordpress/data', getDataMock );
+		jest.dontMock( '@woocommerce/atomic-utils' );
+	} );
+
+	it( 'registers only post-editor-enabled blocks with the Single Product ancestor', () => {
+		const registerProductBlockType = loadRegistrationFunction();
+
+		registerProductBlockType( 'woocommerce/post-enabled', {
+			...blockSettings,
+			isAvailableOnPostEditor: true,
+		} );
+		registerProductBlockType( 'woocommerce/post-disabled', {
+			...blockSettings,
+			isAvailableOnPostEditor: false,
+		} );
+		mockContextSubscription();
+
+		expect( mockRegisterBlockType ).toHaveBeenCalledTimes( 1 );
+		expect( mockRegisterBlockType ).toHaveBeenCalledWith(
+			'woocommerce/post-enabled',
+			expect.objectContaining( {
+				ancestor: [ 'woocommerce/single-product' ],
+			} )
+		);
+		expect( mockUnsubscribe ).toHaveBeenCalledTimes( 1 );
+	} );
+
+	it( 'keeps the Single Product ancestor outside a Single Product template', () => {
+		mockPostType = 'wp_template';
+		mockTemplateSlug = 'twentytwentyfour//coming-soon';
+		mockIsSiteEditor = true;
+		const registerProductBlockType = loadRegistrationFunction();
+
+		registerProductBlockType(
+			'woocommerce/site-editor-block',
+			blockSettings
+		);
+		mockContextSubscription();
+
+		expect( mockRegisterBlockType ).toHaveBeenCalledTimes( 1 );
+		expect( mockRegisterBlockType ).toHaveBeenCalledWith(
+			'woocommerce/site-editor-block',
+			expect.objectContaining( {
+				ancestor: [ 'woocommerce/single-product' ],
+			} )
+		);
+		expect( mockUnregisterBlockType ).not.toHaveBeenCalled();
+	} );
+
+	it( 're-registers a block with the ancestor required by each template', () => {
+		mockPostType = 'wp_template';
+		mockTemplateSlug = 'twentytwentyfour//coming-soon';
+		mockIsSiteEditor = true;
+		const registerProductBlockType = loadRegistrationFunction();
+
+		registerProductBlockType(
+			'woocommerce/transition-block',
+			blockSettings
+		);
+		registerProductBlockType(
+			'woocommerce/transition-block',
+			blockSettings
+		);
+		mockContextSubscription();
+
+		expect( mockRegisterBlockType ).toHaveBeenCalledTimes( 1 );
+
+		mockTemplateSlug = 'woocommerce//single-product';
+		mockTemplateSubscription();
+
+		expect( mockUnregisterBlockType ).toHaveBeenNthCalledWith(
+			1,
+			'woocommerce/transition-block'
+		);
+		expect( mockRegisterBlockType ).toHaveBeenNthCalledWith(
+			2,
+			'woocommerce/transition-block',
+			expect.objectContaining( { ancestor: undefined } )
+		);
+
+		mockTemplateSlug = 'twentytwentyfour//page';
+		mockTemplateSubscription();
+
+		expect( mockUnregisterBlockType ).toHaveBeenNthCalledWith(
+			2,
+			'woocommerce/transition-block'
+		);
+		expect( mockUnregisterBlockType ).toHaveBeenCalledTimes( 2 );
+		expect( mockRegisterBlockType ).toHaveBeenCalledTimes( 3 );
+		expect( mockRegisterBlockType ).toHaveBeenNthCalledWith(
+			3,
+			'woocommerce/transition-block',
+			expect.objectContaining( {
+				ancestor: [ 'woocommerce/single-product' ],
+			} )
+		);
+	} );
+
+	it( 're-registers variations when the template context changes', () => {
+		mockPostType = 'wp_template';
+		mockTemplateSlug = 'twentytwentyfour//coming-soon';
+		mockIsSiteEditor = true;
+		const registerProductBlockType = loadRegistrationFunction();
+		const variationSettings = {
+			name: 'related-products',
+			title: 'Related products',
+			isVariationBlock: true,
+			variationName: 'related-products',
+		};
+
+		registerProductBlockType(
+			'woocommerce/product-query',
+			variationSettings
+		);
+		mockContextSubscription();
+
+		expect( mockRegisterBlockVariation ).toHaveBeenCalledTimes( 1 );
+		expect( mockRegisterBlockVariation ).toHaveBeenCalledWith(
+			'woocommerce/product-query',
+			expect.objectContaining( {
+				name: 'related-products',
+				title: 'Related products',
+			} )
+		);
+
+		mockTemplateSlug = 'woocommerce//single-product';
+		mockTemplateSubscription();
+
+		expect( mockUnregisterBlockVariation ).toHaveBeenCalledWith(
+			'woocommerce/product-query',
+			'related-products'
+		);
+		expect( mockRegisterBlockVariation ).toHaveBeenCalledTimes( 2 );
+		expect( mockRegisterBlockVariation ).toHaveBeenLastCalledWith(
+			'woocommerce/product-query',
+			expect.objectContaining( {
+				name: 'related-products',
+				title: 'Related products',
+			} )
+		);
+
+		mockTemplateSlug = 'twentytwentyfour//page';
+		mockTemplateSubscription();
+
+		expect( mockUnregisterBlockVariation ).toHaveBeenNthCalledWith(
+			2,
+			'woocommerce/product-query',
+			'related-products'
+		);
+		expect( mockUnregisterBlockVariation ).toHaveBeenCalledTimes( 2 );
+		expect( mockRegisterBlockVariation ).toHaveBeenCalledTimes( 3 );
+		expect( mockRegisterBlockVariation ).toHaveBeenLastCalledWith(
+			'woocommerce/product-query',
+			expect.objectContaining( {
+				name: 'related-products',
+				title: 'Related products',
+			} )
+		);
+	} );
+} );
+
+describe( 'product block registration call sites', () => {
+	beforeEach( () => {
+		jest.resetModules();
+		jest.clearAllMocks();
+		jest.dontMock( '@wordpress/blocks' );
+		jest.dontMock( '@wordpress/data' );
+		jest.doMock( '@woocommerce/atomic-utils', () => ( {
+			registerProductBlockType: mockRegisterProductBlockTypeCallSite,
+		} ) );
+	} );
+
+	it( 'declares the post-editor availability of Product Price and Product Image Gallery', () => {
+		jest.isolateModules( () => {
+			jest.requireActual( '../../blocks/product-elements/price' );
+			jest.requireActual(
+				'../../blocks/product-elements/product-image-gallery'
+			);
+		} );
+
+		expect( mockRegisterProductBlockTypeCallSite ).toHaveBeenCalledTimes(
+			2
+		);
+		expect( mockRegisterProductBlockTypeCallSite ).toHaveBeenCalledWith(
+			expect.objectContaining( { name: 'woocommerce/product-price' } ),
+			expect.objectContaining( { isAvailableOnPostEditor: true } )
+		);
+		expect( mockRegisterProductBlockTypeCallSite ).toHaveBeenCalledWith(
+			expect.objectContaining( {
+				name: 'woocommerce/product-image-gallery',
+			} ),
+			expect.objectContaining( { isAvailableOnPostEditor: false } )
+		);
+	} );
+
+	it( 'declares the deprecated Related Products block unavailable in the post editor and hidden from the inserter', () => {
+		// The editor components load the block editor and the Product Query
+		// variations, which log to the console and aren't part of registration.
+		jest.doMock(
+			'../../blocks/product-elements/related-products/edit',
+			() => () => null
+		);
+		jest.doMock(
+			'../../blocks/product-elements/related-products/save',
+			() => () => null
+		);
+
+		jest.isolateModules( () => {
+			jest.requireActual(
+				'../../blocks/product-elements/related-products'
+			);
+		} );
+
+		expect( mockRegisterProductBlockTypeCallSite ).toHaveBeenCalledTimes(
+			1
+		);
+		expect( mockRegisterProductBlockTypeCallSite ).toHaveBeenCalledWith(
+			expect.objectContaining( {
+				name: 'woocommerce/related-products',
+				supports: expect.objectContaining( { inserter: false } ),
+			} ),
+			expect.objectContaining( { isAvailableOnPostEditor: false } )
+		);
+	} );
+
+	it( 'declares the Product Details block available in the post editor', () => {
+		// The editor components pull in the block editor, which logs a duplicate Yjs
+		// import when loaded inside isolateModules, and they aren't part of registration.
+		jest.doMock( '../../../blocks/product-details/edit', () => () => null );
+		jest.doMock( '../../../blocks/product-details/save', () => () => null );
+
+		jest.isolateModules( () => {
+			jest.requireActual( '../../../blocks/product-details' );
+		} );
+
+		expect( mockRegisterProductBlockTypeCallSite ).toHaveBeenCalledTimes(
+			1
+		);
+		expect( mockRegisterProductBlockTypeCallSite ).toHaveBeenCalledWith(
+			expect.objectContaining( { name: 'woocommerce/product-details' } ),
+			expect.objectContaining( { isAvailableOnPostEditor: true } )
+		);
+	} );
+} );
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-details/test/block.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/product-details/test/block.tsx
index 6b6390fdd8b..faf68edc7eb 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-details/test/block.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-details/test/block.tsx
@@ -129,7 +129,7 @@ describe( 'Product Details block', () => {
 		).not.toContain( 'style=' );
 	} );

-	describe( 'Single Product block', () => {
+	describe( 'editor integration', () => {
 		const server = setupServer(
 			http.get( '/wc-admin/options', ( { request } ) => {
 				const url = new URL( request.url );
@@ -192,6 +192,20 @@ describe( 'Product Details block', () => {
 			jest.restoreAllMocks();
 		} );

+		test( 'should populate a freshly inserted block with the Product Description placeholder', async () => {
+			await initializeEditor( {
+				name: 'woocommerce/product-details',
+				attributes: {},
+			} );
+
+			expect(
+				await screen.findByText(
+					'This block displays the product description. When viewing a product page, the description content will automatically appear here.',
+					{ exact: true }
+				)
+			).toBeVisible();
+		} );
+
 		test( 'should render product specifications when product is selected', async () => {
 			await setupWithSingleProduct( {}, 2 );

diff --git a/plugins/woocommerce/client/blocks/changelog/testops-234-single-product-page-blocks b/plugins/woocommerce/client/blocks/changelog/testops-234-single-product-page-blocks
new file mode 100644
index 00000000000..eab8a59626f
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/changelog/testops-234-single-product-page-blocks
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Reduce product block registration E2E tests from 9 to 3; Jest owns the registration manager, the Product Price and Image Gallery declarations, and the Product Details placeholder.
+
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/related-products/related-products.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/related-products/related-products.block_theme.spec.ts
index 021e6af6bdf..80ddc20592f 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/related-products/related-products.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/related-products/related-products.block_theme.spec.ts
@@ -20,44 +20,7 @@ const blockData: BlockData = {
 };

 test.describe( `${ blockData.name } Block`, () => {
-	test( "can't be added in the Post Editor", async ( { admin, editor } ) => {
-		await admin.createNewPost();
-
-		try {
-			await editor.insertBlock( { name: blockData.slug } );
-		} catch ( _error ) {
-			// noop
-		}
-
-		await expect(
-			await editor.getBlockByName( blockData.slug )
-		).toBeHidden();
-	} );
-
-	test( "can't be added in the Product Catalog Template", async ( {
-		admin,
-		editor,
-	} ) => {
-		await admin.visitSiteEditor( {
-			postId: `${ BLOCK_THEME_SLUG }//archive-product`,
-			postType: 'wp_template',
-			canvas: 'edit',
-		} );
-
-		await editor.setContent( '' );
-
-		try {
-			await editor.insertBlock( { name: blockData.slug } );
-		} catch ( _error ) {
-			// noop
-		}
-
-		await expect(
-			await editor.getBlockByName( blockData.slug )
-		).toBeHidden();
-	} );
-
-	test( "can't be added in the Single Product Template", async ( {
+	test( 'inserts the supported Related Products variation', async ( {
 		admin,
 		editor,
 	} ) => {
@@ -68,11 +31,11 @@ test.describe( `${ blockData.name } Block`, () => {
 		} );
 		await editor.setContent( '' );

-		// Inserting Related Products by name
-		// (but it's a Product Collection variation).
 		await editor.insertBlockUsingGlobalInserter( blockData.name );

-		// Verifying by slug - it's expected it's NOT woocommerce/related-products.
+		await expect(
+			await editor.getBlockByName( 'woocommerce/product-collection' )
+		).toBeVisible();
 		await expect(
 			await editor.getBlockByName( blockData.slug )
 		).toBeHidden();
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/single-product-details/single-product-details.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/single-product-details/single-product-details.block_theme.spec.ts
deleted file mode 100644
index f0f653d437c..00000000000
--- a/plugins/woocommerce/tests/e2e/tests/blocks/single-product-details/single-product-details.block_theme.spec.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * External dependencies
- */
-import { expect, test } from '@woocommerce/e2e-utils';
-
-/**
- * Internal dependencies
- */
-
-const blockData = {
-	name: 'Product Details',
-	slug: 'woocommerce/product-details',
-};
-
-test.describe( `${ blockData.slug } Block`, () => {
-	test( "block can't be inserted in Post Editor", async ( {
-		editor,
-		admin,
-	} ) => {
-		await admin.createNewPost();
-
-		try {
-			await editor.insertBlock( { name: blockData.slug } );
-		} catch ( _error ) {
-			// noop
-		}
-
-		await expect(
-			await editor.getBlockByName( blockData.slug )
-		).toBeHidden();
-	} );
-
-	test( 'block can be inserted in the Site Editor', async ( {
-		admin,
-		requestUtils,
-		editor,
-	} ) => {
-		const template = await requestUtils.createTemplate( 'wp_template', {
-			// Single Product Details block is addable only in Single Product Templates
-			slug: 'single-product-v-neck-t-shirt',
-			title: 'Sorter',
-			content: 'placeholder',
-		} );
-
-		await admin.visitSiteEditor( {
-			postId: template.id,
-			postType: 'wp_template',
-			canvas: 'edit',
-		} );
-
-		await expect(
-			editor.getCustomHtmlBlockContentLocator( 'placeholder' )
-		).toBeVisible();
-
-		await editor.insertBlock( {
-			name: blockData.slug,
-		} );
-
-		const block = await editor.getBlockByName( blockData.slug );
-
-		await expect( block ).toHaveText(
-			/This block displays the product description. When viewing a product page, the description content will automatically appear here./
-		);
-	} );
-} );
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/utils/register-block-single-product-template.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/utils/register-block-single-product-template.block_theme.spec.ts
index 68c21564f19..bcde958a5a3 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/utils/register-block-single-product-template.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/utils/register-block-single-product-template.block_theme.spec.ts
@@ -2,70 +2,8 @@
  * External dependencies
  */
 import { test, expect, BLOCK_THEME_SLUG } from '@woocommerce/e2e-utils';
-import type { Editor, Admin } from '@woocommerce/e2e-utils';
-
-const insertSingleProductBlock = async ( editor: Editor ) => {
-	await editor.insertBlock( { name: 'woocommerce/single-product' } );
-	await editor.canvas.getByText( 'Album' ).click();
-	await editor.canvas.getByText( 'Done' ).click();
-	const singleProductBlock = await editor.getBlockByName(
-		'woocommerce/single-product'
-	);
-	const singleProductClientId =
-		( await singleProductBlock.getAttribute( 'data-block' ) ) ?? '';
-	return singleProductClientId;
-};
-
-const insertInSingleProductTemplate = async (
-	blockName: string,
-	editor: Editor,
-	admin: Admin
-) => {
-	await admin.visitSiteEditor( {
-		postId: `${ BLOCK_THEME_SLUG }//single-product`,
-		postType: 'wp_template',
-		canvas: 'edit',
-	} );
-	await editor.setContent( '' );
-	await editor.insertBlock( { name: blockName } );
-};

 test.describe( 'registerProductBlockType registers', () => {
-	test( 'block available on posts, e.g. Product Price', async ( {
-		admin,
-		editor,
-	} ) => {
-		const blockName = 'woocommerce/product-price';
-
-		await test.step( 'Unavailable in post globally', async () => {
-			await admin.createNewPost();
-			await editor.insertBlock( { name: blockName } );
-			await expect(
-				await editor.getBlockByName( blockName )
-			).toHaveCount( 0 );
-		} );
-
-		await test.step( 'Available in post within Single Product block', async () => {
-			const singleProductClientId =
-				await insertSingleProductBlock( editor );
-			// One from the global inserter, one from the single product block
-			await editor.insertBlock(
-				{ name: blockName },
-				{ clientId: singleProductClientId }
-			);
-			await expect(
-				await editor.getBlockByName( blockName )
-			).toHaveCount( 2 );
-		} );
-
-		await test.step( 'Available in Single Product template globally', async () => {
-			await insertInSingleProductTemplate( blockName, editor, admin );
-			await expect(
-				await editor.getBlockByName( blockName )
-			).toHaveCount( 1 );
-		} );
-	} );
-
 	test( 'blocks are registered correctly when switching templates via command palette', async ( {
 		admin,
 		editor,
@@ -117,7 +55,13 @@ test.describe( 'registerProductBlockType registers', () => {
 			await editor.setContent( '' );

 			// Product Price is available in the global inserter. For some reason, using await editor.insertBlock( { name: blockName } ); does not work here.
-			await editor.insertBlockUsingGlobalInserter( blockTitle );
+			await editor.openGlobalBlockInserter();
+			await page.getByPlaceholder( 'Search' ).fill( blockTitle );
+			const productPriceOption = page
+				.getByRole( 'option', { name: blockTitle, exact: true } )
+				.first();
+			await expect( productPriceOption ).toBeVisible();
+			await productPriceOption.click();

 			await expect(
 				await editor.getBlockByName( blockName )
@@ -162,35 +106,4 @@ test.describe( 'registerProductBlockType registers', () => {
 			await expect( block.first() ).toBeAttached();
 		}
 	} );
-
-	test( 'block unavailable on posts, e.g. Product Image Gallery', async ( {
-		admin,
-		editor,
-	} ) => {
-		const blockName = 'woocommerce/product-image-gallery';
-
-		await test.step( 'Unavailable in post, also within Single Product block', async () => {
-			await admin.createNewPost();
-			await insertSingleProductBlock( editor );
-
-			await editor.canvas
-				.getByRole( 'button', { name: 'Add block' } )
-				.click();
-
-			await editor.page
-				.getByRole( 'searchbox', { name: 'Search' } )
-				.fill( blockName );
-
-			await expect(
-				editor.page.getByText( 'Product Image Gallery' )
-			).toBeHidden();
-		} );
-
-		await test.step( 'Available in Single Product template globally', async () => {
-			await insertInSingleProductTemplate( blockName, editor, admin );
-			await expect(
-				await editor.getBlockByName( blockName )
-			).toHaveCount( 1 );
-		} );
-	} );
 } );