appId: ${APP_ID}
env:
  USER_SEND: foo.bar@example.com
  USER_RECEIVER: john.doe@example.com
  PASSWORD: 12345678
  INSTANCE_ID: ${EL_INSTANCE_ID}
  API_URL: ${API_URL}
  MESSAGE: Hello, this is a test message for testing PUSH NOTIFICATIONS
onFlowStart:
  - runScript: ../../../shared/scripts/api.js
---
- runFlow: ../../../shared/launch-app.yml
- runFlow:
    file: ../../../shared/login-to-community.yml
    env:
      USERNAME: ${USER_RECEIVER}
      PASSWORD: ${PASSWORD}
      COMMUNITY_NAME: 'Humand E2E'
# To close the bottom sheet after login if not when the user open the push
# it displays the bottom sheet and the push notification is not visible
- tapOn: Chats
- runFlow: ../../../shared/handle-bottom-sheet.yml

# Check for amount of notifications in home screen
- pressKey: Home
- runScript: ../scripts/sendMesageViaApi.js
- runFlow:
    file: ../../../shared/push-notification/open-push-notification.yml
    env:
      TITLE: Foo Bar
      DESCRIPTION: ${MESSAGE}
- extendedWaitUntil:
    visible: .*Foo Bar.*
    timeout: 10000
- scrollUntilVisible:
    element: .*${MESSAGE}.*
    direction: DOWN
- tapOn: Back

# Mute user
- swipe:
    from:
      text: .*Foo Bar.*
    direction: left
    duration: 500
- assertVisible: Options
- tapOn: Options
- assertVisible: .*Mute.*
- assertVisible: .*Go to profile.*
- tapOn: Mute
- tapOn: 8 hours
- assertVisible: .*mute.*

# Check for no having a push notification
- pressKey: Home
- runScript: ../scripts/sendMesageViaApi.js
- runFlow:
    file: ../../../shared/push-notification/check-push-notification-not-visible.yml
    env:
      TITLE: Foo Bar
      DESCRIPTION: ${MESSAGE}
# Close notification center
- pressKey: Home

# Check for receive the message
- tapOn: Humand.*
- assertVisible: .*Foo Bar.*mute.*

# Unmute user
- swipe:
    from:
      text: .*Foo Bar.*
    direction: left
    duration: 500
- assertVisible: Options
- tapOn: Options
- assertVisible: .*Unmute.*
- assertVisible: .*Go to profile.*
- tapOn: Unmute
- assertNotVisible: .*mute.*
# Tap user to mark as read
- tapOn: .*Foo Bar.*
