appId: world.respect.app
onFlowStart:
  - clearState: world.respect.app
  - runScript:
      file: "scripts/school_init.js"
      env:
        TESTCONTROLLER_URL: ${TESTCONTROLLER_URL}
        SCHOOL_ADMIN_PASSWORD: ${SCHOOL_ADMIN_PASSWORD}
        DIR_ADMIN_AUTH_HEADER: ${DIR_ADMIN_AUTH_HEADER}
        SCHOOL_URL: ${SCHOOL_URL}
        SCHOOL_NAME: ${SCHOOL_NAME}
        URL_SUBSTITUTION: ${URL_SUBSTITUTION}
        NAME: "002_001_browse_lessons_test"

onFlowComplete:
  - runFlow:
      file: "subflows/teardown.yaml"
      env:
        NAME: "db-final"
---
- runFlow: "subflows/school_admin_login_flow.yaml"
- assertVisible: "Home"
- assertVisible:
    id: "app_title"
    text: "Home"
- tapOn:
    id: "nav_home"
- tapOn:
    id: "floating_action_button"
- tapOn: "Add from Link"
- tapOn: "Link*"
- inputText: ${output.TEST_APP_URL}
- tapOn: "Next"
- assertVisible:
    id: "app_title"
    text: "App detail"
- assertVisible: "Example Web App"
- assertVisible: "Add to school apps"
# verify App got added to Apps section
- tapOn: "Add to school apps"
- tapOn:
    id: "nav_home"
- assertVisible:
    id: "app_title"
    text: "Home"
- assertVisible: "Example Web App"
- tapOn: "Example Web App"
- assertVisible: "Lessons"
- tapOn: "Lessons"
- tapOn: "Examples"
- tapOn: "Lesson 001"
- assertVisible: "Lesson 001"
- assertVisible: "Download"
- tapOn: "Open"
- extendedWaitUntil:
    visible: "Lesson 001"
    timeout: 10000
- assertVisible: "Hello World Lesson"
- tapOn: "Close"
- setAirplaneMode: disabled
- tapOn:
    id: "nav_home"
- tapOn: "Example Web App"
- tapOn: "Lessons"
- tapOn: "Examples"
- tapOn: "Assignment Result Statement Demo"
- assertVisible:
    id: "app_title"
    text: "Assignment Result Statement Demo"
- tapOn: "Download"
- extendedWaitUntil:
    visible: "Downloaded"
    timeout: 10000
# Set device on Offline mode
- setAirplaneMode: enabled
- assertVisible: "Downloaded"
- stopApp
- launchApp
- assertVisible:
    id: "nav_home"
- tapOn: "Example Web App"
- tapOn: "Lessons"
- tapOn: "Examples"
- tapOn: "Assignment Result Statement Demo"
- assertVisible:
    id: "app_title"
    text: "Assignment Result Statement Demo"
- assertVisible: "Downloaded"
- tapOn: "Open"
- extendedWaitUntil:
    visible: "Assignment Result Statement Demo"
    timeout: 10000
- assertVisible: "Assignment Result.*"
- tapOn: "Score"
- inputText: 1
- retry:
    maxRetries: 3
    commands:
      - tapOn: "Send statement"
      - assertVisible: "Statement sent.*"
- tapOn: "Close"
- setAirplaneMode: disabled # Set device on Online mode
- tapOn:
    id: "nav_home"
- tapOn: "Apps"
- assertVisible: "Example Web App"
- tapOn: "Bookmarks"
- assertVisible: "No bookmarks yet"
- assertVisible: "Bookmark a lesson or a playlist to see it here."
- tapOn: "Apps"
- tapOn: "Example Web App"
- tapOn: "Examples"
- tapOn: "Lesson 001"
- assertVisible: "Lesson 001"
- tapOn: "Open"
- extendedWaitUntil:
    visible: "Lesson 001"
    timeout: 1000
- assertVisible: "Hello World Lesson"
- tapOn: "Close"
- assertVisible: "Download"
- assertVisible: "Assign"
- tapOn: "Bookmark"
- tapOn:
    id: "nav_home"
- tapOn: "Apps"
- tapOn: "Example Web App"
- tapOn: "Examples"
- tapOn: "Statement Maker"
- tapOn: "Bookmark"
- tapOn:
    id: "nav_home"
- tapOn: "Bookmarks"
- assertVisible: "Lesson 001"
- assertVisible: "Statement Maker"
- assertVisible:
        id: "nav_home"
- assertVisible:
    id: "app_title"
    text: "Home"
- tapOn: "Bookmarks"
- assertVisible: "Lesson 001"
- assertVisible: "Statement Maker"
- tapOn:                       #Remove bookmark
    text: "Bookmark"
    index: 0
- assertNotVisible: "Lesson 001"
- assertVisible: "Statement Maker"
