@@ -4103,4 +4103,54 @@ public function test_get_note_with_children_link() {
41034103
41044104 $ this ->assertArrayHasKey ( 'children ' , $ response ->get_links () );
41054105 }
4106+
4107+ /**
4108+ * Test that children note links are properly embedded in the REST API response.
4109+ *
4110+ * @ticket 64145
4111+ */
4112+ public function test_get_note_with_embedded_children () {
4113+ $ parent_comment_id = self ::factory ()->comment ->create (
4114+ array (
4115+ 'comment_approved ' => 1 ,
4116+ 'comment_post_ID ' => self ::$ post_id ,
4117+ 'user_id ' => self ::$ admin_id ,
4118+ 'comment_type ' => 'note ' ,
4119+ 'comment_content ' => 'Parent note comment ' ,
4120+ )
4121+ );
4122+
4123+ self ::factory ()->comment ->create (
4124+ array (
4125+ 'comment_approved ' => 1 ,
4126+ 'comment_parent ' => $ parent_comment_id ,
4127+ 'comment_post_ID ' => self ::$ post_id ,
4128+ 'user_id ' => self ::$ admin_id ,
4129+ 'comment_type ' => 'note ' ,
4130+ 'comment_content ' => 'First child note comment ' ,
4131+ )
4132+ );
4133+
4134+ wp_set_current_user ( self ::$ admin_id );
4135+
4136+ $ request = new WP_REST_Request ( 'GET ' , '/wp/v2/comments ' );
4137+ $ request ->set_param ( 'post ' , self ::$ post_id );
4138+ $ request ->set_param ( 'type ' , 'note ' );
4139+ $ request ->set_param ( 'context ' , 'edit ' );
4140+ $ request ->set_param ( 'parent ' , 0 );
4141+
4142+ $ response = rest_get_server ()->dispatch ( $ request );
4143+ $ this ->assertSame ( 200 , $ response ->get_status () );
4144+
4145+ $ data = $ response ->get_data ();
4146+
4147+ $ this ->assertArrayHasKey ( '_links ' , $ data [0 ] );
4148+ $ this ->assertArrayHasKey ( 'children ' , $ data [0 ]['_links ' ] );
4149+
4150+ $ children = $ data [0 ]['_links ' ]['children ' ];
4151+
4152+ // Verify the href attribute contains the expected status and type parameters.
4153+ $ this ->assertStringContainsString ( 'status=all ' , $ children [0 ]['href ' ] );
4154+ $ this ->assertStringContainsString ( 'type=note ' , $ children [0 ]['href ' ] );
4155+ }
41064156}
0 commit comments