Files
archived-orca/tests/e2e/desktop/cli-invocation/compiled-orca-cli.ts
Neil a16afc4e67 refactor(e2e): group journeys by feature and repair browser recovery (#43628)
* refactor(e2e): group journeys and fixtures by feature ownership

* refactor(e2e): consolidate remaining Playwright owner imports

* test(ci): stop copying retired route modules into fixtures

* fix(browser): preserve one-shot follow intent across equal snapshots

* refactor(settings): colocate commit message defaults with source control

* test(browser): await page registration and focus the concrete page

* fix(browser): keep viewport recovery progressing during incompatible frames

* fix(browser): wait for stale helper exit before replacement commands
2026-11-17 11:44:44 -08:00

64 lines
1.8 KiB
TypeScript

// Run the bundled CLI as a separate process discovering this E2E runtime through its user-data directory.
import path from 'node:path'
import { runProcess } from '@orca/process-host'
export type OrcaCliResult = {
args: string[]
code: number | null
stdout: string
stderr: string
/** The parsed `--json` envelope, or null when stdout was not JSON. */
json: {
ok?: boolean
result?: unknown
error?: { code?: string; message?: string }
} | null
}
export async function runCompiledOrcaCli(
userDataDir: string,
args: string[],
timeoutMs = 120_000
): Promise<OrcaCliResult> {
const result = await runProcess({
program: process.execPath,
args: [path.join(process.cwd(), 'out', 'cli', 'index.js'), ...args],
env: {
...process.env,
ORCA_USER_DATA_PATH: userDataDir,
ORCA_DEV_CLI_INVOCATION: '1'
},
timeoutMs,
maxOutputBytes: 4 * 1024 * 1024
})
let json: OrcaCliResult['json'] = null
try {
json = JSON.parse(result.stdout)
} catch {
json = null
}
return {
args,
code: result.code,
stdout: result.stdout,
stderr: result.stderr,
json
}
}
/** The `--json` result of a command that must succeed; a failure names the command and its output. */
export async function orcaCliResult<T>(
userDataDir: string,
args: string[],
timeoutMs?: number
): Promise<T> {
const run = await runCompiledOrcaCli(userDataDir, [...args, '--json'], timeoutMs)
if (run.code !== 0 || !run.json?.ok) {
throw new Error(
`orca ${args.join(' ')} exited ${run.code}: ${run.stdout.slice(0, 2_000)} ${run.stderr.slice(0, 2_000)}`
)
}
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: callers name the shape the CLI's --json envelope documents for that command; tests assert on it.
return run.json.result as T
}