@@ -10,6 +10,7 @@ import {
1010 fromArrayLiteral ,
1111 fromObjectLiteral ,
1212 ObjectBuilder ,
13+ literal ,
1314} from '@/codegen/estree'
1415import { mapNonEmpty } from '@/utils/list'
1516import { exhaustive } from '@/utils/typescript'
@@ -328,6 +329,41 @@ function emitExpectExpression(
328329 }
329330}
330331
332+ function emitWaitForExpression (
333+ context : ScenarioContext ,
334+ expression : ir . WaitForExpression
335+ ) : ts . Expression {
336+ const target = emitExpression ( context , expression . target )
337+ const args =
338+ expression . options !== null
339+ ? [ emitExpression ( context , expression . options ) ]
340+ : [ ]
341+
342+ return new ExpressionBuilder ( target )
343+ . member ( 'waitFor' )
344+ . call ( args )
345+ . await ( context )
346+ . done ( )
347+ }
348+
349+ function emitWaitForOptionsExpression (
350+ _context : ScenarioContext ,
351+ expression : ir . WaitForOptionsExpression
352+ ) : ts . Expression {
353+ const timeout = typeof expression . timeout !== 'undefined' && {
354+ timeout : literal ( { value : expression . timeout } ) ,
355+ }
356+
357+ const state = typeof expression . state !== 'undefined' && {
358+ state : string ( expression . state ) ,
359+ }
360+
361+ return fromObjectLiteral ( {
362+ ...timeout ,
363+ ...state ,
364+ } )
365+ }
366+
331367function emitWaitForNavigationExpression (
332368 context : ScenarioContext ,
333369 expression : ir . WaitForNavigationExpression
@@ -416,6 +452,12 @@ function emitExpression(
416452 case 'ExpectExpression' :
417453 return emitExpectExpression ( context , expression )
418454
455+ case 'WaitForExpression' :
456+ return emitWaitForExpression ( context , expression )
457+
458+ case 'WaitForOptionsExpression' :
459+ return emitWaitForOptionsExpression ( context , expression )
460+
419461 case 'WaitForNavigationExpression' :
420462 return emitWaitForNavigationExpression ( context , expression )
421463
0 commit comments