appId: ${APP_ID}
env:
  USERNAME: foo.bar@example.com
  # Name of the library seeded in the E2E dev environment
  LIBRARY_NAME: Test E2E
  # Name of the sub-library inside LIBRARY_NAME
  SUB_LIBRARY_NAME: Sub test E2E
---
# === SETUP ===
- runFlow: ../../shared/launch-app.yml
- runFlow: ../../shared/login-to-community.yml

# === NAVIGATE TO LIBRARIES ===
# Mirrors the go-to-goals-from-apps.yml pattern instead of go-to-module-from-apps.yml
# because:
#  1. Libraries V2 nav title may not contain "Libraries", so the built-in
#     assertVisible in go-to-module-from-apps.yml fails.
#  2. When VIEW_TABBAR_KNOWLEDGE_LIBRARIES is enabled, Libraries gets its own
#     bottom-nav tab with label "Libraries". Without an initial scroll of the
#     apps-flatlist, tapOn: Libraries hits that tab (a tab-switch, not a stack
#     push) instead of the grid tile, which later causes useGoBack() to reset
#     to the Home tab.  Scrolling first ensures the grid tile is in the viewport
#     and is the first accessibility-tree match.
- runFlow: ../../shared/handle-bottom-sheet.yml
- extendedWaitUntil:
    visible: 'Home'
    timeout: 5000
- extendedWaitUntil:
    visible: 'Apps'
    timeout: 5000
- tapOn: Apps
- waitForAnimationToEnd:
    timeout: 3000
# Scroll the apps list first so the Libraries grid tile is visible in the
# viewport (same fix used by go-to-goals-from-apps.yml).
- runFlow: ../../shared/scroll-apps-list.yml
- runFlow:
    when:
      notVisible: '^(\d+\s+)?Libraries$'
    commands:
      - runFlow: ../../shared/scroll-apps-list.yml
- tapOn:
    text: '^(\d+\s+)?Libraries$'
# Neither the nav header title nor the search bar placeholder is in the iOS
# accessibility tree. Let the animation finish; libraries-home.yml asserts
# the first real text element (the "Test E2E" list item).
- waitForAnimationToEnd:
    timeout: 3000

# === LIBRARIES HOME ===
- runFlow: ./subFlows/libraries-home.yml

# === LIBRARY DETAIL + ATTACHMENTS + SUB-LIBRARY ===
- runFlow:
    file: ./subFlows/library-detail.yml
    env:
      LIBRARY_NAME: ${LIBRARY_NAME}
      SUB_LIBRARY_NAME: ${SUB_LIBRARY_NAME}
