# ts-mitra-1-06 — §1 Offline variant: tile grid (Undangan/Perpanjang) is hidden
# Spec ref: requirement/flow_mitra.mermaid.md §1 (offline branch)
#
# When the mitra is OFFLINE the home renders BestieHomeOffline which (per
# Stage 2) drops the entire tile grid + Pengingat — only the greeting,
# status card, and "Nyalain Status (Online)" CTA remain.
#
# Negative coverage: tile labels "Undangan" / "Perpanjang" are NOT visible
# on Home in the offline state. Complements ts-mitra-1-02 (which is
# focused on the offline chrome) with a tile-grid-specific negative assertion.
appId: com.mybestie.mitra
env:
  TEST_PHONE: "+628200000706"
  MITRA_DISPLAY_NAME: "Maestro Tiles Hidden"
  BACKEND_INTERNAL_URL: http://localhost:3001
---
- runScript:
    file: ../scripts/seed_mitra.js
    env:
      TEST_PHONE: ${TEST_PHONE}
      MITRA_DISPLAY_NAME: ${MITRA_DISPLAY_NAME}
      IS_ACTIVE: "true"
      BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}
- runScript:
    file: ../scripts/reset_phone.js
    env:
      TEST_PHONE: ${TEST_PHONE}
      BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}
# Force this mitra OFFLINE so the GET /api/mitra/status on home mount
# returns is_online=false → BestieHomeOffline variant renders without the
# tile grid.
- runScript:
    file: ../scripts/force_mitra_offline.js
    env:
      MITRA_ID: ${output.MITRA_ID}
      BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}

- launchApp:
    clearState: true
- extendedWaitUntil:
    visible:
      text: "(?s).*Halo Mitra Bestie.*"
    timeout: 30000

- tapOn:
    point: "50%, 53%"
- inputText: "8200000706"
- tapOn: "(?s).*kirim kode.*"
- extendedWaitUntil:
    visible:
      text: "(?s).*masukin 6 digit kode.*"
    timeout: 10000
- runScript:
    file: ../scripts/peek_otp.js
    env:
      TEST_PHONE: ${TEST_PHONE}
      BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}
- inputText: ${output.OTP}

# Offline variant lands.
- extendedWaitUntil:
    visible:
      text: "(?s).*Kamu lagi OFFLINE.*"
    timeout: 15000
- assertVisible:
    text: "(?s).*Nyalain Status \\(Online\\).*"

# Tile-grid labels MUST NOT be visible — _PrimaryTileRow is not rendered.
# Note: the "Chat" tab label in the BestieTabBar is still visible at the
# bottom; the negative assertions target the tile-specific labels
# "Undangan" and "Perpanjang" which only appear in the tile-grid widgets.
- assertNotVisible: "(?s).*Undangan.*"
- assertNotVisible: "(?s).*Perpanjang.*"
- assertNotVisible: "(?s).*Pengingat.*"
- assertNotVisible: "(?s).*Opening protocol.*"

- takeScreenshot: ts-mitra-1-06-offline-no-tiles
