# urge/sos-flow.yaml
# Tests: Login → Header dropdown → SOS → Lyra chat screen loads → breathing exercise
#        triggered → session ends → feedback rating drawer appears.
# Pre-requisite: App installed. Test-user exists on staging. Staging backend running.
#                Groq API key configured (SOS streams via /api/coach/sos-stream).
# Env-Vars: E2E_TEST_USER, E2E_TEST_PASSWORD
# Expected outcome: Lyra chat input visible after SOS screen loads.
#                   Breathing drawer opens when "Atemübung" chip is tapped.
#
# TIMING NOTE: SOS screen boots RiveAvatar + streams first Lyra message via Groq.
# Timeout of 12s post-navigation is intentional — cold LLM response on staging.
#
# BLOCKER: Avatar button in AppHeader has no testID → coordinate fallback (93%, 6%).
# SOS-entry Pressable in HeaderDropdownMenu has no testID → text "SOS" selector works
# because "SOS" only appears inside the open dropdown.

appId: org.rebreak.app
---
- launchApp:
    clearState: true

- waitForAnimationToEnd:
    timeout: 5000

# --- Auth ---
- assertVisible:
    text: "E-Mail"
- tapOn:
    text: "E-Mail"
- inputText: ${E2E_TEST_USER}@rebreak.internal
- tapOn:
    text: "Passwort"
- inputText: ${E2E_TEST_PASSWORD}
- tapOn:
    text: "Anmelden"
- waitForAnimationToEnd:
    timeout: 10000

- assertVisible:
    text: "ReBreak"

# Open Header dropdown
- tapOn:
    point: "93%, 6%"
- waitForAnimationToEnd:
    timeout: 2000

# t('appHeader.sosLabel') = "SOS" (de.json) — red text, top of dropdown
- assertVisible:
    text: "SOS"
- tapOn:
    text: "SOS"

# SOS screen loads: RiveAvatar renders + Lyra streaming starts.
# Boot takes 6-12s on staging (Groq cold start + audio pre-cache).
- waitForAnimationToEnd:
    timeout: 12000

# Chat input: placeholder = t('coach.placeholder') = "Was beschäftigt dich?" (de.json).
# This placeholder ONLY exists on the SOS/Urge screen.
- assertVisible:
    text: "Was beschäftigt dich?"

# Type a message to trigger Lyra response + chip suggestions
- tapOn:
    text: "Was beschäftigt dich?"
- inputText: "Ich habe gerade einen starken Drang."
- tapOn:
    text: "Was beschäftigt dich?"

# After typing, a send button should appear (Ionicons send icon, no text/testID).
# Tap on the text input area then look for the send button via coordinates.
# FRAGILE — needs testID="sos-send-btn" on the send Pressable. See TODO_TESTIDS.md.
# Instead of sending (which triggers another streaming round-trip),
# we verify the chip row is visible if Lyra has already responded.
# If this is the first message, wait for Lyra's response + chip appearance.
- waitForAnimationToEnd:
    timeout: 15000

# After Lyra responds, chipSet changes from 'start' to dynamic chips.
# "Atemübung" is a chip in CHIP_SETS.start (sosConstants.ts) — always shown first.
# Text is hardcoded in sosConstants.ts, not i18n.
# If visible: tap to open BreathingDrawer.
- assertVisible:
    text: "Atemübung"
- tapOn:
    text: "Atemübung"
- waitForAnimationToEnd:
    timeout: 3000

# BreathingDrawer opens as a bottom sheet. Header text is hardcoded
# "Atemübung" in Breathing.tsx — safe to assert.
- assertVisible:
    text: "Atemübung"
