# ts-customer-02-02 — §2 verified path, EXISTING customer with no prior
# transactions → S6 paywall.
# Spec ref: requirement/flow_customer.mermaid.md §2, branch
#   OTPok="verified" → UserLookup="yes · existing" → LoadCallSign →
#   TransactedCheck="no · never paid" → S6 Paywall.
#
# Pre-seeds an identified customer with display_name but no chat_sessions
# before the run, so:
#   1. The OTP-verify backend lookup finds the existing customer.
#   2. The stored display_name overwrites the typed S2 Nama (per spec L62).
#   3. has_transacted is implicitly false (no chat_sessions →
#      isCustomerEligibleForFirstSessionDiscount returns true).
#   4. /payment/entry routes to /payment/discount-paywall (S6).
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 the existing identified customer AFTER reset (which would otherwise
# drop them). No history session is seeded → has_transacted=false.
- runScript:
    file: ../scripts/seed_customer.js
    env:
      TEST_PHONE: ${TEST_PHONE}
      DISPLAY_NAME: "ExistingPriorName"
      BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}

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

# Post-OTP: existing customer with no prior chat_sessions →
# first_session_discount.eligible=true → S6 paywall.
- extendedWaitUntil:
    visible:
      text: "(?s).*biar yakin yang mau cerita.*"
    timeout: 20000
- assertVisible: "(?s).*mulai ·.*"
