# ts-mitra-2-02 — §2 Undangan: Perpanjang Curhat tab empty state
# Spec ref: requirement/flow_mitra.mermaid.md §2 + figma BestieInvitesExtend (v5.jsx)
#
# Same as 2-01 but taps into the second tab (Perpanjang Curhat) and asserts
# its dedicated empty-state copy. The Perpanjang tab today is a placeholder
# until the backend exposes a queryable list of pending extension invitations
# (see undangan_screen.dart::_PerpanjangTab TODO), so the empty state is the
# only verifiable visual.
appId: com.mybestie.mitra
env:
  TEST_PHONE: "+628200000802"
  MITRA_DISPLAY_NAME: "Maestro Perpanjang Empty"
  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}

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

- tapOn:
    point: "50%, 53%"
- inputText: "8200000802"
- 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}

- extendedWaitUntil:
    visible:
      text: "(?s).*Kamu lagi (ONLINE|OFFLINE).*"
    timeout: 15000

# Navigate to Undangan via the Chat tab.
- tapOn: "(?s).*Chat.*"
- extendedWaitUntil:
    visible:
      text: "(?s).*Undangan.*"
    timeout: 8000

# Switch to the Perpanjang Curhat tab.
- tapOn: "(?s).*Perpanjang Curhat.*"
- extendedWaitUntil:
    visible:
      text: "(?s).*Belum ada permintaan perpanjangan.*"
    timeout: 5000

- takeScreenshot: ts-mitra-2-02-perpanjang-empty
