Commit e36709ff43a for woocommerce

commit e36709ff43a2cbd0350fe095edb490e4aea2ac22
Author: Chris Lilitsas <1105590+xristos3490@users.noreply.github.com>
Date:   Thu Sep 10 14:14:37 2026 +0300

    Add REST-path regression test for stock notifications endpoint slug sanitization (#68542)

    * test: cover REST-path sanitization of the stock notifications endpoint slug

    Claude-Session: https://claude.ai/code/session_016CARMu7GumCJSWiDBqwPfc

    * test: make stock notifications REST slug test order-independent

    Claude-Session: https://claude.ai/code/session_01143z2YeFbqkfpvMz1kPLGW

    * test: use the controller built in setUp for the REST slug test

    Claude-Session: https://claude.ai/code/session_013ZtVeEvPyx4MGBS8owuCBW

diff --git a/plugins/woocommerce/changelog/wooairr-278-rest-endpoint-slug-sanitize-test b/plugins/woocommerce/changelog/wooairr-278-rest-endpoint-slug-sanitize-test
new file mode 100644
index 00000000000..47f29fa7203
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooairr-278-rest-endpoint-slug-sanitize-test
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Add a regression test covering that the stock notifications My Account endpoint slug is sanitized when saved through the REST settings API.
diff --git a/plugins/woocommerce/tests/php/src/Internal/StockNotifications/Admin/SettingsControllerTests.php b/plugins/woocommerce/tests/php/src/Internal/StockNotifications/Admin/SettingsControllerTests.php
index d522865ddc1..e62da777d4a 100644
--- a/plugins/woocommerce/tests/php/src/Internal/StockNotifications/Admin/SettingsControllerTests.php
+++ b/plugins/woocommerce/tests/php/src/Internal/StockNotifications/Admin/SettingsControllerTests.php
@@ -7,6 +7,7 @@ use Automattic\WooCommerce\Internal\StockNotifications\Admin\SettingsController;
 use Automattic\WooCommerce\Internal\StockNotifications\Frontend\MyAccountEndpoint;
 use WC_Settings_Advanced;
 use WC_Settings_Products;
+use WP_REST_Request;

 /**
  * SettingsControllerTests data tests.
@@ -145,4 +146,32 @@ class SettingsControllerTests extends \WC_Settings_Unit_Test_Case {
 		$this->assertSame( 'restock-alerts', apply_filters( $hook, 'Restock Alerts' ) );
 		$this->assertSame( 'stock-notifications', apply_filters( $hook, 'stock-notifications' ) );
 	}
+
+	/**
+	 * @testdox The My Account endpoint setting is sanitized the same way when saved through the REST settings API.
+	 */
+	public function test_my_account_endpoint_setting_is_sanitized_via_rest() {
+		// Routes must register on rest_api_init; firing it explicitly makes the test's outcome
+		// independent of whatever REST server state an earlier test in the process left behind.
+		do_action( 'rest_api_init' );
+
+		$admin_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
+		wp_set_current_user( $admin_id );
+
+		$request = new WP_REST_Request( 'PUT', '/wc/v3/settings/advanced/' . MyAccountEndpoint::ENDPOINT_OPTION );
+		$request->set_body_params( array( 'value' => 'Restock Alerts' ) );
+
+		$response = rest_do_request( $request );
+
+		$this->assertSame( 200, $response->get_status(), 'Saving the endpoint setting via REST should succeed.' );
+		$this->assertSame( 'restock-alerts', get_option( MyAccountEndpoint::ENDPOINT_OPTION ), 'The value saved via the REST settings API should be sanitized as an endpoint slug, matching the classic admin settings save path.' );
+	}
+
+	/**
+	 * Reset the REST server so this test does not leak it into tests that run after it.
+	 */
+	public function tearDown(): void {
+		$this->clear_rest_server();
+		parent::tearDown();
+	}
 }