@@ -12,8 +12,12 @@ import { cliTest } from "../../support/cli/cliFixture.js";
1212const scenarios = [
1313 {
1414 name : "undeclared secret references" ,
15- issuePath : [ "secrets" ] ,
16- issueMessage : "Secret reference pw is not declared" ,
15+ fullSchemaValid : true ,
16+ issue : {
17+ path : [ "secrets" ] ,
18+ reason : "invalid_value" ,
19+ message : "Secret reference pw is not declared" ,
20+ } ,
1721 actions : [
1822 {
1923 step_id : "pw" ,
@@ -25,18 +29,57 @@ const scenarios = [
2529 } ,
2630 {
2731 name : "duplicate action step IDs" ,
28- issuePath : [ "actions" ] ,
29- issueMessage : "Action step IDs must be unique" ,
32+ fullSchemaValid : true ,
33+ issue : {
34+ path : [ "actions" ] ,
35+ reason : "invalid_value" ,
36+ message : "Action step IDs must be unique" ,
37+ } ,
3038 actions : [
3139 { step_id : "wait" , action : "wait_for_timeout" , duration_ms : 1 } ,
3240 { step_id : "wait" , action : "wait_for_timeout" , duration_ms : 1 } ,
3341 ] ,
3442 } ,
43+ {
44+ name : "overflowing wait duration" ,
45+ fullSchemaValid : false ,
46+ issue : {
47+ path : [ "actions" , 0 , "duration_ms" ] ,
48+ reason : "out_of_range" ,
49+ maximum : 2_147_483_647 ,
50+ } ,
51+ actions : [
52+ {
53+ step_id : "wait" ,
54+ action : "wait_for_timeout" ,
55+ duration_ms : 2_147_483_648 ,
56+ } ,
57+ ] ,
58+ } ,
59+ {
60+ name : "overflowing action deadline" ,
61+ fullSchemaValid : false ,
62+ issue : {
63+ path : [ "actions" , 0 , "timeout_ms" ] ,
64+ reason : "out_of_range" ,
65+ maximum : 2_147_483_647 ,
66+ } ,
67+ actions : [
68+ {
69+ step_id : "visible" ,
70+ action : "wait_for" ,
71+ locator : { kind : "css" , selector : "#btn" } ,
72+ state : "visible" ,
73+ timeout_ms : 2_147_483_648 ,
74+ } ,
75+ ] ,
76+ } ,
3577] as const ;
3678
37- cliTest (
38- "projects refined browser scenario validation into CLI-equivalent diagnostics over stdio MCP" ,
39- async ( { cli } ) => {
79+ cliTest . for ( [ "full" , "compact" ] as const ) (
80+ "projects browser scenario input diagnostics over stdio MCP (%s)" ,
81+ { timeout : 60_000 } ,
82+ async ( profile , { cli } ) => {
4083 const home = await createTestTempDirectory (
4184 "rea-browser-scenario-mcp-home-" ,
4285 ) ;
@@ -52,6 +95,7 @@ cliTest(
5295 PATH : process . env . PATH ?? "" ,
5396 HOME : home ,
5497 REA_LOG_LEVEL : "silent" ,
98+ REA_MCP_INPUT_SCHEMA_PROFILE : profile ,
5599 } ,
56100 stderr : "pipe" ,
57101 } ) ;
@@ -81,7 +125,7 @@ cliTest(
81125 expect (
82126 validate ( input ) ,
83127 `${ scenario . name } : ${ JSON . stringify ( validate . errors ) } ` ,
84- ) . toBe ( true ) ;
128+ ) . toBe ( scenario . fullSchemaValid || profile === "compact" ) ;
85129
86130 const cliResult = await cli . run ( {
87131 arguments : [
@@ -111,13 +155,7 @@ cliTest(
111155 } ,
112156 details : {
113157 operation : "capture_browser_scenario" ,
114- issues : [
115- {
116- path : scenario . issuePath ,
117- reason : "invalid_value" ,
118- message : scenario . issueMessage ,
119- } ,
120- ] ,
158+ issues : [ scenario . issue ] ,
121159 } ,
122160 } ) ;
123161
@@ -126,12 +164,31 @@ cliTest(
126164 arguments : input ,
127165 } ) ;
128166 expect ( mcpResult . structuredContent ) . toBeUndefined ( ) ;
129- expect ( parseMcpToolError ( mcpResult ) . error ) . toEqual ( cliDiagnostic ) ;
167+ const mcpError = parseMcpToolError ( mcpResult ) . error ;
168+ if ( scenario . fullSchemaValid ) expect ( mcpError ) . toEqual ( cliDiagnostic ) ;
169+ else {
170+ // The SDK validates the canonical schema before invoking the handler.
171+ expect ( mcpError ) . toMatchObject ( {
172+ code : "invalid_request" ,
173+ category : "invalid_input" ,
174+ retryable : true ,
175+ recovery : { kind : "inspect_input_contract" , operation : tool . name } ,
176+ details : {
177+ operation : tool . name ,
178+ issues : [
179+ {
180+ message : expect . stringContaining (
181+ `${ scenario . issue . path . join ( "." ) } : Too big: expected number to be <=2147483647` ,
182+ ) ,
183+ } ,
184+ ] ,
185+ } ,
186+ } ) ;
187+ }
130188 await expect ( client . ping ( ) ) . resolves . toEqual ( { } ) ;
131189 }
132190 } finally {
133191 await Promise . all ( [ client . close ( ) , transport . close ( ) ] ) ;
134192 }
135193 } ,
136- 60_000 ,
137194) ;
0 commit comments