( runtime, options, )
| 348 | }); |
| 349 | |
| 350 | export const waitCommand: RuntimeCommand<WaitCommandOptions, WaitCommandResult> = async ( |
| 351 | runtime, |
| 352 | options, |
| 353 | ): Promise<WaitCommandResult> => { |
| 354 | if (options.target.kind === 'sleep') { |
| 355 | await sleep(runtime, options.target.durationMs); |
| 356 | return { kind: 'sleep', waitedMs: options.target.durationMs }; |
| 357 | } |
| 358 | if (options.target.kind === 'ref') { |
| 359 | const capture = await requireSnapshotSession(runtime, options.session); |
| 360 | const ref = normalizeRef(options.target.ref); |
| 361 | if (!ref) throw new AppError('INVALID_ARGS', `Invalid ref: ${options.target.ref}`); |
| 362 | const node = findNodeByRef(capture.snapshot.nodes, ref); |
| 363 | const text = node ? resolveRefLabel(node, capture.snapshot.nodes) : undefined; |
| 364 | if (!text) { |
| 365 | throw new AppError('COMMAND_FAILED', `Ref ${options.target.ref} not found or has no label`); |
| 366 | } |
| 367 | return await waitForText(runtime, options, text, options.target.timeoutMs); |
| 368 | } |
| 369 | if (options.target.kind === 'selector') { |
| 370 | return await waitForSelector( |
| 371 | runtime, |
| 372 | options, |
| 373 | options.target.selector, |
| 374 | options.target.timeoutMs, |
| 375 | ); |
| 376 | } |
| 377 | if (!options.target.text) throw new AppError('INVALID_ARGS', 'wait requires text'); |
| 378 | return await waitForText(runtime, options, options.target.text, options.target.timeoutMs); |
| 379 | }; |
| 380 | |
| 381 | export const waitForTextCommand: RuntimeCommand< |
| 382 | WaitForTextCommandOptions, |
no test coverage detected