appId: ${APP_ID}
---
# Send image fragment - assumes user is already in a chat conversation
# Note: Media must be added before running this fragment via addMedia in parent flow
# TODO: Need to improve accessibility for Attachments button

# Dialog should be opened
- tapOn: .*Add Attachments.*
- tapOn:
    point: 50%,80%

# Allow gallery permissions
- runFlow:
    when:
      platform: android
    commands:
      - tapOn:
          id: 'com.android.permissioncontroller:id/permission_allow_all_button'
          optional: true
    when:
      platform: ios
    commands:
      - tapOn:
          text: .*Allow Full Access.*
          optional: true

# Dialog should dismiss
- tapOn: 'Cancel'
- assertNotVisible: 'Select an option'

# Pick & send first image
- tapOn: .*Add Attachments.*
- tapOn:
    point: 50%,80%
- runFlow:
    file: ../../../shared/pick-asset/pick-from-gallery.yml
    env:
      ANDROID_INDEX: '1'
      IOS_POINT: '88%,30%'
      ASSET_NAME: 'chats1.jpg'
- extendedWaitUntil:
    visible: Image 1, Uploaded
    timeout: 15000
- assertVisible: Remove Image 1
- tapOn: Send
- runScript: ../scripts/getTime.js
- assertVisible: .*You, Image, ${output.time}.*

#Pick 2 images and send
- tapOn: .*Add Attachments.*
- tapOn:
    point: 50%,80%
- runFlow:
    file: ../../../shared/pick-asset/pick-from-gallery.yml
    env:
      ANDROID_INDEX: '2'
      IOS_POINT: '12%,41%'
      ASSET_NAME: 'chats2.jpeg'
      SECOND_ANDROID_INDEX: '3'
      SECOND_IOS_POINT: '37%,41%'
      SECOND_ASSET_NAME: 'chats3.png'
- extendedWaitUntil:
    visible: Image 1, Uploaded
    timeout: 15000
- extendedWaitUntil:
    visible: Image 2, Uploaded
    timeout: 15000
- tapOn: Send
- runScript: ../scripts/getTime.js
- assertVisible: .*You, 2 Images, ${output.time}.*
