appId: ${APP_ID}
env:
  USERNAME: foo.bar@example.com
  COMMUNITY_NAME: Humand E2E
  # MODULE_NAME must match the Kudos module label in the E2E community's Apps list
  MODULE_NAME: Kudos
  # PEER_1_NAME / PEER_2_NAME must be real users in the E2E environment
  PEER_1_NAME: E2E User 1
  PEER_2_NAME: E2E User 2
  # CATEGORY_NAME must match a real acknowledgement category in the E2E environment
  CATEGORY_NAME: Innovación
  # PRODUCT_NAME must match a real product name in the E2E environment's Canjes catalogue
  PRODUCT_NAME: E2E Product
---
# === SETUP ===
- runFlow: ../../shared/launch-app.yml
- runFlow: ../../shared/login-to-community.yml

# Navigate to the Kudos module from the Apps screen
- runFlow:
    file: ../../shared/go-to-module-from-apps.yml
    env:
      MODULE_NAME: ${MODULE_NAME}

# Generate a unique title for this test run (output.kudosTitle is available after this)
- runScript: ./scripts/get-kudos-title.js

# =====================================================================
# 1. CREATE ACKNOWLEDGEMENT + REACT
# =====================================================================
- runFlow:
    file: ./subFlows/create-acknowledgement.yml
    env:
      KUDOS_TITLE: ${output.kudosTitle}
      PEER_1_NAME: ${PEER_1_NAME}
      PEER_2_NAME: ${PEER_2_NAME}
      CATEGORY_NAME: ${CATEGORY_NAME}

# =====================================================================
# 2. VIEW ACKNOWLEDGEMENT DETAIL
# (opens the topmost/just-created acknowledgement — no title needed)
# =====================================================================
- runFlow: ./subFlows/acknowledgement-detail.yml

# =====================================================================
# 3 + 4. COMMENTS — add/react/edit comment, then add/edit/react reply
# This sub-flow is best-effort (all of its steps are optional); if it fails partway the
# run still continues here.
# =====================================================================
- runFlow: ./subFlows/comments.yml

# Return to the Kudos tabs. The comments sub-flow may leave us 0–2 screens deep (or fail
# partway), so pop Back until the "Ranking" tab is visible — each Back only fires while the
# tabs are NOT yet showing, so we stop as soon as we reach KudosTabs and never exit Kudos.
- runFlow:
    when:
      notVisible: 'Ranking'
    commands:
      - tapOn:
          text: Back
          optional: true
- runFlow:
    when:
      notVisible: 'Ranking'
    commands:
      - tapOn:
          text: Back
          optional: true
- runFlow:
    when:
      notVisible: 'Ranking'
    commands:
      - tapOn:
          text: Back
          optional: true

# =====================================================================
# 5. RANKING TAB — open and apply a filter
# =====================================================================
- tapOn: Ranking
- runFlow:
    file: ./subFlows/ranking.yml
    env:
      CATEGORY_NAME: ${CATEGORY_NAME}

# =====================================================================
# 6 + 7 + 8. REDEMPTIONS/CANJES TAB — browse products, view detail, view history
# =====================================================================
- tapOn:
    text: '.*(Redemptions|Canjes).*'
- runFlow:
    file: ./subFlows/products.yml
    env:
      PRODUCT_NAME: ${PRODUCT_NAME}
