Commit f2850fe7aff for woocommerce
commit f2850fe7affcaf75fa3025067f1f80b076f1d3d2
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date: Mon Nov 23 19:28:07 2026 +0200
Run 2 Blocks e2e notice tests in parallel and document the theme-switching specs (#71320)
Split the block theme notices spec: the 2 tests that do not switch the
theme run in blocks-parallel, logged out and without the site-wide cart
page option. The 3 tests that activate child themes move to a new file
in blocksSerialSpecs.
Add the reason each theme-switching spec stays serial next to its entry
in blocksSerialSpecs.
diff --git a/plugins/woocommerce/changelog/dev-testops-324-blocks-e2e-theme-switching-specs b/plugins/woocommerce/changelog/dev-testops-324-blocks-e2e-theme-switching-specs
new file mode 100644
index 00000000000..617859f4dea
--- /dev/null
+++ b/plugins/woocommerce/changelog/dev-testops-324-blocks-e2e-theme-switching-specs
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Run 2 Blocks e2e notice tests in the parallel project; no production change.
diff --git a/plugins/woocommerce/tests/e2e/playwright.config.ts b/plugins/woocommerce/tests/e2e/playwright.config.ts
index 8ab9277010b..2ff3ec41672 100644
--- a/plugins/woocommerce/tests/e2e/playwright.config.ts
+++ b/plugins/woocommerce/tests/e2e/playwright.config.ts
@@ -179,19 +179,46 @@ const nonCoreSpecs = [
* serial resets wipe the data of the parallel workers.
*/
const blocksSerialSpecs = [
- // Switch the active theme, which every other spec renders with.
+ // Switch the active theme. It is a site-wide setting, and every spec
+ // renders with the active theme, so a test lock cannot isolate the switch.
+
+ // Activates `theme-with-woo-templates` and saves its Single Product
+ // template and Add to Cart + Options template part.
'**/tests/blocks/add-to-cart-with-options/add-to-cart-with-options.block_theme_with_templates.spec.ts',
- '**/tests/blocks/cart/cart-checkout-block-notices.shopper.block_theme.spec.ts',
+ // Activates three child themes of the block theme to check their notices,
+ // and makes the Cart Shortcode page the cart page.
+ '**/tests/blocks/cart/cart-checkout-block-notices-child-themes.shopper.block_theme.spec.ts',
+ // Activates Storefront and three of its child themes to check notices in a
+ // classic theme, and makes the Cart Shortcode page the cart page.
'**/tests/blocks/cart/cart-checkout-block-notices.shopper.classic_theme.spec.ts',
+ // Activates Storefront to check the Mini-Cart drawer with the classic AJAX
+ // add-to-cart button.
'**/tests/blocks/mini-cart/mini-cart.classic_theme.spec.ts',
+ // Activates Storefront to check the Product Button block in a classic
+ // theme.
'**/tests/blocks/product-button/product-button.classic_theme.spec.ts',
+ // Activates Storefront to check which block styles a classic theme loads.
'**/tests/blocks/style.classic_theme.spec.ts',
+ // Activates `theme-with-woo-templates` and saves its template for one
+ // product.
'**/tests/blocks/templates/single-product-template.block_theme_with_templates.spec.ts',
+ // Saves each site-wide WooCommerce template and template part. The
+ // template part priority tests also activate `theme-with-woo-templates`.
'**/tests/blocks/templates/template-customization.block_theme.spec.ts',
+ // Activates `theme-with-woo-templates` and saves each of its WooCommerce
+ // templates.
'**/tests/blocks/templates/template-customization.block_theme_with_templates.spec.ts',
+ // Activates a Storefront child theme that has block template parts, and
+ // saves its Mini-Cart template part.
'**/tests/blocks/templates/template-part-customization.classic_theme_with_template_parts.spec.ts',
+ // Activates two Storefront child themes with block template part support,
+ // and saves the Mini-Cart template part.
'**/tests/blocks/templates/template-part-customization.classic_theme_with_template_parts_support.spec.ts',
+ // Activates `theme-with-woo-templates`, and saves the site-wide Single
+ // Product, Product Catalog and Products by Category templates.
'**/tests/blocks/templates/template-priority.block_theme.spec.ts',
+ // Activates Storefront, because only a classic theme has the widget
+ // editor.
'**/tests/blocks/widget-area/widget-area.classic_theme.spec.ts',
// Save site-wide templates, template parts or pages (single product, product
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/cart/cart-checkout-block-notices-child-themes.shopper.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/cart/cart-checkout-block-notices-child-themes.shopper.block_theme.spec.ts
new file mode 100644
index 00000000000..87a2a77d4e2
--- /dev/null
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/cart/cart-checkout-block-notices-child-themes.shopper.block_theme.spec.ts
@@ -0,0 +1,206 @@
+/**
+ * External dependencies
+ */
+import {
+ expect,
+ test as base,
+ wpCLI,
+ BLOCK_THEME_SLUG,
+ BLOCK_CHILD_THEME_WITH_BLOCK_NOTICES_FILTER_SLUG,
+ BLOCK_CHILD_THEME_WITH_BLOCK_NOTICES_TEMPLATE_SLUG,
+ BLOCK_CHILD_THEME_WITH_CLASSIC_NOTICES_TEMPLATE_SLUG,
+} from '@woocommerce/e2e-utils';
+
+/**
+ * Internal dependencies
+ */
+import { CheckoutPage } from '../checkout/checkout.page';
+import { REGULAR_PRICED_PRODUCT_NAME } from '../checkout/constants';
+
+const test = base.extend< { checkoutPageObject: CheckoutPage } >( {
+ checkoutPageObject: async ( { page }, use ) => {
+ const pageObject = new CheckoutPage( {
+ page,
+ } );
+ await use( pageObject );
+ },
+} );
+
+test.describe( 'Shopper → Notice Templates', () => {
+ test.beforeEach( async ( { frontendUtils } ) => {
+ const cliOutput = await wpCLI(
+ 'post list --title="Cart Shortcode" --post_type=page --field=ID'
+ );
+ const cartShortcodeID = cliOutput.stdout.match( /\d+/g )?.pop();
+
+ await wpCLI(
+ `option update woocommerce_cart_page_id ${ cartShortcodeID }`
+ );
+
+ await frontendUtils.goToShop();
+ await frontendUtils.addToCart( REGULAR_PRICED_PRODUCT_NAME );
+ } );
+
+ test( 'custom block notice templates, except for coupon errors, are visible by template overwrite', async ( {
+ requestUtils,
+ frontendUtils,
+ page,
+ } ) => {
+ await requestUtils.activateTheme(
+ BLOCK_CHILD_THEME_WITH_BLOCK_NOTICES_TEMPLATE_SLUG
+ );
+
+ await frontendUtils.goToCartShortcode();
+ await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
+ await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
+
+ await expect(
+ page.getByText(
+ 'BLOCK SUCCESS NOTICE: Coupon code applied successfully.'
+ )
+ ).toBeVisible();
+
+ // We're explicitly checking the CSS classes of the block notices, and that the SVG is visible.
+ await expect(
+ page.locator( '.wc-block-components-notice-banner.is-success svg' )
+ ).toBeVisible();
+
+ await page.reload();
+ await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
+ await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
+
+ await expect(
+ page.getByText(
+ 'BLOCK ERROR NOTICE: Coupon code "testcoupon" already applied!'
+ )
+ ).toBeVisible();
+
+ // We're explicitly checking the CSS classes of the block notices, and that the SVG is hidden.
+ await expect(
+ page.locator( '.wc-block-components-notice-banner.is-error svg' )
+ ).toBeHidden();
+
+ await page.getByLabel( 'Remove Polo from cart' ).click();
+
+ await expect(
+ page.getByText( 'BLOCK INFO NOTICE: Your cart is currently empty.' )
+ ).toBeVisible();
+
+ // We're explicitly checking the CSS classes of the block notices, and that the SVG is visible.
+ await expect(
+ page.locator( '.wc-block-components-notice-banner.is-success svg' )
+ ).toBeVisible();
+
+ await requestUtils.activateTheme( BLOCK_THEME_SLUG );
+ } );
+
+ test( 'classic notice templates, except for coupon errors, are visible by template overwrite', async ( {
+ requestUtils,
+ frontendUtils,
+ page,
+ } ) => {
+ await requestUtils.activateTheme(
+ BLOCK_CHILD_THEME_WITH_CLASSIC_NOTICES_TEMPLATE_SLUG
+ );
+
+ await frontendUtils.goToCartShortcode();
+ await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
+ await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
+
+ await expect(
+ page.getByText(
+ 'CLASSIC SUCCESS NOTICE: Coupon code applied successfully.'
+ )
+ ).toBeVisible();
+
+ // We're explicitly checking the CSS classes of the classic notices.
+ await expect(
+ page.locator( '.woocommerce-notices-wrapper .woocommerce-message' )
+ ).toBeVisible();
+
+ await page.reload();
+ await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
+ await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
+
+ await expect(
+ page.getByText(
+ 'CLASSIC ERROR NOTICE: Coupon code "testcoupon" already applied!'
+ )
+ ).toBeVisible();
+
+ // We're explicitly checking the CSS classes of the classic notices.
+ await expect(
+ page.locator( '.woocommerce-notices-wrapper .woocommerce-error' )
+ ).toBeHidden();
+
+ await page.getByLabel( 'Remove Polo from cart' ).click();
+
+ await expect(
+ page.getByText(
+ 'CLASSIC INFO NOTICE: Your cart is currently empty.'
+ )
+ ).toBeVisible();
+
+ // We're explicitly checking the CSS classes of the classic notices.
+ await expect(
+ page.locator( '.woocommerce-notices-wrapper .woocommerce-info' )
+ ).toBeVisible();
+
+ await requestUtils.activateTheme( BLOCK_THEME_SLUG );
+ } );
+
+ test( 'default classic notice templates cannot be triggered by filter', async ( {
+ requestUtils,
+ frontendUtils,
+ page,
+ } ) => {
+ await requestUtils.activateTheme(
+ BLOCK_CHILD_THEME_WITH_BLOCK_NOTICES_FILTER_SLUG
+ );
+
+ await frontendUtils.goToCartShortcode();
+ await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
+ await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
+
+ await expect(
+ page.getByText( 'Coupon code applied successfully.', {
+ exact: true,
+ } )
+ ).toBeVisible();
+
+ // We're explicitly checking the CSS classes and that the SVG is visible.
+ await expect(
+ page.locator( '.wc-block-components-notice-banner.is-success svg' )
+ ).toBeVisible();
+
+ await page.reload();
+ await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
+ await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
+
+ await expect(
+ page.getByText( 'Coupon code "testcoupon" already applied!', {
+ exact: true,
+ } )
+ ).toBeVisible();
+
+ // We're explicitly checking the CSS classes and that the SVG is hidden.
+ await expect(
+ page.locator( '.wc-block-components-notice-banner.is-error svg' )
+ ).toBeHidden();
+
+ await page.getByLabel( 'Remove Polo from cart' ).click();
+
+ await expect(
+ page.getByText( 'Your cart is currently empty.', {
+ exact: true,
+ } )
+ ).toBeVisible();
+
+ // We're explicitly checking the CSS classes and that the SVG is visible.
+ await expect(
+ page.locator( '.wc-block-components-notice-banner.is-success svg' )
+ ).toBeVisible();
+
+ await requestUtils.activateTheme( BLOCK_THEME_SLUG );
+ } );
+} );
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/cart/cart-checkout-block-notices.shopper.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/cart/cart-checkout-block-notices.shopper.block_theme.spec.ts
index 08e43e64a71..e9cc4ac8aa2 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/cart/cart-checkout-block-notices.shopper.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/cart/cart-checkout-block-notices.shopper.block_theme.spec.ts
@@ -1,45 +1,21 @@
/**
* External dependencies
*/
-import {
- expect,
- test as base,
- wpCLI,
- BLOCK_THEME_SLUG,
- BLOCK_CHILD_THEME_WITH_BLOCK_NOTICES_FILTER_SLUG,
- BLOCK_CHILD_THEME_WITH_BLOCK_NOTICES_TEMPLATE_SLUG,
- BLOCK_CHILD_THEME_WITH_CLASSIC_NOTICES_TEMPLATE_SLUG,
-} from '@woocommerce/e2e-utils';
+import { expect, test, guestFile } from '@woocommerce/e2e-utils';
/**
* Internal dependencies
*/
-import { CheckoutPage } from '../checkout/checkout.page';
import {
REGULAR_PRICED_PRODUCT_NAME,
INVALID_COUPON,
} from '../checkout/constants';
-const test = base.extend< { checkoutPageObject: CheckoutPage } >( {
- checkoutPageObject: async ( { page }, use ) => {
- const pageObject = new CheckoutPage( {
- page,
- } );
- await use( pageObject );
- },
-} );
-
test.describe( 'Shopper → Notice Templates', () => {
- test.beforeEach( async ( { frontendUtils } ) => {
- const cliOutput = await wpCLI(
- 'post list --title="Cart Shortcode" --post_type=page --field=ID'
- );
- const cartShortcodeID = cliOutput.stdout.match( /\d+/g )?.pop();
-
- await wpCLI(
- `option update woocommerce_cart_page_id ${ cartShortcodeID }`
- );
+ // A guest cart, because all workers share the admin cart.
+ test.use( { storageState: guestFile } );
+ test.beforeEach( async ( { frontendUtils } ) => {
await frontendUtils.goToShop();
await frontendUtils.addToCart( REGULAR_PRICED_PRODUCT_NAME );
} );
@@ -92,169 +68,6 @@ test.describe( 'Shopper → Notice Templates', () => {
).toBeVisible();
} );
- test( 'custom block notice templates, except for coupon errors, are visible by template overwrite', async ( {
- requestUtils,
- frontendUtils,
- page,
- } ) => {
- await requestUtils.activateTheme(
- BLOCK_CHILD_THEME_WITH_BLOCK_NOTICES_TEMPLATE_SLUG
- );
-
- await frontendUtils.goToCartShortcode();
- await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
- await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
-
- await expect(
- page.getByText(
- 'BLOCK SUCCESS NOTICE: Coupon code applied successfully.'
- )
- ).toBeVisible();
-
- // We're explicitly checking the CSS classes of the block notices, and that the SVG is visible.
- await expect(
- page.locator( '.wc-block-components-notice-banner.is-success svg' )
- ).toBeVisible();
-
- await page.reload();
- await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
- await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
-
- await expect(
- page.getByText(
- 'BLOCK ERROR NOTICE: Coupon code "testcoupon" already applied!'
- )
- ).toBeVisible();
-
- // We're explicitly checking the CSS classes of the block notices, and that the SVG is hidden.
- await expect(
- page.locator( '.wc-block-components-notice-banner.is-error svg' )
- ).toBeHidden();
-
- await page.getByLabel( 'Remove Polo from cart' ).click();
-
- await expect(
- page.getByText( 'BLOCK INFO NOTICE: Your cart is currently empty.' )
- ).toBeVisible();
-
- // We're explicitly checking the CSS classes of the block notices, and that the SVG is visible.
- await expect(
- page.locator( '.wc-block-components-notice-banner.is-success svg' )
- ).toBeVisible();
-
- await requestUtils.activateTheme( BLOCK_THEME_SLUG );
- } );
-
- test( 'classic notice templates, except for coupon errors, are visible by template overwrite', async ( {
- requestUtils,
- frontendUtils,
- page,
- } ) => {
- await requestUtils.activateTheme(
- BLOCK_CHILD_THEME_WITH_CLASSIC_NOTICES_TEMPLATE_SLUG
- );
-
- await frontendUtils.goToCartShortcode();
- await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
- await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
-
- await expect(
- page.getByText(
- 'CLASSIC SUCCESS NOTICE: Coupon code applied successfully.'
- )
- ).toBeVisible();
-
- // We're explicitly checking the CSS classes of the classic notices.
- await expect(
- page.locator( '.woocommerce-notices-wrapper .woocommerce-message' )
- ).toBeVisible();
-
- await page.reload();
- await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
- await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
-
- await expect(
- page.getByText(
- 'CLASSIC ERROR NOTICE: Coupon code "testcoupon" already applied!'
- )
- ).toBeVisible();
-
- // We're explicitly checking the CSS classes of the classic notices.
- await expect(
- page.locator( '.woocommerce-notices-wrapper .woocommerce-error' )
- ).toBeHidden();
-
- await page.getByLabel( 'Remove Polo from cart' ).click();
-
- await expect(
- page.getByText(
- 'CLASSIC INFO NOTICE: Your cart is currently empty.'
- )
- ).toBeVisible();
-
- // We're explicitly checking the CSS classes of the classic notices.
- await expect(
- page.locator( '.woocommerce-notices-wrapper .woocommerce-info' )
- ).toBeVisible();
-
- await requestUtils.activateTheme( BLOCK_THEME_SLUG );
- } );
-
- test( 'default classic notice templates cannot be triggered by filter', async ( {
- requestUtils,
- frontendUtils,
- page,
- } ) => {
- await requestUtils.activateTheme(
- BLOCK_CHILD_THEME_WITH_BLOCK_NOTICES_FILTER_SLUG
- );
-
- await frontendUtils.goToCartShortcode();
- await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
- await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
-
- await expect(
- page.getByText( 'Coupon code applied successfully.', {
- exact: true,
- } )
- ).toBeVisible();
-
- // We're explicitly checking the CSS classes and that the SVG is visible.
- await expect(
- page.locator( '.wc-block-components-notice-banner.is-success svg' )
- ).toBeVisible();
-
- await page.reload();
- await page.getByPlaceholder( 'Coupon code' ).fill( 'testcoupon' );
- await page.getByRole( 'button', { name: 'Apply coupon' } ).click();
-
- await expect(
- page.getByText( 'Coupon code "testcoupon" already applied!', {
- exact: true,
- } )
- ).toBeVisible();
-
- // We're explicitly checking the CSS classes and that the SVG is hidden.
- await expect(
- page.locator( '.wc-block-components-notice-banner.is-error svg' )
- ).toBeHidden();
-
- await page.getByLabel( 'Remove Polo from cart' ).click();
-
- await expect(
- page.getByText( 'Your cart is currently empty.', {
- exact: true,
- } )
- ).toBeVisible();
-
- // We're explicitly checking the CSS classes and that the SVG is visible.
- await expect(
- page.locator( '.wc-block-components-notice-banner.is-success svg' )
- ).toBeVisible();
-
- await requestUtils.activateTheme( BLOCK_THEME_SLUG );
- } );
-
test( 'coupon inline notice is visible', async ( {
frontendUtils,
page,