appId: ${APP_ID}
---
# Precondition: KudosTabs with Redemptions/Canjes tab active
# Env: PRODUCT_NAME — must match a real product name in the E2E environment
# Text matchers are bilingual (English|Spanish).

# Assert we are on the Products (Redemptions/Canjes) screen
- assertVisible:
    text: '.*(Points available|Puntos disponibles).*'

# =====================================================================
# STEP 1: View a product detail
# =====================================================================
- scrollUntilVisible:
    element:
      text: '.*${PRODUCT_NAME}.*'
- tapOn:
    text: '.*${PRODUCT_NAME}.*'

# Assert we are on the ProductDetail screen — "Confirm exchange" / "Confirmar canje"
# (or the "Back" / "Volver" button when no points are available to redeem).
- extendedWaitUntil:
    visible:
      text: '.*(Confirm exchange|Confirmar canje|Back|Volver).*'
    timeout: 5000

# Navigate back to the Redemptions tab.
# Assert the tab label (always visible in the tab bar regardless of scroll position)
# rather than 'Points available' which lives in the scrollable header and may be off-screen.
- tapOn: Back
- assertVisible:
    text: '.*(Redemptions|Canjes).*'

# =====================================================================
# STEP 2: View exchange history
# =====================================================================
- tapOn:
    text: '.*(Exchange history|Historial de canjes).*'
- extendedWaitUntil:
    visible:
      text: '.*(Exchange|Canje|history|historial|status|estado).*'
    timeout: 5000
