Commit c692ed503d7 for woocommerce
commit c692ed503d79714ae333850b5b1d3e1b9ff87514
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date: Thu Jul 9 14:06:10 2026 +0300
php tests: fix flaky variation-gallery "feature off" test (#66445)
diff --git a/plugins/woocommerce/changelog/testops-217-fix-flaky-variation-gallery-feature-off-test b/plugins/woocommerce/changelog/testops-217-fix-flaky-variation-gallery-feature-off-test
new file mode 100644
index 00000000000..914352ae773
--- /dev/null
+++ b/plugins/woocommerce/changelog/testops-217-fix-flaky-variation-gallery-feature-off-test
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Fix flaky variation-gallery "feature off" unit test by setting the enable option to 'no' explicitly instead of deleting it, so is_enabled() short-circuits before the canary-cohort path; test-only, no changes to shipped code.
diff --git a/plugins/woocommerce/tests/php/includes/wc-product-functions-test.php b/plugins/woocommerce/tests/php/includes/wc-product-functions-test.php
index c51ca0e1111..4c9ed886c47 100644
--- a/plugins/woocommerce/tests/php/includes/wc-product-functions-test.php
+++ b/plugins/woocommerce/tests/php/includes/wc-product-functions-test.php
@@ -1157,7 +1157,11 @@ class WC_Product_Functions_Tests extends \WC_Unit_Test_Case {
* @testdox Variable add-to-cart skips the gallery snapshot when the feature is off.
*/
public function test_woocommerce_variable_add_to_cart_skips_gallery_snapshot_when_feature_off() {
- delete_option( \Automattic\WooCommerce\Internal\VariationGallery\Package::ENABLE_OPTION_NAME );
+ // Set the option to 'no' explicitly rather than deleting it: an empty option makes
+ // Package::is_enabled() fall through to the canary cohort, which reads a separate
+ // option (woocommerce_remote_variant_assignment) that other tests in the same worker
+ // may have left set, non-deterministically re-enabling the feature. 'no' short-circuits.
+ update_option( \Automattic\WooCommerce\Internal\VariationGallery\Package::ENABLE_OPTION_NAME, 'no' );
$inline_js = $this->capture_variable_add_to_cart_inline_js();