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_002_browse_demo_app_test"

onFlowComplete:
  - runFlow:
      file: "subflows/teardown.yaml"
      env:
        NAME: "db-final"
---
- runFlow: "subflows/school_admin_login_flow.yaml"
- tapOn:
    id: "floating_action_button"
- tapOn: "Add from Link"
- tapOn: "Link*"
- inputText: "${output.SCHOOL_URL}/static-resources/respect-ds/case_valid/launchable-app.json"
- tapOn: "Next"
- assertVisible:
    id: "app_title"
    text: "App detail"
- assertVisible: "Demo Launchable App"
- assertVisible: "Add to school apps"
- assertVisible: "Open Source: AFL-3.0"
- assertVisible: "Get it on Google Play"
- assertVisible: "Case Study"
- assertVisible: "This is a demo launchable app along with the lessons."
- assertVisible: "Lessons"
# verify App got added to Apps section
- tapOn: "Add to school apps"
- tapOn:
    id: "nav_home"
- assertVisible:
    id: "app_title"
    text: "Home"
- assertVisible: "Demo Launchable App"
- tapOn: "Demo Launchable App"
- assertVisible:
    id: "app_title"
    text: "App detail"
- tapOn: "Open Source: AFL-3.0"
- tapOn: "Close tab"
#- tapOn:
#    text: "Get it on Google Play"
#    index: 1
- tapOn: "Lessons"
- assertVisible: "Native Demo"
- tapOn: "Native Demo"
- assertVisible:
       id: "app_title"
       text: "Native Demo"
- assertVisible: "Download"
- assertVisible: "Open"  # Demo app needs to be installed to open and view the lesson
- tapOn:
    id: "nav_home"
- assertVisible: "Demo Launchable App"