# Phase 4 — verified onboarding path (post-ESP retirement, 2026-05-12):
#   Splash → Display Name → Verif Choice Sheet (verifikasi nomor HP) →
#   USP one-time gate (first-time user → USP screen) → Register → OTP (6-digit)
#   → S6 paywall (when first-session-discount eligible) or duration picker.
#
# Run:
#   maestro test client_app/.maestro/flows/02_onboarding_verified.yaml
#
# Pre-reqs: client_app debug APK installed, backend reachable at
# BACKEND_URL/BACKEND_INTERNAL_URL, NODE_ENV != 'production' (so the
# /internal/_test/peek-otp + /reset-phone routes register), and
# `anonymity_enabled = true` in the dev DB so the verif choice sheet shows.
#
# NOTE: numeric prefix conflicts with the existing
# 02_cta_disabled_when_no_mitra.yaml — Stage 9 will reorganize the flow
# directory once the full Phase 4 suite lands.
appId: com.mybestie
env:
  TEST_PHONE: "+628155557701"
  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
# Onboarding carousel (still present per Phase 4 Stage 9 minimum-touch).
- extendedWaitUntil:
    visible:
      text: "Mulai"
    timeout: 15000
- tapOn:
    text: "Mulai"
    retryTapIfNoChange: true
# Phase 4 Stage 9: /welcome is retired. SHome1st CTA "aku mau curhat"
# leads into the onboarding flow.
- extendedWaitUntil:
    visible:
      text: "aku mau curhat"
    timeout: 10000
- tapOn:
    text: "aku mau curhat"
    retryTapIfNoChange: true
- extendedWaitUntil:
    visible:
      text: "Nama panggilan"
    timeout: 10000
- tapOn:
    text: "Nama panggilan"
- inputText: "Maestro"
- hideKeyboard
- tapOn:
    text: "lanjut"
    retryTapIfNoChange: true
# Verif Choice Sheet
- extendedWaitUntil:
    visible:
      text: "verifikasi nomor HP"
    timeout: 10000
- tapOn:
    text: "verifikasi nomor HP"
    retryTapIfNoChange: true
# USP one-time gate — first run after clearState, so usp_seen=false → USP shown.
# Explicitly assert ESP "Lagi mikirin apa?" is NOT visible to catch regression.
- extendedWaitUntil:
    visible:
      text: "Sebelum mulai"
    timeout: 10000
- assertNotVisible:
    text: "Lagi mikirin apa?"
- tapOn:
    text: "aku ngerti, lanjut"
    retryTapIfNoChange: true
# Register (S3a) — phone entry
- extendedWaitUntil:
    visible:
      text: "Nomor HP"
    timeout: 10000
- tapOn:
    text: "Nomor HP"
- inputText: ${TEST_PHONE}
- hideKeyboard
- tapOn:
    text: "kirim OTP"
    retryTapIfNoChange: true
# OTP screen (S3b)
- extendedWaitUntil:
    visible:
      text: "Masukkan OTP"
    timeout: 15000
- runScript:
    file: ../scripts/peek_otp.js
    env:
      TEST_PHONE: ${TEST_PHONE}
      BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}
- inputText: ${output.OTP}
# Verified path: first-session-discount eligible customers land on the S6
# paywall; non-eligibles land on the duration picker. Either is acceptable
# arrival for this flow.
- extendedWaitUntil:
    notVisible:
      text: "Masukkan OTP"
    timeout: 15000
# Verified path: first-session-discount eligible customers land on the S6
# paywall; non-eligibles land on the duration picker. Accept either.
- extendedWaitUntil:
    visible:
      text: "harga sesi pertama"
    timeout: 5000
    optional: true
