# ts-customer-02-03 — §2 verified path, EXISTING customer with prior
# transactions → PickMethod (skip S6).
# Spec ref: requirement/flow_customer.mermaid.md §2, branch
#   OTPok="verified" → UserLookup="yes · existing" → LoadCallSign →
#   TransactedCheck="yes · returning verified" → PickMethod.
#
# Pre-seeds an identified customer with a completed chat_session so
# `isCustomerEligibleForFirstSessionDiscount` returns false → /payment/entry
# routes to /payment/method-pick instead of /payment/discount-paywall.
#
# Pre-reqs:
#   - ≥1 mitra online (seed_history_session pairs with the most-recent
#     online mitra to write the chat_sessions row).
appId: com.mybestie
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}

# Seed identified customer first — seed_history_session needs an existing
# customers row to attach the chat_session FK to.
- runScript:
    file: ../scripts/seed_customer.js
    env:
      TEST_PHONE: ${TEST_PHONE}
      DISPLAY_NAME: "ExistingTxName"
      BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}
- runScript:
    file: ../scripts/seed_history_session.js
    env:
      TEST_PHONE: ${TEST_PHONE}
      BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}

- launchApp:
    clearState: true
- runFlow: ../subflows/onboarding_new_user_verified.yaml

# Post-OTP: existing customer with prior chat_session →
# first_session_discount.eligible=false → /payment/method-pick (PickMethod).
- extendedWaitUntil:
    visible:
      text: "(?s).*pilih cara curhat.*"
    timeout: 20000
- assertVisible: "(?s).*tulis dan baca dengan tenang.*"
