(args: string[])
| 8 | | { kind: 'text'; text: string; timeoutMs: number | null }; |
| 9 | |
| 10 | export function parseWaitPositionals(args: string[]): WaitParsed | null { |
| 11 | const firstArg = args[0]; |
| 12 | if (firstArg === undefined) return null; |
| 13 | const sleepMs = parseTimeout(firstArg); |
| 14 | if (sleepMs !== null) return { kind: 'sleep', durationMs: sleepMs }; |
| 15 | const timeoutMs = parseTimeout(args[args.length - 1]); |
| 16 | if (firstArg === 'text') { |
| 17 | const text = timeoutMs !== null ? args.slice(1, -1).join(' ') : args.slice(1).join(' '); |
| 18 | return { kind: 'text', text: text.trim(), timeoutMs }; |
| 19 | } |
| 20 | if (firstArg.startsWith('@')) return { kind: 'ref', rawRef: firstArg, timeoutMs }; |
| 21 | const argsWithoutTimeout = timeoutMs !== null ? args.slice(0, -1) : args.slice(); |
| 22 | const split = splitSelectorFromArgs(argsWithoutTimeout); |
| 23 | if (split && split.rest.length === 0 && tryParseSelectorChain(split.selectorExpression)) { |
| 24 | return { kind: 'selector', selectorExpression: split.selectorExpression, timeoutMs }; |
| 25 | } |
| 26 | const text = timeoutMs !== null ? args.slice(0, -1).join(' ') : args.join(' '); |
| 27 | return { kind: 'text', text: text.trim(), timeoutMs }; |
| 28 | } |
no test coverage detected