#!/usr/bin/env bash
# Run from the checkout under test. WORKSPACE is a clone of the synthetic repo.
# Set TEST_PORT, TEST_HOME, DEVICE_ORIGIN, METRO_ORIGIN and SESSION for that side.
set -euo pipefail
node apps/server/src/bin.ts project add "$WORKSPACE" --title 'PR43452 proof' --base-dir "$TEST_HOME"
vp run mobile:install android --session "$SESSION" --metro "$METRO_ORIGIN"
# After Metro loads, pair the isolated server.
.agents/skills/test-t3-mobile/scripts/pair-client.sh "$TEST_PORT" "$TEST_HOME" "$DEVICE_ORIGIN" agent-device --session "$SESSION"
# Open Pulls, tap Search pull requests, fill PR43452 repro, dismiss keyboard,
# and open the sole synthetic PR. Use fresh snapshot refs for each action.
agent-device snapshot -i --session "$SESSION"
# Wait for one check (after seed.py); for the plural run manage.py two,
# pull to refresh with the swipe below, then wait for 2 awaiting action.
agent-device wait text '1 awaiting action' --session "$SESSION"
agent-device screenshot one-a.png --session "$SESSION"
sleep 0.5
agent-device screenshot one-b.png --session "$SESSION"
agent-device snapshot --json --session "$SESSION" > one-tree.json
python3 manage.py two
agent-device swipe 540 700 540 1500 --session "$SESSION"
agent-device wait text '2 awaiting action' --session "$SESSION"
# Let the refresh indicator disappear; compare two captures and recapture if unequal.
agent-device screenshot two-a.png --session "$SESSION"
sleep 0.5
agent-device screenshot two-b.png --session "$SESSION"
agent-device snapshot --json --session "$SESSION" > two-tree.json
# manage.py one removes the second policy before the next side's singular run.
