# Happy-path golden flow: customer taps CTA → payment screen → confirm →
# searching → mitra accepts (via curl harness) → chat screen.
#
# This is the canonical demonstration of the "single-emulator + curl-as-mitra"
# pattern. The customer side is real Maestro; the mitra side is a backend API call
# fired from a runScript step.
#
# Pre-req:
#   1. At least one mitra is ONLINE on the target backend
#   2. TEST_MITRA_ID and TEST_MITRA_JWT in .maestro/config.yaml point at that mitra
#   3. The mitra has spare capacity (active_session_count < max_customers_per_mitra)
#
# Run:
#   maestro test client_app/.maestro/flows/03_payment_to_chat_happy.yaml
appId: ${APP_ID_ANDROID}
---
- launchApp:
    clearState: false
- assertVisible: "Mulai Curhat"

# Step 1: customer taps CTA → payment screen
- tapOn: "Mulai Curhat"
- assertVisible:
    text: "Bayar|Mulai"   # "Bayar" for paid tier, "Mulai" for free trial
    timeout: 5000

# Step 2: customer confirms payment → searching screen
- tapOn:
    text: "Bayar|Mulai"
- assertVisible:
    text: "Mencari Bestie"
    timeout: 5000

# Step 3: simulate mitra accepting via backend API (the "curl-as-mitra" trick).
# This avoids needing a second emulator — the backend treats mitra interactions as
# REST calls regardless of whether they originate from the mitra app or a script.
- runScript: ../scripts/mitra_accept_latest.sh

# Step 4: customer screen transitions to "found" then chat
- assertVisible:
    text: "Bestie Ditemukan"
    timeout: 10000   # blast→accept→WS round-trip takes a few seconds
