Commit a6fdcc7b413 for woocommerce
commit a6fdcc7b4139752afae21f0f82dcf6dfa09b0997
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date: Thu Nov 26 19:50:30 2026 +0200
Run Product Collection errors and checkout order Blocks e2e tests in parallel (#71512)
diff --git a/plugins/woocommerce/changelog/testops-324-blocks-e2e-parallel-follow-ups b/plugins/woocommerce/changelog/testops-324-blocks-e2e-parallel-follow-ups
new file mode 100644
index 00000000000..c3ccddd5147
--- /dev/null
+++ b/plugins/woocommerce/changelog/testops-324-blocks-e2e-parallel-follow-ups
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Run two more Blocks e2e specs in the parallel project; no production change.
diff --git a/plugins/woocommerce/tests/e2e/fixtures/fixtures.ts b/plugins/woocommerce/tests/e2e/fixtures/fixtures.ts
index d2ede6b693f..06f58d1d8ac 100644
--- a/plugins/woocommerce/tests/e2e/fixtures/fixtures.ts
+++ b/plugins/woocommerce/tests/e2e/fixtures/fixtures.ts
@@ -119,6 +119,10 @@ export const locks = {
// sent emails or the Email settings page also take it, since the flags
// change both.
EMAIL_FEATURE_FLAGS: 'email-feature-flags',
+ // The visible product that sorts last by title. A test that creates a
+ // visible product named to sort last shares it with tests that list
+ // products by title in descending order.
+ LAST_PRODUCT_BY_TITLE: 'last-product-by-title',
// `woocommerce_pickup_location_settings` and `pickup_location_pickup_locations`.
LOCAL_PICKUP: 'local-pickup',
// The Back in Stock feature flag and `woocommerce_customer_stock_notifications_*`.
diff --git a/plugins/woocommerce/tests/e2e/playwright.config.ts b/plugins/woocommerce/tests/e2e/playwright.config.ts
index 78a30c88c8a..ae717f9dcbc 100644
--- a/plugins/woocommerce/tests/e2e/playwright.config.ts
+++ b/plugins/woocommerce/tests/e2e/playwright.config.ts
@@ -304,12 +304,6 @@ const blocksSerialSpecs = [
// Changes the shop page slug, so the `shop/` URL that other specs visit
// stops working.
'**/tests/blocks/templates/shop-page.block_theme.spec.ts',
-
- // Creates a visible $10 product with limited stock, which the Product
- // Collection block needs to show it. While it exists, it changes product
- // counts that catalog specs check, such as the single product under $10 in
- // `inspector-controls`.
- '**/tests/blocks/product-collection/product-collection-errors.block_theme.spec.ts',
];
export default defineConfig< { resetDatabaseAfterEachTest: boolean } >( {
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block-place-order.shopper.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block-place-order.shopper.block_theme.spec.ts
new file mode 100644
index 00000000000..2295a0b7174
--- /dev/null
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block-place-order.shopper.block_theme.spec.ts
@@ -0,0 +1,159 @@
+/**
+ * External dependencies
+ */
+import { randomUUID } from 'crypto';
+import { expect, test as base, guestFile } from '@woocommerce/e2e-utils';
+
+/**
+ * Internal dependencies
+ */
+import {
+ FREE_SHIPPING_NAME,
+ FREE_SHIPPING_PRICE,
+ FLAT_RATE_SHIPPING_NAME,
+ FLAT_RATE_SHIPPING_PRICE,
+} from './constants';
+import { CheckoutPage } from './checkout.page';
+
+const test = base.extend< { checkoutPageObject: CheckoutPage } >( {
+ checkoutPageObject: async ( { page, requestUtils }, use ) => {
+ const pageObject = new CheckoutPage( {
+ page,
+ requestUtils,
+ } );
+ await use( pageObject );
+ },
+} );
+
+test.describe( 'Shopper → Shipping (customer user)', () => {
+ test.use( { storageState: guestFile } );
+
+ // Logs in as a new customer. All workers share the cart of the seeded
+ // customer, because `blocks-parallel` does not reset the database.
+ test.beforeEach( async ( { page, requestUtils, cleanup } ) => {
+ const username = `place-order-${ randomUUID().slice( 0, 8 ) }`;
+ const password = 'password';
+ const { id } = await requestUtils.rest< { id: number } >( {
+ method: 'POST',
+ path: 'wc/v3/customers',
+ data: {
+ username,
+ password,
+ email: `${ username }@example.com`,
+ },
+ } );
+ cleanup( () =>
+ requestUtils.rest( {
+ method: 'DELETE',
+ path: `wc/v3/customers/${ id }`,
+ params: { force: true },
+ } )
+ );
+
+ const login = await page.request.post( 'wp-login.php', {
+ form: { log: username, pwd: password },
+ } );
+ // A failed login shows the form again instead of redirecting.
+ expect( login.url() ).not.toContain( 'wp-login.php' );
+ } );
+
+ test( 'Shopper can choose free shipping, flat rate shipping, and can have different billing and shipping addresses', async ( {
+ checkoutPageObject,
+ frontendUtils,
+ page,
+ createHiddenProduct,
+ } ) => {
+ const { id: productId } = await createHiddenProduct( {
+ name: 'Place order product',
+ regular_price: '20',
+ } );
+ await page.goto( `/?add-to-cart=${ productId }` );
+ await frontendUtils.goToCheckout();
+ expect(
+ await checkoutPageObject.selectAndVerifyShippingOption(
+ FREE_SHIPPING_NAME,
+ FREE_SHIPPING_PRICE
+ )
+ ).toBe( true );
+ await checkoutPageObject.fillInCheckoutWithTestData();
+ await checkoutPageObject.placeOrder();
+ await checkoutPageObject.verifyAddressDetails( 'billing' );
+ await checkoutPageObject.verifyAddressDetails( 'shipping' );
+ await expect( page.getByText( FREE_SHIPPING_NAME ) ).toBeVisible();
+
+ await page.goto( `/?add-to-cart=${ productId }` );
+ await frontendUtils.goToCheckout();
+ expect(
+ await checkoutPageObject.selectAndVerifyShippingOption(
+ FLAT_RATE_SHIPPING_NAME,
+ FLAT_RATE_SHIPPING_PRICE
+ )
+ ).toBe( true );
+
+ await checkoutPageObject.syncBillingWithShipping();
+ await checkoutPageObject.fillInCheckoutWithTestData( {
+ phone: '0987654322',
+ } );
+ await checkoutPageObject.unsyncBillingWithShipping();
+ const shippingForm = page.getByRole( 'group', {
+ name: 'Shipping address',
+ } );
+ const billingForm = page.getByRole( 'group', {
+ name: 'Billing address',
+ } );
+
+ await expect( billingForm.getByLabel( 'Phone' ) ).toHaveValue(
+ await shippingForm.getByLabel( 'Phone' ).inputValue()
+ );
+
+ await checkoutPageObject.fillInCheckoutWithTestData();
+ const overrideBillingDetails = {
+ firstname: 'Juan',
+ lastname: 'Perez',
+ addressfirstline: '123 Test Street',
+ addresssecondline: 'Apartment 6',
+ countryKey: 'ES',
+ city: 'Madrid',
+ postcode: '08830',
+ state: 'M',
+ phone: '0987654321',
+ email: 'juan.perez@test.com',
+ };
+ await checkoutPageObject.fillBillingDetails( overrideBillingDetails );
+ await checkoutPageObject.placeOrder();
+ await checkoutPageObject.verifyAddressDetails(
+ 'billing',
+ overrideBillingDetails
+ );
+ await checkoutPageObject.verifyAddressDetails( 'shipping' );
+ } );
+} );
+
+test.describe( 'Shopper → Place Guest Order', () => {
+ test.use( { storageState: guestFile } );
+
+ test( 'Guest user can place order', async ( {
+ checkoutPageObject,
+ frontendUtils,
+ page,
+ createHiddenProduct,
+ } ) => {
+ const { id: productId } = await createHiddenProduct( {
+ name: 'Place order product',
+ regular_price: '20',
+ } );
+ await page.goto( `/?add-to-cart=${ productId }` );
+ await frontendUtils.goToCheckout();
+ expect(
+ await checkoutPageObject.selectAndVerifyShippingOption(
+ FREE_SHIPPING_NAME,
+ FREE_SHIPPING_PRICE
+ )
+ ).toBe( true );
+ await checkoutPageObject.fillInCheckoutWithTestData();
+ await checkoutPageObject.placeOrder();
+ await expect(
+ page.getByText( 'Your order has been received.' )
+ ).toBeVisible();
+ } );
+} );
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block.shopper.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block.shopper.block_theme.spec.ts
index b980cdba333..a32c4f5294e 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block.shopper.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/checkout/checkout-block.shopper.block_theme.spec.ts
@@ -4,7 +4,6 @@
import {
expect,
test as base,
- customerFile,
guestFile,
BlockData,
BLOCK_THEME_SLUG,
@@ -16,10 +15,6 @@ import {
import {
REGULAR_PRICED_PRODUCT_NAME,
SIMPLE_PHYSICAL_PRODUCT_NAME,
- FREE_SHIPPING_NAME,
- FREE_SHIPPING_PRICE,
- FLAT_RATE_SHIPPING_NAME,
- FLAT_RATE_SHIPPING_PRICE,
SIMPLE_VIRTUAL_PRODUCT_NAME,
} from './constants';
import { CheckoutPage } from './checkout.page';
@@ -369,103 +364,6 @@ test.describe( 'Shopper → Shipping and Billing Addresses', () => {
} );
} );
-test.describe( 'Shopper → Shipping (customer user)', () => {
- test.use( { storageState: customerFile } );
-
- test( 'Shopper can choose free shipping, flat rate shipping, and can have different billing and shipping addresses', async ( {
- checkoutPageObject,
- frontendUtils,
- page,
- } ) => {
- await frontendUtils.goToShop();
- await frontendUtils.addToCart( 'Beanie' );
- await frontendUtils.goToCheckout();
- expect(
- await checkoutPageObject.selectAndVerifyShippingOption(
- FREE_SHIPPING_NAME,
- FREE_SHIPPING_PRICE
- )
- ).toBe( true );
- await checkoutPageObject.fillInCheckoutWithTestData();
- await checkoutPageObject.placeOrder();
- await checkoutPageObject.verifyAddressDetails( 'billing' );
- await checkoutPageObject.verifyAddressDetails( 'shipping' );
- await expect( page.getByText( FREE_SHIPPING_NAME ) ).toBeVisible();
-
- await frontendUtils.goToShop();
- await frontendUtils.addToCart( 'Beanie' );
- await frontendUtils.goToCheckout();
- expect(
- await checkoutPageObject.selectAndVerifyShippingOption(
- FLAT_RATE_SHIPPING_NAME,
- FLAT_RATE_SHIPPING_PRICE
- )
- ).toBe( true );
-
- await checkoutPageObject.syncBillingWithShipping();
- await checkoutPageObject.fillInCheckoutWithTestData( {
- phone: '0987654322',
- } );
- await checkoutPageObject.unsyncBillingWithShipping();
- const shippingForm = page.getByRole( 'group', {
- name: 'Shipping address',
- } );
- const billingForm = page.getByRole( 'group', {
- name: 'Billing address',
- } );
-
- expect( shippingForm.getByLabel( 'Phone' ).inputValue ).toEqual(
- billingForm.getByLabel( 'Phone' ).inputValue
- );
-
- await checkoutPageObject.fillInCheckoutWithTestData();
- const overrideBillingDetails = {
- firstname: 'Juan',
- lastname: 'Perez',
- addressfirstline: '123 Test Street',
- addresssecondline: 'Apartment 6',
- countryKey: 'ES',
- city: 'Madrid',
- postcode: '08830',
- state: 'M',
- phone: '0987654321',
- email: 'juan.perez@test.com',
- };
- await checkoutPageObject.fillBillingDetails( overrideBillingDetails );
- await checkoutPageObject.placeOrder();
- await checkoutPageObject.verifyAddressDetails(
- 'billing',
- overrideBillingDetails
- );
- await checkoutPageObject.verifyAddressDetails( 'shipping' );
- } );
-} );
-
-test.describe( 'Shopper → Place Guest Order', () => {
- test.use( { storageState: guestFile } );
-
- test( 'Guest user can place order', async ( {
- checkoutPageObject,
- frontendUtils,
- page,
- } ) => {
- await frontendUtils.goToShop();
- await frontendUtils.addToCart( SIMPLE_PHYSICAL_PRODUCT_NAME );
- await frontendUtils.goToCheckout();
- expect(
- await checkoutPageObject.selectAndVerifyShippingOption(
- FREE_SHIPPING_NAME,
- FREE_SHIPPING_PRICE
- )
- ).toBe( true );
- await checkoutPageObject.fillInCheckoutWithTestData();
- await checkoutPageObject.placeOrder();
- await expect(
- page.getByText( 'Your order has been received.' )
- ).toBeVisible();
- } );
-} );
-
test.describe( 'Shopper → Place Virtual Order', () => {
test.beforeEach( async ( { requestUtils } ) => {
await requestUtils.rest( {
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/inspector-controls.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/inspector-controls.block_theme.spec.ts
index 78d6dc94da9..67608b3f6f5 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/inspector-controls.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/inspector-controls.block_theme.spec.ts
@@ -83,29 +83,32 @@ test.describe( 'Product Collection: Inspector Controls', () => {
await expect( pageObject.productTemplate ).toHaveClass( /columns-4/ );
} );
- test( 'Order By - sort products by title in descending order correctly', async ( {
- pageObject,
- } ) => {
- await pageObject.createNewPostAndInsertBlock();
-
- const sortedTitles = [
- 'WordPress Pennant',
- 'V-Neck T-Shirt',
- 'T-Shirt with Logo',
- 'T-Shirt',
- /Sunglasses/, // In the frontend it's "Protected: Sunglasses"
- 'Single',
- 'Polo',
- 'Long Sleeve Tee',
- 'Logo Collection',
- ];
-
- await pageObject.setOrderBy( 'title/desc' );
- await expect( pageObject.productTitles ).toHaveText( sortedTitles );
+ // A visible product that sorts last by title would show first here.
+ test(
+ 'Order By - sort products by title in descending order correctly',
+ { lock: locks.LAST_PRODUCT_BY_TITLE },
+ async ( { pageObject } ) => {
+ await pageObject.createNewPostAndInsertBlock();
- await pageObject.publishAndGoToFrontend();
- await expect( pageObject.productTitles ).toHaveText( sortedTitles );
- } );
+ const sortedTitles = [
+ 'WordPress Pennant',
+ 'V-Neck T-Shirt',
+ 'T-Shirt with Logo',
+ 'T-Shirt',
+ /Sunglasses/, // In the frontend it's "Protected: Sunglasses"
+ 'Single',
+ 'Polo',
+ 'Long Sleeve Tee',
+ 'Logo Collection',
+ ];
+
+ await pageObject.setOrderBy( 'title/desc' );
+ await expect( pageObject.productTitles ).toHaveText( sortedTitles );
+
+ await pageObject.publishAndGoToFrontend();
+ await expect( pageObject.productTitles ).toHaveText( sortedTitles );
+ }
+ );
test( 'Products can be filtered based on "on sale" status', async ( {
pageObject,
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/product-collection-errors.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/product-collection-errors.block_theme.spec.ts
index 6c2acf0b690..67771db8414 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/product-collection-errors.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/product-collection/product-collection-errors.block_theme.spec.ts
@@ -1,56 +1,96 @@
/**
* External dependencies
*/
-import { test as base, expect, wpCLI } from '@woocommerce/e2e-utils';
+import { test, expect, guestFile } from '@woocommerce/e2e-utils';
/**
* Internal dependencies
*/
-import ProductCollectionPage from './product-collection.page';
+import { locks } from '../../../fixtures/fixtures';
-const test = base.extend< { pageObject: ProductCollectionPage } >( {
- pageObject: async ( { page, admin, editor }, use ) => {
- const pageObject = new ProductCollectionPage( {
+// All workers share the admin cart, so a guest adds to the cart.
+test.use( { storageState: guestFile } );
+
+test.describe(
+ 'Product Page: error notices',
+ { lock: locks.LAST_PRODUCT_BY_TITLE },
+ () => {
+ test( 'displays error notice when attempting to add product beyond stock limit', async ( {
page,
- admin,
- editor,
- } );
- await use( pageObject );
- },
-} );
-
-test.describe( 'Product Page: error notices', () => {
- test( 'displays error notice when attempting to add product beyond stock limit', async ( {
- page,
- pageObject,
- } ) => {
- const productName = 'A Managed Stock';
-
- await wpCLI(
- `wc product create --name="${ productName }" --regular_price=10 --manage_stock=true --stock_quantity=1 --user=admin`
- );
- await pageObject.createNewPostAndInsertBlock();
- await pageObject.publishAndGoToFrontend();
-
- const productBlock = page
- .locator( '.wc-block-product' )
- .filter( { hasText: productName } );
-
- await expect( productBlock ).toBeVisible();
-
- const addButton = productBlock.getByRole( 'button', {
- name: 'Add to cart',
+ requestUtils,
+ cleanup,
+ } ) => {
+ const productName = 'Z Limited Stock';
+
+ // Only visible products show in the block, so catalog specs see
+ // this one too. The price and date keep it out of price filters
+ // and New Arrivals, and last when sorted newest first. The lock
+ // covers the title order.
+ const product = await requestUtils.rest< { id: number } >( {
+ method: 'POST',
+ path: 'wc/v3/products',
+ data: {
+ name: productName,
+ regular_price: '20',
+ manage_stock: true,
+ stock_quantity: 1,
+ date_created: '2018-01-01T00:00:00',
+ },
+ } );
+ cleanup( () =>
+ requestUtils.rest( {
+ method: 'DELETE',
+ path: `wc/v3/products/${ product.id }`,
+ params: { force: true },
+ } )
+ );
+
+ const post = await requestUtils.rest< { id: number } >( {
+ method: 'POST',
+ path: '/wp/v2/posts',
+ data: {
+ status: 'publish',
+ title: 'Product Collection errors',
+ content: `<!-- wp:woocommerce/product-collection {"query":{"perPage":9,"pages":0,"offset":0,"postType":"product","order":"asc","orderBy":"title","search":"","exclude":[],"inherit":false,"taxQuery":[],"isProductCollectionBlock":true,"featured":false,"woocommerceOnSale":false,"woocommerceStockStatus":["instock","outofstock","onbackorder"],"woocommerceAttributes":[],"woocommerceHandPickedProducts":["${ product.id }"]},"tagName":"div","displayLayout":{"type":"flex","columns":3,"shrinkColumns":true},"queryContextIncludes":["collection"]} -->
+<div class="wp-block-woocommerce-product-collection">
+<!-- wp:woocommerce/product-template -->
+<!-- wp:post-title {"isLink":true,"__woocommerceNamespace":"woocommerce/product-collection/product-title"} /-->
+<!-- wp:woocommerce/product-button /-->
+<!-- /wp:woocommerce/product-template -->
+</div>
+<!-- /wp:woocommerce/product-collection -->`,
+ },
+ } );
+ cleanup( () =>
+ requestUtils.rest( {
+ method: 'DELETE',
+ path: `/wp/v2/posts/${ post.id }`,
+ params: { force: true },
+ } )
+ );
+
+ await page.goto( `/?p=${ post.id }` );
+
+ const productBlock = page
+ .locator( '.wc-block-product' )
+ .filter( { hasText: productName } );
+
+ await expect( productBlock ).toBeVisible();
+
+ const addButton = productBlock.getByRole( 'button', {
+ name: 'Add to cart',
+ } );
+ await addButton.click();
+ await expect( addButton ).toHaveText( /1 in cart/i ); // Wait until the button reflects the cart state.
+
+ // Add to cart again — triggers out-of-stock error.
+ await addButton.click();
+
+ // Verify error notice is displayed.
+ await expect( page.getByRole( 'alert' ) ).toBeVisible();
+ await expect( page.getByRole( 'alert' ) ).toHaveText(
+ /maximum quantity|You cannot add that amount/i
+ );
} );
- await addButton.click();
- await expect( addButton ).toHaveText( /1 in cart/i ); // Wait until the button reflects the cart state.
-
- // Add to cart again — triggers out-of-stock error.
- await addButton.click();
-
- // Verify error notice is displayed.
- await expect( page.getByRole( 'alert' ) ).toBeVisible();
- await expect( page.getByRole( 'alert' ) ).toHaveText(
- /maximum quantity|You cannot add that amount/i
- );
- } );
-} );
+ }
+);