#!/usr/bin/env bash
set -euo pipefail
# Usage: bash run-comparison.sh BASE_CHECKOUT HEAD_CHECKOUT SYNTHETIC_FORGE_MODULE
base_checkout=$(realpath "$1")
head_checkout=$(realpath "$2")
fixture=$(realpath "$3")
cd "$head_checkout"
test "$(git rev-parse HEAD)" = c48aa675e7d2e7cf1bd242cad66a439dde774cab
test "$(git -C "$base_checkout" rev-parse HEAD)" = b3fdf2b10fb92e5dbc71a83381c602a8a464bbca
# Install each checkout first; place the uploaded scenario in scripts/scenarios/.
python3 - <<'PY'
from pathlib import Path
p=Path('scripts/e2e.config.ts')
s=p.read_text()
if 'inheritEnv: ["NODE_OPTIONS", "GH_TOKEN", "T3CODE_DEV_SEED"]' not in s:
 s=s.replace('executable: resolved.node,','inheritEnv: ["NODE_OPTIONS", "GH_TOKEN", "T3CODE_DEV_SEED"],\n          executable: resolved.node,')
s=s.replace('path.resolve(scripts, "../.t3/scenarios")','path.resolve(scripts, env.T3_SCENARIO_APP_DIR ?? "..", ".t3/scenarios")')
p.write_text(s)
PY
export T3CODE_DEV_SEED=0
export GH_TOKEN=scenario-placeholder
export NODE_OPTIONS="--import=$fixture"
vp run scenarios scenarios/mobile-sidebar-controls.e2e.ts --target web --output .e2e/manual-head
# Base should finish the whole driver and report the hidden-control assertions failing.
set +e
T3_SCENARIO_APP_DIR="$base_checkout" vp run scenarios scenarios/mobile-sidebar-controls.e2e.ts --target web --output .e2e/manual-base
base_status=$?
set -e
test "$base_status" -eq 1
