#!/usr/bin/env bash
# Begin with the target environment details expanded. Both reported threads have been opened.
# Usage: bash removal-driver.sh SESSION OUTPUT_PARENT
set -euo pipefail
session="$1"
out="$2/$(date -u +%Y%m%dT%H%M%SZ)"
mkdir -p "$out"
ad() { agent-device "$@" --session "$session"; }
ad wait 'label="Remove environment"' 10000
ad record start "$out/removal-raw.mp4" --scope device --hide-touches
ad press 'label="Remove environment"' --settle
ad press 'text="Remove"'
ad wait text 'This environment is no longer saved on this device.' 10000
ad home
ad wait 'id="com.google.android.apps.nexuslauncher:id/workspace"' 10000
ad swipe 540 2100 540 400
ad wait 'text="T3 Code Dev"' 10000
ad longpress 'text="T3 Code Dev"' --settle
ad screenshot "$out/menu-a.png"
ad screenshot "$out/menu-b.png"
ad record stop
printf '%s\n' "$out"
