Commit a6938504181 for woocommerce
commit a69385041812572cbde6b4d7cf05e2288758de4a
Author: theAverageDev (Luca Tumedei) <luca.tumedei@automattic.com>
Date: Tue Jun 23 11:51:14 2026 +0200
Remove benign Blocks e2e build-log errors from provisioning and teardown (#65861)
* Make Blocks e2e provisioning idempotent and drop redundant CLI flag
Guard the customer-user creation and Test Helper APIs activation so they no-op when the Core and Blocks e2e setup paths both run, and drop a redundant --fields=id from the product attribute listing (it made the WC CLI foreach over scalar IDs). Removes benign errors from the Blocks e2e build log.
* Add changelog entry for Blocks e2e provisioning fixes
* Remove duplicate customer setup log output
* test: add QAO-524 diagnostic probes for Blocks e2e build-log errors
Temporary, revert before merge. These surface what CI strips (the console
fixture prints only message.text(), no URL):
- tests/e2e-pw/utils/blocks/test.ts: per-test aggregation of net failures
(ERR_INSUFFICIENT_RESOURCES storm + peak in-flight) and HTTP >=400, plus
truncated 5xx response bodies, flushed once per test.
- shared-controls.ts: log path/status/content-type/body at the three
invalid_json rejection sites.
The errors reproduce only on the Linux CI runner (not macOS at full parity),
so the probes read out the URLs/bodies there.
* test: QAO-524 probe — capture 500s at context level
The page-scoped response listener missed the 500s: they fire on secondary
pages the editor opens (frontend / preview). Listen on page.context() so the
HTTP-error/5xx-body capture covers every page in the test, and record the
originating frame path.
* test: QAO-524 probe — richer non-JSON capture; drop settled probes
Only the not-a-valid-JSON case is still unexplained, so keep just that probe
and drop the rest:
- tests/e2e-pw/utils/blocks/test.ts: restored to pre-probe state (removes the
net-failure storm + HTTP/5xx aggregation; ERR / 404 / 500 are settled).
- shared-controls.ts site=a: also log finalUrl, redirected, resType and a
1200-char body so we can see where /wc/store/v1/products?include= ends up
(redirect target / which HTML page) instead of just the generic <head>.
Revert before merge.
* Fix Blocks e2e false JSON-response errors during teardown DB reset
The page fixture reset the DB out from under a still-live page; late
in-flight Store API fetches were served the WordPress install page (HTTP
200 text/html) and logged "The response is not a valid JSON response."
Navigate to about:blank before db reset so the page stops issuing
requests. Drop the QAO-524 JSON probe that pinned this.
* Update changelog entry for teardown JSON-response fix
diff --git a/plugins/woocommerce/changelog/fix-blocks-e2e-provisioning-log-errors b/plugins/woocommerce/changelog/fix-blocks-e2e-provisioning-log-errors
new file mode 100644
index 00000000000..25879ce5e2d
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-blocks-e2e-provisioning-log-errors
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Remove benign errors from the Blocks e2e build log: make provisioning idempotent (customer user and Test Helper APIs plugin) across the Core and Blocks setup paths, drop a redundant `--fields=id` from the product attribute listing, and navigate the page away before the per-test DB reset so late Store API requests stop logging false "not a valid JSON response" errors.
diff --git a/plugins/woocommerce/tests/e2e/bin/blocks/scripts/parallel/customer.sh b/plugins/woocommerce/tests/e2e/bin/blocks/scripts/parallel/customer.sh
index 6bc7053ae81..58bbd6623a1 100644
--- a/plugins/woocommerce/tests/e2e/bin/blocks/scripts/parallel/customer.sh
+++ b/plugins/woocommerce/tests/e2e/bin/blocks/scripts/parallel/customer.sh
@@ -1,9 +1,11 @@
#!/usr/bin/env bash
-wp user create customer customer@woocommerceblockse2etestsuite.com \
- --user_pass=password \
- --role=subscriber \
- --first_name='Jane' \
- --last_name='Smith' \
- --path=/var/www/html \
- --user_registered='2022-01-01 12:23:45'
+if ! wp user get customer --field=ID --path=/var/www/html >/dev/null 2>&1; then
+ wp user create customer customer@woocommerceblockse2etestsuite.com \
+ --user_pass=password \
+ --role=subscriber \
+ --first_name='Jane' \
+ --last_name='Smith' \
+ --path=/var/www/html \
+ --user_registered='2022-01-01 12:23:45'
+fi
diff --git a/plugins/woocommerce/tests/e2e/bin/blocks/scripts/products.sh b/plugins/woocommerce/tests/e2e/bin/blocks/scripts/products.sh
index d876cfeec32..164e2d4dc61 100644
--- a/plugins/woocommerce/tests/e2e/bin/blocks/scripts/products.sh
+++ b/plugins/woocommerce/tests/e2e/bin/blocks/scripts/products.sh
@@ -55,7 +55,11 @@ sunglasses_product_id=$(wp post list --post_type=product --field=ID --name="Sung
wp post update $sunglasses_product_id --post_password="password" --user=1
# Enable attribute archives.
-attribute_ids=$(wp wc product_attribute list --fields=id --format=ids --user=1)
+# `--format=ids` already returns only the IDs; passing `--fields=id` on top of
+# it makes the WC CLI try to field-limit scalar IDs as if they were rows, which
+# triggers a "foreach() argument must be of type array|object, int given"
+# warning in class-wc-cli-rest-command.php. The two flags are redundant.
+attribute_ids=$(wp wc product_attribute list --format=ids --user=1)
if [ -n "$attribute_ids" ]; then
for id in $attribute_ids; do
wp wc product_attribute update "$id" --has_archives=true --user=1
diff --git a/plugins/woocommerce/tests/e2e/bin/blocks/test-env-setup.sh b/plugins/woocommerce/tests/e2e/bin/blocks/test-env-setup.sh
index 14e2466a18d..0429fe3c1fc 100755
--- a/plugins/woocommerce/tests/e2e/bin/blocks/test-env-setup.sh
+++ b/plugins/woocommerce/tests/e2e/bin/blocks/test-env-setup.sh
@@ -20,8 +20,10 @@ $prefs["core/edit-site"]["welcomeGuidePage"] = false;
$prefs["core/edit-site"]["welcomeGuideTemplate"] = false;
update_user_meta( 1, "wp_persisted_preferences", $prefs );
'
-# Activate the Test Helper APIs utility plugin.
-wp-env run tests-cli -- wp plugin activate e2e-test-helpers/test-helper-apis.php
+# Activate the Test Helper APIs utility plugin if not already activated.
+if ! wp-env run tests-cli -- wp plugin is-active e2e-test-helpers/test-helper-apis.php >/dev/null 2>&1; then
+ wp-env run tests-cli -- wp plugin activate e2e-test-helpers/test-helper-apis.php
+fi
echo "Generating test translations"
node $script_dir/generate-test-translations.js
diff --git a/plugins/woocommerce/tests/e2e/bin/test-env-setup.sh b/plugins/woocommerce/tests/e2e/bin/test-env-setup.sh
index 3783c654a11..ca553c6aab2 100755
--- a/plugins/woocommerce/tests/e2e/bin/test-env-setup.sh
+++ b/plugins/woocommerce/tests/e2e/bin/test-env-setup.sh
@@ -50,12 +50,14 @@ echo -e 'Install Plugin-check utility plugin \n'
wp-env run tests-cli wp plugin install plugin-check --activate
echo -e 'Add Customer user \n'
-wp-env run tests-cli wp user create customer customer@woocommercecoree2etestsuite.com \
- --user_pass=password \
- --role=customer \
- --first_name='Jane' \
- --last_name='Smith' \
- --user_registered='2022-01-01 12:23:45'
+if ! wp-env run tests-cli wp user get customer --field=ID >/dev/null 2>&1; then
+ wp-env run tests-cli wp user create customer customer@woocommercecoree2etestsuite.com \
+ --user_pass=password \
+ --role=customer \
+ --first_name='Jane' \
+ --last_name='Smith' \
+ --user_registered='2022-01-01 12:23:45'
+fi
echo -e 'Update Blog Name \n'
wp-env run tests-cli wp option update blogname 'WooCommerce Core E2E Test Suite'
diff --git a/plugins/woocommerce/tests/e2e/utils/blocks/test.ts b/plugins/woocommerce/tests/e2e/utils/blocks/test.ts
index 95ad62c09a5..18a8e85b1f7 100644
--- a/plugins/woocommerce/tests/e2e/utils/blocks/test.ts
+++ b/plugins/woocommerce/tests/e2e/utils/blocks/test.ts
@@ -143,6 +143,22 @@ const test = base.extend<
// Dispose the current APIRequestContext to free up resources.
await page.request.dispose();
+ // Navigate away before resetting the DB so the page stops issuing
+ // Store API requests against a half-dropped database. Otherwise late
+ // in-flight fetches are served the WordPress install page (HTTP 200,
+ // text/html) and surface as "The response is not a valid JSON
+ // response." console noise.
+ try {
+ await page.goto( 'about:blank' );
+ } catch ( error ) {
+ // Ignore errors if page is already closed/navigated away.
+ // eslint-disable-next-line no-console
+ console.log(
+ 'Failed to navigate away before DB reset:',
+ error.message
+ );
+ }
+
await wpCLI( `db reset --yes` );
// Reset the database to the initial state via snapshot import.
await wpCLI( `db import ${ DB_EXPORT_FILE }` );