#!/usr/bin/env bash
# Interaction recipe used on freshly paired native dev clients for each commit.
# Lease and install through mobile:install; start Metro for the commit being tested.
# Pair using the repository pair-client helper. No browser Azure login is used.
set -euo pipefail
: "${DEVICE_SESSION:?Set to the leased device session}"
: "${PLATFORM:?ios or android}"
: "${OUTPUT_DIR:?Choose an evidence directory}"
ad() { agent-device "$@" --session "$DEVICE_SESSION"; }
ad press 'label="PRs"'
# Select the synthetic Repro attachments PR in the returned snapshot.
# iOS exposes the row as other/cell; Android exposes it as button.
ad press 'label="Pull request 314, Repro attachments, Open, by Julius@markping791.onmicrosoft.com, 0 additions, 0 deletions"'
ad press 'label="Expand description"'
if [[ "$PLATFORM" == ios ]]; then ad scroll down 0.3; else ad scroll down 0.45; fi
ad screenshot "$OUTPUT_DIR/description.png"
ad press 'label="Play demo.mp4"'
# Base reaches Video unavailable / Retry. Head plays the six-second synthetic clip.
# On head expose native controls, pause, then seek from six to three seconds.
# Android: press the seekbar from a fresh snapshot. iOS: drag Current position
# from its right-hand thumb to its middle (402x874 device: 287,767 -> 180,767).
ad screenshot "$OUTPUT_DIR/video.png"
ad scroll down --until 'label="View attachment: demo.gif"' --max-passes 4 --settle
ad scroll down 0.25
ad screenshot "$OUTPUT_DIR/attachments.png"
ad press 'label="View attachment: demo.gif"'
ad screenshot "$OUTPUT_DIR/expanded-gif.png"
# Record the full interaction, inspect decoded frames, and export with record stop.
# Published native videos trim initial idle time; head appends a second capture
# continuing at the full Attachments row, without changing screen content.
