appId: ${APP_ID}
env:
  ADMIN: supervisor.e2e
  PASSWORD: 12345678
  USERNAME: collaborator1.e2e
  INSTANCE_ID: ${EL_INSTANCE_ID}
  API_URL: ${API_URL}
  COLLABORATOR_ID: ${EL_COLLABORATOR_ID}

onFlowStart:
  - runScript: ../../shared/scripts/api.js
  - runScript: ./scripts/employeeLifecycleApi.js
  - runScript: ./scripts/setupProcess.js

onFlowComplete:
  - runScript: ./scripts/teardownProcess.js
---
- runFlow: ../../shared/launch-app.yml
- runFlow: ../../shared/login-to-community.yml

# TODO: Use the go-to-module-from-apps.yml flow when the old module is removed
- tapOn: Apps
- waitForAnimationToEnd:
    timeout: 3000
- assertVisible: '.*Onboarding$'
- tapOn:
    text: '^(\d+\s+)?Onboarding$'
    index: 1

# Search for onboarding process
- tapOn: 'Search'
- inputText: E2E
- assertVisible: 'E2E Onboarding Process.*'
- tapOn: # Dismiss keyboard and tap on the process
    text: 'E2E Onboarding Process.*'
    repeat: 2
- waitForAnimationToEnd:
    timeout: 1000
- assertVisible: 'E2E Onboarding Step.*'
- tapOn: 'E2E Onboarding Step.*'
- assertVisible: 'E2E Answer the questionnaire.*'
- tapOn: 'E2E Answer the questionnaire.*'
- assertVisible: 'Start questionnaire.*'
- tapOn: 'Start questionnaire.*'

# Answer the questionnaire
- tapOn: 'Continue'
- runFlow:
    when:
      notVisible: 'You have mandatory questions unanswered'
    commands:
      - scrollUntilVisible:
          element: 'You have mandatory questions unanswered'
          direction: UP
- assertVisible: 'You have mandatory questions unanswered'
- tapOn: 'Write here'
- inputText: 'E2E test answer'
- tapOn: # Dismiss keyboard
    point: 50%, 25%
- scrollUntilVisible:
    element: 'CHECKBOX Option 1'
- tapOn: 'CHECKBOX Option 1'
- scrollUntilVisible:
    element: 'CHECKBOX Option 3'
- tapOn: 'CHECKBOX Option 3'
- scrollUntilVisible:
    element: 'CHECKBOX Option 5'
- tapOn: 'CHECKBOX Option 5'
- scrollUntilVisible:
    element: 'MULTIPLE Option 2'
- tapOn: 'MULTIPLE Option 2'
- scrollUntilVisible:
    element: 'No response question'
- scrollUntilVisible:
    element: 'Autocomplete question | Hiring date'
- tapOn: 'Continue'
- assertVisible: 'This field cannot be empty'
- tapOn: '4/5'
- tapOn: 'Continue'
- waitForAnimationToEnd:
    timeout: 5000

# Questionnaire completed
- assertVisible: 'Well done!.*You have completed the questionnaire.*'
- assertVisible: 'Back to my tasks'
- tapOn: 'Back to my tasks'

# Check completed tasks
- assertVisible: 'Completed Tasks'
- tapOn: 'Completed Tasks'
- assertVisible: 'E2E Answer the questionnaire.*'
