@@ -299,6 +299,29 @@ struct ProtocolTests {
299299 )
300300 }
301301
302+ static func cliFillPreservesLiteralValue( ) throws {
303+ let value = " pass --json \t to API "
304+ let invocation = try CLIParser ( ) . parse ( [
305+ " --session " , " qa " , " --json " , " fill " , " @e1 " , " -- " , value,
306+ ] )
307+ try expect ( invocation. jsonOutput, " global --json before the sentinel should parse " )
308+ try expect ( invocation. request? . session == " qa " , " global --session before the sentinel should parse " )
309+ try expect ( invocation. request? . parameters [ " target " ] == . string( " @e1 " ) , " fill target should parse " )
310+ try expect ( invocation. request? . parameters [ " value " ] == . string( value) , " fill text should preserve whitespace and literal flags " )
311+
312+ let literalFlag = try CLIParser ( ) . parse ( [ " fill " , " @e1 " , " -- " , " --json " ] )
313+ try expect ( !literalFlag. jsonOutput, " --json after the sentinel should not become a global option " )
314+ try expect ( literalFlag. request? . parameters [ " value " ] == . string( " --json " ) , " a literal --json fill value should survive " )
315+
316+ let literalSession = try CLIParser ( ) . parse ( [ " fill " , " @e1 " , " -- " , " --session " ] )
317+ try expect ( literalSession. request? . session == nil , " --session after the sentinel should not become a global option " )
318+ try expect ( literalSession. request? . parameters [ " value " ] == . string( " --session " ) , " a literal --session fill value should survive " )
319+
320+ try expectThrows ( " multi-word fill text must stay one shell argument " ) {
321+ _ = try CLIParser ( ) . parse ( [ " fill " , " @e1 " , " two " , " words " ] )
322+ }
323+ }
324+
302325 static func cliSemanticClick( ) throws {
303326 let invocation = try CLIParser ( ) . parse ( [ " click " , " --role " , " button " , " --name " , " Continue " ] )
304327 try expect (
@@ -871,6 +894,7 @@ struct ProtocolTests {
871894 ( " command parameter validation " , commandParameterValidation) ,
872895 ( " strict request fields " , rejectsUnexpectedRequestFields) ,
873896 ( " CLI visit " , cliVisit) ,
897+ ( " CLI fill literal value " , cliFillPreservesLiteralValue) ,
874898 ( " CLI semantic click " , cliSemanticClick) ,
875899 ( " CLI inspect context and task " , cliInspectContextAndTask) ,
876900 ( " CLI conflicting target " , cliRejectsConflictingClickTarget) ,
0 commit comments