# ts-customer-02-04 — §2 verified path, OTP blocked → fallback to anonymous
# → PickMethod.
# Spec ref: requirement/flow_customer.mermaid.md §2, branch
#   S3b OTP → OTPok="too many retries" → OTPBlock → fallback to Anon → USPGateB.
#
# The OtpBlockedPopup is gated by OTP_ATTEMPTS_EXCEEDED (default config:
# 5 verification attempts per OTP request; the 6th submission triggers the
# 429). Popup CTA "lanjut tanpa verif" calls context.go('/onboarding/anon/method')
# which redirects to /payment/method-pick — USP is presumed already evaluated
# upstream (verif_choice_sheet shown → USPb skipped), so the anonymous flow
# jumps straight into PickMethod.
#
# This flow inlines the pre-OTP onboarding steps (instead of using the
# onboarding_new_user_verified subflow) because we want to enter wrong OTPs
# rather than the peeked valid one.
appId: com.halobestie.client.client_app
env:
  TEST_PHONE: "+6281234567890"
  BACKEND_INTERNAL_URL: http://localhost:3001
---
- runScript:
    file: ../scripts/reset_phone.js
    env:
      TEST_PHONE: ${TEST_PHONE}
      BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}
- launchApp:
    clearState: true

- extendedWaitUntil:
    visible:
      text: "Mulai"
    timeout: 15000
- tapOn:
    text: "Mulai"
    retryTapIfNoChange: true
- extendedWaitUntil:
    visible:
      text: "(?s).*aku mau curhat.*"
    timeout: 30000
- tapOn: "(?s).*aku mau curhat.*"
- extendedWaitUntil:
    visible:
      text: "(?s).*Siapa namamu.*"
    timeout: 10000
- tapOn:
    point: "50%, 28%"
- inputText: "MaestroBlock"
- tapOn: "lanjut"
- extendedWaitUntil:
    visible:
      text: "(?s).*Mau curhat sebagai siapa.*"
    timeout: 10000
- tapOn: "(?s).*verifikasi nomor HP.*"
- runFlow:
    when:
      visible:
        text: "Sebelum mulai"
    commands:
      - tapOn: "(?s).*aku ngerti.*"
- extendedWaitUntil:
    visible:
      text: "(?s).*nomor wa-mu.*"
    timeout: 10000
- tapOn:
    point: "60%, 47%"
- inputText: "81234567890"
- tapOn: "(?s).*kirim kode.*"

# OTP screen — type wrong "000000" six times. Default config is
# verify_max_attempts=5 (config.service.js L218); attempt 6 throws
# OTP_ATTEMPTS_EXCEEDED → OtpBlockedPopup fires.
- extendedWaitUntil:
    visible:
      text: "Masukkan OTP"
    timeout: 15000
- inputText: "000000"
- inputText: "000000"
- inputText: "000000"
- inputText: "000000"
- inputText: "000000"
- inputText: "000000"

# Popup: "Verifikasi nomor lagi penuh" with primary CTA "lanjut tanpa verif".
- extendedWaitUntil:
    visible:
      text: "(?s).*Verifikasi nomor lagi penuh.*"
    timeout: 15000
- tapOn: "(?s).*lanjut tanpa verif.*"

# Assert: redirected to /payment/method-pick (PickMethod).
- extendedWaitUntil:
    visible:
      text: "(?s).*pilih cara curhat.*"
    timeout: 15000
- assertVisible: "(?s).*tulis dan baca dengan tenang.*"
