@@ -71,6 +71,31 @@ public function set_up() {
71
71
parent ::set_up ();
72
72
73
73
WPCOM_JSON_API ::init ()->token_details = array ( 'blog_id ' => $ blog_id );
74
+
75
+ // Mock MCP abilities for testing
76
+ add_filter (
77
+ 'jetpack_mcp_abilities ' ,
78
+ function () {
79
+ return array (
80
+ 'wpcom-mcp/posts-search ' => array (
81
+ 'label ' => 'Posts Search ' ,
82
+ 'description ' => 'Search posts ' ,
83
+ 'enabled ' => true ,
84
+ ),
85
+ 'wpcom-mcp/user-sites ' => array (
86
+ 'label ' => 'User Sites ' ,
87
+ 'description ' => 'Access user sites ' ,
88
+ 'enabled ' => false ,
89
+ ),
90
+ );
91
+ }
92
+ );
93
+ }
94
+
95
+ public function tear_down () {
96
+ // Remove the filter to avoid affecting other tests
97
+ remove_all_filters ( 'jetpack_mcp_abilities ' );
98
+ parent ::tear_down ();
74
99
}
75
100
76
101
/**
@@ -272,7 +297,7 @@ public function make_post_request( $setting ) {
272
297
'page_on_front ' => '(string) The page ID of the page to use as the site \'s homepage. It will apply only if \'show_on_front \' is set to \'page \'. ' ,
273
298
'page_for_posts ' => '(string) The page ID of the page to use as the site \'s posts page. It will apply only if \'show_on_front \' is set to \'page \'. ' ,
274
299
'subscription_options ' => '(array) Array of two options used in subscription email templates: \'invitation \' and \'comment_follow \' strings. ' ,
275
- 'mcp_settings ' => '(string ) Whether MCP Settings is enabled and list of enabled abilities ' ,
300
+ 'mcp_settings ' => '(array ) Whether MCP Settings is enabled and list of enabled abilities ' ,
276
301
),
277
302
278
303
'response_format ' => array (
@@ -308,7 +333,18 @@ public static function setting_default_key_values() {
308
333
'mcp_settings ' ,
309
334
array (
310
335
'mcp_enabled ' => true ,
311
- 'mcp_abilities ' => array (),
336
+ 'mcp_abilities ' => array (
337
+ 'wpcom-mcp/posts-search ' => array (
338
+ 'label ' => 'Posts Search ' ,
339
+ 'description ' => 'Search posts ' ,
340
+ 'enabled ' => true ,
341
+ ),
342
+ 'wpcom-mcp/user-sites ' => array (
343
+ 'label ' => 'User Sites ' ,
344
+ 'description ' => 'Access user sites ' ,
345
+ 'enabled ' => false ,
346
+ ),
347
+ ),
312
348
),
313
349
),
314
350
);
@@ -334,8 +370,16 @@ public static function setting_value_pairs_get_request() {
334
370
array (
335
371
'mcp_enabled ' => true ,
336
372
'mcp_abilities ' => array (
337
- 'wpcom-mcp/posts-search ' => true ,
338
- 'wpcom-mcp/user-sites ' => false ,
373
+ 'wpcom-mcp/posts-search ' => array (
374
+ 'label ' => 'Posts Search ' ,
375
+ 'description ' => 'Search posts ' ,
376
+ 'enabled ' => true ,
377
+ ),
378
+ 'wpcom-mcp/user-sites ' => array (
379
+ 'label ' => 'User Sites ' ,
380
+ 'description ' => 'Access user sites ' ,
381
+ 'enabled ' => false ,
382
+ ),
339
383
),
340
384
),
341
385
),
@@ -373,43 +417,64 @@ public static function setting_value_pairs_post_request() {
373
417
),
374
418
),
375
419
// Add MCP settings POST tests
376
- 'mcp_settings valid json ' => array (
420
+ 'mcp_settings valid params ' => array (
377
421
'mcp_settings ' ,
378
- wp_json_encode (
379
- array (
380
- 'mcp_enabled ' => true ,
381
- 'mcp_abilities ' => array (
382
- 'wpcom-mcp/posts-search ' => array ( 'enabled ' => true ),
383
- 'wpcom-mcp/user-sites ' => array ( 'enabled ' => false ),
384
- ),
385
- )
422
+ array ( // This should be the actual input structure
423
+ 'mcp_enabled ' => true ,
424
+ 'mcp_abilities ' => array (
425
+ 'wpcom-mcp/posts-search ' => array ( 'enabled ' => true ),
426
+ 'wpcom-mcp/user-sites ' => array ( 'enabled ' => false ),
427
+ ),
386
428
),
387
- array (
429
+ array ( // Expected output
388
430
'mcp_enabled ' => true ,
389
431
'mcp_abilities ' => array (
390
- 'wpcom-mcp/posts-search ' => true ,
391
- 'wpcom-mcp/user-sites ' => false ,
432
+ 'wpcom-mcp/posts-search ' => array (
433
+ 'label ' => 'Posts Search ' ,
434
+ 'description ' => 'Search posts ' ,
435
+ 'enabled ' => true ,
436
+ ),
437
+ 'wpcom-mcp/user-sites ' => array (
438
+ 'label ' => 'User Sites ' ,
439
+ 'description ' => 'Access user sites ' ,
440
+ 'enabled ' => false ,
441
+ ),
392
442
),
393
443
),
394
444
),
395
445
'mcp_settings disabled ' => array (
396
446
'mcp_settings ' ,
397
- wp_json_encode (
398
- array (
399
- 'mcp_enabled ' => false ,
400
- 'mcp_abilities ' => array (),
401
- )
447
+ array (
448
+ 'mcp_enabled ' => false ,
449
+ 'mcp_abilities ' => array (
450
+ 'wpcom-mcp/posts-search ' => array (
451
+ 'label ' => 'Posts Search ' ,
452
+ 'description ' => 'Search posts ' ,
453
+ 'enabled ' => true ,
454
+ ),
455
+ 'wpcom-mcp/user-sites ' => array (
456
+ 'label ' => 'User Sites ' ,
457
+ 'description ' => 'Access user sites ' ,
458
+ 'enabled ' => false ,
459
+ ),
460
+ ),
402
461
),
403
462
array (
404
463
'mcp_enabled ' => false ,
405
- 'mcp_abilities ' => array (),
464
+ 'mcp_abilities ' => array (
465
+ 'wpcom-mcp/posts-search ' => array (
466
+ 'label ' => 'Posts Search ' ,
467
+ 'description ' => 'Search posts ' ,
468
+ 'enabled ' => true ,
469
+ ),
470
+ 'wpcom-mcp/user-sites ' => array (
471
+ 'label ' => 'User Sites ' ,
472
+ 'description ' => 'Access user sites ' ,
473
+ 'enabled ' => false ,
474
+ ),
475
+ ),
406
476
),
407
477
),
408
- 'mcp_settings malformed json ' => array (
409
- 'mcp_settings ' ,
410
- 'invalid json string ' ,
411
- false , // Should fail validation
412
- ),
413
478
);
414
479
}
415
480
}
0 commit comments