# profile/demographics.yaml
# Tests: Login → Profile → DemographicsAccordion toggle → WheelPicker opens for Geburtsjahr
#        → dismiss → Gender picker opens → dismiss → verify accordion still expanded.
# Pre-requisite: App installed. Test-user exists on staging.
# Env-Vars: E2E_TEST_USER, E2E_TEST_PASSWORD
# Expected outcome: Accordion expands, pickers open without crash.
#
# LIMITATION: WheelPickerModal is a Modal + ScrollView — Maestro can tap within it
# but cannot reliably assert a specific wheel item is selected. This flow only verifies
# the UI path opens and dismisses cleanly (no crash). Full field-fill test requires
# testIDs on each picker trigger row.
#
# NOTE: The accordion header uses hardcoded text (not i18n):
#   "ANONYMER BEITRAG ZUR FORSCHUNG" — safe to match as static string.
#
# BLOCKER on Avatar tap: coordinate-based (93%, 6%). See TODO_TESTIDS.md.

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 dropdown → Profile
- tapOn:
    point: "93%, 6%"
- waitForAnimationToEnd:
    timeout: 2000
- assertVisible:
    text: "Profil"
- tapOn:
    text: "Profil"
- waitForAnimationToEnd:
    timeout: 4000

- assertVisible:
    text: "Profil"

# Scroll down to reach DemographicsAccordion (below StreakSection / UrgeStatsCard)
- scrollUntilVisible:
    element:
      text: "ANONYMER BEITRAG ZUR FORSCHUNG"
    direction: DOWN
    timeout: 6000

# Accordion header text is hardcoded — safe to use as selector.
- assertVisible:
    text: "ANONYMER BEITRAG ZUR FORSCHUNG"

# Tap accordion header to expand
- tapOn:
    text: "ANONYMER BEITRAG ZUR FORSCHUNG"
- waitForAnimationToEnd:
    timeout: 1500

# After expansion: the progress bar area and field rows appear.
# "Geburtsjahr" label is hardcoded in DemographicsAccordion.
# FRAGILE: no testID on the row Pressable. Using text selector on label.
- scrollUntilVisible:
    element:
      text: "Geburtsjahr"
    direction: DOWN
    timeout: 3000
- assertVisible:
    text: "Geburtsjahr"

# Tap Geburtsjahr row to open WheelPickerModal
- tapOn:
    text: "Geburtsjahr"
- waitForAnimationToEnd:
    timeout: 2000

# WheelPickerModal is open. Dismiss by tapping the backdrop or close button.
# WheelPickerModal has no testID on the backdrop. Tap outside the picker area.
- tapOn:
    point: "50%, 10%"
- waitForAnimationToEnd:
    timeout: 1000

# Tap Geschlecht (Gender) row — also hardcoded label text in DemographicsAccordion
- scrollUntilVisible:
    element:
      text: "Geschlecht"
    direction: DOWN
    timeout: 3000
- tapOn:
    text: "Geschlecht"
- waitForAnimationToEnd:
    timeout: 2000

# Dismiss gender picker
- tapOn:
    point: "50%, 10%"
- waitForAnimationToEnd:
    timeout: 1000

# Verify accordion is still expanded after dismissing pickers
- assertVisible:
    text: "Geburtsjahr"
