appId: com.toughra.ustadmobile
tags:
  - courseTest
env:
  TESTRESULTSDIR: "build/reports/maestro/002_002_student_joining_course_using_code/Screenshots"
  TESTCOURSENAME: "Test Course Block"
onFlowStart:
  - startRecording: 002_002_student_joining_course_using_code
  - runScript:
      file: "common/startserver.js"
      env:
        TESTCONTROLLER_URL: ${TESTCONTROLLER_URL}
  - clearState: com.toughra.ustadmobile
onFlowComplete:
  - stopRecording
  - runScript:
      file: "common/stopserver.js"
      env:
        TESTCONTROLLER_URL: ${TESTCONTROLLER_URL}
---
- runScript:
    file: "common/import_users_via_http.js"
    env:
      TESTCONTROLLER_URL: ${TESTCONTROLLER_URL}
      IMPORT_FROM_CSV_FILE: "Ustad_Teacher_And_Unenrolled_Student.csv"

- runFlow: "common/clear_state_and_get_started.yaml"
- runFlow: "common/select_site.yaml"
- runFlow:
    file: "common/user_login.yaml"
    env:
      USERNAME: "teach1"
      PASSWORD: "testt1"

- tapOn: ${TESTCOURSENAME}
- scrollUntilVisible:
    element:
      text: "Invite code"
    direction: DOWN
- tapOn: "Invite code"
- runFlow:
    when:
      visible:
       id: "com.android.systemui:id/dismiss_image"
    commands:
      - tapOn:
          id: "com.android.systemui:id/dismiss_image"
- runFlow: "common/clear_state_and_get_started.yaml"
- runFlow: "common/select_site.yaml"
- runFlow:
    file: "common/user_login.yaml"
    env:
      USERNAME: "stud1"
      PASSWORD: "tests1"
- runFlow:  "common/student_send_course_join_request_using_code.yaml"
- runFlow: "common/clear_state_and_get_started.yaml"
- runFlow: "common/select_site.yaml"
- runFlow:
    file: "common/user_login.yaml"
    env:
      USERNAME: "teach1"
      PASSWORD: "testt1"
- runFlow: "common/accepting_course_join_request.yaml"
#---------Launch App & Student Login------------------#
- runFlow: "common/clear_state_and_get_started.yaml"
- runFlow: "common/select_site.yaml"
- runFlow:
    file: "common/user_login.yaml"
    env:
      USERNAME: "stud1"
      PASSWORD: "tests1"
- tapOn: "Courses"
- assertVisible: ${TESTCOURSENAME}
