Phase 4 Stage 9: real-device sweep, 4 flows green + 2 shipping bugs fixed

Stage 9 sweep on Client_Phone AVD + physical mitra phone:
- 01_smoke 
- 02_onboarding_verified 
- 03_onboarding_anon 
- 04_payment_expired 
- 05_searching_timeout: in progress when wrap-up began
- 06–08: not yet attempted

## Real shipping bugs fixed (would have hit prod)

1. **Router carve-out too narrow** (router.dart). The AuthAnonymousData
   carve-out only protected /auth/display-name. On refreshListenable
   notify after loginAnonymous resolves, GoRouter re-evaluates the
   *bottom* of the navigation stack (/welcome — also an auth route),
   and the AuthAnonymousData fallback redirected to /home, tearing down
   the verif sheet before it could open. Loosened to allow any auth
   route under AuthAnonymousData.

2. **Phase 4 multi-screen payment never called startSearch**
   (searching_screen.dart). The legacy single-screen /payment did
   `pairing.startSearch()` on confirm. The Phase 4 flow is
   waiting → notif-gate → /chat/searching with no intermediate that
   owned the call — customers would land on the searching screen with
   no pairing in flight and never get matched. Added the kickoff to
   searching_screen::initState when state is PairingInitialData and
   paymentDraft.paymentId is set.

## Test infrastructure

- Self-contained Maestro flows 04 + 05 with inline verified-onboarding
  prelude, distinct test phones per flow, robust waits.
- 02 + 03 fixed: malformed `extendedWaitUntil` (visible: + notVisible:
  true → Maestro parsed as compound predicate); now use proper
  notVisible: block.
- New dev-only POST /internal/_test/force-confirm-payment so flows can
  advance past the waiting-payment screen without going through Xendit.
- /internal/_test/reset-phone now cascades through chat_messages →
  chat_sessions → payment_sessions → auth_sessions before deleting the
  customer row (FK 23503 was blocking re-runs).
- /internal/_test/force-pairing-timeout now accepts both
  `searching` and `pending_acceptance` states (mitra-online dev means
  the chat_session transitions through searching very quickly).
- mark_latest_payment_paid.js helper script for Stage 5+ flows.

## Maestro YAML quirks documented in flows

- text: matches anchored regex against the FULL content-desc — need .*
  wildcards for substring, e.g. "mulai.*Rp.*" not "mulai".
- The middot `·` and other special unicode break naive matching;
  always use .* anchors when the source string contains them.
- runFlow `when:` evaluates immediately; pair with waitForAnimationToEnd
  or a preceding extendedWaitUntil before branching.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-10 22:11:05 +08:00
parent ccc52a5c3c
commit 770f61074c
8 changed files with 371 additions and 123 deletions

View File

