Commit e800f120583 for woocommerce

commit e800f120583ea907612596e29dc8c47b43703718
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date:   Tue Nov 17 15:25:12 2026 +0200

    Run Blocks e2e specs that use test plugins in parallel (#71038)

diff --git a/plugins/woocommerce/changelog/testops-324-blocks-e2e-parallel-test-plugins b/plugins/woocommerce/changelog/testops-324-blocks-e2e-parallel-test-plugins
new file mode 100644
index 00000000000..92790ff1e7c
--- /dev/null
+++ b/plugins/woocommerce/changelog/testops-324-blocks-e2e-parallel-test-plugins
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Run six Blocks e2e specs that use test plugins in the parallel pool; no production change.
+
diff --git a/plugins/woocommerce/tests/e2e/playwright.config.ts b/plugins/woocommerce/tests/e2e/playwright.config.ts
index fa17b21e377..9a1a79d488f 100644
--- a/plugins/woocommerce/tests/e2e/playwright.config.ts
+++ b/plugins/woocommerce/tests/e2e/playwright.config.ts
@@ -118,8 +118,8 @@ const serialRunSpecs = [
 	// behavior for every other worker. (`cart.spec.ts` runs in core-parallel — it
 	// scopes its tax rate to a dedicated tax class instead of toggling global tax.)
 	'**/tests/cart/add-to-cart.spec.ts',
-	// Activates a custom-gateway test plugin globally, which would surface its extra
-	// payment button on every other worker's checkout.
+	// Activates a test plugin with WP-CLI, which races other workers on the
+	// `active_plugins` option.
 	'**/tests/checkout/checkout-shortcode-custom-place-order-button.spec.ts',
 	// Mutate the global onboarding profile/options, site-visibility options and
 	// the active theme.
@@ -214,14 +214,8 @@ const blocksSerialSpecs = [
 	'**/tests/blocks/stock-filter/stock-filter.block_theme.spec.ts',
 	'**/tests/blocks/templates/legacy-templates.block_theme.spec.ts',

-	// Activate test plugins that change every cart, checkout or product page, or
-	// race other specs on the `active_plugins` option.
-	'**/tests/blocks/cart/cart-checkout-block-extension-callbacks.shopper.block_theme.spec.ts',
-	'**/tests/blocks/checkout/checkout-block-custom-place-order-button.block_theme.spec.ts',
-	'**/tests/blocks/checkout/checkout-block-extensibility.shopper.block_theme.spec.ts',
-	'**/tests/blocks/product-button/product-button.block_theme.spec.ts',
-	'**/tests/blocks/product-collection/product-picker.block_theme.spec.ts',
-	'**/tests/blocks/product-collection/register-product-collection.block_theme.spec.ts',
+	// Turn off AJAX add to cart, which every Product Button reads.
+	'**/tests/blocks/product-button/product-button-ajax-disabled.block_theme.spec.ts',

 	// Change global settings that cart, checkout and storefront specs read.

diff --git a/plugins/woocommerce/tests/e2e/test-plugins/blocks/cart-extensions-test-helper.php b/plugins/woocommerce/tests/e2e/test-plugins/blocks/cart-extensions-test-helper.php
index 4881e1df62c..5492ca35164 100644
--- a/plugins/woocommerce/tests/e2e/test-plugins/blocks/cart-extensions-test-helper.php
+++ b/plugins/woocommerce/tests/e2e/test-plugins/blocks/cart-extensions-test-helper.php
@@ -8,6 +8,11 @@
  * @package woocommerce-blocks-test-cart-extensions
  */

+// Only requests from specs that enable this plugin send the cookie.
+if ( ! isset( $_COOKIE['woocommerce-blocks-test-cart-extensions-test-helper'] ) ) {
+	return;
+}
+
 class Cart_Extensions_Test_Helper {
 	/**
 	 * Constructor.
diff --git a/plugins/woocommerce/tests/e2e/test-plugins/blocks/custom-add-to-cart-button-text.php b/plugins/woocommerce/tests/e2e/test-plugins/blocks/custom-add-to-cart-button-text.php
index 16e3ddafacf..61203e263c3 100644
--- a/plugins/woocommerce/tests/e2e/test-plugins/blocks/custom-add-to-cart-button-text.php
+++ b/plugins/woocommerce/tests/e2e/test-plugins/blocks/custom-add-to-cart-button-text.php
@@ -8,6 +8,11 @@
  * @package woocommerce-blocks-test-custom-add-to-cart-button-text
  */

+// Only requests from specs that enable this plugin send the cookie.
+if ( ! isset( $_COOKIE['woocommerce-blocks-test-custom-add-to-cart-button-text'] ) ) {
+	return;
+}
+
 function woocommerce_add_to_cart_button_text_archives() {
 	return 'Buy Now';
 }
diff --git a/plugins/woocommerce/tests/e2e/test-plugins/blocks/custom-place-order-button-test.php b/plugins/woocommerce/tests/e2e/test-plugins/blocks/custom-place-order-button-test.php
index 17fbb366395..f73195baa8c 100644
--- a/plugins/woocommerce/tests/e2e/test-plugins/blocks/custom-place-order-button-test.php
+++ b/plugins/woocommerce/tests/e2e/test-plugins/blocks/custom-place-order-button-test.php
@@ -10,6 +10,11 @@

 declare(strict_types=1);

+// Only requests from specs that enable this plugin send the cookie.
+if ( ! isset( $_COOKIE['woocommerce-blocks-test-custom-place-order-button-test'] ) ) {
+	return;
+}
+
 add_action(
 	'plugins_loaded',
 	function () {
diff --git a/plugins/woocommerce/tests/e2e/test-plugins/blocks/extension-cart-update.php b/plugins/woocommerce/tests/e2e/test-plugins/blocks/extension-cart-update.php
index c33e8b3f90e..73aad8bad46 100644
--- a/plugins/woocommerce/tests/e2e/test-plugins/blocks/extension-cart-update.php
+++ b/plugins/woocommerce/tests/e2e/test-plugins/blocks/extension-cart-update.php
@@ -11,6 +11,11 @@
 use Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema;
 use Automattic\WooCommerce\StoreApi\StoreApi;

+// Only requests from specs that enable this plugin send the cookie.
+if ( ! isset( $_COOKIE['woocommerce-blocks-test-extension-cart-update'] ) ) {
+	return;
+}
+
 add_action(
 	'woocommerce_init',
 	function () {
diff --git a/plugins/woocommerce/tests/e2e/test-plugins/blocks/register-product-collection.php b/plugins/woocommerce/tests/e2e/test-plugins/blocks/register-product-collection.php
index e4aedacbe95..61aaa0d4960 100644
--- a/plugins/woocommerce/tests/e2e/test-plugins/blocks/register-product-collection.php
+++ b/plugins/woocommerce/tests/e2e/test-plugins/blocks/register-product-collection.php
@@ -13,6 +13,11 @@ if (!defined('ABSPATH')) {
 	exit;
 }

+// Only requests from specs that enable this plugin send the cookie.
+if ( ! isset( $_COOKIE['woocommerce-blocks-test-register-product-collection'] ) ) {
+	return;
+}
+
 // Enqueue the JavaScript file.
 function register_product_collections_script()
 {
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/cart/cart-checkout-block-extension-callbacks.shopper.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/cart/cart-checkout-block-extension-callbacks.shopper.block_theme.spec.ts
index 37cabfe774a..238e81a4db9 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/cart/cart-checkout-block-extension-callbacks.shopper.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/cart/cart-checkout-block-extension-callbacks.shopper.block_theme.spec.ts
@@ -1,7 +1,12 @@
 /**
  * External dependencies
  */
-import { expect, test as base } from '@woocommerce/e2e-utils';
+import {
+	expect,
+	test as base,
+	enableTestPlugin,
+	guestFile,
+} from '@woocommerce/e2e-utils';

 /**
  * Internal dependencies
@@ -19,15 +24,16 @@ const test = base.extend< { checkoutPageObject: CheckoutPage } >( {
 } );

 test.describe( 'Shopper → Cart Extension Callbacks', () => {
+	test.use( { storageState: guestFile } );
+
+	test.beforeEach( async ( { context } ) => {
+		await enableTestPlugin( context, 'cart-extensions-test-helper' );
+	} );
+
 	test( 'Custom error code creates exception', async ( {
 		frontendUtils,
-		requestUtils,
 		page,
 	} ) => {
-		await requestUtils.activatePlugin(
-			'woocommerce-blocks-test-cart-extensions'
-		);
-
 		await frontendUtils.goToShop();
 		await frontendUtils.addToCart( REGULAR_PRICED_PRODUCT_NAME );
 		await frontendUtils.goToCart();
@@ -47,13 +53,8 @@ test.describe( 'Shopper → Cart Extension Callbacks', () => {

 	test( 'Error code `woocommerce_rest_cart_extensions_error` creates notice', async ( {
 		frontendUtils,
-		requestUtils,
 		page,
 	} ) => {
-		await requestUtils.activatePlugin(
-			'woocommerce-blocks-test-cart-extensions'
-		);
-
 		await frontendUtils.goToShop();
 		await frontendUtils.addToCart( REGULAR_PRICED_PRODUCT_NAME );
 		await frontendUtils.goToCart();
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block-custom-place-order-button.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block-custom-place-order-button.block_theme.spec.ts
index 1629b6dfd9d..6e0c7e6b411 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block-custom-place-order-button.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block-custom-place-order-button.block_theme.spec.ts
@@ -1,7 +1,13 @@
 /**
  * External dependencies
  */
-import { expect, test as base, guestFile, wpCLI } from '@woocommerce/e2e-utils';
+import {
+	expect,
+	test as base,
+	enableTestPlugin,
+	guestFile,
+	wpCLI,
+} from '@woocommerce/e2e-utils';

 /**
  * Internal dependencies
@@ -22,10 +28,8 @@ const test = base.extend< { checkoutPageObject: CheckoutPage } >( {
 test.describe( 'Custom Place Order Button', () => {
 	test.use( { storageState: guestFile } );

-	test.beforeEach( async ( { requestUtils } ) => {
-		await requestUtils.activatePlugin(
-			'woocommerce-blocks-test-custom-place-order-button'
-		);
+	test.beforeEach( async ( { context } ) => {
+		await enableTestPlugin( context, 'custom-place-order-button-test' );
 		await wpCLI(
 			'option set woocommerce_test-custom-button_settings --format=json \'{"enabled":"yes"}\''
 		);
@@ -77,11 +81,33 @@ test.describe( 'Custom Place Order Button', () => {

 	test( 'clicking custom button submits order when form is valid', async ( {
 		page,
+		requestUtils,
 		frontendUtils,
 		checkoutPageObject,
+		cleanup,
 	} ) => {
-		await frontendUtils.goToShop();
-		await frontendUtils.addToCart( SIMPLE_PHYSICAL_PRODUCT_NAME );
+		// An order adds to the product's sales, so it buys a product of its own
+		// and leaves the Best Sellers ranking alone. Hidden and dated in the
+		// past, the product stays out of the catalog and New Arrivals.
+		const { id: productId } = await requestUtils.rest< { id: number } >( {
+			method: 'POST',
+			path: 'wc/v3/products',
+			data: {
+				name: 'Custom place order button product',
+				regular_price: '10',
+				catalog_visibility: 'hidden',
+				date_created: '2020-01-01T00:00:00',
+			},
+		} );
+		cleanup( () =>
+			requestUtils.rest( {
+				method: 'DELETE',
+				path: `wc/v3/products/${ productId }`,
+				params: { force: true },
+			} )
+		);
+
+		await page.goto( `/?add-to-cart=${ productId }` );
 		await frontendUtils.goToCheckout();

 		// Fill in valid checkout data.
@@ -106,10 +132,25 @@ test.describe( 'Custom Place Order Button', () => {
 		const customButton = page.getByTestId( 'custom-place-order-button' );
 		await expect( customButton ).toBeEnabled();

+		const checkoutResponse = page.waitForResponse(
+			( response ) =>
+				response.url().includes( '/wc/store/v1/checkout' ) &&
+				response.request().method() === 'POST'
+		);
+
 		// Focus then click the custom button to avoid misses due to page content shifting.
 		await customButton.focus();
 		await customButton.click();

+		const { order_id: orderId } = await ( await checkoutResponse ).json();
+		cleanup( () =>
+			requestUtils.rest( {
+				method: 'DELETE',
+				path: `wc/v3/orders/${ orderId }`,
+				params: { force: true },
+			} )
+		);
+
 		// Verify order was placed successfully by checking for order confirmation.
 		await expect( page ).toHaveURL( /order-received/ );
 	} );
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block-extensibility.shopper.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block-extensibility.shopper.block_theme.spec.ts
index e7a05fda2ba..b7160a3a165 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block-extensibility.shopper.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block-extensibility.shopper.block_theme.spec.ts
@@ -1,7 +1,12 @@
 /**
  * External dependencies
  */
-import { expect, test as base, guestFile } from '@woocommerce/e2e-utils';
+import {
+	expect,
+	test as base,
+	enableTestPlugin,
+	guestFile,
+} from '@woocommerce/e2e-utils';

 /**
  * Internal dependencies
@@ -21,20 +26,8 @@ const test = base.extend< { checkoutPageObject: CheckoutPage } >( {
 test.describe( 'Shopper → Extensibility', () => {
 	test.use( { storageState: guestFile } );

-	test.beforeEach( async ( { requestUtils, frontendUtils } ) => {
-		await requestUtils.rest( {
-			method: 'PUT',
-			path: 'wc/v3/settings/account/woocommerce_enable_guest_checkout',
-			data: { value: 'yes' },
-		} );
-		await requestUtils.rest( {
-			method: 'PUT',
-			path: 'wc/v3/settings/account/woocommerce_enable_checkout_login_reminder',
-			data: { value: 'yes' },
-		} );
-		await requestUtils.activatePlugin(
-			'woocommerce-blocks-test-extensioncartupdate'
-		);
+	test.beforeEach( async ( { context, frontendUtils } ) => {
+		await enableTestPlugin( context, 'extension-cart-update' );

 		await frontendUtils.goToShop();
 		await frontendUtils.addToCart( REGULAR_PRICED_PRODUCT_NAME );
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/product-button/product-button-ajax-disabled.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/product-button/product-button-ajax-disabled.block_theme.spec.ts
new file mode 100644
index 00000000000..fc98c9f341e
--- /dev/null
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/product-button/product-button-ajax-disabled.block_theme.spec.ts
@@ -0,0 +1,48 @@
+/**
+ * External dependencies
+ */
+import { expect, test } from '@woocommerce/e2e-utils';
+
+/**
+ * Internal dependencies
+ */
+import { blockData, handleAddToCartAjaxSetting } from './utils';
+
+test.describe( `${ blockData.name } Block with AJAX add to cart disabled`, () => {
+	test( 'should add product to the cart - with ajax disabled', async ( {
+		frontendUtils,
+		page,
+		admin,
+	} ) => {
+		await handleAddToCartAjaxSetting( admin, page, {
+			isChecked: true,
+		} );
+		await frontendUtils.goToShop();
+
+		const blocks = await frontendUtils.getBlockByName( blockData.slug );
+		const block = blocks.first();
+		const button = block.getByRole( 'link' );
+
+		const productId = await button.getAttribute( 'data-product_id' );
+
+		const productNameLocator = page.locator( `li.post-${ productId } h2` );
+		await expect( productNameLocator ).not.toBeEmpty();
+
+		const productName =
+			( await productNameLocator.textContent() ) as string;
+
+		await block.click();
+
+		await expect(
+			page.locator( `a[href*="cart=${ productId }"]` )
+		).toBeVisible();
+
+		await frontendUtils.goToCheckout();
+
+		const productElement = page.getByText( productName, {
+			exact: true,
+		} );
+
+		await expect( productElement ).toBeVisible();
+	} );
+} );
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/product-button/product-button.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/product-button/product-button.block_theme.spec.ts
index adc8b7ad409..d6637dfbd96 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/product-button/product-button.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/product-button/product-button.block_theme.spec.ts
@@ -1,14 +1,22 @@
 /**
  * External dependencies
  */
-import { expect, test } from '@woocommerce/e2e-utils';
+import {
+	expect,
+	test,
+	enableTestPlugin,
+	guestFile,
+} from '@woocommerce/e2e-utils';

 /**
  * Internal dependencies
  */
-import { blockData, handleAddToCartAjaxSetting } from './utils';
+import { blockData } from './utils';

 test.describe( `${ blockData.name } Block`, () => {
+	// A guest cart, because all workers share the admin cart.
+	test.use( { storageState: guestFile } );
+
 	test.beforeEach( async ( { frontendUtils } ) => {
 		await frontendUtils.goToShop();
 	} );
@@ -66,54 +74,11 @@ test.describe( `${ blockData.name } Block`, () => {
 		await expect( productElement ).toBeVisible();
 	} );

-	test( 'should add product to the cart - with ajax disabled', async ( {
-		frontendUtils,
-		page,
-		admin,
-	} ) => {
-		await handleAddToCartAjaxSetting( admin, page, {
-			isChecked: true,
-		} );
-		await frontendUtils.goToShop();
-
-		const blocks = await frontendUtils.getBlockByName( blockData.slug );
-		const block = blocks.first();
-		const button = block.getByRole( 'link' );
-
-		const productId = await button.getAttribute( 'data-product_id' );
-
-		const productNameLocator = page.locator( `li.post-${ productId } h2` );
-		await expect( productNameLocator ).not.toBeEmpty();
-
-		const productName =
-			( await productNameLocator.textContent() ) as string;
-
-		await block.click();
-
-		await expect(
-			page.locator( `a[href*="cart=${ productId }"]` )
-		).toBeVisible();
-
-		await frontendUtils.goToCheckout();
-
-		const productElement = page.getByText( productName, {
-			exact: true,
-		} );
-
-		await expect( productElement ).toBeVisible();
-
-		await handleAddToCartAjaxSetting( admin, page, {
-			isChecked: false,
-		} );
-	} );
-
 	test( 'the filter `woocommerce_product_add_to_cart_text` should be applied', async ( {
-		requestUtils,
+		context,
 		frontendUtils,
 	} ) => {
-		await requestUtils.activatePlugin(
-			'woocommerce-blocks-test-custom-add-to-cart-button-text'
-		);
+		await enableTestPlugin( context, 'custom-add-to-cart-button-text' );
 		await frontendUtils.goToShop();
 		const blocks = await frontendUtils.getBlockByName( blockData.slug );
 		const buttonWithNewText = blocks.getByText( 'Buy Now' );
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/product-picker.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/product-picker.block_theme.spec.ts
index 9b2bf5d9f59..c0cc5fdb9b9 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/product-picker.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/product-picker.block_theme.spec.ts
@@ -1,7 +1,12 @@
 /**
  * External dependencies
  */
-import { test as base, expect, BLOCK_THEME_SLUG } from '@woocommerce/e2e-utils';
+import {
+	test as base,
+	expect,
+	BLOCK_THEME_SLUG,
+	enableTestPlugin,
+} from '@woocommerce/e2e-utils';

 /**
  * Internal dependencies
@@ -12,6 +17,27 @@ import ProductCollectionPage, {
 } from './product-collection.page';

 const test = base.extend< { pageObject: ProductCollectionPage } >( {
+	// Each new post gets an ID when the editor opens it, so this deletes
+	// published posts and drafts alike.
+	admin: async ( { admin, requestUtils, cleanup }, use ) => {
+		const createNewPost = admin.createNewPost.bind( admin );
+		admin.createNewPost = async ( ...args ) => {
+			await createNewPost( ...args );
+			const postId = await (
+				await admin.page.waitForFunction( () =>
+					window.wp.data.select( 'core/editor' )?.getCurrentPostId()
+				)
+			).jsonValue();
+			cleanup( () =>
+				requestUtils.rest( {
+					method: 'DELETE',
+					path: `/wp/v2/posts/${ postId }`,
+					params: { force: true },
+				} )
+			);
+		};
+		await use( admin );
+	},
 	pageObject: async ( { page, admin, editor }, use ) => {
 		const pageObject = new ProductCollectionPage( {
 			page,
@@ -40,11 +66,9 @@ test.describe( 'Product Collection: Product Picker', () => {
 		},
 	];

-	// Activate plugin which registers custom product collections
-	test.beforeEach( async ( { requestUtils } ) => {
-		await requestUtils.activatePlugin(
-			'woocommerce-blocks-test-register-product-collection'
-		);
+	// Enable the plugin which registers custom product collections.
+	test.beforeEach( async ( { context } ) => {
+		await enableTestPlugin( context, 'register-product-collection' );
 	} );

 	CUSTOM_COLLECTIONS.forEach( ( collection ) => {
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/register-product-collection.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/register-product-collection.block_theme.spec.ts
index 6b66e883608..b29c01e0d80 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/register-product-collection.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/register-product-collection.block_theme.spec.ts
@@ -1,7 +1,12 @@
 /**
  * External dependencies
  */
-import { test as base, expect, BLOCK_THEME_SLUG } from '@woocommerce/e2e-utils';
+import {
+	test as base,
+	expect,
+	BLOCK_THEME_SLUG,
+	enableTestPlugin,
+} from '@woocommerce/e2e-utils';

 /**
  * Internal dependencies
@@ -11,6 +16,7 @@ import ProductCollectionPage, {
 	Collections,
 	SELECTORS,
 } from './product-collection.page';
+import { locks } from '../../../fixtures/fixtures';

 declare global {
 	interface Window {
@@ -19,6 +25,27 @@ declare global {
 }

 const test = base.extend< { pageObject: ProductCollectionPage } >( {
+	// Each new post gets an ID when the editor opens it, so this deletes
+	// published posts and drafts alike.
+	admin: async ( { admin, requestUtils, cleanup }, use ) => {
+		const createNewPost = admin.createNewPost.bind( admin );
+		admin.createNewPost = async ( ...args ) => {
+			await createNewPost( ...args );
+			const postId = await (
+				await admin.page.waitForFunction( () =>
+					window.wp.data.select( 'core/editor' )?.getCurrentPostId()
+				)
+			).jsonValue();
+			cleanup( () =>
+				requestUtils.rest( {
+					method: 'DELETE',
+					path: `/wp/v2/posts/${ postId }`,
+					params: { force: true },
+				} )
+			);
+		};
+		await use( admin );
+	},
 	pageObject: async ( { page, admin, editor }, use ) => {
 		const pageObject = new ProductCollectionPage( {
 			page,
@@ -53,47 +80,9 @@ test.describe( 'Product Collection: Register Product Collection', () => {
 		},
 	};

-	// Activate plugin which registers custom product collections
-	test.beforeEach( async ( { requestUtils } ) => {
-		// There's been multiple instances of flaky tests due to "socket hang up" errors.
-		// Seems it's more common as I found a similar issue in here:
-		// https://github.com/sillsdev/web-languageforge/issues/1402.
-		// This is a retry mechanism to ensure the plugin is activated and ready.
-		const maxRetries = 3;
-		let retryCount = 0;
-		let lastError;
-
-		while ( retryCount < maxRetries ) {
-			try {
-				await requestUtils.activatePlugin(
-					'woocommerce-blocks-test-register-product-collection'
-				);
-
-				// Verify plugin is active by making a test request
-				try {
-					await requestUtils.rest( {
-						method: 'GET',
-						path: 'wp/v2/plugins',
-					} );
-					return; // If we get here, plugin is ready
-				} catch ( verifyError ) {
-					// If verification fails, continue to retry
-					lastError = verifyError;
-				}
-			} catch ( error ) {
-				lastError = error;
-			}
-
-			retryCount++;
-			if ( retryCount < maxRetries ) {
-				// Exponential backoff for retries
-				await new Promise( ( resolve ) =>
-					setTimeout( resolve, Math.pow( 2, retryCount ) * 200 )
-				);
-			}
-		}
-
-		throw lastError;
+	// Enable the plugin which registers custom product collections.
+	test.beforeEach( async ( { context } ) => {
+		await enableTestPlugin( context, 'register-product-collection' );
 	} );

 	test( `Registered collections should be available in Collection chooser`, async ( {
@@ -359,35 +348,60 @@ test.describe( 'Product Collection: Register Product Collection', () => {
 		},
 	].forEach( ( collection ) => {
 		collection.previewLabelTemplate.forEach( ( template ) => {
-			test( `Collection "${ collection.name }" should show preview label in "${ template }"`, async ( {
-				admin,
-				pageObject,
-				editor,
-			} ) => {
-				if (
-					template === `${ BLOCK_THEME_SLUG }//taxonomy-product_cat`
-				) {
-					await admin.visitSiteEditor( {
-						postType: 'wp_template',
-					} );
-					await editor.createTemplate( {
-						templateName: 'Products by Category',
-					} );
-				} else {
-					await pageObject.goToEditorTemplate( template );
+			const isTaxonomyTemplate =
+				template === `${ BLOCK_THEME_SLUG }//taxonomy-product_cat`;
+
+			test(
+				`Collection "${ collection.name }" should show preview label in "${ template }"`,
+				{ lock: isTaxonomyTemplate ? locks.TAXONOMY_TEMPLATES : [] },
+				async ( {
+					admin,
+					pageObject,
+					editor,
+					requestUtils,
+					cleanup,
+				} ) => {
+					if ( isTaxonomyTemplate ) {
+						const deleteTemplate = () =>
+							requestUtils
+								.rest( {
+									method: 'DELETE',
+									path: `/wp/v2/templates/${ template }`,
+									params: { force: true },
+								} )
+								.catch( ( error ) => {
+									if (
+										error?.code !==
+										'rest_template_not_found'
+									) {
+										throw error;
+									}
+								} );
+						// A stopped run can leave the template, and then the Site Editor does not offer it.
+						await deleteTemplate();
+						cleanup( deleteTemplate );
+						await admin.visitSiteEditor( {
+							postType: 'wp_template',
+						} );
+						await editor.createTemplate( {
+							templateName: 'Products by Category',
+						} );
+					} else {
+						await pageObject.goToEditorTemplate( template );
+					}
+					await pageObject.insertProductCollection();
+					await pageObject.chooseCollectionInTemplate(
+						collection.id as Collections
+					);
+
+					// Check if the preview button is visible
+					const previewButtonLocator = editor.canvas.getByTestId(
+						SELECTORS.previewButtonTestID
+					);
+
+					await expect( previewButtonLocator ).toBeVisible();
 				}
-				await pageObject.insertProductCollection();
-				await pageObject.chooseCollectionInTemplate(
-					collection.id as Collections
-				);
-
-				// Check if the preview button is visible
-				const previewButtonLocator = editor.canvas.getByTestId(
-					SELECTORS.previewButtonTestID
-				);
-
-				await expect( previewButtonLocator ).toBeVisible();
-			} );
+			);
 		} );

 		test( `Collection "${ collection.name }" should not show preview label in a post`, async ( {
@@ -449,18 +463,37 @@ test.describe( 'Product Collection: Register Product Collection', () => {
 		editor,
 		requestUtils,
 		page,
+		cleanup,
 	} ) => {
-		// Add a new test product to the database
-		let testProductId: number | null = null;
-		const newProduct = await requestUtils.rest( {
+		// Other specs read the sample catalog. Hidden and dated in the past,
+		// this product stays out of the catalog and New Arrivals.
+		const { id: testProductId } = await requestUtils.rest< {
+			id: number;
+		} >( {
 			method: 'POST',
 			path: 'wc/v3/products',
 			data: {
 				name: 'A Test Product',
 				price: 10,
+				catalog_visibility: 'hidden',
+				date_created: '2020-01-01T00:00:00',
 			},
 		} );
-		testProductId = newProduct.id;
+		cleanup( () =>
+			requestUtils
+				.rest( {
+					method: 'DELETE',
+					path: `wc/v3/products/${ testProductId }`,
+					params: { force: true },
+				} )
+				.catch( ( error ) => {
+					if (
+						error?.code !== 'woocommerce_rest_product_invalid_id'
+					) {
+						throw error;
+					}
+				} )
+		);

 		await admin.createNewPost();
 		await pageObject.insertProductCollection();
diff --git a/plugins/woocommerce/tests/e2e/tests/checkout/checkout-shortcode-custom-place-order-button.spec.ts b/plugins/woocommerce/tests/e2e/tests/checkout/checkout-shortcode-custom-place-order-button.spec.ts
index e5bd04ae32e..85329d791ce 100644
--- a/plugins/woocommerce/tests/e2e/tests/checkout/checkout-shortcode-custom-place-order-button.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/checkout/checkout-shortcode-custom-place-order-button.spec.ts
@@ -17,6 +17,7 @@ import {
 } from '../../utils/pages';
 import { wpCLI } from '../../utils/cli';
 import { setGatewayEnabled } from '../../utils/payment-gateways';
+import { enableTestPlugin } from '../../utils/blocks/test-plugins';

 const test = baseTest.extend( {
 	page: async ( { page, restApi }, use ) => {
@@ -37,12 +38,13 @@ const test = baseTest.extend( {
 		const codWasEnabled = await setGatewayEnabled( restApi, 'cod', true );

 		await page.context().clearCookies();
+		await enableTestPlugin(
+			page.context(),
+			'custom-place-order-button-test'
+		);
 		await use( page );

-		// Cleanup: deactivate the test plugin so its custom gateway stops being
-		// registered on every checkout/order-pay page for the rest of the run.
-		// The gateway hardcodes `enabled = 'yes'` in its constructor, so deleting
-		// the option alone would NOT disable it — only deactivation does.
+		// Cleanup: undo the plugin activation and the option.
 		await wpCLI(
 			'wp plugin deactivate woocommerce-blocks-test-plugins/custom-place-order-button-test.php'
 		);
diff --git a/plugins/woocommerce/tests/e2e/utils/blocks/test-plugins.ts b/plugins/woocommerce/tests/e2e/utils/blocks/test-plugins.ts
index a2f10e3dd4b..3c0350fc9aa 100644
--- a/plugins/woocommerce/tests/e2e/utils/blocks/test-plugins.ts
+++ b/plugins/woocommerce/tests/e2e/utils/blocks/test-plugins.ts
@@ -15,9 +15,14 @@ import { BASE_URL } from './constants';
  */
 export const COOKIE_GATED_TEST_PLUGINS = [
 	'additional-checkout-fields',
+	'cart-extensions-test-helper',
+	'custom-add-to-cart-button-text',
+	'custom-place-order-button-test',
+	'extension-cart-update',
 	'item-data-display',
 	'locale-hide-country',
 	'product-collection-compatibility-layer',
+	'register-product-collection',
 	'single-product-template-compatibility-layer',
 	'update-price',
 ] as const;