@@ -8,11 +8,19 @@ import {
88 sanitizeUiOptionsForFormat ,
99} from '../../packages/core-ui/js/gui_components/options-catalog-adapter.js' ;
1010
11- function firstJsonLine ( output ) {
11+ function jsonRpcMessages ( output ) {
1212 return output
1313 . split ( / \r ? \n / )
1414 . map ( ( line ) => line . trim ( ) )
15- . find ( ( line ) => line . startsWith ( '{' ) ) ;
15+ . filter ( ( line ) => line . startsWith ( '{' ) )
16+ . map ( ( line ) => {
17+ try {
18+ return JSON . parse ( line ) ;
19+ } catch {
20+ return null ;
21+ }
22+ } )
23+ . filter ( Boolean ) ;
1624}
1725
1826function requestMcpServer ( payload ) {
@@ -23,10 +31,13 @@ function requestMcpServer(payload) {
2331 input : request ,
2432 encoding : 'utf8' ,
2533 cwd : repoRoot ,
34+ timeout : 15000 ,
2635 } ) ;
27- const line = firstJsonLine ( output ) ;
28- expect ( line ) . toBeTruthy ( ) ;
29- return JSON . parse ( line ) ;
36+ const messages = jsonRpcMessages ( output ) ;
37+ expect ( messages . length ) . toBeGreaterThan ( 0 ) ;
38+ const response = messages . find ( ( message ) => message ?. id === payload . id ) ;
39+ expect ( response ) . toBeTruthy ( ) ;
40+ return response ;
3041}
3142
3243describe ( 'cross-surface option parity (API vs MCP vs CLI helper)' , ( ) => {
@@ -56,9 +67,8 @@ describe('cross-surface option parity (API vs MCP vs CLI helper)', () => {
5667 expect ( mcpPayload . ok ) . toBe ( true ) ;
5768 const props = mcpPayload ?. formatSchema ?. optionSchema ?. properties || { } ;
5869 for ( const [ key , tip ] of Object . entries ( tips ) ) {
59- if ( props [ key ] ) {
60- expect ( props [ key ] . description ) . toBe ( tip ) ;
61- }
70+ expect ( Object . hasOwn ( props , key ) ) . toBe ( true ) ;
71+ expect ( props [ key ] . description ) . toBe ( tip ) ;
6272 }
6373
6474 const normalized = normalizeAndValidateFormat ( format . toUpperCase ( ) ) ;
0 commit comments