11import assert from 'node:assert/strict' ;
22import { test } from 'vitest' ;
3+ import type { AgentDeviceClient } from '../../../client.ts' ;
34import { getCommandCapability } from '../../../core/capabilities.ts' ;
4- import { getCommandSchema } from '../../../utils/command-schema.ts' ;
5+ import { getCommandSchema , type CliFlags } from '../../../utils/command-schema.ts' ;
56import { CAPTURE_COMMAND_DEFINITIONS } from '../../capture-definition.ts' ;
67import { SELECTOR_COMMAND_DEFINITIONS } from '../../selectors-definition.ts' ;
78import { SESSION_LIFECYCLE_COMMAND_DEFINITIONS } from '../../session-lifecycle/definition.ts' ;
8- import { INTERACTION_COMMAND_DEFINITIONS } from '../definition.ts' ;
9+ import { runTypeCliCommand } from '../cli.ts' ;
10+ import { INTERACTION_COMMAND_DEFINITIONS , typeCommandDefinition } from '../definition.ts' ;
911
1012test ( 'command definitions feed schema and capability registries' , ( ) => {
1113 for ( const definition of [
@@ -18,3 +20,34 @@ test('command definitions feed schema and capability registries', () => {
1820 assert . deepEqual ( getCommandCapability ( definition . name ) , definition . capability ) ;
1921 }
2022} ) ;
23+
24+ test ( 'type command definition exposes its positional codec' , ( ) => {
25+ assert . deepEqual ( typeCommandDefinition . codec . decode ( [ 'hello' , 'world' ] , { delayMs : 25 } ) , {
26+ text : 'hello world' ,
27+ delayMs : 25 ,
28+ } ) ;
29+ assert . deepEqual ( typeCommandDefinition . codec . encode ( { text : 'hello world' } ) , [ 'hello world' ] ) ;
30+ } ) ;
31+
32+ test ( 'type CLI command routes through the definition codec' , async ( ) => {
33+ let received : unknown ;
34+ const client = {
35+ interactions : {
36+ type : async ( options : unknown ) => {
37+ received = options ;
38+ return { } ;
39+ } ,
40+ } ,
41+ } as AgentDeviceClient ;
42+
43+ await runTypeCliCommand ( {
44+ client,
45+ positionals : [ 'hello' , 'world' ] ,
46+ flags : { platform : 'ios' , delayMs : 25 } as CliFlags ,
47+ } ) ;
48+
49+ const options = received as Record < string , unknown > ;
50+ assert . equal ( options . platform , 'ios' ) ;
51+ assert . equal ( options . text , 'hello world' ) ;
52+ assert . equal ( options . delayMs , 25 ) ;
53+ } ) ;
0 commit comments