@@ -1,86 +1,178 @@
# Stage 5 acceptance: drive the searching screen into the 5-min timeout
# state without waiting 5 minutes, verify the new copy + both CTAs render.
#
# Flow:
# home → tap CTA → payment funnel → confirm → /chat/searching →
# force-timeout via dev endpoint → verify timeout panel + CTAs.
# Self-contained: clearState=true + verified-onboarding-to-home + payment
# funnel + searching → force-timeout via dev endpoint.
#
# Pre-req:
# 1. Customer is already onboarded + on /home (run flow 01 first).
# 2. At least one mitra is ONLINE on the target backend (so the home
# "Mulai Curhat" CTA is enabled — we then force-timeout server-side
# regardless of mitra availability).
# 3. Backend reachable at BACKEND_INTERNAL_URL with NODE_ENV != 'production'
# (so the _test routes register).
#
# Run:
# maestro test client_app/.maestro/flows/05_searching_timeout.yaml
appId: ${APP_ID_ANDROID}
# 1. At least one mitra is ONLINE (so the home CTA is enabled). The
# mitra is force-timed-out server-side regardless of availability.
# 2. anonymity_enabled=true on the dev backend.
# 3. NODE_ENV != 'production' (so /internal/_test/* routes register).
appId: com.halobestie.client.client_app
env:
TEST_PHONE: "+628155557705"
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: false
- assertVisible: "Mulai Curhat"
clearState: true
# Step 1: enter payment funnel.
- tapOn: "Mulai Curhat"
# --- Onboarding prelude (verified path → /home). ---
- extendedWaitUntil:
visible:
text: "pilih cara curhat|sesi pertama|pilih durasi"
text: "Mulai"
timeout: 15000
- tapOn:
text: "Mulai"
- waitForAnimationToEnd:
timeout: 5000
- runFlow:
when:
visible:
text: "Mulai"
commands:
- tapOn:
text: "Mulai"
- extendedWaitUntil:
visible:
text: "Lanjut sebagai Tamu"
timeout: 15000
- tapOn:
text: "Lanjut sebagai Tamu"
retryTapIfNoChange: true
- extendedWaitUntil:
visible:
text: "Nama panggilan"
timeout: 10000
- tapOn:
text: "Nama panggilan"
- inputText: "Maestro"
- hideKeyboard
- tapOn:
text: "lanjut"
retryTapIfNoChange: true
- extendedWaitUntil:
visible:
text: "verifikasi nomor HP"
timeout: 10000
- tapOn:
text: "verifikasi nomor HP"
retryTapIfNoChange: true
- extendedWaitUntil:
visible:
text: "Lagi mikirin apa.*"
timeout: 10000
- tapOn:
text: "lewati"
- extendedWaitUntil:
visible:
text: "Sebelum mulai"
timeout: 10000
- tapOn:
text: "aku ngerti, lanjut"
retryTapIfNoChange: true
- extendedWaitUntil:
visible:
text: "Nomor HP"
timeout: 10000
- tapOn:
text: "Nomor HP"
- inputText: ${TEST_PHONE}
- hideKeyboard
- tapOn:
text: "kirim OTP"
retryTapIfNoChange: true
- 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}
- extendedWaitUntil:
notVisible:
text: "Masukkan OTP"
timeout: 15000
- extendedWaitUntil:
visible:
text: "Nama panggilan"
timeout: 15000
- tapOn:
text: "Nama panggilan"
- inputText: "Maestro"
- hideKeyboard
- tapOn:
text: "Lanjut"
retryTapIfNoChange: true
- extendedWaitUntil:
visible:
text: "Mulai Curhat"
timeout: 15000
# Step 2: regardless of branch, end up on /payment/method.
- runFlow:
when:
visible:
text: "pilih cara curhat"
commands:
- tapOn: "chat"
- extendedWaitUntil:
visible:
text: "pilih durasi"
timeout: 5000
- tapOn:
text: "5 menit"
retryTapIfNoChange: true
- tapOn:
text: "bayar"
retryTapIfNoChange: true
- runFlow:
when:
visible:
text: "sesi pertama"
commands:
- tapOn:
text: "mulai"
retryTapIfNoChange: true
# Step 3: cara-bayar → tap bayar → waiting screen.
# --- Now on /home. Enter payment funnel via discount paywall. ---
- tapOn:
text: "Mulai Curhat"
retryTapIfNoChange: true
- extendedWaitUntil:
visible:
text: "SESI PERTAMA"
timeout: 10000
- tapOn:
text: "mulai.*Rp.*"
retryTapIfNoChange: true
- extendedWaitUntil:
visible:
text: "cara bayar"
timeout: 10000
- tapOn:
text: "bayar"
text: "bayar Rp.*"
retryTapIfNoChange: true
# Step 4: payment confirms via mock; the searching screen opens. The
# soft-prompt copy ships in Stage 5 — we wait for that landmark.
# --- The waiting-payment screen needs to flip to paid before pairing
# can start. We can't fake that here — flow 05 was designed assuming
# a free-trial path that doesn't exist anymore. For Stage 5 testing,
# we need a "mark as paid" dev endpoint or a free-tier path. Use the
# existing CC tooling: directly mark the latest payment as confirmed
# via DB. ---
- runScript:
file: ../scripts/mark_latest_payment_paid.js
env:
BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}
# --- Notif gate may appear (Stage 4); tap "nanti aja" if so. ---
- extendedWaitUntil:
visible:
text: "sambil nunggu"
text: "nanti aja|lagi nyari bestie.*"
timeout: 15000
- assertVisible: "lagi nyari bestie..."
- runFlow:
when:
visible:
text: "nanti aja"
commands:
- tapOn:
text: "nanti aja"
# Step 5: force the 5-min timeout server-side; the WS event lands within
# ~1s and the screen flips to the timeout panel.
# --- Searching screen — verify soft-prompt + searching state. ---
- extendedWaitUntil:
visible:
text: "lagi nyari bestie.*"
timeout: 15000
# --- Force 5-min timeout server-side. ---
- runScript:
file: ../scripts/force_pairing_timeout.js
env:
BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL}
# Step 6: verify timeout panel + both CTAs render.
# --- Verify timeout panel + both CTAs. ---
- extendedWaitUntil:
visible:
text: "masih nyari nih"