@@ -88,7 +88,7 @@ test('trigger-app-event supports explicit selector without active session', asyn
8888 assert . equal ( response . ok , true ) ;
8989} ) ;
9090
91- test ( 'trigger command records action and refreshes session app bundle context' , async ( ) => {
91+ test ( 'trigger-app-event records action and refreshes session app bundle context' , async ( ) => {
9292 const sessionStore = makeStore ( ) ;
9393 const session = makeSession ( 'default' , {
9494 platform : 'android' ,
@@ -103,8 +103,8 @@ test('trigger command records action and refreshes session app bundle context',
103103 req : {
104104 token : 't' ,
105105 session : 'default' ,
106- command : 'trigger-screenshot-notification ' ,
107- positionals : [ ] ,
106+ command : 'trigger-app-event ' ,
107+ positionals : [ 'screenshot_taken' ] ,
108108 flags : { } ,
109109 } ,
110110 sessionName : 'default' ,
@@ -130,74 +130,3 @@ test('trigger command records action and refreshes session app bundle context',
130130 assert . equal ( nextSession ?. actions [ 0 ] ?. command , 'trigger-app-event' ) ;
131131 assert . deepEqual ( nextSession ?. actions [ 0 ] ?. positionals , [ 'screenshot_taken' ] ) ;
132132} ) ;
133-
134- test ( 'trigger aliases are normalized to trigger-app-event before dispatch' , async ( ) => {
135- const sessionStore = makeStore ( ) ;
136- sessionStore . set ( 'default' , makeSession ( 'default' , {
137- platform : 'android' ,
138- id : 'emulator-5554' ,
139- name : 'Pixel' ,
140- kind : 'emulator' ,
141- booted : true ,
142- } ) ) ;
143-
144- let dispatchedCommand = '' ;
145- let dispatchedPositionals : string [ ] = [ ] ;
146- const response = await handleSessionCommands ( {
147- req : {
148- token : 't' ,
149- session : 'default' ,
150- command : 'trigger-memory-warning' ,
151- positionals : [ ] ,
152- flags : { } ,
153- } ,
154- sessionName : 'default' ,
155- logPath : '/tmp/daemon.log' ,
156- sessionStore,
157- invoke,
158- ensureReady : async ( ) => { } ,
159- dispatch : async ( _device , command , positionals ) => {
160- dispatchedCommand = command ;
161- dispatchedPositionals = positionals ;
162- return { event : 'memory_warning' , eventUrl : 'myapp://agent-device/event?name=memory_warning' } ;
163- } ,
164- } ) ;
165-
166- assert . ok ( response ) ;
167- assert . equal ( response . ok , true ) ;
168- assert . equal ( dispatchedCommand , 'trigger-app-event' ) ;
169- assert . deepEqual ( dispatchedPositionals , [ 'memory_warning' ] ) ;
170- } ) ;
171-
172- test ( 'trigger aliases reject unexpected positional arguments' , async ( ) => {
173- const sessionStore = makeStore ( ) ;
174- sessionStore . set ( 'default' , makeSession ( 'default' , {
175- platform : 'android' ,
176- id : 'emulator-5554' ,
177- name : 'Pixel' ,
178- kind : 'emulator' ,
179- booted : true ,
180- } ) ) ;
181-
182- await assert . rejects (
183- ( ) => handleSessionCommands ( {
184- req : {
185- token : 't' ,
186- session : 'default' ,
187- command : 'trigger-screenshot' ,
188- positionals : [ 'extra' ] ,
189- flags : { } ,
190- } ,
191- sessionName : 'default' ,
192- logPath : '/tmp/daemon.log' ,
193- sessionStore,
194- invoke,
195- ensureReady : async ( ) => { } ,
196- } ) ,
197- ( error : unknown ) =>
198- error instanceof Error
199- && 'code' in error
200- && ( error as { code ?: string } ) . code === 'INVALID_ARGS'
201- && / d o e s n o t a c c e p t p o s i t i o n a l a r g u m e n t s / i. test ( error . message ) ,
202- ) ;
203- } ) ;
0 commit comments