#!/usr/bin/env bash
set -euo pipefail
# Run from a current main checkout with dependencies installed and the adjacent
# browser-address-ime.e2e.ts copied to scripts/scenarios/.
# Enable a web-only target attached to Chromium so the scenario can send native IME commands.
python3 - <<'PY'
p = 'scripts/e2e.config.ts'
s = open(p).read().replace('engine: web({ viewport: { width: 1280, height: 800 } }),', 'engine: web({ viewport: { width: 1280, height: 800 }, connect: { cdpEndpoint: () => "http://127.0.0.1:19222" } }),')
start = s.index('    {\n      name: "ios",')
end = s.index('\n  ],', start)
s = s[:start] + s[end:]
open(p, 'w').write(s)
PY
node scripts/node_modules/playwright-core/cli.js install chromium ffmpeg
chrome=$(node --input-type=module -e 'import {chromium} from "./scripts/node_modules/playwright-core/index.mjs"; console.log(chromium.executablePath())')
profile=$(mktemp -d)
"$chrome" --headless --no-sandbox --disable-gpu --remote-debugging-port=19222 --user-data-dir="$profile" about:blank &
chrome_pid=$!
trap 'kill "$chrome_pid"' EXIT
T3CODE_DEV_SEED=0 vp run scenarios:prove scripts/scenarios/browser-address-ime.e2e.ts --base 3a30b011c3867884d7e5180be77886de65e12ac9 --head d277ba8dd8ddb56959ebdc3d69f25d58904f6e1f --upload-command "ghdrop upload"
