appId: ${APP_ID}
---
# Scroll up until we find the first message of current flow
- scrollUntilVisible:
    element: .*Start e2e test.*
    direction: UP
    speed: 50
    timeout: 60000
    centerElement: true

# Start reply and cancel it
- longPressOn: .*Start e2e test.*
- waitForAnimationToEnd:
    timeout: 1500
- tapOn: Reply
- assertVisible: Reply to, You, Start e2e test
- tapOn: Cancel reply
- assertNotVisible: Reply to, You, Start e2e test

# Type and send the reply
- runFlow: ../../../shared/dismiss-keyboard.yml
- scrollUntilVisible:
    element: '.*Start e2e test.*'
    direction: DOWN
- longPressOn: .*Start e2e test.*
- waitForAnimationToEnd:
    timeout: 1500
- tapOn: Reply
- assertVisible: Reply to, You, Start e2e test
- inputText: This is a reply for a message
- tapOn: Send
- assertVisible: 'You, Reply: Foo Bar, This is a reply for a message,.*'

# Verify we navigated to the original message (chat scrolls to it)
- runFlow: ../../../shared/dismiss-keyboard.yml
- tapOn: 'You, Reply: Foo Bar, This is a reply for a message,.*'
- extendedWaitUntil:
    visible: .*Start e2e test.*
    timeout: 3000

- runFlow:
    when:
      visible:
        id: scroll-to-bottom-button
    commands:
      # Scroll to bottom and delete the reply for future tests
      - tapOn:
          id: scroll-to-bottom-button
