@@ -344,4 +344,81 @@ describe('MaestroRuntimePort', () => {
344344 } ) ,
345345 ) . rejects . toBe ( failure ) ;
346346 } ) ;
347+
348+ test ( 'resolves ${VAR} numeric option fields to numbers at runtime' , async ( ) => {
349+ const calls : RecordedCall [ ] = [ ] ;
350+ const operations = makeOperations ( {
351+ tapOn : vi . fn ( async ( input , context ) => record ( calls , 'tapOn' , input , context ) ) ,
352+ doubleTapOn : vi . fn ( async ( input , context ) => record ( calls , 'doubleTapOn' , input , context ) ) ,
353+ eraseText : vi . fn ( async ( input , context ) => record ( calls , 'eraseText' , input , context ) ) ,
354+ scrollUntilVisible : vi . fn ( async ( input , context ) =>
355+ record ( calls , 'scrollUntilVisible' , input , context ) ,
356+ ) ,
357+ waitForAnimationToEnd : vi . fn ( async ( input , context ) =>
358+ record ( calls , 'waitForAnimationToEnd' , input , context ) ,
359+ ) ,
360+ gesture : vi . fn ( async ( input , context ) => record ( calls , 'gesture' , input , context ) ) ,
361+ } ) ;
362+ const program = parseMaestroProgram (
363+ [
364+ '---' ,
365+ '- tapOn:' ,
366+ ' id: button' ,
367+ ' index: ${INDEX}' ,
368+ ' repeat: ${REPEAT}' ,
369+ ' delay: ${DELAY}' ,
370+ '- doubleTapOn:' ,
371+ ' id: button' ,
372+ ' delay: ${DELAY}' ,
373+ '- eraseText:' ,
374+ ' charactersToErase: ${CHARS}' ,
375+ '- scrollUntilVisible:' ,
376+ ' element: Item' ,
377+ ' timeout: ${SCROLL_TIMEOUT}' ,
378+ '- waitForAnimationToEnd: ${ANIM_TIMEOUT}' ,
379+ '- swipe:' ,
380+ ' start: 90%, 50%' ,
381+ ' end: 10%, 50%' ,
382+ ' duration: ${DURATION}' ,
383+ ] . join ( '\n' ) ,
384+ ) ;
385+
386+ await executeMaestroProgram ( program , createMaestroRuntimePort ( operations ) , {
387+ env : {
388+ INDEX : '2' ,
389+ REPEAT : '3' ,
390+ DELAY : '100' ,
391+ CHARS : '4' ,
392+ SCROLL_TIMEOUT : '5000' ,
393+ ANIM_TIMEOUT : '2000' ,
394+ DURATION : '250' ,
395+ } ,
396+ } ) ;
397+
398+ expect ( calls ) . toHaveLength ( 6 ) ;
399+ expect ( calls [ 0 ] ) . toMatchObject ( {
400+ kind : 'tapOn' ,
401+ input : { target : expect . anything ( ) , repeat : 3 , delay : 100 } ,
402+ } ) ;
403+ expect ( calls [ 1 ] ) . toMatchObject ( {
404+ kind : 'doubleTapOn' ,
405+ input : { target : expect . anything ( ) , delay : 100 } ,
406+ } ) ;
407+ expect ( calls [ 2 ] ) . toMatchObject ( {
408+ kind : 'eraseText' ,
409+ input : { charactersToErase : 4 } ,
410+ } ) ;
411+ expect ( calls [ 3 ] ) . toMatchObject ( {
412+ kind : 'scrollUntilVisible' ,
413+ input : { timeoutMs : 5000 } ,
414+ } ) ;
415+ expect ( calls [ 4 ] ) . toMatchObject ( {
416+ kind : 'waitForAnimationToEnd' ,
417+ input : { timeoutMs : 2000 } ,
418+ } ) ;
419+ expect ( calls [ 5 ] ) . toMatchObject ( {
420+ kind : 'gesture' ,
421+ input : { durationMs : 250 } ,
422+ } ) ;
423+ } ) ;
347424} ) ;
0 commit comments