# Workout Player Flow Test
# Tests starting a workout, timer controls, and completion
# Prerequisite: User must have completed onboarding

appId: com.millianlmx.tabatafit
name: Workout Player

---
# Start from home screen
- assertVisible: "program-card-upper-body"

# Open the Upper Body program
- tapOn: "program-upper-body-cta"

# Wait for program detail screen to load
- assertVisible:
    text: ".*Upper Body.*"
    timeout: 5000

# Tap on first workout in the program
- tapOn:
    text: ".*Start.*"
    index: 0
    optional: true
- tapOn:
    text: ".*Begin.*"
    index: 0
    optional: true

# Wait for player screen to load — look for the play button
- extendedWaitUntil:
    visible:
      text: ".*PREP.*"
    timeout: 10000
    optional: true

# If no PREP text, look for the play icon or workout title
- assertVisible:
    text: ".*Workout.*"
    timeout: 5000
    optional: true

# Start the workout — tap the play button (center of screen)
- tapOn:
    point: "50%,50%"

# Wait for timer to start — PREP phase should appear
- extendedWaitUntil:
    visible:
      text: ".*PREP.*"
    timeout: 5000
    optional: true

# Wait a few seconds for the timer to tick
- swipe:
    direction: UP
    duration: 100
    optional: true

# Verify timer is running — time display should be visible
- assertVisible:
    text: ".*:.*"
    timeout: 5000

# Test pause — tap the pause button (center area)
- tapOn:
    point: "50%,80%"
    optional: true

# Wait briefly
- swipe:
    direction: UP
    duration: 100
    optional: true

# Resume — tap again
- tapOn:
    point: "50%,80%"
    optional: true

# Close the player — look for close/stop button (top-left area)
- tapOn:
    point: "10%,8%"
    optional: true

# If close button was in a different location, try the stop button
- tapOn:
    text: ".*close.*"
    optional: true

# Verify we're back on the program screen or home
- assertVisible:
    text: ".*Upper Body.*"
    timeout: 5000
    optional: true

# Go back to home
- back
- assertVisible:
    id: "program-card-upper-body"
    timeout: 5000
    optional: true
