Commit 66565cdbfe2 for woocommerce

commit 66565cdbfe236f1f762fad91625fba6c797f70b4
Author: Rostislav Wolný <1082140+costasovo@users.noreply.github.com>
Date:   Thu Jul 30 17:02:43 2026 +0200

    Fix flaky Mini-Cart variation attributes e2e test (#67165)

    * Fix flaky Mini-Cart variation attributes e2e test

    The test gated on the hidden `variation_id` input becoming non-zero before
    clicking Add to cart, but the variations script sets that synchronously and
    only drops the button's `disabled` class ~300ms later, from a setTimeout.
    Clicking inside that window hits the guard in add-to-cart-variation.js, which
    calls preventDefault and raises a window.alert that Playwright silently
    dismisses, so the form never submits and the test times out waiting for the
    "added to your cart" notice.

    Gate on the button losing its `disabled` class as well, matching the pattern
    already used in the add-to-cart-with-options and cart-line-identity specs.

diff --git a/plugins/woocommerce/changelog/fix-mini-cart-variation-e2e-race b/plugins/woocommerce/changelog/fix-mini-cart-variation-e2e-race
new file mode 100644
index 00000000000..31cddfbb666
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-mini-cart-variation-e2e-race
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Fix flaky Mini-Cart variation-attributes e2e test by waiting for the Add to cart button to be enabled.
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/mini-cart/mini-cart.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/mini-cart/mini-cart.block_theme.spec.ts
index 1bf9957e2dc..47921c85373 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/mini-cart/mini-cart.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/mini-cart/mini-cart.block_theme.spec.ts
@@ -1021,12 +1021,20 @@ test.describe( `${ blockData.name } Block (variation attributes)`, () => {
 		// no-op (the disabled state is class-based, which Playwright's
 		// actionability checks ignore). Wait for the variation to be registered
 		// (a positive, non-zero variation id) before clicking.
+		// That is necessary but not sufficient: the script sets `variation_id`
+		// synchronously and only drops the `disabled` class ~300ms later, from a
+		// setTimeout, so wait for the button to be enabled as well. Clicking in
+		// that window hits the guard that raises a window.alert Playwright
+		// silently dismisses, and the form never submits.
 		await expect( page.locator( 'input.variation_id' ) ).toHaveValue(
 			/^[1-9][0-9]*$/
 		);
-		await page
-			.getByRole( 'button', { name: 'Add to cart', exact: true } )
-			.click();
+		const addToCartButton = page.getByRole( 'button', {
+			name: 'Add to cart',
+			exact: true,
+		} );
+		await expect( addToCartButton ).not.toHaveClass( /\bdisabled\b/ );
+		await addToCartButton.click();

 		// Wait for a definitive "added to cart" confirmation before navigating
 		// to the shop. The single-product Add to cart is a form submission; if