Commit 9b4c1eba560 for woocommerce
commit 9b4c1eba560b70aee11a28de82fa8a4f1c906798
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date: Mon Nov 9 15:51:59 2026 +0200
Fix race in mutation batcher rollback E2E test (#70714)
Wait for the first cart cycle to settle in the batcher rollback E2E test
The first click shows "1 in cart" before the request finishes. If the
next clicks join that open cycle, the batcher commits the successful
response instead of rolling back, and the test passes without testing
rollback.
diff --git a/plugins/woocommerce/changelog/fix-e2e-mutation-batcher-rollback-race b/plugins/woocommerce/changelog/fix-e2e-mutation-batcher-rollback-race
new file mode 100644
index 00000000000..6ea37e8dbab
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-e2e-mutation-batcher-rollback-race
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Fix a race in the mutation batcher rollback E2E test; no production change.
diff --git a/plugins/woocommerce/tests/e2e/tests/blocks/cart-store/mutation-batcher.block_theme.spec.ts b/plugins/woocommerce/tests/e2e/tests/blocks/cart-store/mutation-batcher.block_theme.spec.ts
index 3a2bac4f287..624f56ddb70 100644
--- a/plugins/woocommerce/tests/e2e/tests/blocks/cart-store/mutation-batcher.block_theme.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/blocks/cart-store/mutation-batcher.block_theme.spec.ts
@@ -39,6 +39,19 @@ test.describe( 'Mutation Batcher', () => {
await button.click();
await expect( button ).toHaveText( '1 in cart' );
+ // "1 in cart" is optimistic. Wait for the first cycle to settle, or
+ // the failing clicks join it and commit its successful response
+ // instead of rolling back.
+ await page.evaluate( async () => {
+ const { store } = await import( '@wordpress/interactivity' );
+ const unlockKey =
+ 'I acknowledge that using a private store means my plugin will inevitably break on the next store release.';
+
+ await import( '@woocommerce/stores/woocommerce/cart' );
+ const { actions } = store( 'woocommerce', {}, { lock: unlockKey } );
+ await actions.waitForIdle();
+ } );
+
// Intercept batch requests with a delay so we can observe
// the optimistic state before the failure triggers rollback.
await page.route( '**/wc/store/v1/batch**', async ( route ) => {