appId: com.toughra.ustadmobile
tags:
  - assignments
env:
  TESTRESULTSDIR: "build/reports/maestro/004_005_assignment_grace_period_finished/Screenshots"
onFlowStart:
  - startRecording: 004_005_assignment_grace_period_finished
  - 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_Students.csv"

- runFlow: "common/clear_state_and_learning_space_existing_userflow.yaml"
- runFlow: "common/select_site.yaml"
- runFlow:
    file: "common/user_login.yaml"
    env:
      USERNAME: "teach1"
      PASSWORD: "testt1"
- tapOn: "Test Course Block"

# edit the course to add blocks
- tapOn:
    id: "floating_action_button"
# add assignment block ------ 1
- scrollUntilVisible:
    element:
      text: "Add block"
    direction: DOWN
- tapOn: "Add block"
- runFlow:
    when:
      notVisible:
        text: "Assignment"
    commands:
      - swipe:
          from:
            text: "Drag handle"
          direction: UP
- tapOn: "Assignment"
- tapOn: "Title*"
- inputText: "Assignment 1"
- hideKeyboard
- tapOn: "Description"
- tapOn:
    id: "com.toughra.ustadmobile:id/editor"
- inputText: "test block"
- tapOn: "Done"
- scrollUntilVisible:
    element:
      text: "Deadline"
    direction: DOWN
- tapOn: "Deadline"
- runScript:
    file: "common/setDate.js"
- inputText: ${output.yesterdayDate}
- tapOn: "hh:mm"
- runScript:
    file: "common/setDate.js"
- inputText: ${output.currentTime}
- hideKeyboard
- tapOn: "End of grace period"
- runScript:
    file: "common/setDate.js"
- inputText: ${output.currentDate}
- tapOn: "hh:mm"
- runScript:
    file: "common/setDate.js"
- inputText: ${output.delayTime}
- hideKeyboard
- tapOn: "Late submission penalty"
- inputText: "10"
- hideKeyboard
- scrollUntilVisible:
    element:
      text: "Submission policy"
    direction: DOWN
- assertVisible: "Must submit all at once"
- assertVisible: "Done"
- takeScreenshot: "${TESTRESULTSDIR}/added_assignment"
- tapOn:
    text: "Done"
- assertNotVisible: "Done"
- tapOn: "Save"
# student not able to view submit button
- runFlow: "common/clear_state_and_learning_space_existing_userflow.yaml"
- runFlow: "common/select_site.yaml"
- runFlow:
    file: "common/user_login.yaml"
    env:
      USERNAME: "stud1"
      PASSWORD: "tests1"
- tapOn: "Courses"
- tapOn: "Test Course Block"
- scrollUntilVisible:
    element:
      text: "Assignment 1"
    direction: DOWN
- tapOn: "Assignment 1"
- assertNotVisible: "Submit"
