appId: ${APP_ID}
---
# Precondition: AcknowledgementDetail screen is visible.
#
# BEST-EFFORT SUB-FLOW: every tap/assert is `optional: true` so that if any step fails
# (e.g. an icon button can't be located on a given build, or a character is dropped while
# typing), the run is NOT aborted — the root flow continues with the Ranking and
# Redemptions sub-flows.
#
# Comment/reply body text is matched as a substring ('.*...*'): the comment card is
# pressable, so iOS merges its children into one label like
# "Foo Bar, A moment ago, E2E Comment". A bare 'E2E Comment' (full match) would miss it.
#
# After every Send we dismiss the keyboard, which otherwise covers the new comment/reply.

# =====================================================================
# STEP 1: Add a comment to the acknowledgement
# =====================================================================
- tapOn:
    text: '.*(Write a comment|Escribe un comentario).*'
    optional: true
- inputText: 'E2E Comment'
- tapOn:
    text: '.*(Send|Enviar).*'
    optional: true
- runFlow: ../../../shared/dismiss-keyboard.yml
- assertVisible:
    text: '.*E2E Comment.*'
    optional: true

# =====================================================================
# STEP 2: React to the comment with 👍
# Reaction button merges emoji + count, so match '.*👍.*'.
# index: 1 — the acknowledgement post's reaction is index 0; the comment's is index 1.
# =====================================================================
- tapOn:
    text: '.*👍.*'
    index: 1
    optional: true

# =====================================================================
# STEP 3: Edit the comment
# The options button is an icon exposing accessibilityLabel = general.more_options
# ("More options"/"Más opciones"). On the detail screen only the comment carries this
# label (the post's options button is unlabeled), so index 0 is the comment.
# =====================================================================
- tapOn:
    text: '.*(More options|Más opciones).*'
    index: 0
    optional: true
- tapOn:
    text: '.*(Edit|Editar).*'
    optional: true
# The edit input focuses ~1s after the menu action; wait before erasing/typing.
- waitForAnimationToEnd:
    timeout: 1200
- eraseText: 50
- inputText: 'E2E Comment editado'
- tapOn:
    text: '.*(Send|Enviar).*'
    optional: true
- runFlow: ../../../shared/dismiss-keyboard.yml
- assertVisible:
    text: '.*E2E Comment editado.*'
    optional: true

# =====================================================================
# STEP 4: Open the comment replies (CommentDetail screen)
# =====================================================================
- tapOn:
    text: '.*E2E Comment editado.*'
    optional: true
- assertVisible:
    text: '.*(Responses to|Respuestas a).*'
    optional: true

# =====================================================================
# STEP 5: Add a reply to the comment
# =====================================================================
- tapOn:
    text: '.*(Write a comment|Escribe un comentario).*'
    optional: true
- inputText: 'E2E Reply'
- tapOn:
    text: '.*(Send|Enviar).*'
    optional: true
- runFlow: ../../../shared/dismiss-keyboard.yml
- assertVisible:
    text: '.*E2E Reply.*'
    optional: true

# =====================================================================
# STEP 6: Edit the reply
# On CommentDetail both the parent comment (index 0) and the reply (index 1) expose the
# "More options"/"Más opciones" label, so index 1 targets the reply.
# =====================================================================
- tapOn:
    text: '.*(More options|Más opciones).*'
    index: 1
    optional: true
- tapOn:
    text: '.*(Edit|Editar).*'
    optional: true
- waitForAnimationToEnd:
    timeout: 1200
- eraseText: 50
- inputText: 'E2E Reply editado'
- tapOn:
    text: '.*(Send|Enviar).*'
    optional: true
- runFlow: ../../../shared/dismiss-keyboard.yml
- assertVisible:
    text: '.*E2E Reply editado.*'
    optional: true

# =====================================================================
# STEP 7: React to the reply with 👍
# index: 1 — parent comment's reaction is index 0; reply's is index 1.
# =====================================================================
- tapOn:
    text: '.*👍.*'
    index: 1
    optional: true

# Flow ends here on AcknowledgementCommentDetail screen
# root-flow will navigate back: Back → AcknowledgementDetail → Back → KudosTabs
